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