annotate src/video/dummy/SDL_nullrender.c @ 2033:b657f0bc72c2

More work for 1.3
author Patrice Mandin <patmandin@gmail.com>
date Wed, 20 Sep 2006 21:29:44 +0000
parents 7387e0514595
children b252359547ed
rev   line source
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
1992
7387e0514595 Take advantage of the existing SDL blitters for normal copy blits.
Sam Lantinga <slouken@libsdl.org>
parents: 1990
diff changeset
283 /* We only need a special copy function for advanced features */
7387e0514595 Take advantage of the existing SDL blitters for normal copy blits.
Sam Lantinga <slouken@libsdl.org>
parents: 1990
diff changeset
284 if (texture->modMode
7387e0514595 Take advantage of the existing SDL blitters for normal copy blits.
Sam Lantinga <slouken@libsdl.org>
parents: 1990
diff changeset
285 || (texture->
7387e0514595 Take advantage of the existing SDL blitters for normal copy blits.
Sam Lantinga <slouken@libsdl.org>
parents: 1990
diff changeset
286 blendMode & (SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD))
7387e0514595 Take advantage of the existing SDL blitters for normal copy blits.
Sam Lantinga <slouken@libsdl.org>
parents: 1990
diff changeset
287 || texture->scaleMode) {
7387e0514595 Take advantage of the existing SDL blitters for normal copy blits.
Sam Lantinga <slouken@libsdl.org>
parents: 1990
diff changeset
288 surface->userdata =
7387e0514595 Take advantage of the existing SDL blitters for normal copy blits.
Sam Lantinga <slouken@libsdl.org>
parents: 1990
diff changeset
289 SDL_GetRenderCopyFunc(texture->format,
7387e0514595 Take advantage of the existing SDL blitters for normal copy blits.
Sam Lantinga <slouken@libsdl.org>
parents: 1990
diff changeset
290 display->current_mode.format,
7387e0514595 Take advantage of the existing SDL blitters for normal copy blits.
Sam Lantinga <slouken@libsdl.org>
parents: 1990
diff changeset
291 texture->modMode, texture->blendMode,
7387e0514595 Take advantage of the existing SDL blitters for normal copy blits.
Sam Lantinga <slouken@libsdl.org>
parents: 1990
diff changeset
292 texture->scaleMode);
7387e0514595 Take advantage of the existing SDL blitters for normal copy blits.
Sam Lantinga <slouken@libsdl.org>
parents: 1990
diff changeset
293 } else {
7387e0514595 Take advantage of the existing SDL blitters for normal copy blits.
Sam Lantinga <slouken@libsdl.org>
parents: 1990
diff changeset
294 surface->userdata = NULL;
7387e0514595 Take advantage of the existing SDL blitters for normal copy blits.
Sam Lantinga <slouken@libsdl.org>
parents: 1990
diff changeset
295 }
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
296 }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
297
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
298 static int
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
299 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
300 {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
301 SDL_DUMMY_UpdateRenderCopyFunc(renderer, texture);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
302 return 0;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
303 }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
304
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
305 static int
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
306 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
307 {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
308 SDL_DUMMY_UpdateRenderCopyFunc(renderer, texture);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
309 return 0;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
310 }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
311
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
312 static int
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
313 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
314 {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
315 switch (texture->blendMode) {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
316 case SDL_TEXTUREBLENDMODE_NONE:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
317 case SDL_TEXTUREBLENDMODE_MASK:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
318 case SDL_TEXTUREBLENDMODE_BLEND:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
319 case SDL_TEXTUREBLENDMODE_ADD:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
320 case SDL_TEXTUREBLENDMODE_MOD:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
321 SDL_DUMMY_UpdateRenderCopyFunc(renderer, texture);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
322 return 0;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
323 default:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
324 SDL_Unsupported();
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
325 texture->blendMode = SDL_TEXTUREBLENDMODE_NONE;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
326 SDL_DUMMY_UpdateRenderCopyFunc(renderer, texture);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
327 return -1;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
328 }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
329 }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
330
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
331 static int
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
332 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
333 {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
334 switch (texture->scaleMode) {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
335 case SDL_TEXTURESCALEMODE_NONE:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
336 case SDL_TEXTURESCALEMODE_FAST:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
337 SDL_DUMMY_UpdateRenderCopyFunc(renderer, texture);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
338 return 0;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
339 case SDL_TEXTURESCALEMODE_SLOW:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
340 case SDL_TEXTURESCALEMODE_BEST:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
341 SDL_Unsupported();
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
342 texture->scaleMode = SDL_TEXTURESCALEMODE_FAST;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
343 SDL_DUMMY_UpdateRenderCopyFunc(renderer, texture);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
344 return -1;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
345 default:
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
346 SDL_Unsupported();
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
347 texture->scaleMode = SDL_TEXTURESCALEMODE_NONE;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
348 SDL_DUMMY_UpdateRenderCopyFunc(renderer, texture);
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
349 return -1;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
350 }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
351 }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
352
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
353 static int
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
354 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
355 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
356 {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
357 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
358 return SDL_SW_UpdateYUVTexture((SDL_SW_YUVTexture *) texture->
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
359 driverdata, rect, pixels, pitch);
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_Surface *surface = (SDL_Surface *) texture->driverdata;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
362 Uint8 *src, *dst;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
363 int row;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
364 size_t length;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
365
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
366 src = (Uint8 *) pixels;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
367 dst =
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
368 (Uint8 *) surface->pixels + rect->y * surface->pitch +
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
369 rect->x * surface->format->BytesPerPixel;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
370 length = rect->w * surface->format->BytesPerPixel;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
371 for (row = 0; row < rect->h; ++row) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
372 SDL_memcpy(dst, src, length);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
373 src += pitch;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
374 dst += surface->pitch;
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 return 0;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
377 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
378 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
379
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
380 static int
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
381 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
382 const SDL_Rect * rect, int markDirty, void **pixels,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
383 int *pitch)
1908
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 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
386 return SDL_SW_LockYUVTexture((SDL_SW_YUVTexture *) texture->
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
387 driverdata, rect, markDirty, pixels,
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
388 pitch);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
389 } else {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
390 SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
391
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
392 *pixels =
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
393 (void *) ((Uint8 *) surface->pixels + rect->y * surface->pitch +
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
394 rect->x * surface->format->BytesPerPixel);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
395 *pitch = surface->pitch;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
396 return 0;
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
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
400 static void
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
401 SDL_DUMMY_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
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 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
404 SDL_SW_UnlockYUVTexture((SDL_SW_YUVTexture *) texture->driverdata);
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 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
407
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
408 static void
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
409 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
410 int numrects, const SDL_Rect * rects)
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
411 {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
412 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
413
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
414 static int
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
415 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
416 Uint8 a, const SDL_Rect * rect)
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
417 {
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
418 SDL_DUMMY_RenderData *data =
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
419 (SDL_DUMMY_RenderData *) renderer->driverdata;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
420 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
421 Uint32 color;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
422 SDL_Rect real_rect = *rect;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
423
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
424 color = SDL_MapRGBA(target->format, r, g, b, a);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
425
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
426 return SDL_FillRect(target, &real_rect, color);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
427 }
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 static int
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
430 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
431 const SDL_Rect * srcrect, const SDL_Rect * dstrect)
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
432 {
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
433 SDL_DUMMY_RenderData *data =
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
434 (SDL_DUMMY_RenderData *) renderer->driverdata;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
435 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
436 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
437
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
438 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
439 SDL_Surface *target = data->screens[data->current_screen];
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
440 void *pixels =
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
441 (Uint8 *) target->pixels + dstrect->y * target->pitch +
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
442 dstrect->x * target->format->BytesPerPixel;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
443 return SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata,
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
444 srcrect, display->current_mode.format,
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
445 dstrect->w, dstrect->h, pixels,
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
446 target->pitch);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
447 } else {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
448 SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
449 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
450 SDL_RenderCopyFunc copyfunc = (SDL_RenderCopyFunc) surface->userdata;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
451
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
452 if (copyfunc) {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
453 SDL_RenderCopyData copydata;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
454
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
455 copydata.src =
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
456 (Uint8 *) surface->pixels + srcrect->y * surface->pitch +
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
457 srcrect->x * surface->format->BytesPerPixel;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
458 copydata.src_w = srcrect->w;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
459 copydata.src_h = srcrect->h;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
460 copydata.src_pitch = surface->pitch;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
461 copydata.dst =
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
462 (Uint8 *) target->pixels + dstrect->y * target->pitch +
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
463 dstrect->x * target->format->BytesPerPixel;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
464 copydata.dst_w = dstrect->w;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
465 copydata.dst_h = dstrect->h;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
466 copydata.dst_pitch = target->pitch;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
467 copydata.flags = 0;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
468 if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
469 copydata.flags |= SDL_RENDERCOPY_MODULATE_COLOR;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
470 copydata.r = texture->r;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
471 copydata.g = texture->g;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
472 copydata.b = texture->b;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
473 }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
474 if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
475 copydata.flags |= SDL_RENDERCOPY_MODULATE_ALPHA;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
476 copydata.a = texture->a;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
477 }
1990
7b573c59cb1f The dummy renderer can task advantage of the MASK optimization too, though performance probably doesn't matter here...
Sam Lantinga <slouken@libsdl.org>
parents: 1985
diff changeset
478 if (texture->blendMode & SDL_TEXTUREBLENDMODE_MASK) {
7b573c59cb1f The dummy renderer can task advantage of the MASK optimization too, though performance probably doesn't matter here...
Sam Lantinga <slouken@libsdl.org>
parents: 1985
diff changeset
479 copydata.flags |= SDL_RENDERCOPY_MASK;
7b573c59cb1f The dummy renderer can task advantage of the MASK optimization too, though performance probably doesn't matter here...
Sam Lantinga <slouken@libsdl.org>
parents: 1985
diff changeset
480 } else if (texture->blendMode & SDL_TEXTUREBLENDMODE_BLEND) {
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
481 copydata.flags |= SDL_RENDERCOPY_BLEND;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
482 } else if (texture->blendMode & SDL_TEXTUREBLENDMODE_ADD) {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
483 copydata.flags |= SDL_RENDERCOPY_ADD;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
484 } else if (texture->blendMode & SDL_TEXTUREBLENDMODE_MOD) {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
485 copydata.flags |= SDL_RENDERCOPY_MOD;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
486 }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
487 if (texture->scaleMode) {
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
488 copydata.flags |= SDL_RENDERCOPY_NEAREST;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
489 }
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
490 return copyfunc(&copydata);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
491 } else {
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
492 SDL_Rect real_srcrect = *srcrect;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
493 SDL_Rect real_dstrect = *dstrect;
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
494
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
495 return SDL_LowerBlit(surface, &real_srcrect, target,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
496 &real_dstrect);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
497 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
498 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
499 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
500
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
501 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
502 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
503 {
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
504 static int frame_number;
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
505 SDL_DUMMY_RenderData *data =
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
506 (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
507
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
508 /* 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
509 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
510 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
511 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
512 renderer->window, ++frame_number);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
513 SDL_SaveBMP(data->screens[data->current_screen], file);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
514 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
515
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
516 /* Update the flipping chain, if any */
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
517 if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
518 data->current_screen = (data->current_screen + 1) % 2;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
519 } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) {
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
520 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
521 }
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
522 }
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
523
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
524 static void
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
525 SDL_DUMMY_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
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 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
528 SDL_SW_DestroyYUVTexture((SDL_SW_YUVTexture *) texture->driverdata);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
529 } else {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
530 SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
531
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
532 SDL_FreeSurface(surface);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
533 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
534 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
535
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
536 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
537 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
538 {
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
539 SDL_DUMMY_RenderData *data =
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
540 (SDL_DUMMY_RenderData *) renderer->driverdata;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
541 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
542
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 if (data) {
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
544 for (i = 0; i < SDL_arraysize(data->screens); ++i) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
545 if (data->screens[i]) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
546 SDL_FreeSurface(data->screens[i]);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
547 }
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
548 }
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
549 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
550 }
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
551 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
552 }
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
553
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
554 /* vi: set ts=4 sw=4 expandtab: */