src/render/software/SDL_render_sw.c
author Sam Lantinga <slouken@libsdl.org>
Sun, 13 Feb 2011 13:46:10 -0800
changeset 5288 d4381f3b0d1e
parent 5276 8e421890cdb8
child 5296 48067bfc300c
permissions -rw-r--r--
A few fixes:
Fixed creating render texture framebuffer.
Removed the need for palette watch, added surface format caching.
Added an SDL_DONTFREE flag so you can't free the window and 1.2 shadow surfaces.
slouken@1895
     1
/*
slouken@1895
     2
    SDL - Simple DirectMedia Layer
slouken@5262
     3
    Copyright (C) 1997-2011 Sam Lantinga
slouken@1895
     4
slouken@1895
     5
    This library is free software; you can redistribute it and/or
slouken@1895
     6
    modify it under the terms of the GNU Lesser General Public
slouken@1895
     7
    License as published by the Free Software Foundation; either
slouken@1895
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@1895
     9
slouken@1895
    10
    This library is distributed in the hope that it will be useful,
slouken@1895
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@1895
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1895
    13
    Lesser General Public License for more details.
slouken@1895
    14
slouken@1895
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1895
    16
    License along with this library; if not, write to the Free Software
slouken@1895
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@1895
    18
slouken@1895
    19
    Sam Lantinga
slouken@1895
    20
    slouken@libsdl.org
slouken@1895
    21
*/
slouken@1895
    22
#include "SDL_config.h"
slouken@1895
    23
slouken@5226
    24
#if !SDL_RENDER_DISABLED
slouken@5226
    25
slouken@5154
    26
#include "../SDL_sysrender.h"
slouken@1895
    27
slouken@5163
    28
#include "SDL_draw.h"
slouken@5163
    29
#include "SDL_blendfillrect.h"
slouken@5163
    30
#include "SDL_blendline.h"
slouken@5163
    31
#include "SDL_blendpoint.h"
slouken@5163
    32
#include "SDL_drawline.h"
slouken@5163
    33
#include "SDL_drawpoint.h"
slouken@5163
    34
slouken@1895
    35
slouken@1895
    36
/* SDL surface based renderer implementation */
slouken@1895
    37
slouken@1918
    38
static SDL_Renderer *SW_CreateRenderer(SDL_Window * window, Uint32 flags);
slouken@5147
    39
static void SW_WindowEvent(SDL_Renderer * renderer,
slouken@5147
    40
                           const SDL_WindowEvent *event);
slouken@1918
    41
static int SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
slouken@1985
    42
static int SW_SetTextureColorMod(SDL_Renderer * renderer,
slouken@1985
    43
                                 SDL_Texture * texture);
slouken@1985
    44
static int SW_SetTextureAlphaMod(SDL_Renderer * renderer,
slouken@1985
    45
                                 SDL_Texture * texture);
slouken@5141
    46
static int SW_SetTextureBlendMode(SDL_Renderer * renderer,
slouken@5141
    47
                                  SDL_Texture * texture);
slouken@1985
    48
static int SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@1985
    49
                            const SDL_Rect * rect, const void *pixels,
slouken@1985
    50
                            int pitch);
slouken@1918
    51
static int SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@5156
    52
                          const SDL_Rect * rect, void **pixels, int *pitch);
slouken@1918
    53
static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
slouken@5224
    54
static void SW_SetClipRect(SDL_Renderer * renderer, const SDL_Rect * rect);
slouken@3596
    55
static int SW_RenderDrawPoints(SDL_Renderer * renderer,
slouken@3596
    56
                               const SDL_Point * points, int count);
slouken@3596
    57
static int SW_RenderDrawLines(SDL_Renderer * renderer,
slouken@3596
    58
                              const SDL_Point * points, int count);
slouken@3596
    59
static int SW_RenderFillRects(SDL_Renderer * renderer,
slouken@3596
    60
                              const SDL_Rect ** rects, int count);
slouken@1918
    61
static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@1985
    62
                         const SDL_Rect * srcrect, const SDL_Rect * dstrect);
slouken@3427
    63
static int SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
slouken@3435
    64
                               Uint32 format, void * pixels, int pitch);
slouken@1918
    65
static void SW_RenderPresent(SDL_Renderer * renderer);
slouken@1918
    66
static void SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture);
slouken@1918
    67
static void SW_DestroyRenderer(SDL_Renderer * renderer);
slouken@1895
    68
slouken@1895
    69
slouken@1918
    70
