comparison src/video/win32/SDL_gdirender.c @ 1913:83420da906a5

Implemented Windows OpenGL support Fixed slowdown enumerating display modes, which was hosing OpenGL as well... Removed SDL_ from the render driver prefixes
author Sam Lantinga <slouken@libsdl.org>
date Mon, 17 Jul 2006 06:47:33 +0000
parents 06c27a737b7a
children 092bd3a019c5
comparison
equal deleted inserted replaced
1912:8d384b647307 1913:83420da906a5
27 #include "../SDL_rect_c.h" 27 #include "../SDL_rect_c.h"
28 #include "../SDL_yuv_sw_c.h" 28 #include "../SDL_yuv_sw_c.h"
29 29
30 /* GDI renderer implementation */ 30 /* GDI renderer implementation */
31 31
32 static SDL_Renderer *SDL_GDI_CreateRenderer(SDL_Window * window, 32 static SDL_Renderer *GDI_CreateRenderer(SDL_Window * window, Uint32 flags);
33 Uint32 flags); 33 static int GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
34 static int SDL_GDI_CreateTexture(SDL_Renderer * renderer, 34 static int GDI_QueryTexturePixels(SDL_Renderer * renderer,
35 SDL_Texture * texture); 35 SDL_Texture * texture, void **pixels,
36 static int SDL_GDI_QueryTexturePixels(SDL_Renderer * renderer, 36 int *pitch);
37 SDL_Texture * texture, void **pixels, 37 static int GDI_SetTexturePalette(SDL_Renderer * renderer,
38 int *pitch); 38 SDL_Texture * texture,
39 static int SDL_GDI_SetTexturePalette(SDL_Renderer * renderer, 39 const SDL_Color * colors, int firstcolor,
40 SDL_Texture * texture, 40 int ncolors);
41 const SDL_Color * colors, int firstcolor, 41 static int GDI_GetTexturePalette(SDL_Renderer * renderer,
42 int ncolors); 42 SDL_Texture * texture, SDL_Color * colors,
43 static int SDL_GDI_GetTexturePalette(SDL_Renderer * renderer, 43 int firstcolor, int ncolors);
44 SDL_Texture * texture, 44 static int GDI_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
45 SDL_Color * colors, int firstcolor, 45 const SDL_Rect * rect, const void *pixels,
46 int ncolors); 46 int pitch);
47 static int SDL_GDI_UpdateTexture(SDL_Renderer * renderer, 47 static int GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
48 SDL_Texture * texture, const SDL_Rect * rect, 48 const SDL_Rect * rect, int markDirty,
49 const void *pixels, int pitch); 49 void **pixels, int *pitch);
50 static int SDL_GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, 50 static void GDI_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
51 const SDL_Rect * rect, int markDirty, 51 static void GDI_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture,
52 void **pixels, int *pitch); 52 int numrects, const SDL_Rect * rects);
53 static void SDL_GDI_UnlockTexture(SDL_Renderer * renderer, 53 static int GDI_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect,
54 SDL_Texture * texture); 54 Uint32 color);
55 static void SDL_GDI_DirtyTexture(SDL_Renderer * renderer, 55 static int GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
56 SDL_Texture * texture, int numrects, 56 const SDL_Rect * srcrect, const SDL_Rect * dstrect,
57 const SDL_Rect * rects); 57 int blendMode, int scaleMode);
58 static int SDL_GDI_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect, 58 static void GDI_RenderPresent(SDL_Renderer * renderer);
59 Uint32 color); 59 static void GDI_DestroyTexture(SDL_Renderer * renderer,
60 static int SDL_GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, 60 SDL_Texture * texture);
61 const SDL_Rect * srcrect, 61 static void GDI_DestroyRenderer(SDL_Renderer * renderer);
62 const SDL_Rect * dstrect, int blendMode, 62
63 int scaleMode); 63
64 static void SDL_GDI_RenderPresent(SDL_Renderer * renderer); 64 SDL_RenderDriver GDI_RenderDriver = {
65 static void SDL_GDI_DestroyTexture(SDL_Renderer * renderer, 65 GDI_CreateRenderer,
66 SDL_Texture * texture);
67 static void SDL_GDI_DestroyRenderer(SDL_Renderer * renderer);
68
69
70 SDL_RenderDriver SDL_GDI_RenderDriver = {
71 SDL_GDI_CreateRenderer,
72 { 66 {
73 "gdi", 67 "gdi",
74 (SDL_Renderer_SingleBuffer | SDL_Renderer_PresentCopy | 68 (SDL_Renderer_SingleBuffer | SDL_Renderer_PresentCopy |
75 SDL_Renderer_PresentFlip2 | SDL_Renderer_PresentFlip3 | 69 SDL_Renderer_PresentFlip2 | SDL_Renderer_PresentFlip3 |
76 SDL_Renderer_PresentDiscard), 70 SDL_Renderer_PresentDiscard),
104 LPBITMAPINFO bmi; 98 LPBITMAPINFO bmi;
105 HBITMAP hbm[3]; 99 HBITMAP hbm[3];
106 int current_hbm; 100 int current_hbm;
107 SDL_DirtyRectList dirty; 101 SDL_DirtyRectList dirty;
108 SDL_bool makedirty; 102 SDL_bool makedirty;
109 } SDL_GDI_RenderData; 103 } GDI_RenderData;
110 104
111 typedef struct 105 typedef struct
112 { 106 {
113 SDL_SW_YUVTexture *yuv; 107 SDL_SW_YUVTexture *yuv;
114 Uint32 format; 108 Uint32 format;
115 HPALETTE hpal; 109 HPALETTE hpal;
116 HBITMAP hbm; 110 HBITMAP hbm;
117 void *pixels; 111 void *pixels;
118 int pitch; 112 int pitch;
119 } SDL_GDI_TextureData; 113 } GDI_TextureData;
120 114
121 static void 115 static void
122 UpdateYUVTextureData(SDL_Texture * texture) 116 UpdateYUVTextureData(SDL_Texture * texture)
123 { 117 {
124 SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata; 118 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
125 SDL_Rect rect; 119 SDL_Rect rect;
126 120
127 rect.x = 0; 121 rect.x = 0;
128 rect.y = 0; 122 rect.y = 0;
129 rect.w = texture->w; 123 rect.w = texture->w;
133 } 127 }
134 128
135 void 129 void
136 GDI_AddRenderDriver(_THIS) 130 GDI_AddRenderDriver(_THIS)
137 { 131 {
138 SDL_AddRenderDriver(0, &SDL_GDI_RenderDriver); 132 SDL_AddRenderDriver(0, &GDI_RenderDriver);
139 } 133 }
140 134
141 SDL_Renderer * 135 SDL_Renderer *
142 SDL_GDI_CreateRenderer(SDL_Window * window, Uint32 flags) 136 GDI_CreateRenderer(SDL_Window * window, Uint32 flags)
143 { 137 {
144 SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata; 138 SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
145 SDL_Renderer *renderer; 139 SDL_Renderer *renderer;
146 SDL_GDI_RenderData *data; 140 GDI_RenderData *data;
147 int bmi_size; 141 int bmi_size;
148 HBITMAP hbm; 142 HBITMAP hbm;
149 int i, n; 143 int i, n;
150 144
151 renderer = (SDL_Renderer *) SDL_malloc(sizeof(*renderer)); 145 renderer = (SDL_Renderer *) SDL_malloc(sizeof(*renderer));
153 SDL_OutOfMemory(); 147 SDL_OutOfMemory();
154 return NULL; 148 return NULL;
155 } 149 }
156 SDL_zerop(renderer); 150 SDL_zerop(renderer);
157 151
158 data = (SDL_GDI_RenderData *) SDL_malloc(sizeof(*data)); 152 data = (GDI_RenderData *) SDL_malloc(sizeof(*data));
159 if (!data) { 153 if (!data) {
160 SDL_GDI_DestroyRenderer(renderer); 154 GDI_DestroyRenderer(renderer);
161 SDL_OutOfMemory(); 155 SDL_OutOfMemory();
162 return NULL; 156 return NULL;
163 } 157 }
164 SDL_zerop(data); 158 SDL_zerop(data);
165 159
166 renderer->CreateTexture = SDL_GDI_CreateTexture; 160 renderer->CreateTexture = GDI_CreateTexture;
167 renderer->QueryTexturePixels = SDL_GDI_QueryTexturePixels; 161 renderer->QueryTexturePixels = GDI_QueryTexturePixels;
168 renderer->SetTexturePalette = SDL_GDI_SetTexturePalette; 162 renderer->SetTexturePalette = GDI_SetTexturePalette;
169 renderer->GetTexturePalette = SDL_GDI_GetTexturePalette; 163 renderer->GetTexturePalette = GDI_GetTexturePalette;
170 renderer->UpdateTexture = SDL_GDI_UpdateTexture; 164 renderer->UpdateTexture = GDI_UpdateTexture;
171 renderer->LockTexture = SDL_GDI_LockTexture; 165 renderer->LockTexture = GDI_LockTexture;
172 renderer->UnlockTexture = SDL_GDI_UnlockTexture; 166 renderer->UnlockTexture = GDI_UnlockTexture;
173 renderer->DirtyTexture = SDL_GDI_DirtyTexture; 167 renderer->DirtyTexture = GDI_DirtyTexture;
174 renderer->RenderFill = SDL_GDI_RenderFill; 168 renderer->RenderFill = GDI_RenderFill;
175 renderer->RenderCopy = SDL_GDI_RenderCopy; 169 renderer->RenderCopy = GDI_RenderCopy;
176 renderer->RenderPresent = SDL_GDI_RenderPresent; 170 renderer->RenderPresent = GDI_RenderPresent;
177 renderer->DestroyTexture = SDL_GDI_DestroyTexture; 171 renderer->DestroyTexture = GDI_DestroyTexture;
178 renderer->DestroyRenderer = SDL_GDI_DestroyRenderer; 172 renderer->DestroyRenderer = GDI_DestroyRenderer;
179 renderer->info = SDL_GDI_RenderDriver.info; 173 renderer->info = GDI_RenderDriver.info;
180 renderer->window = window->id; 174 renderer->window = window->id;
181 renderer->driverdata = data; 175 renderer->driverdata = data;
182 176
183 renderer->info.flags = SDL_Renderer_Accelerated; 177 renderer->info.flags = SDL_Renderer_Accelerated;
184 178
185 data->hwnd = windowdata->hwnd; 179 data->hwnd = windowdata->hwnd;
186 data->window_hdc = GetDC(data->hwnd); 180 data->window_hdc = windowdata->hdc;
187 data->render_hdc = CreateCompatibleDC(data->window_hdc); 181 data->render_hdc = CreateCompatibleDC(data->window_hdc);
188 data->memory_hdc = CreateCompatibleDC(data->window_hdc); 182 data->memory_hdc = CreateCompatibleDC(data->window_hdc);
189 183
190 /* Fill in the compatible bitmap info */ 184 /* Fill in the compatible bitmap info */
191 bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD); 185 bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
192 data->bmi = (LPBITMAPINFO) SDL_malloc(bmi_size); 186 data->bmi = (LPBITMAPINFO) SDL_malloc(bmi_size);
193 if (!data->bmi) { 187 if (!data->bmi) {
194 SDL_GDI_DestroyRenderer(renderer); 188 GDI_DestroyRenderer(renderer);
195 SDL_OutOfMemory(); 189 SDL_OutOfMemory();
196 return NULL; 190 return NULL;
197 } 191 }
198 SDL_memset(data->bmi, 0, bmi_size); 192 SDL_memset(data->bmi, 0, bmi_size);
199 data->bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 193 data->bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
219 } 213 }
220 for (i = 0; i < n; ++i) { 214 for (i = 0; i < n; ++i) {
221 data->hbm[i] = 215 data->hbm[i] =
222 CreateCompatibleBitmap(data->window_hdc, window->w, window->h); 216 CreateCompatibleBitmap(data->window_hdc, window->w, window->h);
223 if (!data->hbm[i]) { 217 if (!data->hbm[i]) {
224 SDL_GDI_DestroyRenderer(renderer); 218 GDI_DestroyRenderer(renderer);
225 WIN_SetError("CreateCompatibleBitmap()"); 219 WIN_SetError("CreateCompatibleBitmap()");
226 return NULL; 220 return NULL;
227 } 221 }
228 } 222 }
229 if (n > 0) { 223 if (n > 0) {
238 232
239 return renderer; 233 return renderer;
240 } 234 }
241 235
242 static int 236 static int
243 SDL_GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) 237 GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
244 { 238 {
245 SDL_GDI_RenderData *renderdata = 239 GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata;
246 (SDL_GDI_RenderData *) renderer->driverdata;
247 SDL_Window *window = SDL_GetWindowFromID(renderer->window); 240 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
248 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); 241 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
249 SDL_GDI_TextureData *data; 242 GDI_TextureData *data;
250 243
251 data = (SDL_GDI_TextureData *) SDL_malloc(sizeof(*data)); 244 data = (GDI_TextureData *) SDL_malloc(sizeof(*data));
252 if (!data) { 245 if (!data) {
253 SDL_OutOfMemory(); 246 SDL_OutOfMemory();
254 return -1; 247 return -1;
255 } 248 }
256 SDL_zerop(data); 249 SDL_zerop(data);
258 texture->driverdata = data; 251 texture->driverdata = data;
259 252
260 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { 253 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
261 data->yuv = SDL_SW_CreateYUVTexture(texture); 254 data->yuv = SDL_SW_CreateYUVTexture(texture);
262 if (!data->yuv) { 255 if (!data->yuv) {
263 SDL_GDI_DestroyTexture(renderer, texture); 256 GDI_DestroyTexture(renderer, texture);
264 return -1; 257 return -1;
265 } 258 }
266 data->format = display->current_mode.format; 259 data->format = display->current_mode.format;
267 } else { 260 } else {
268 data->format = texture->format; 261 data->format = texture->format;
275 LPBITMAPINFO bmi; 268 LPBITMAPINFO bmi;
276 269
277 bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD); 270 bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD);
278 bmi = (LPBITMAPINFO) SDL_malloc(bmi_size); 271 bmi = (LPBITMAPINFO) SDL_malloc(bmi_size);
279 if (!bmi) { 272 if (!bmi) {
280 SDL_GDI_DestroyTexture(renderer, texture); 273 GDI_DestroyTexture(renderer, texture);
281 SDL_OutOfMemory(); 274 SDL_OutOfMemory();
282 return -1; 275 return -1;
283 } 276 }
284 SDL_memset(bmi, 0, bmi_size); 277 SDL_memset(bmi, 0, bmi_size);
285 bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 278 bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
301 palette = 294 palette =
302 (LOGPALETTE *) SDL_malloc(sizeof(*palette) + 295 (LOGPALETTE *) SDL_malloc(sizeof(*palette) +
303 ncolors * sizeof(PALETTEENTRY)); 296 ncolors * sizeof(PALETTEENTRY));
304 if (!palette) { 297 if (!palette) {
305 SDL_free(bmi); 298 SDL_free(bmi);
306 SDL_GDI_DestroyTexture(renderer, texture); 299 GDI_DestroyTexture(renderer, texture);
307 SDL_OutOfMemory(); 300 SDL_OutOfMemory();
308 return -1; 301 return -1;
309 } 302 }
310 palette->palVersion = 0x300; 303 palette->palVersion = 0x300;
311 palette->palNumEntries = ncolors; 304 palette->palNumEntries = ncolors;
337 CreateCompatibleBitmap(renderdata->window_hdc, texture->w, 330 CreateCompatibleBitmap(renderdata->window_hdc, texture->w,
338 texture->h); 331 texture->h);
339 data->pixels = NULL; 332 data->pixels = NULL;
340 } 333 }
341 if (!data->hbm) { 334 if (!data->hbm) {
342 SDL_GDI_DestroyTexture(renderer, texture); 335 GDI_DestroyTexture(renderer, texture);
343 WIN_SetError("Couldn't create bitmap"); 336 WIN_SetError("Couldn't create bitmap");
344 return -1; 337 return -1;
345 } 338 }
346 return 0; 339 return 0;
347 } 340 }
348 341
349 static int 342 static int
350 SDL_GDI_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, 343 GDI_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
351 void **pixels, int *pitch) 344 void **pixels, int *pitch)
352 { 345 {
353 SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata; 346 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
354 347
355 if (data->yuv) { 348 if (data->yuv) {
356 return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch); 349 return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch);
357 } else { 350 } else {
358 *pixels = data->pixels; 351 *pixels = data->pixels;
360 return 0; 353 return 0;
361 } 354 }
362 } 355 }
363 356
364 static int 357 static int
365 SDL_GDI_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, 358 GDI_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
366 const SDL_Color * colors, int firstcolor, 359 const SDL_Color * colors, int firstcolor, int ncolors)
367 int ncolors) 360 {
368 { 361 GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata;
369 SDL_GDI_RenderData *renderdata = 362 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
370 (SDL_GDI_RenderData *) renderer->driverdata;
371 SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata;
372 363
373 if (data->yuv) { 364 if (data->yuv) {
374 SDL_SetError("YUV textures don't have a palette"); 365 SDL_SetError("YUV textures don't have a palette");
375 return -1; 366 return -1;
376 } else { 367 } else {
390 return 0; 381 return 0;
391 } 382 }
392 } 383 }
393 384
394 static int 385 static int
395 SDL_GDI_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, 386 GDI_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture,
396 SDL_Color * colors, int firstcolor, int ncolors) 387 SDL_Color * colors, int firstcolor, int ncolors)
397 { 388 {
398 SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata; 389 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
399 390
400 if (data->yuv) { 391 if (data->yuv) {
401 SDL_SetError("YUV textures don't have a palette"); 392 SDL_SetError("YUV textures don't have a palette");
402 return -1; 393 return -1;
403 } else { 394 } else {
416 return 0; 407 return 0;
417 } 408 }
418 } 409 }
419 410
420 static int 411 static int
421 SDL_GDI_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, 412 GDI_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
422 const SDL_Rect * rect, const void *pixels, int pitch) 413 const SDL_Rect * rect, const void *pixels, int pitch)
423 { 414 {
424 SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata; 415 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
425 416
426 if (data->yuv) { 417 if (data->yuv) {
427 if (SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch) < 0) { 418 if (SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch) < 0) {
428 return -1; 419 return -1;
429 } 420 }
430 UpdateYUVTextureData(texture); 421 UpdateYUVTextureData(texture);
431 return 0; 422 return 0;
432 } else { 423 } else {
433 SDL_GDI_RenderData *renderdata = 424 GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata;
434 (SDL_GDI_RenderData *) renderer->driverdata;
435 425
436 if (data->pixels) { 426 if (data->pixels) {
437 Uint8 *src, *dst; 427 Uint8 *src, *dst;
438 int row; 428 int row;
439 size_t length; 429 size_t length;
463 return 0; 453 return 0;
464 } 454 }
465 } 455 }
466 456
467 static int 457 static int
468 SDL_GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, 458 GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
469 const SDL_Rect * rect, int markDirty, void **pixels, 459 const SDL_Rect * rect, int markDirty, void **pixels,
470 int *pitch) 460 int *pitch)
471 { 461 {
472 SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata; 462 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
473 463
474 if (data->yuv) { 464 if (data->yuv) {
475 return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels, 465 return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels,
476 pitch); 466 pitch);
477 } else if (data->pixels) { 467 } else if (data->pixels) {
486 return -1; 476 return -1;
487 } 477 }
488 } 478 }
489 479
490 static void 480 static void
491 SDL_GDI_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) 481 GDI_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
492 { 482 {
493 SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata; 483 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
494 484
495 if (data->yuv) { 485 if (data->yuv) {
496 SDL_SW_UnlockYUVTexture(data->yuv); 486 SDL_SW_UnlockYUVTexture(data->yuv);
497 UpdateYUVTextureData(texture); 487 UpdateYUVTextureData(texture);
498 } 488 }
499 } 489 }
500 490
501 static void 491 static void
502 SDL_GDI_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, 492 GDI_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects,
503 int numrects, const SDL_Rect * rects) 493 const SDL_Rect * rects)
504 { 494 {
505 } 495 }
506 496
507 static int 497 static int
508 SDL_GDI_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect, 498 GDI_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 color)
509 Uint32 color) 499 {
510 { 500 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
511 SDL_GDI_RenderData *data = (SDL_GDI_RenderData *) renderer->driverdata;
512 Uint8 r, g, b; 501 Uint8 r, g, b;
513 RECT rc; 502 RECT rc;
514 HBRUSH brush; 503 HBRUSH brush;
515 int status; 504 int status;
516 505
539 } 528 }
540 return 0; 529 return 0;
541 } 530 }
542 531
543 static int 532 static int
544 SDL_GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, 533 GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
545 const SDL_Rect * srcrect, const SDL_Rect * dstrect, 534 const SDL_Rect * srcrect, const SDL_Rect * dstrect,
546 int blendMode, int scaleMode) 535 int blendMode, int scaleMode)
547 { 536 {
548 SDL_GDI_RenderData *data = (SDL_GDI_RenderData *) renderer->driverdata; 537 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
549 SDL_GDI_TextureData *texturedata = 538 GDI_TextureData *texturedata = (GDI_TextureData *) texture->driverdata;
550 (SDL_GDI_TextureData *) texture->driverdata;
551 539
552 if (data->makedirty) { 540 if (data->makedirty) {
553 SDL_AddDirtyRect(&data->dirty, dstrect); 541 SDL_AddDirtyRect(&data->dirty, dstrect);
554 } 542 }
555 543
594 } 582 }
595 return 0; 583 return 0;
596 } 584 }
597 585
598 static void 586 static void
599 SDL_GDI_RenderPresent(SDL_Renderer * renderer) 587 GDI_RenderPresent(SDL_Renderer * renderer)
600 { 588 {
601 SDL_GDI_RenderData *data = (SDL_GDI_RenderData *) renderer->driverdata; 589 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
602 SDL_DirtyRect *dirty; 590 SDL_DirtyRect *dirty;
603 591
604 /* Send the data to the display */ 592 /* Send the data to the display */
605 if (!(renderer->info.flags & SDL_Renderer_SingleBuffer)) { 593 if (!(renderer->info.flags & SDL_Renderer_SingleBuffer)) {
606 for (dirty = data->dirty.list; dirty; dirty = dirty->next) { 594 for (dirty = data->dirty.list; dirty; dirty = dirty->next) {
620 SelectObject(data->render_hdc, data->hbm[data->current_hbm]); 608 SelectObject(data->render_hdc, data->hbm[data->current_hbm]);
621 } 609 }
622 } 610 }
623 611
624 static void 612 static void
625 SDL_GDI_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) 613 GDI_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
626 { 614 {
627 SDL_GDI_TextureData *data = (SDL_GDI_TextureData *) texture->driverdata; 615 GDI_TextureData *data = (GDI_TextureData *) texture->driverdata;
628 616
629 if (!data) { 617 if (!data) {
630 return; 618 return;
631 } 619 }
632 if (data->yuv) { 620 if (data->yuv) {
641 SDL_free(data); 629 SDL_free(data);
642 texture->driverdata = NULL; 630 texture->driverdata = NULL;
643 } 631 }
644 632
645 void 633 void
646 SDL_GDI_DestroyRenderer(SDL_Renderer * renderer) 634 GDI_DestroyRenderer(SDL_Renderer * renderer)
647 { 635 {
648 SDL_GDI_RenderData *data = (SDL_GDI_RenderData *) renderer->driverdata; 636 GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata;
649 int i; 637 int i;
650 638
651 if (data) { 639 if (data) {
652 ReleaseDC(data->hwnd, data->window_hdc);
653 DeleteDC(data->render_hdc); 640 DeleteDC(data->render_hdc);
654 DeleteDC(data->memory_hdc); 641 DeleteDC(data->memory_hdc);
655 if (data->bmi) { 642 if (data->bmi) {
656 SDL_free(data->bmi); 643 SDL_free(data->bmi);
657 } 644 }