annotate src/video/dummy/SDL_nullrender.c @ 1677:5e4c5e095925 SDL-1.3

Added new style dummy renderer
author Sam Lantinga <slouken@libsdl.org>
date Tue, 13 Jun 2006 04:37:45 +0000
parents
children 90bf530ced8e
rev   line source
1677
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 #include "SDL_config.h"
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 #include "SDL_video.h"
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 #include "../SDL_sysvideo.h"
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 /* SDL surface based renderer implementation */
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 static SDL_Renderer *SDL_DUMMY_CreateRenderer(SDL_Window * window,
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 Uint32 flags);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 static int SDL_DUMMY_CreateTexture(SDL_Renderer * renderer,
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 SDL_Texture * texture);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 static int SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer,
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 SDL_Rect * rect, void *pixels,
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 int pitch);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 static int SDL_DUMMY_RenderWritePixels(SDL_Renderer * renderer,
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 SDL_Rect * rect, const void *pixels,
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 int pitch);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 static void SDL_DUMMY_RenderPresent(SDL_Renderer * renderer);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 static void SDL_DUMMY_DestroyRenderer(SDL_Renderer * renderer);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 SDL_RenderDriver SDL_DUMMY_RenderDriver = {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 SDL_DUMMY_CreateRenderer,
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 "minimal",
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 (SDL_Renderer_Minimal | SDL_Renderer_PresentCopy),
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 SDL_TextureBlendMode_None,
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 SDL_TextureScaleMode_None,
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 0,
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 {},
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 0,
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 0}
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 };
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 typedef struct
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 SDL_Surface *screen;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 } SDL_DUMMY_RenderData;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 SDL_Renderer *
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 SDL_DUMMY_CreateRenderer(SDL_Window * window, Uint32 flags)
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 SDL_DisplayMode *displayMode = &window->display->current_mode;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 SDL_Renderer *renderer;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 SDL_DUMMY_RenderData *data;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 int i, n;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 int bpp;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 Uint32 Rmask, Gmask, Bmask, Amask;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 if (!SDL_PixelFormatEnumToMasks
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 SDL_SetError("Unknown display format");
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 return NULL;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 renderer = (SDL_Renderer *) SDL_malloc(sizeof(*renderer));
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 if (!renderer) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 SDL_OutOfMemory();
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 return NULL;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 SDL_zerop(renderer);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 data = (SDL_DUMMY_RenderData *) SDL_malloc(sizeof(*data));
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 if (!data) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 SDL_DUMMY_DestroyRenderer(renderer);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 SDL_OutOfMemory();
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 return NULL;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 SDL_zerop(data);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 renderer->RenderReadPixels = SDL_DUMMY_RenderReadPixels;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 renderer->RenderWritePixels = SDL_DUMMY_RenderWritePixels;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 renderer->RenderPresent = SDL_DUMMY_RenderPresent;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 renderer->DestroyRenderer = SDL_DUMMY_DestroyRenderer;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 renderer->info = SDL_DUMMY_RenderDriver.info;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 renderer->window = window;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 renderer->driverdata = data;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 data->screen =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 SDL_CreateRGBSurface(0, window->w, window->h, bpp, Rmask, Gmask,
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 Bmask, Amask);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 if (!data->screen) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 SDL_DUMMY_DestroyRenderer(renderer);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 return NULL;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 return renderer;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 int
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer, SDL_Rect * rect,
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 void *pixels, int pitch)
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 SDL_DUMMY_RenderData *data =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 (SDL_DUMMY_RenderData *) renderer->driverdata;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 SDL_Surface *surface = data->screen;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 Uint8 *src, *dst;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 int row;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 size_t length;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 src =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 (Uint8 *) surface->pixels + rect->y * surface->pitch +
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 rect->x * surface->format->BytesPerPixel;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 dst = (Uint8 *) pixels;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 length = rect->w * surface->format->BytesPerPixel;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 for (row = 0; row < rect->h; ++row) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 SDL_memcpy(dst, src, length);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 src += surface->pitch;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 dst += pitch;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 return 0;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 int
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 SDL_DUMMY_RenderWritePixels(SDL_Renderer * renderer, SDL_Rect * rect,
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 const void *pixels, int pitch)
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 SDL_DUMMY_RenderData *data =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 (SDL_DUMMY_RenderData *) renderer->driverdata;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 SDL_Surface *surface = data->screen;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 Uint8 *src, *dst;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 int row;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 size_t length;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 src = (Uint8 *) pixels;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 dst =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 (Uint8 *) surface->pixels + rect->y * surface->pitch +
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 rect->x * surface->format->BytesPerPixel;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 length = rect->w * surface->format->BytesPerPixel;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 for (row = 0; row < rect->h; ++row) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 SDL_memcpy(dst, src, length);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 src += pitch;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 dst += surface->pitch;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 return 0;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 void
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 SDL_DUMMY_RenderPresent(SDL_Renderer * renderer)
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 static int frame_number;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 SDL_DUMMY_RenderData *data =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 (SDL_DUMMY_RenderData *) renderer->driverdata;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 SDL_Surface *surface = data->screen;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 char file[128];
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 SDL_snprintf(file, sizeof(file), "SDL_screen-%8.8d.bmp",
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 ++frame_number);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 SDL_SaveBMP(surface, file);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 void
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 SDL_DUMMY_DestroyRenderer(SDL_Renderer * renderer)
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 SDL_DUMMY_RenderData *data =
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 (SDL_DUMMY_RenderData *) renderer->driverdata;
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 if (data) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 if (data->screen) {
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 SDL_FreeSurface(data->screen);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 SDL_free(data);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 SDL_free(renderer);
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 }
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190
5e4c5e095925 Added new style dummy renderer
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 /* vi: set ts=4 sw=4 expandtab: */