src/video/SDL_renderer_sw.c
author Sam Lantinga <slouken@libsdl.org>
Wed, 14 Jun 2006 06:14:26 +0000
branchSDL-1.3
changeset 1678 90bf530ced8e
parent 1676 e136f3ffdc1b
child 1680 9488fca10677
permissions -rw-r--r--
SDL_SetVideoMode() compiles now...
slouken@1676
     1
/*
slouken@1676
     2
    SDL - Simple DirectMedia Layer
slouken@1676
     3
    Copyright (C) 1997-2006 Sam Lantinga
slouken@1676
     4
slouken@1676
     5
    This library is free software; you can redistribute it and/or
slouken@1676
     6
    modify it under the terms of the GNU Lesser General Public
slouken@1676
     7
    License as published by the Free Software Foundation; either
slouken@1676
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@1676
     9
slouken@1676
    10
    This library is distributed in the hope that it will be useful,
slouken@1676
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@1676
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1676
    13
    Lesser General Public License for more details.
slouken@1676
    14
slouken@1676
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1676
    16
    License along with this library; if not, write to the Free Software
slouken@1676
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@1676
    18
slouken@1676
    19
    Sam Lantinga
slouken@1676
    20
    slouken@libsdl.org
slouken@1676
    21
*/
slouken@1676
    22
#include "SDL_config.h"
slouken@1676
    23
slouken@1676
    24
#include "SDL_video.h"
slouken@1676
    25
#include "SDL_sysvideo.h"
slouken@1676
    26
slouken@1676
    27
slouken@1676
    28
/* SDL surface based renderer implementation */
slouken@1676
    29
slouken@1676
    30
static SDL_Renderer *SDL_SW_CreateRenderer(SDL_Window * window, Uint32 flags);
slouken@1676
    31
static int SDL_SW_CreateTexture(SDL_Renderer * renderer,
slouken@1676
    32
                                SDL_Texture * texture);
slouken@1678
    33
static int SDL_SW_QueryTexturePixels(SDL_Renderer * renderer,
slouken@1678
    34
                                     SDL_Texture * texture, void **pixels,
slouken@1678
    35
                                     int *pitch);
slouken@1676
    36
static int SDL_SW_UpdateTexture(SDL_Renderer * renderer,
slouken@1676
    37
                                SDL_Texture * texture, SDL_Rect * rect,
slouken@1676
    38
                                const void *pixels, int pitch);
slouken@1676
    39
static int SDL_SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@1676
    40
                              SDL_Rect * rect, int markDirty, void **pixels,
slouken@1676
    41
                              int *pitch);
slouken@1676
    42
static void SDL_SW_UnlockTexture(SDL_Renderer * renderer,
slouken@1676
    43
                                 SDL_Texture * texture);
slouken@1676
    44
static void SDL_SW_DirtyTexture(SDL_Renderer * renderer,
slouken@1676
    45
                                SDL_Texture * texture, int numrects,
slouken@1676
    46
                                SDL_Rect * rects);
slouken@1676
    47
static void SDL_SW_SelectRenderTexture(SDL_Renderer * renderer,
slouken@1676
    48
                                       SDL_Texture * texture);
slouken@1676
    49
static void SDL_SW_RenderFill(SDL_Renderer * renderer, SDL_Rect * rect,
slouken@1676
    50
                              Uint32 color);
slouken@1676
    51
static int SDL_SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@1676
    52
                             SDL_Rect * srcrect, SDL_Rect * dstrect,
slouken@1676
    53
                             int blendMode, int scaleMode);
slouken@1676
    54
static int SDL_SW_RenderReadPixels(SDL_Renderer * renderer, SDL_Rect * rect,
slouken@1676
    55
                                   void *pixels, int pitch);
slouken@1676
    56
static int SDL_SW_RenderWritePixels(SDL_Renderer * renderer, SDL_Rect * rect,
slouken@1676
    57
                                    const void *pixels, int pitch);
slouken@1676
    58
static void SDL_SW_RenderPresent(SDL_Renderer * renderer);
slouken@1676
    59