SDL_RenderDriver SW_RenderDriver = {
slouken@1918
    71
    SW_CreateRenderer,
slouken@1895
    72
    {
slouken@1895
    73
     "software",
slouken@5166
    74
     0,
slouken@5156
    75
     8,
slouken@1895
    76
     {
slouken@1965
    77
      SDL_PIXELFORMAT_RGB555,
slouken@1965
    78
      SDL_PIXELFORMAT_RGB565,
slouken@1965
    79
      SDL_PIXELFORMAT_RGB888,
slouken@1965
    80
      SDL_PIXELFORMAT_BGR888,
slouken@1965
    81
      SDL_PIXELFORMAT_ARGB8888,
slouken@1965
    82
      SDL_PIXELFORMAT_RGBA8888,
slouken@1965
    83
      SDL_PIXELFORMAT_ABGR8888,
slouken@5156
    84
      SDL_PIXELFORMAT_BGRA8888
slouken@5156
    85
     },
slouken@1895
    86
     0,
slouken@1895
    87
     0}
slouken@1895
    88
};
slouken@1895
    89
slouken@1895
    90
typedef struct
slouken@1895
    91
{
slouken@1972
    92
    SDL_bool updateSize;
slouken@5166
    93
    SDL_Surface *surface;
slouken@1918
    94
} SW_RenderData;
slouken@1895
    95
slouken@1907
    96
slouken@1895
    97
SDL_Renderer *
slouken@5166
    98
SW_CreateRendererForSurface(SDL_Surface * surface)
slouken@1895
    99
{
slouken@1895
   100
    SDL_Renderer *renderer;
slouken@1918
   101
    SW_RenderData *data;
slouken@1895
   102
slouken@5166
   103
    if (!surface) {
slouken@5166
   104
        SDL_SetError("Can't create renderer for NULL surface");
slouken@1895
   105
        return NULL;
slouken@1895
   106
    }
slouken@1895
   107
slouken@1895
   108
    renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
slouken@1895
   109
    if (!renderer) {
slouken@1895
   110
        SDL_OutOfMemory();
slouken@1895
   111
        return NULL;
slouken@1895
   112
    }
slouken@1895
   113
slouken@1920
   114
    data = (SW_RenderData *) SDL_calloc(1, sizeof(*data));
slouken@1895
   115
    if (!data) {
slouken@1918
   116
        SW_DestroyRenderer(renderer);
slouken@1895
   117
        SDL_OutOfMemory();
slouken@1895
   118
        return NULL;
slouken@1895
   119
    }
slouken@5166
   120
    data->surface = surface;
slouken@5166
   121
slouken@5147
   122
    renderer->WindowEvent = SW_WindowEvent;
slouken@5154
   123
    renderer->CreateTexture = SW_CreateTexture;
slouken@5154
   124
    renderer->SetTextureColorMod = SW_SetTextureColorMod;
slouken@5154
   125
    renderer->SetTextureAlphaMod = SW_SetTextureAlphaMod;
slouken@5154
   126
    renderer->SetTextureBlendMode = SW_SetTextureBlendMode;
slouken@5154
   127
    renderer->UpdateTexture = SW_UpdateTexture;
slouken@5154
   128
    renderer->LockTexture = SW_LockTexture;
slouken@5154
   129
    renderer->UnlockTexture = SW_UnlockTexture;
slouken@5224
   130
    renderer->SetClipRect = SW_SetClipRect;
slouken@5154
   131
    renderer->DestroyTexture = SW_DestroyTexture;
slouken@3596
   132
    renderer->RenderDrawPoints = SW_RenderDrawPoints;
slouken@3596
   133
    renderer->RenderDrawLines = SW_RenderDrawLines;
slouken@3596
   134
    renderer->RenderFillRects = SW_RenderFillRects;
slouken@1918
   135
    renderer->RenderCopy = SW_RenderCopy;
slouken@3427
   136
    renderer->RenderReadPixels = SW_RenderReadPixels;
slouken@1918
   137
    renderer->RenderPresent = SW_RenderPresent;
slouken@1918
   138
    renderer->DestroyRenderer = SW_DestroyRenderer;
slouken@5154
   139
    renderer->info = SW_RenderDriver.info;
slouken@1895
   140
    renderer->driverdata = data;
slouken@1895
   141
slouken@1895
   142
    return renderer;
slouken@1895
   143
}
slouken@1895
   144
slouken@5166
   145
SDL_Renderer *
slouken@5166
   146
SW_CreateRenderer(SDL_Window * window, Uint32 flags)
slouken@5166
   147
{
slouken@5166
   148
    SDL_Surface *surface;
slouken@5166
   149
slouken@5166
   150
    surface = SDL_GetWindowSurface(window);
slouken@5166
   151
    if (!surface) {
slouken@5166
   152
        return NULL;
slouken@5166
   153
    }
slouken@5166
   154
    return SW_CreateRendererForSurface(surface);
slouken@5166
   155
}
slouken@5166
   156
