Mercurial > sdl-ios-xcode
comparison src/video/dummy/SDL_nullrender.c @ 3451:a65f7b3a2524
Implemented SDL_RenderReadPixels()/SDL_RenderWritePixels() for the dummy renderer.
This is helpful to validate the automated test suite, since this renderer is super simple and should always pass tests.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 18 Nov 2009 09:20:01 +0000 |
parents | 2133d2d300fd |
children | 0267b8b1595c |
comparison
equal
deleted
inserted
replaced
3450:173199bce642 | 3451:a65f7b3a2524 |
---|---|
38 const SDL_Rect * rect); | 38 const SDL_Rect * rect); |
39 static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, | 39 static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, |
40 SDL_Texture * texture, | 40 SDL_Texture * texture, |
41 const SDL_Rect * srcrect, | 41 const SDL_Rect * srcrect, |
42 const SDL_Rect * dstrect); | 42 const SDL_Rect * dstrect); |
43 static int SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer, | |
44 const SDL_Rect * rect, | |
45 Uint32 format, | |
46 void * pixels, int pitch); | |
47 static int SDL_DUMMY_RenderWritePixels(SDL_Renderer * renderer, | |
48 const SDL_Rect * rect, | |
49 Uint32 format, | |
50 const void * pixels, int pitch); | |
43 static void SDL_DUMMY_RenderPresent(SDL_Renderer * renderer); | 51 static void SDL_DUMMY_RenderPresent(SDL_Renderer * renderer); |
44 static void SDL_DUMMY_DestroyRenderer(SDL_Renderer * renderer); | 52 static void SDL_DUMMY_DestroyRenderer(SDL_Renderer * renderer); |
45 | 53 |
46 | 54 |
47 SDL_RenderDriver SDL_DUMMY_RenderDriver = { | 55 SDL_RenderDriver SDL_DUMMY_RenderDriver = { |
93 | 101 |
94 renderer->RenderPoint = SDL_DUMMY_RenderPoint; | 102 renderer->RenderPoint = SDL_DUMMY_RenderPoint; |
95 renderer->RenderLine = SDL_DUMMY_RenderLine; | 103 renderer->RenderLine = SDL_DUMMY_RenderLine; |
96 renderer->RenderFill = SDL_DUMMY_RenderFill; | 104 renderer->RenderFill = SDL_DUMMY_RenderFill; |
97 renderer->RenderCopy = SDL_DUMMY_RenderCopy; | 105 renderer->RenderCopy = SDL_DUMMY_RenderCopy; |
106 renderer->RenderReadPixels = SDL_DUMMY_RenderReadPixels; | |
107 renderer->RenderWritePixels = SDL_DUMMY_RenderWritePixels; | |
98 renderer->RenderPresent = SDL_DUMMY_RenderPresent; | 108 renderer->RenderPresent = SDL_DUMMY_RenderPresent; |
99 renderer->DestroyRenderer = SDL_DUMMY_DestroyRenderer; | 109 renderer->DestroyRenderer = SDL_DUMMY_DestroyRenderer; |
100 renderer->info.name = SDL_DUMMY_RenderDriver.info.name; | 110 renderer->info.name = SDL_DUMMY_RenderDriver.info.name; |
101 renderer->info.flags = 0; | 111 renderer->info.flags = 0; |
102 renderer->window = window->id; | 112 renderer->window = window->id; |
223 | 233 |
224 return SDL_LowerBlit(surface, &real_srcrect, target, &real_dstrect); | 234 return SDL_LowerBlit(surface, &real_srcrect, target, &real_dstrect); |
225 } | 235 } |
226 } | 236 } |
227 | 237 |
238 static int | |
239 SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, | |
240 Uint32 format, void * pixels, int pitch) | |
241 { | |
242 SDL_DUMMY_RenderData *data = | |
243 (SDL_DUMMY_RenderData *) renderer->driverdata; | |
244 SDL_Window *window = SDL_GetWindowFromID(renderer->window); | |
245 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); | |
246 SDL_Surface *screen = data->screens[data->current_screen]; | |
247 Uint32 screen_format = display->current_mode.format; | |
248 Uint8 *screen_pixels = (Uint8 *) screen->pixels + | |
249 rect->y * screen->pitch + | |
250 rect->x * screen->format->BytesPerPixel; | |
251 int screen_pitch = screen->pitch; | |
252 | |
253 return SDL_ConvertPixels(rect->w, rect->h, | |
254 screen_format, screen_pixels, screen_pitch, | |
255 format, pixels, pitch); | |
256 } | |
257 | |
258 static int | |
259 SDL_DUMMY_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, | |
260 Uint32 format, const void * pixels, int pitch) | |
261 { | |
262 SDL_DUMMY_RenderData *data = | |
263 (SDL_DUMMY_RenderData *) renderer->driverdata; | |
264 SDL_Window *window = SDL_GetWindowFromID(renderer->window); | |
265 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); | |
266 SDL_Surface *screen = data->screens[data->current_screen]; | |
267 Uint32 screen_format = display->current_mode.format; | |
268 Uint8 *screen_pixels = (Uint8 *) screen->pixels + | |
269 rect->y * screen->pitch + | |
270 rect->x * screen->format->BytesPerPixel; | |
271 int screen_pitch = screen->pitch; | |
272 | |
273 return SDL_ConvertPixels(rect->w, rect->h, | |
274 format, pixels, pitch, | |
275 screen_format, screen_pixels, screen_pitch); | |
276 } | |
277 | |
228 static void | 278 static void |
229 SDL_DUMMY_RenderPresent(SDL_Renderer * renderer) | 279 SDL_DUMMY_RenderPresent(SDL_Renderer * renderer) |
230 { | 280 { |
231 static int frame_number; | 281 static int frame_number; |
232 SDL_DUMMY_RenderData *data = | 282 SDL_DUMMY_RenderData *data = |