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