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