static void SDL_SW_DestroyTexture(SDL_Renderer * renderer,
slouken@1676
    60
                                  SDL_Texture * texture);
slouken@1676
    61
static void SDL_SW_DestroyRenderer(SDL_Renderer * renderer);
slouken@1676
    62
slouken@1676
    63
slouken@1676
    64
SDL_RenderDriver SDL_SW_RenderDriver = {
slouken@1676
    65
    SDL_SW_CreateRenderer,
slouken@1676
    66
    {
slouken@1676
    67
     "software",
slouken@1676
    68
     (SDL_Renderer_PresentDiscard |
slouken@1676
    69
      SDL_Renderer_PresentCopy |
slouken@1676
    70
      SDL_Renderer_PresentFlip2 |
slouken@1676
    71
      SDL_Renderer_PresentFlip3 | SDL_Renderer_RenderTarget),
slouken@1676
    72
     (SDL_TextureBlendMode_None |
slouken@1676
    73
      SDL_TextureBlendMode_Mask | SDL_TextureBlendMode_Blend),
slouken@1676
    74
     (SDL_TextureScaleMode_None | SDL_TextureScaleMode_Fast),
slouken@1676
    75
     11,
slouken@1676
    76
     {
slouken@1676
    77
      SDL_PixelFormat_Index8,
slouken@1676
    78
      SDL_PixelFormat_RGB555,
slouken@1676
    79
      SDL_PixelFormat_RGB565,
slouken@1676
    80
      SDL_PixelFormat_RGB888,
slouken@1676
    81
      SDL_PixelFormat_BGR888,
slouken@1676
    82
      SDL_PixelFormat_ARGB8888,
slouken@1676
    83
      SDL_PixelFormat_RGBA8888,
slouken@1676
    84
      SDL_PixelFormat_ABGR8888,
slouken@1676
    85
      SDL_PixelFormat_BGRA8888,
slouken@1676
    86
      SDL_PixelFormat_YUY2,
slouken@1676
    87
      SDL_PixelFormat_UYVY},
slouken@1676
    88
     32768,
slouken@1676
    89
     32768}
slouken@1676
    90
};
slouken@1676
    91
slouken@1676
    92
typedef struct
slouken@1676
    93
{
slouken@1676
    94
    int current_screen;
slouken@1676
    95
    SDL_Surface *screens[3];
slouken@1676
    96
    SDL_Surface *target;
slouken@1676
    97
    SDL_Renderer *renderer;
slouken@1676
    98
} SDL_SW_RenderData;
slouken@1676
    99
slouken@1676
   100
SDL_Renderer *
slouken@1676
   101