slouken@5166
   157
static SDL_Surface *
slouken@1970
   158
SW_ActivateRenderer(SDL_Renderer * renderer)
slouken@1970
   159
{
slouken@1970
   160
    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
slouken@3685
   161
    SDL_Window *window = renderer->window;
slouken@1970
   162
slouken@1972
   163
    if (data->updateSize) {
slouken@5166
   164
        data->surface = SDL_GetWindowSurface(window);
slouken@5166
   165
        data->updateSize = SDL_FALSE;
slouken@1972
   166
    }
slouken@5166
   167
    return data->surface;
slouken@1970
   168
}
slouken@1970
   169
slouken@5147
   170
static void
slouken@5147
   171
SW_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event)
slouken@1970
   172
{
slouken@1970
   173
    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
slouken@1970
   174
slouken@5276
   175
    if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) {
slouken@5147
   176
        data->updateSize = SDL_TRUE;
slouken@1970
   177
    }
slouken@1970
   178
}
slouken@1970
   179
slouken@1970
   180
static int
slouken@1918
   181
SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
slouken@1895
   182
{
slouken@5156
   183
    int bpp;
slouken@5156
   184
    Uint32 Rmask, Gmask, Bmask, Amask;
slouken@1895
   185
slouken@5156
   186
    if (!SDL_PixelFormatEnumToMasks
slouken@5156
   187
        (texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
slouken@5156
   188
        SDL_SetError("Unknown texture format");
slouken@5156
   189
        return -1;
slouken@5156
   190
    }
slouken@1895
   191
slouken@5156
   192
    texture->driverdata =
slouken@5156
   193
        SDL_CreateRGBSurface(0, texture->w, texture->h, bpp, Rmask, Gmask,
slouken@5156
   194
                             Bmask, Amask);
slouken@5156
   195
    SDL_SetSurfaceColorMod(texture->driverdata, texture->r, texture->g,
slouken@5156
   196
                           texture->b);
slouken@5156
   197
    SDL_SetSurfaceAlphaMod(texture->driverdata, texture->a);
slouken@5156
   198
    SDL_SetSurfaceBlendMode(texture->driverdata, texture->blendMode);
slouken@3053
   199
slouken@5156
   200
    if (texture->access == SDL_TEXTUREACCESS_STATIC) {
slouken@5156
   201
        SDL_SetSurfaceRLE(texture->driverdata, 1);
slouken@1895
   202
    }
slouken@1895
   203
slouken@1895
   204
    if (!texture->driverdata) {
slouken@1895
   205
        return -1;
slouken@1895
   206
    }
slouken@1895
   207
    return 0;
slouken@1895
   208
}
slouken@1895
   209
slouken@1895
   210
static int
slouken@1985
   211
SW_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
slouken@1985
   212
{
slouken@2267
   213
    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
slouken@2267
   214
    return SDL_SetSurfaceColorMod(surface, texture->r, texture->g,
slouken@2267
   215
                                  texture->b);
slouken@1985
   216
}
slouken@1985
   217
slouken@1985
   218
static int
slouken@1985
   219
SW_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
slouken@1985
   220
{
slouken@2267
   221
    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
slouken@2267
   222
    return SDL_SetSurfaceAlphaMod(surface, texture->a);
slouken@1985
   223
}
slouken@1985
   224
slouken@1985
   225
static int
slouken@1985
   226
SW_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
slouken@1985
   227
{
slouken@2267
   228
    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
slouken@2267
   229
    return SDL_SetSurfaceBlendMode(surface, texture->blendMode);
slouken@1985
   230
}
slouken@1985
   231
slouken@1985
   232
static int
slouken@1918
   233
SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@1918
   234
                 const SDL_Rect * rect, const void *pixels, int pitch)
slouken@1895
   235
{
slouken@5156
   236
    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
slouken@5156
   237
    Uint8 *src, *dst;
slouken@5156
   238
    int row;
slouken@5156
   239
    size_t length;
slouken@1895
   240
slouken@5156
   241
    src = (Uint8 *) pixels;
slouken@5156
   242
    dst = (Uint8 *) surface->pixels +
slouken@5156
   243
                        rect->y * surface->pitch +
slouken@5156
   244
                        rect->x * surface->format->BytesPerPixel;
slouken@5156
   245
    length = rect->w * surface->format->BytesPerPixel;
slouken@5156
   246
    for (row = 0; row < rect->h; ++row) {
slouken@5156
   247
        SDL_memcpy(dst, src, length);
slouken@5156
   248
        src += pitch;
slouken@5156
   249
        dst += surface->pitch;
slouken@1895
   250
    }
slouken@5156
   251
    return 0;
slouken@1895
   252
}
slouken@1895
   253
