annotate src/video/dummy/SDL_nullrender.c @ 4411:6f025b97c55c gsoc2008_iphone

Closing obsolete gsoc2008_iphone named branch
author Ryan C. Gordon <icculus@icculus.org>
date Sun, 28 Feb 2010 00:21:32 -0500
parents c785543d1843
children c3e7c0698cbb 99210400e8b9
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"
2228
bb67fd5ccfdb Fixed compile warnings with Visual C++
Sam Lantinga <slouken@libsdl.org>
parents: 2227
diff changeset
27 #include "../SDL_renderer_sw.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);
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
34 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
35 Uint8 b, Uint8 a, const SDL_Rect * rect);
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
36 static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
37 SDL_Texture * texture,
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
38 const SDL_Rect * srcrect,
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
39 const SDL_Rect * dstrect);
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
40 static void 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
41 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
42
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 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
45 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
46 {
1906
0c49855a7a3e Changed the name of the dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1895
diff changeset
47 "dummy",
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
48 (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY |
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
49 SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 |
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
50 SDL_RENDERER_PRESENTDISCARD),
2227
b252359547ed Exported the software renderer texture functions to make easier to create
Sam Lantinga <slouken@libsdl.org>
parents: 1992
diff changeset
51 }
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
52 };
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 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
55 {
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
56 int current_screen;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
57 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
58 } 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
59
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 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
61 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
62 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 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
64 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
65 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
66 SDL_DUMMY_RenderData *data;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
67 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
68 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
69 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
70
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 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
72 (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
73 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
74 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
75 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
77 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
78 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
79 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
80 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
81 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 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
84 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
85 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
86 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
87 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
88 }
c121d94672cb 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 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
90
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
91 renderer->RenderFill = SDL_DUMMY_RenderFill;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
92 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
93 renderer->RenderPresent = SDL_DUMMY_RenderPresent;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 renderer->DestroyRenderer = SDL_DUMMY_DestroyRenderer;
2227
b252359547ed Exported the software renderer texture functions to make easier to create
Sam Lantinga <slouken@libsdl.org>
parents: 1992
diff changeset
95 renderer->info.name = SDL_DUMMY_RenderDriver.info.name;
b252359547ed Exported the software renderer texture functions to make easier to create
Sam Lantinga <slouken@libsdl.org>
parents: 1992
diff changeset
96 renderer->info.flags = 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
97 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
98 renderer->driverdata = data;
2227
b252359547ed Exported the software renderer texture functions to make easier to create
Sam Lantinga <slouken@libsdl.org>
parents: 1992
diff changeset
99 Setup_SoftwareRenderer(renderer);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
100
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
101 if (flags & SDL_RENDERER_PRESENTFLIP2) {
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
102 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
103 n = 2;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
104 } else if (flags & SDL_RENDERER_PRESENTFLIP3) {
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
105 renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
106 n = 3;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
107 } else {
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
108 renderer->info.flags |= SDL_RENDERER_PRESENTCOPY;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
109 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
110 }
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
111 for (i = 0; i < n; ++i) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
112 data->screens[i] =
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
113 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
114 Bmask, Amask);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
115 if (!data->screens[i]) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
116 SDL_DUMMY_DestroyRenderer(renderer);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
117 return NULL;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
118 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
119 SDL_SetSurfacePalette(data->screens[i], display->palette);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
120 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
121 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
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 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
124 }
c121d94672cb 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
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
126 static int
1985
8055185ae4ed Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents: 1965
diff changeset
127 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
128 Uint8 a, const SDL_Rect * rect)
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
129 {
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
130 SDL_DUMMY_RenderData *data =
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
131 (SDL_DUMMY_RenderData *) renderer->driverdata;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
132 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
133 Uint32 color;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
134 SDL_Rect real_rect = *rect;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
135
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
136 color = SDL_MapRGBA(target->format, r, g, b, a);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
137
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
138 return SDL_FillRect(target, &real_rect, color);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
139 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
140
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
141 static int
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
142 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
143 const SDL_Rect * srcrect, const SDL_Rect * dstrect)
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
144 {
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
145 SDL_DUMMY_RenderData *data =
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
146 (SDL_DUMMY_RenderData *) renderer->driverdata;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
147 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
148 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
149
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
150 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
151 SDL_Surface *target = data->screens[data->current_screen];
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
152 void *pixels =
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
153 (Uint8 *) target->pixels + dstrect->y * target->pitch +
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
154 dstrect->x * target->format->BytesPerPixel;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
155 return SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata,
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
156 srcrect, display->current_mode.format,
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
157 dstrect->w, dstrect->h, pixels,
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
158 target->pitch);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
159 } else {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
160 SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
161 SDL_Surface *target = data->screens[data->current_screen];
2267
c785543d1843 Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
162 SDL_Rect real_srcrect = *srcrect;
c785543d1843 Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
163 SDL_Rect real_dstrect = *dstrect;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
164
2267
c785543d1843 Okay, still some bugs, but everything builds again...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
165 return SDL_LowerBlit(surface, &real_srcrect, target, &real_dstrect);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
166 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
167 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
168
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
169 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
170 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
171 {
c121d94672cb 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 static int frame_number;
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
173 SDL_DUMMY_RenderData *data =
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
174 (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
175
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
176 /* 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
177 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
178 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
179 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
180 renderer->window, ++frame_number);
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
181 SDL_SaveBMP(data->screens[data->current_screen], file);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
182 }
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
183
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
184 /* Update the flipping chain, if any */
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
185 if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
186 data->current_screen = (data->current_screen + 1) % 2;
1965
a788656ca29a SDL constants are all uppercase.
Sam Lantinga <slouken@libsdl.org>
parents: 1912
diff changeset
187 } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) {
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
188 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
189 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
192 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
193 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
194 {
1912
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
195 SDL_DUMMY_RenderData *data =
8d384b647307 Setting up the OpenGL support
Sam Lantinga <slouken@libsdl.org>
parents: 1908
diff changeset
196 (SDL_DUMMY_RenderData *) renderer->driverdata;
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
197 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
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 if (data) {
1908
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
200 for (i = 0; i < SDL_arraysize(data->screens); ++i) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
201 if (data->screens[i]) {
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
202 SDL_FreeSurface(data->screens[i]);
e079dafea2bf Implemented fully featured dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents: 1907
diff changeset
203 }
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
204 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 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
206 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 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
208 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 /* vi: set ts=4 sw=4 expandtab: */