SDL_SW_CreateRenderer(SDL_Window * window, Uint32 flags)
slouken@1676
   102
{
slouken@1676
   103
    SDL_DisplayMode *displayMode = &window->display->current_mode;
slouken@1676
   104
    SDL_Renderer *renderer;
slouken@1676
   105
    SDL_SW_RenderData *data;
slouken@1676
   106
    int i, n;
slouken@1676
   107
    int bpp;
slouken@1676
   108
    Uint32 Rmask, Gmask, Bmask, Amask;
slouken@1676
   109
slouken@1676
   110
    if (!SDL_PixelFormatEnumToMasks
slouken@1676
   111
        (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
slouken@1676
   112
        SDL_SetError("Unknown display format");
slouken@1676
   113
        return NULL;
slouken@1676
   114
    }
slouken@1676
   115
slouken@1676
   116
    renderer = (SDL_Renderer *) SDL_malloc(sizeof(*renderer));
slouken@1676
   117
    if (!renderer) {
slouken@1676
   118
        SDL_OutOfMemory();
slouken@1676
   119
        return NULL;
slouken@1676
   120
    }
slouken@1676
   121
    SDL_zerop(renderer);
slouken@1676
   122
slouken@1676
   123
    data = (SDL_SW_RenderData *) SDL_malloc(sizeof(*data));
slouken@1676
   124
    if (!data) {
slouken@1676
   125
        SDL_SW_DestroyRenderer(renderer);
slouken@1676
   126
        SDL_OutOfMemory();
slouken@1676
   127
        return NULL;
slouken@1676
   128
    }
slouken@1676
   129
    SDL_zerop(data);
slouken@1676
   130
slouken@1676
   131
    renderer->CreateTexture = SDL_SW_CreateTexture;
slouken@1678
   132
    renderer->QueryTexturePixels = SDL_SW_QueryTexturePixels;
slouken@1676
   133
    renderer->UpdateTexture = SDL_SW_UpdateTexture;
slouken@1676
   134
    renderer->LockTexture = SDL_SW_LockTexture;
slouken@1676
   135
    renderer->UnlockTexture = SDL_SW_UnlockTexture;
slouken@1676
   136
    renderer->DirtyTexture = SDL_SW_DirtyTexture;
slouken@1676
   137
    renderer->SelectRenderTexture = SDL_SW_SelectRenderTexture;
slouken@1676
   138
    renderer->RenderFill = SDL_SW_RenderFill;
slouken@1676
   139
    renderer->RenderCopy = SDL_SW_RenderCopy;
slouken@1676
   140
    renderer->RenderReadPixels = SDL_SW_RenderReadPixels;
slouken@1676
   141
    renderer->RenderWritePixels = SDL_SW_RenderWritePixels;
slouken@1676
   142
    renderer->RenderPresent = SDL_SW_RenderPresent;
slouken@1676
   143
    renderer->DestroyTexture = SDL_SW_DestroyTexture;
slouken@1676
   144
    renderer->DestroyRenderer = SDL_SW_DestroyRenderer;
slouken@1676
   145
    renderer->info = SDL_SW_RenderDriver.info;
slouken@1676
   146
    renderer->window = window;
slouken@1676
   147
    renderer->driverdata = data;
slouken@1676
   148
slouken@1676
   149
    renderer->info.flags = SDL_Renderer_RenderTarget;
slouken@1676
   150
slouken@1676
   151
    if (flags & SDL_Renderer_PresentFlip2) {
slouken@1676
   152
        renderer->info.flags |= SDL_Renderer_PresentFlip2;
slouken@1676
   153
        n = 2;
slouken@1676
   154
    } else if (flags & SDL_Renderer_PresentFlip3) {
slouken@1676
   155
        renderer->info.flags |= SDL_Renderer_PresentFlip3;
slouken@1676
   156
        n = 3;
slouken@1676
   157
    } else {
slouken@1676
   158
        renderer->info.flags |= SDL_Renderer_PresentCopy;
slouken@1676
   159
        n = 1;
slouken@1676
   160
    }
slouken@1676
   161
    for (i = 0; i < n; ++i) {
slouken@1676
   162
        data->screens[i] =
slouken@1676
   163
            SDL_CreateRGBSurface(0, window->w, window->h, bpp, Rmask, Gmask,
slouken@1676
   164
                                 Bmask, Amask);
slouken@1676
   165
        if (!data->screens[i]) {
slouken@1676
   166
            SDL_SW_DestroyRenderer(renderer);
slouken@1676
   167
            return NULL;
slouken@1676
   168
        }
slouken@1676
   169
    }
slouken@1676
   170
    data->current_screen = 0;
slouken@1676
   171
    data->target = data->screens[0];
slouken@1676
   172
slouken@1676
   173
    /* Find a render driver that we can use to display data */
slouken@1676
   174
    for (i = 0; i < window->display->num_render_drivers; ++i) {
slouken@1676
   175
        SDL_RenderDriver *driver = &window->display->render_drivers[i];
slouken@1676
   176
        if (driver->info.name != SDL_SW_RenderDriver.info.name) {
slouken@1676
   177
            data->renderer =
slouken@1676
   178
                driver->CreateRenderer(window, SDL_Renderer_PresentDiscard);
slouken@1676
   179
            if (data->renderer) {
slouken@1676
   180
                break;
slouken@1676
   181
            }
slouken@1676
   182
        }
slouken@1676
   183
    }
slouken@1676
   184
    if (i == window->display->num_render_drivers) {
slouken@1676
   185
        SDL_SW_DestroyRenderer(renderer);
slouken@1676
   186
        SDL_SetError("Couldn't find display render driver");
slouken@1676
   187
        return NULL;
slouken@1676
   188
    }
slouken@1676
   189
    return renderer;
slouken@1676
   190
}
slouken@1676
   191
slouken@1676
   192
int
slouken@1676
   193
SDL_SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
slouken@1676
   194
{
slouken@1676
   195
    SDL_Surface *surface;
slouken@1676
   196
    int bpp;
slouken@1676
   197
    Uint32 Rmask, Gmask, Bmask, Amask;
slouken@1676
   198
slouken@1676
   199
    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
slouken@1676
   200
        /* FIXME: implement this */
slouken@1676
   201
        return -1;
slouken@1676
   202
    }
slouken@1676
   203
slouken@1676
   204
    if (!SDL_PixelFormatEnumToMasks
slouken@1676
   205
        (texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
slouken@1676
   206
        SDL_SetError("Unknown texture format");
slouken@1676
   207
        return -1;
slouken@1676
   208
    }
slouken@1676
   209
slouken@1676
   210
    surface =
slouken@1676
   211
        SDL_CreateRGBSurface(0, texture->w, texture->h, bpp, Rmask, Gmask,
slouken@1676
   212
                             Bmask, Amask);
slouken@1676
   213
    if (!surface) {
slouken@1676
   214
        return -1;
slouken@1676
   215
    }
slouken@1676
   216
slouken@1676
   217
    texture->driverdata = surface;
slouken@1676
   218
    return 0;
slouken@1676
   219
}
slouken@1676
   220
slouken@1676
   221
int
slouken@1678
   222
SDL_SW_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@1678
   223
                          void **pixels, int *pitch)