slouken@1895
   254
static int
slouken@1918
   255
SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@5156
   256
               const SDL_Rect * rect, void **pixels, int *pitch)
slouken@1895
   257
{
slouken@5156
   258
    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
slouken@1895
   259
slouken@5156
   260
    *pixels =
slouken@5156
   261
        (void *) ((Uint8 *) surface->pixels + rect->y * surface->pitch +
slouken@5156
   262
                  rect->x * surface->format->BytesPerPixel);
slouken@5156
   263
    *pitch = surface->pitch;
slouken@5156
   264
    return 0;
slouken@1895
   265
}
slouken@1895
   266
slouken@1895
   267
static void
slouken@1918
   268
SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
slouken@1895
   269
{
slouken@1895
   270
}
slouken@1895
   271
slouken@5224
   272
static void
slouken@5224
   273
SW_SetClipRect(SDL_Renderer * renderer, const SDL_Rect * rect)
slouken@5224
   274
{
slouken@5224
   275
    SDL_Surface *surface = SW_ActivateRenderer(renderer);
slouken@5224
   276
slouken@5224
   277
    if (!surface) {
slouken@5224
   278
        return;
slouken@5224
   279
    }
slouken@5224
   280
    SDL_SetClipRect(surface, rect);
slouken@5224
   281
}
slouken@5224
   282
slouken@1895
   283
static int
slouken@3596
   284
SW_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points,
slouken@3596
   285
                    int count)
slouken@2901
   286
{
slouken@5166
   287
    SDL_Surface *surface = SW_ActivateRenderer(renderer);
slouken@2901
   288
slouken@5166
   289
    if (!surface) {
slouken@5147
   290
        return -1;
slouken@5147
   291
    }
slouken@5147
   292
slouken@3536
   293
    /* Draw the points! */
slouken@5140
   294
    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
slouken@5166
   295
        Uint32 color = SDL_MapRGBA(surface->format,
slouken@3536
   296
                                   renderer->r, renderer->g, renderer->b,
slouken@3536
   297
                                   renderer->a);
slouken@2888
   298
slouken@5166
   299
        return SDL_DrawPoints(surface, points, count, color);
slouken@2888
   300
    } else {
slouken@5166
   301
        return SDL_BlendPoints(surface, points, count,
slouken@5166
   302
                               renderer->blendMode,
slouken@5166
   303
                               renderer->r, renderer->g, renderer->b,
slouken@5166
   304
                               renderer->a);
slouken@2888
   305
    }
slouken@2888
   306
}
slouken@2888
   307
slouken@2888
   308
static int
slouken@3596
   309
SW_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points,
slouken@3596
   310
                   int count)
slouken@1895
   311
{
slouken@5166
   312
    SDL_Surface *surface = SW_ActivateRenderer(renderer);
slouken@3536
   313
slouken@5166
   314
    if (!surface) {
slouken@5147
   315
        return -1;
slouken@5147
   316
    }
slouken@5147
   317
slouken@5166
   318
    /* Draw the lines! */
slouken@5140
   319
    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
slouken@5166
   320
        Uint32 color = SDL_MapRGBA(surface->format,
slouken@3536
   321
                                   renderer->r, renderer->g, renderer->b,
slouken@3536
   322
                                   renderer->a);
slouken@2888
   323
slouken@5166
   324
        return SDL_DrawLines(surface, points, count, color);
slouken@2888
   325
    } else {
slouken@5166
   326
        return SDL_BlendLines(surface, points, count,
slouken@5166
   327
                              renderer->blendMode,
slouken@5166
   328
                              renderer->r, renderer->g, renderer->b,
slouken@5166
   329
                              renderer->a);
slouken@2888
   330
    }
slouken@3536
   331
}
slouken@3536
   332
slouken@3536
   333
static int
slouken@3596
   334
SW_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects,
slouken@3596
   335
                   int count)
