src/video/dummy/SDL_nullrender.c
author Sam Lantinga <slouken@libsdl.org>
Mon, 28 Aug 2006 03:17:39 +0000
changeset 1985 8055185ae4ed
parent 1965 a788656ca29a
child 1990 7b573c59cb1f
permissions -rw-r--r--
Added source color and alpha modulation support. Added perl script to generate optimized render copy functions.
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"
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
    27
#include "../SDL_rendercopy.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
    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
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
/* 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
    31
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    32
static SDL_Renderer *SDL_DUMMY_CreateRenderer(SDL_Window * window,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    33
                                              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
    34
static int SDL_DUMMY_CreateTexture(SDL_Renderer * renderer,
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    35
                                   SDL_Texture * texture);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
    36
static int SDL_DUMMY_QueryTexturePixels(SDL_Renderer * renderer,
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    37
                                        SDL_Texture * texture, void **pixels,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    38
                                        int *pitch);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
    39
static int SDL_DUMMY_SetTexturePalette(SDL_Renderer * renderer,
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    40
                                       SDL_Texture * texture,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    41
                                       const SDL_Color * colors,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    42
                                       int firstcolor, int ncolors);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
    43
static int SDL_DUMMY_GetTexturePalette(SDL_Renderer * renderer,
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    44
                                       SDL_Texture * texture,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    45
                                       SDL_Color * colors, int firstcolor,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    46
                                       int ncolors);
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
    47
static int SDL_DUMMY_SetTextureColorMod(SDL_Renderer * renderer,
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
    48
                                        SDL_Texture * texture);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
    49
static int SDL_DUMMY_SetTextureAlphaMod(SDL_Renderer * renderer,
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
    50
                                        SDL_Texture * texture);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
    51
static int SDL_DUMMY_SetTextureBlendMode(SDL_Renderer * renderer,
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
    52
                                         SDL_Texture * texture);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
    53
static int SDL_DUMMY_SetTextureScaleMode(SDL_Renderer * renderer,
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
    54
                                         SDL_Texture * texture);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
    55
static int SDL_DUMMY_UpdateTexture(SDL_Renderer * renderer,
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    56
                                   SDL_Texture * texture,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    57
                                   const SDL_Rect * rect, const void *pixels,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    58
                                   int pitch);
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    59
static int SDL_DUMMY_LockTexture(SDL_Renderer * renderer,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    60
                                 SDL_Texture * texture, const SDL_Rect * rect,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    61
                                 int markDirty, void **pixels, int *pitch);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
    62
static void SDL_DUMMY_UnlockTexture(SDL_Renderer * renderer,
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    63
                                    SDL_Texture * texture);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
    64
static void SDL_DUMMY_DirtyTexture(SDL_Renderer * renderer,
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    65
                                   SDL_Texture * texture, int numrects,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    66
                                   const SDL_Rect * rects);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
    67
static void SDL_DUMMY_SelectRenderTexture(SDL_Renderer * renderer,
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    68
                                          SDL_Texture * texture);
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
    69
static int SDL_DUMMY_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g,
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
    70
                                Uint8 b, Uint8 a, const SDL_Rect * rect);
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    71
static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    72
                                SDL_Texture * texture,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    73
                                const SDL_Rect * srcrect,
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
    74
                                const SDL_Rect * dstrect);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
    75
static int SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer,
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    76
                                      const SDL_Rect * rect, void *pixels,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    77
                                      int pitch);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
    78
static int SDL_DUMMY_RenderWritePixels(SDL_Renderer * renderer,
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    79
                                       const SDL_Rect * rect,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    80
                                       const void *pixels, 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
    81
static void SDL_DUMMY_RenderPresent(SDL_Renderer * renderer);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
    82
static void SDL_DUMMY_DestroyTexture(SDL_Renderer * renderer,
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
    83
                                     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
    84
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
    85
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
    86
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
    87
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
    88
    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
    89
    {
1906
0c49855a7a3e Changed the name of the dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
    90
     "dummy",
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
    91
     (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
    92
      SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
    93
      SDL_RENDERER_PRESENTDISCARD),
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
    94
     (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR |
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
    95
      SDL_TEXTUREMODULATE_ALPHA),
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
    96
     (SDL_TEXTUREBLENDMODE_NONE | SDL_TEXTUREBLENDMODE_MASK |
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
    97
      SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD |
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
    98
      SDL_TEXTUREBLENDMODE_MOD),
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
    99
     (SDL_TEXTURESCALEMODE_NONE | SDL_TEXTURESCALEMODE_FAST),
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   100
     11,
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   101
     {
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
   102
      SDL_PIXELFORMAT_INDEX8,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
   103
      SDL_PIXELFORMAT_RGB555,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
   104
      SDL_PIXELFORMAT_RGB565,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
   105
      SDL_PIXELFORMAT_RGB888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
   106
      SDL_PIXELFORMAT_BGR888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
   107
      SDL_PIXELFORMAT_ARGB8888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
   108
      SDL_PIXELFORMAT_RGBA8888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
   109
      SDL_PIXELFORMAT_ABGR8888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
   110
      SDL_PIXELFORMAT_BGRA8888,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
   111
      SDL_PIXELFORMAT_YUY2,
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
   112
      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
   113
     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
   114
     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
   115
};
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
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
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
   118
{
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   119
    int current_screen;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   120
    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
   121
} 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
   122
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
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
   124
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
   125
{
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
    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
   127
    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
   128
    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
   129
    SDL_DUMMY_RenderData *data;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   130
    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
   131
    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
   132
    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
   133
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
    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
   135
        (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
   136
        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
   137
        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
   138
    }
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
   139
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   140
    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
   141
    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
   142
        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
   143
        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
   144
    }
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
   145
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
   146
    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
   147
    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
   148
        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
   149
        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
   150
        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
   151
    }
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
    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
   153
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   154
    renderer->CreateTexture = SDL_DUMMY_CreateTexture;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   155
    renderer->QueryTexturePixels = SDL_DUMMY_QueryTexturePixels;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   156
    renderer->SetTexturePalette = SDL_DUMMY_SetTexturePalette;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   157
    renderer->GetTexturePalette = SDL_DUMMY_GetTexturePalette;
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   158
    renderer->SetTextureColorMod = SDL_DUMMY_SetTextureColorMod;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   159
    renderer->SetTextureAlphaMod = SDL_DUMMY_SetTextureAlphaMod;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   160
    renderer->SetTextureBlendMode = SDL_DUMMY_SetTextureBlendMode;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   161
    renderer->SetTextureScaleMode = SDL_DUMMY_SetTextureScaleMode;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   162
    renderer->UpdateTexture = SDL_DUMMY_UpdateTexture;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   163
    renderer->LockTexture = SDL_DUMMY_LockTexture;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   164
    renderer->UnlockTexture = SDL_DUMMY_UnlockTexture;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   165
    renderer->DirtyTexture = SDL_DUMMY_DirtyTexture;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   166
    renderer->RenderFill = SDL_DUMMY_RenderFill;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   167
    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
   168
    renderer->RenderPresent = SDL_DUMMY_RenderPresent;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   169
    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
   170
    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
   171
    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
   172
    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
   173
    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
   174
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   175
    renderer->info.flags = 0;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   176
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
   177
    if (flags & SDL_RENDERER_PRESENTFLIP2) {
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
   178
        renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   179
        n = 2;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
   180
    } else if (flags & SDL_RENDERER_PRESENTFLIP3) {
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
   181
        renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   182
        n = 3;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   183
    } else {
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
   184
        renderer->info.flags |= SDL_RENDERER_PRESENTCOPY;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   185
        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
   186
    }
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   187
    for (i = 0; i < n; ++i) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   188
        data->screens[i] =
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   189
            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
   190
                                 Bmask, Amask);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   191
        if (!data->screens[i]) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   192
            SDL_DUMMY_DestroyRenderer(renderer);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   193
            return NULL;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   194
        }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   195
        SDL_SetSurfacePalette(data->screens[i], display->palette);
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
    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
   198
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
   199
    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
   200
}
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
   201
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   202
static int
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   203
SDL_DUMMY_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   204
{
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   205
    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   206
        texture->driverdata = SDL_SW_CreateYUVTexture(texture);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   207
    } else {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   208
        int bpp;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   209
        Uint32 Rmask, Gmask, Bmask, Amask;
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_PixelFormatEnumToMasks
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   212
            (texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   213
            SDL_SetError("Unknown texture format");
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   214
            return -1;
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
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   217
        texture->driverdata =
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   218
            SDL_CreateRGBSurface(0, texture->w, texture->h, bpp, Rmask, Gmask,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   219
                                 Bmask, Amask);
1908
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
    if (!texture->driverdata) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   223
        return -1;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   224
    }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   225
    return 0;
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
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   228
static int
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   229
SDL_DUMMY_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   230
                             void **pixels, int *pitch)
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   231
{
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   232
    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   233
        return SDL_SW_QueryYUVTexturePixels((SDL_SW_YUVTexture *) texture->
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   234
                                            driverdata, pixels, pitch);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   235
    } else {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   236
        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
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
        *pixels = surface->pixels;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   239
        *pitch = surface->pitch;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   240
        return 0;
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
}
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   243
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   244
static int
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   245
SDL_DUMMY_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   246
                            const SDL_Color * colors, int firstcolor,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   247
                            int ncolors)
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   248
{
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   249
    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   250
        SDL_SetError("YUV textures don't have a palette");
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   251
        return -1;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   252
    } else {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   253
        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   254
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   255
        return SDL_SetPaletteColors(surface->format->palette, colors,
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   256
                                    firstcolor, ncolors);
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
}
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   259
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   260
static int
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   261
SDL_DUMMY_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   262
                            SDL_Color * colors, int firstcolor, int ncolors)
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   263
{
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   264
    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   265
        SDL_SetError("YUV textures don't have a palette");
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   266
        return -1;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   267
    } else {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   268
        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   269
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   270
        SDL_memcpy(colors, &surface->format->palette->colors[firstcolor],
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   271
                   ncolors * sizeof(*colors));
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   272
        return 0;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   273
    }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   274
}
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   275
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   276
static void
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   277
SDL_DUMMY_UpdateRenderCopyFunc(SDL_Renderer * renderer, SDL_Texture * texture)
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   278
{
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   279
    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   280
    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   281
    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   282
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   283
    surface->userdata =
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   284
        SDL_GetRenderCopyFunc(texture->format, display->current_mode.format,
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   285
                              texture->modMode, texture->blendMode,
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   286
                              texture->scaleMode);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   287
}
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   288
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   289
static int
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   290
SDL_DUMMY_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture)
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   291
{
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   292
    SDL_DUMMY_UpdateRenderCopyFunc(renderer, texture);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   293
    return 0;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   294
}
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   295
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   296
static int
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   297
SDL_DUMMY_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture)
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   298
{
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   299
    SDL_DUMMY_UpdateRenderCopyFunc(renderer, texture);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   300
    return 0;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   301
}
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   302
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   303
static int
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   304
SDL_DUMMY_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture)
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   305
{
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   306
    switch (texture->blendMode) {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   307
    case SDL_TEXTUREBLENDMODE_NONE:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   308
    case SDL_TEXTUREBLENDMODE_MASK:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   309
    case SDL_TEXTUREBLENDMODE_BLEND:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   310
    case SDL_TEXTUREBLENDMODE_ADD:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   311
    case SDL_TEXTUREBLENDMODE_MOD:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   312
        SDL_DUMMY_UpdateRenderCopyFunc(renderer, texture);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   313
        return 0;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   314
    default:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   315
        SDL_Unsupported();
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   316
        texture->blendMode = SDL_TEXTUREBLENDMODE_NONE;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   317
        SDL_DUMMY_UpdateRenderCopyFunc(renderer, texture);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   318
        return -1;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   319
    }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   320
}
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   321
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   322
static int
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   323
SDL_DUMMY_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture)
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   324
{
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   325
    switch (texture->scaleMode) {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   326
    case SDL_TEXTURESCALEMODE_NONE:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   327
    case SDL_TEXTURESCALEMODE_FAST:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   328
        SDL_DUMMY_UpdateRenderCopyFunc(renderer, texture);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   329
        return 0;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   330
    case SDL_TEXTURESCALEMODE_SLOW:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   331
    case SDL_TEXTURESCALEMODE_BEST:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   332
        SDL_Unsupported();
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   333
        texture->scaleMode = SDL_TEXTURESCALEMODE_FAST;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   334
        SDL_DUMMY_UpdateRenderCopyFunc(renderer, texture);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   335
        return -1;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   336
    default:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   337
        SDL_Unsupported();
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   338
        texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   339
        SDL_DUMMY_UpdateRenderCopyFunc(renderer, texture);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   340
        return -1;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   341
    }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   342
}
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   343
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   344
static int
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   345
SDL_DUMMY_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   346
                        const SDL_Rect * rect, const void *pixels, int pitch)
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   347
{
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   348
    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   349
        return SDL_SW_UpdateYUVTexture((SDL_SW_YUVTexture *) texture->
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   350
                                       driverdata, rect, pixels, 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
        Uint8 *src, *dst;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   354
        int row;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   355
        size_t length;
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
        src = (Uint8 *) pixels;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   358
        dst =
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   359
            (Uint8 *) surface->pixels + rect->y * surface->pitch +
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   360
            rect->x * surface->format->BytesPerPixel;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   361
        length = rect->w * surface->format->BytesPerPixel;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   362
        for (row = 0; row < rect->h; ++row) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   363
            SDL_memcpy(dst, src, length);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   364
            src += pitch;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   365
            dst += surface->pitch;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   366
        }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   367
        return 0;
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
static int
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   372
SDL_DUMMY_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   373
                      const SDL_Rect * rect, int markDirty, void **pixels,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   374
                      int *pitch)
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   375
{
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   376
    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   377
        return SDL_SW_LockYUVTexture((SDL_SW_YUVTexture *) texture->
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   378
                                     driverdata, rect, markDirty, pixels,
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   379
                                     pitch);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   380
    } else {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   381
        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   382
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   383
        *pixels =
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   384
            (void *) ((Uint8 *) surface->pixels + rect->y * surface->pitch +
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   385
                      rect->x * surface->format->BytesPerPixel);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   386
        *pitch = surface->pitch;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   387
        return 0;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   388
    }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   389
}
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   390
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   391
static void
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   392
SDL_DUMMY_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   393
{
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   394
    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   395
        SDL_SW_UnlockYUVTexture((SDL_SW_YUVTexture *) texture->driverdata);
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
}
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   398
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   399
static void
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   400
SDL_DUMMY_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   401
                       int numrects, const SDL_Rect * rects)
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   402
{
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
static int
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   406
SDL_DUMMY_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b,
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   407
                     Uint8 a, const SDL_Rect * rect)
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   408
{
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   409
    SDL_DUMMY_RenderData *data =
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   410
        (SDL_DUMMY_RenderData *) renderer->driverdata;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   411
    SDL_Surface *target = data->screens[data->current_screen];
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   412
    Uint32 color;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   413
    SDL_Rect real_rect = *rect;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   414
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   415
    color = SDL_MapRGBA(target->format, r, g, b, a);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   416
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   417
    return SDL_FillRect(target, &real_rect, color);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   418
}
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   419
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   420
static int
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   421
SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   422
                     const SDL_Rect * srcrect, const SDL_Rect * dstrect)
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   423
{
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   424
    SDL_DUMMY_RenderData *data =
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   425
        (SDL_DUMMY_RenderData *) renderer->driverdata;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   426
    SDL_Window *window = SDL_GetWindowFromID(renderer->window);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   427
    SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   428
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   429
    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   430
        SDL_Surface *target = data->screens[data->current_screen];
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   431
        void *pixels =
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   432
            (Uint8 *) target->pixels + dstrect->y * target->pitch +
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   433
            dstrect->x * target->format->BytesPerPixel;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   434
        return SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata,
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   435
                                   srcrect, display->current_mode.format,
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   436
                                   dstrect->w, dstrect->h, pixels,
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   437
                                   target->pitch);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   438
    } else {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   439
        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   440
        SDL_Surface *target = data->screens[data->current_screen];
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   441
        SDL_RenderCopyFunc copyfunc = (SDL_RenderCopyFunc) surface->userdata;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   442
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   443
        if (copyfunc) {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   444
            SDL_RenderCopyData copydata;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   445
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   446
            copydata.src =
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   447
                (Uint8 *) surface->pixels + srcrect->y * surface->pitch +
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   448
                srcrect->x * surface->format->BytesPerPixel;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   449
            copydata.src_w = srcrect->w;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   450
            copydata.src_h = srcrect->h;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   451
            copydata.src_pitch = surface->pitch;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   452
            copydata.dst =
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   453
                (Uint8 *) target->pixels + dstrect->y * target->pitch +
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   454
                dstrect->x * target->format->BytesPerPixel;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   455
            copydata.dst_w = dstrect->w;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   456
            copydata.dst_h = dstrect->h;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   457
            copydata.dst_pitch = target->pitch;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   458
            copydata.flags = 0;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   459
            if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   460
                copydata.flags |= SDL_RENDERCOPY_MODULATE_COLOR;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   461
                copydata.r = texture->r;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   462
                copydata.g = texture->g;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   463
                copydata.b = texture->b;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   464
            }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   465
            if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   466
                copydata.flags |= SDL_RENDERCOPY_MODULATE_ALPHA;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   467
                copydata.a = texture->a;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   468
            }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   469
            if (texture->
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   470
                blendMode & (SDL_TEXTUREBLENDMODE_MASK |
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   471
                             SDL_TEXTUREBLENDMODE_BLEND)) {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   472
                copydata.flags |= SDL_RENDERCOPY_BLEND;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   473
            } else if (texture->blendMode & SDL_TEXTUREBLENDMODE_ADD) {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   474
                copydata.flags |= SDL_RENDERCOPY_ADD;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   475
            } else if (texture->blendMode & SDL_TEXTUREBLENDMODE_MOD) {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   476
                copydata.flags |= SDL_RENDERCOPY_MOD;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   477
            }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   478
            if (texture->scaleMode) {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   479
                copydata.flags |= SDL_RENDERCOPY_NEAREST;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   480
            }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   481
            return copyfunc(&copydata);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   482
        } else {
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   483
            SDL_Rect real_srcrect = *srcrect;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   484
            SDL_Rect real_dstrect = *dstrect;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
   485
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   486
            return SDL_LowerBlit(surface, &real_srcrect, target,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   487
                                 &real_dstrect);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   488
        }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   489
    }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   490
}
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   491
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   492
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
   493
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
   494
{
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
   495
    static int frame_number;
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   496
    SDL_DUMMY_RenderData *data =
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   497
        (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
   498
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   499
    /* 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
   500
    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
   501
        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
   502
        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
   503
                     renderer->window, ++frame_number);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   504
        SDL_SaveBMP(data->screens[data->current_screen], file);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   505
    }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   506
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   507
    /* Update the flipping chain, if any */
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
   508
    if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   509
        data->current_screen = (data->current_screen + 1) % 2;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
   510
    } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) {
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   511
        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
   512
    }
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
   513
}
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
   514
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   515
static void
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   516
SDL_DUMMY_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   517
{
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   518
    if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   519
        SDL_SW_DestroyYUVTexture((SDL_SW_YUVTexture *) texture->driverdata);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   520
    } else {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   521
        SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   522
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   523
        SDL_FreeSurface(surface);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   524
    }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   525
}
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   526
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   527
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
   528
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
   529
{
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   530
    SDL_DUMMY_RenderData *data =
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
   531
        (SDL_DUMMY_RenderData *) renderer->driverdata;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   532
    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
   533
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
   534
    if (data) {
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   535
        for (i = 0; i < SDL_arraysize(data->screens); ++i) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   536
            if (data->screens[i]) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   537
                SDL_FreeSurface(data->screens[i]);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
   538
            }
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
   539
        }
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
   540
        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
   541
    }
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
   542
    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
   543
}
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
   544
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
   545
/* vi: set ts=4 sw=4 expandtab: */