slouken@1678
   224
{
slouken@1678
   225
    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
slouken@1678
   226
slouken@1678
   227
    *pixels = surface->pixels;
slouken@1678
   228
    *pitch = surface->pitch;
slouken@1678
   229
    return 0;
slouken@1678
   230
}
slouken@1678
   231
slouken@1678
   232
int
slouken@1676
   233
SDL_SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@1676
   234
                     SDL_Rect * rect, const void *pixels, int pitch)
slouken@1676
   235
{
slouken@1676
   236
    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
slouken@1676
   237
    Uint8 *src, *dst;
slouken@1676
   238
    int row;
slouken@1676
   239
    size_t length;
slouken@1676
   240
slouken@1676
   241
    src = (Uint8 *) pixels;
slouken@1676
   242
    dst =
slouken@1676
   243
        (Uint8 *) surface->pixels + rect->y * surface->pitch +
slouken@1676
   244
        rect->x * surface->format->BytesPerPixel;
slouken@1676
   245
    length = rect->w * surface->format->BytesPerPixel;
slouken@1676
   246
    for (row = 0; row < rect->h; ++row) {
slouken@1676
   247
        SDL_memcpy(dst, src, length);
slouken@1676
   248
        src += pitch;
slouken@1676
   249
        dst += surface->pitch;
slouken@1676
   250
    }
slouken@1676
   251
    return 0;
slouken@1676
   252
}
slouken@1676
   253
slouken@1676
   254
int
slouken@1676
   255
SDL_SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@1676
   256
                   SDL_Rect * rect, int markDirty, void **pixels, int *pitch)
slouken@1676
   257
{
slouken@1676
   258
    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
slouken@1676
   259
slouken@1676
   260
    *pixels =
slouken@1676
   261
        (void *) ((Uint8 *) surface->pixels + rect->y * surface->pitch +
slouken@1676
   262
                  rect->x * surface->format->BytesPerPixel);
slouken@1676
   263
    *pitch = surface->pitch;
slouken@1676
   264
    return 0;
slouken@1676
   265
}
slouken@1676
   266
slouken@1676
   267
void
slouken@1676
   268
SDL_SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
slouken@1676
   269
{
slouken@1676
   270
}
slouken@1676
   271
slouken@1676
   272
void
slouken@1676
   273
SDL_SW_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@1676
   274
                    int numrects, SDL_Rect * rects)
slouken@1676
   275
{
slouken@1676
   276
}
slouken@1676
   277