slouken@3536
   336
{
slouken@5166
   337
    SDL_Surface *surface = SW_ActivateRenderer(renderer);
slouken@3536
   338
slouken@5166
   339
    if (!surface) {
slouken@5147
   340
        return -1;
slouken@5147
   341
    }
slouken@5147
   342
slouken@5140
   343
    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
slouken@5166
   344
        Uint32 color = SDL_MapRGBA(surface->format,
slouken@5166
   345
                                   renderer->r, renderer->g, renderer->b,
slouken@5166
   346
                                   renderer->a);
slouken@5166
   347
        return SDL_FillRects(surface, rects, count, color);
slouken@5166
   348
    } else {
slouken@5166
   349
        return SDL_BlendFillRects(surface, rects, count,
slouken@5166
   350
                                     renderer->blendMode,
slouken@5166
   351
                                     renderer->r, renderer->g, renderer->b,
slouken@5166
   352
                                     renderer->a);
slouken@3536
   353
    }
slouken@1895
   354
}
slouken@1895
   355
slouken@1895
   356
static int
slouken@1918
   357
SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@1985
   358
              const SDL_Rect * srcrect, const SDL_Rect * dstrect)
slouken@1895
   359
{
slouken@5166
   360
    SDL_Surface *surface = SW_ActivateRenderer(renderer);
slouken@5166
   361
    SDL_Surface *src = (SDL_Surface *) texture->driverdata;
slouken@5166
   362
    SDL_Rect final_rect = *dstrect;
slouken@1895
   363
slouken@5166
   364
    if (!surface) {
slouken@5147
   365
        return -1;
slouken@5147
   366
    }
slouken@5166
   367
    return SDL_BlitSurface(src, srcrect, surface, &final_rect);
slouken@1895
   368
}
slouken@1895
   369
slouken@3427
   370
static int
slouken@3427
   371
SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect,
slouken@3435
   372
                    Uint32 format, void * pixels, int pitch)
slouken@3427
   373
{
slouken@5166
   374
    SDL_Surface *surface = SW_ActivateRenderer(renderer);
slouken@5166
   375
    Uint32 src_format;
slouken@5166
   376
    void *src_pixels;
slouken@3427
   377
slouken@5166
   378
    if (!surface) {
slouken@5147
   379
        return -1;
slouken@5147
   380
    }
slouken@5147
   381
slouken@5166
   382
    if (rect->x < 0 || rect->x+rect->w > surface->w ||
slouken@5166
   383
        rect->y < 0 || rect->y+rect->h > surface->h) {
slouken@5166
   384
        SDL_SetError("Tried to read outside of surface bounds");
slouken@3427
   385
        return -1;
slouken@3427
   386
    }
slouken@3427
   387
slouken@5166
   388
    src_format = SDL_MasksToPixelFormatEnum(
slouken@5166
   389
                    surface->format->BitsPerPixel,
slouken@5166
   390
                    surface->format->Rmask, surface->format->Gmask,
slouken@5166
   391
                    surface->format->Bmask, surface->format->Amask);
slouken@3427
   392
slouken@5166
   393
    src_pixels = (void*)((Uint8 *) surface->pixels +
slouken@5166
   394
                    rect->y * surface->pitch +
slouken@5166
   395
                    rect->x * surface->format->BytesPerPixel);
slouken@5166
   396
slouken@5166
   397
    return SDL_ConvertPixels(rect->w, rect->h,
slouken@5166
   398
                             src_format, src_pixels, surface->pitch,
slouken@5166
   399
                             format, pixels, pitch);
slouken@3427
   400
}
slouken@3427
   401
slouken@1895
   402
static void
slouken@1918
   403
SW_RenderPresent(SDL_Renderer * renderer)
slouken@1895
   404
{
slouken@1918
   405
    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
slouken@5166
   406
    SDL_Window *window = renderer->window;
slouken@1895
   407
slouken@5166
   408
    if (window) {
slouken@5166
   409
        SDL_UpdateWindowSurface(window);
slouken@5147
   410
    }
slouken@1895
   411
}
slouken@1895
   412
slouken@1895
   413
static void
slouken@1918
   414
SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
slouken@1895
   415
{
slouken@5156
   416
    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
slouken@1895
   417
slouken@5156
   418
    SDL_FreeSurface(surface);
slouken@1895
   419
}
slouken@1895
   420
slouken@1895
   421
static void
slouken@1918
   422
SW_DestroyRenderer(SDL_Renderer * renderer)
slouken@1895
   423
{
slouken@1918
   424
    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
slouken@1895
   425
slouken@1895
   426
    if (data) {
slouken@1895
   427
        SDL_free(data);
slouken@1895
   428
    }
slouken@1895
   429
    SDL_free(renderer);
slouken@1895
   430
}
slouken@1895
   431
slouken@5226
   432
#endif /* !SDL_RENDER_DISABLED */
slouken@5226
   433
slouken@1895
   434
/* vi: set ts=4 sw=4 expandtab: */