slouken@1676
   278
void
slouken@1676
   279
SDL_SW_SelectRenderTexture(SDL_Renderer * renderer, SDL_Texture * texture)
slouken@1676
   280
{
slouken@1676
   281
    SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
slouken@1676
   282
    data->target = (SDL_Surface *) texture->driverdata;
slouken@1676
   283
}
slouken@1676
   284
slouken@1676
   285
void
slouken@1676
   286
SDL_SW_RenderFill(SDL_Renderer * renderer, SDL_Rect * rect, Uint32 color)
slouken@1676
   287
{
slouken@1676
   288
    SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
slouken@1676
   289
    Uint8 r, g, b, a;
slouken@1676
   290
slouken@1676
   291
    a = (Uint8) ((color >> 24) & 0xFF);
slouken@1676
   292
    r = (Uint8) ((color >> 16) & 0xFF);
slouken@1676
   293
    g = (Uint8) ((color >> 8) & 0xFF);
slouken@1676
   294
    b = (Uint8) (color & 0xFF);
slouken@1676
   295
    color = SDL_MapRGBA(data->target->format, r, g, b, a);
slouken@1676
   296
slouken@1676
   297
    SDL_FillRect(data->target, rect, color);
slouken@1676
   298
}
slouken@1676
   299
slouken@1676
   300
int
slouken@1676
   301
SDL_SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
slouken@1676
   302
                  SDL_Rect * srcrect, SDL_Rect * dstrect, int blendMode,
slouken@1676
   303
                  int scaleMode)
slouken@1676
   304
{
slouken@1676
   305
    SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
slouken@1676
   306
    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
slouken@1676
   307
slouken@1676
   308
    if (blendMode & (SDL_TextureBlendMode_Mask | SDL_TextureBlendMode_Blend)) {
slouken@1676
   309
        SDL_SetAlpha(surface, SDL_SRCALPHA, 0);
slouken@1676
   310
    } else {
slouken@1676
   311
        SDL_SetAlpha(surface, 0, 0);
slouken@1676
   312
    }
slouken@1676
   313
    if (scaleMode != SDL_TextureScaleMode_None &&
slouken@1676
   314
        (srcrect->w != dstrect->w || srcrect->h != dstrect->h)) {
slouken@1676
   315
        return SDL_SoftStretch(surface, srcrect, data->target, dstrect);
slouken@1676
   316
    } else {
slouken@1676
   317
        return SDL_LowerBlit(surface, srcrect, data->target, dstrect);
slouken@1676
   318
    }
slouken@1676
   319
}
slouken@1676
   320
slouken@1676
   321
int
slouken@1676
   322
SDL_SW_RenderReadPixels(SDL_Renderer * renderer, SDL_Rect * rect,
slouken@1676
   323
                        void *pixels, int pitch)
slouken@1676
   324
{
slouken@1676
   325
    SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
slouken@1676
   326
    SDL_Surface *surface = data->target;
slouken@1676
   327
    Uint8 *src, *dst;
slouken@1676
   328
    int row;
slouken@1676
   329
    size_t length;
slouken@1676
   330
slouken@1676
   331
    src =
slouken@1676
   332
        (Uint8 *) surface->pixels + rect->y * surface->pitch +
slouken@1676
   333
        rect->x * surface->format->BytesPerPixel;
slouken@1676
   334
    dst = (Uint8 *) pixels;
slouken@1676
   335
    length = rect->w * surface->format->BytesPerPixel;
slouken@1676
   336
    for (row = 0; row < rect->h; ++row) {
slouken@1676
   337
        SDL_memcpy(dst, src, length);
slouken@1676
   338
        src += surface->pitch;
slouken@1676
   339
        dst += pitch;
slouken@1676
   340
    }
slouken@1676
   341
    return 0;
slouken@1676
   342
}
slouken@1676
   343
slouken@1676
   344
int
slouken@1676
   345
SDL_SW_RenderWritePixels(SDL_Renderer * renderer, SDL_Rect * rect,
slouken@1676
   346
                         const void *pixels, int pitch)
slouken@1676
   347
{
slouken@1676
   348
    SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
slouken@1676
   349
    SDL_Surface *surface = data->target;
slouken@1676
   350
    Uint8 *src, *dst;
slouken@1676
   351
    int row;
slouken@1676
   352
    size_t length;
slouken@1676
   353
slouken@1676
   354
    src = (Uint8 *) pixels;
slouken@1676
   355
    dst =
slouken@1676
   356
        (Uint8 *) surface->pixels + rect->y * surface->pitch +
slouken@1676
   357
        rect->x * surface->format->BytesPerPixel;
slouken@1676
   358
    length = rect->w * surface->format->BytesPerPixel;
slouken@1676
   359
    for (row = 0; row < rect->h; ++row) {
slouken@1676
   360
        SDL_memcpy(dst, src, length);
slouken@1676
   361
        src += pitch;
slouken@1676
   362
        dst += surface->pitch;
slouken@1676
   363
    }
slouken@1676
   364
    return 0;
slouken@1676
   365
}
slouken@1676
   366
slouken@1676
   367
void
slouken@1676
   368
SDL_SW_RenderPresent(SDL_Renderer * renderer)
slouken@1676
   369
{
slouken@1676
   370
    SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
slouken@1676
   371
    SDL_Surface *surface = data->screens[data->current_screen];
slouken@1676
   372
    SDL_Rect rect;
slouken@1676
   373
    int new_screen;
slouken@1676
   374
slouken@1676
   375
    /* Send the data to the display */
slouken@1676
   376
    /* FIXME: implement dirty rect updates */
slouken@1676
   377
    rect.x = 0;
slouken@1676
   378
    rect.y = 0;
slouken@1676
   379
    rect.w = surface->w;
slouken@1676
   380
    rect.h = surface->h;
slouken@1676
   381
    data->renderer->RenderWritePixels(data->renderer, &rect, surface->pixels,
slouken@1676
   382
                                      surface->pitch);
slouken@1676
   383
    data->renderer->RenderPresent(data->renderer);
slouken@1676
   384
slouken@1676
   385
    /* Update the flipping chain, if any */
slouken@1676
   386
    if (renderer->info.flags & SDL_Renderer_PresentFlip2) {
slouken@1676
   387
        new_screen = (data->current_screen + 1) % 2;
slouken@1676
   388
    } else if (renderer->info.flags & SDL_Renderer_PresentFlip3) {
slouken@1676
   389
        new_screen = (data->current_screen + 1) % 3;
slouken@1676
   390
    } else {
slouken@1676
   391
        new_screen = 0;
slouken@1676
   392
    }
slouken@1676
   393
    if (data->target == data->screens[data->current_screen]) {
slouken@1676
   394
        data->target = data->screens[new_screen];
slouken@1676
   395
    }
slouken@1676
   396
    data->current_screen = new_screen;
slouken@1676
   397
}
slouken@1676
   398
slouken@1676
   399
void
slouken@1676
   400
SDL_SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
slouken@1676
   401
{
slouken@1676
   402
    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
slouken@1676
   403
slouken@1676
   404
    SDL_FreeSurface(surface);
slouken@1676
   405
}
slouken@1676
   406
slouken@1676
   407
void
slouken@1676
   408
SDL_SW_DestroyRenderer(SDL_Renderer * renderer)
slouken@1676
   409
{
slouken@1676
   410
    SDL_SW_RenderData *data = (SDL_SW_RenderData *) renderer->driverdata;
slouken@1676
   411
    int i;
slouken@1676
   412
slouken@1676
   413
    if (data) {
slouken@1676
   414
        for (i = 0; i < SDL_arraysize(data->screens); ++i) {
slouken@1676
   415
            if (data->screens[i]) {
slouken@1676
   416
                SDL_FreeSurface(data->screens[i]);
slouken@1676
   417
            }
slouken@1676
   418
        }
slouken@1676
   419
        SDL_free(data);
slouken@1676
   420
    }
slouken@1676
   421
    SDL_free(renderer);
slouken@1676
   422
}
slouken@1676
   423
slouken@1676
   424
/* vi: set ts=4 sw=4 expandtab: */