Mercurial > sdl-ios-xcode
comparison src/video/directfb/SDL_DirectFB_video.c @ 464:1c4be4a16410
Date: Fri, 23 Aug 2002 11:48:56 +0200
From: Denis Oliver Kropp
Subject: Another patch
this is another patch fixing key code mapping
along with some other fixes and better mode handling.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 24 Aug 2002 15:29:06 +0000 |
parents | f6ffac90895c |
children | 22581630aab7 |
comparison
equal
deleted
inserted
replaced
463:bf7389310d27 | 464:1c4be4a16410 |
---|---|
27 | 27 |
28 /* DirectFB video driver implementation. | 28 /* DirectFB video driver implementation. |
29 */ | 29 */ |
30 | 30 |
31 #include <stdlib.h> | 31 #include <stdlib.h> |
32 #include <string.h> | |
32 #include <stdio.h> | 33 #include <stdio.h> |
33 #include <fcntl.h> | 34 #include <fcntl.h> |
34 #include <unistd.h> | 35 #include <unistd.h> |
35 #include <sys/mman.h> | 36 #include <sys/mman.h> |
36 | 37 |
76 struct DirectFBEnumRect { | 77 struct DirectFBEnumRect { |
77 SDL_Rect r; | 78 SDL_Rect r; |
78 struct DirectFBEnumRect* next; | 79 struct DirectFBEnumRect* next; |
79 }; | 80 }; |
80 | 81 |
81 static struct DirectFBEnumRect *enumlists[NUM_MODELISTS]; | 82 static struct DirectFBEnumRect *enumlist = NULL; |
82 | 83 |
83 | 84 |
84 /* DirectFB driver bootstrap functions */ | 85 /* DirectFB driver bootstrap functions */ |
85 | 86 |
86 static int DirectFB_Available(void) | 87 static int DirectFB_Available(void) |
148 VideoBootStrap DirectFB_bootstrap = { | 149 VideoBootStrap DirectFB_bootstrap = { |
149 "directfb", "DirectFB", | 150 "directfb", "DirectFB", |
150 DirectFB_Available, DirectFB_CreateDevice | 151 DirectFB_Available, DirectFB_CreateDevice |
151 }; | 152 }; |
152 | 153 |
154 static DFBSurfacePixelFormat GetFormatForBpp (int bpp, IDirectFBDisplayLayer *layer) | |
155 { | |
156 DFBDisplayLayerConfig dlc; | |
157 int bytes = (bpp + 7) / 8; | |
158 | |
159 layer->GetConfiguration (layer, &dlc); | |
160 | |
161 if (bytes == DFB_BYTES_PER_PIXEL(dlc.pixelformat)) | |
162 return dlc.pixelformat; | |
163 | |
164 switch (bytes) | |
165 { | |
166 case 1: | |
167 return DSPF_RGB332; | |
168 case 2: | |
169 return DSPF_RGB16; | |
170 case 3: | |
171 return DSPF_RGB24; | |
172 case 4: | |
173 return DSPF_RGB32; | |
174 } | |
175 | |
176 return DSPF_UNKNOWN; | |
177 } | |
178 | |
153 static DFBEnumerationResult EnumModesCallback (unsigned int width, | 179 static DFBEnumerationResult EnumModesCallback (unsigned int width, |
154 unsigned int height, | 180 unsigned int height, |
155 unsigned int bpp, | 181 unsigned int bpp, |
156 void *data) | 182 void *data) |
157 { | 183 { |
158 SDL_VideoDevice *this = (SDL_VideoDevice *)data; | 184 SDL_VideoDevice *this = (SDL_VideoDevice *)data; |
159 struct DirectFBEnumRect *enumrect; | 185 struct DirectFBEnumRect *enumrect; |
160 | 186 |
161 switch (bpp) | 187 HIDDEN->nummodes++; |
162 { | 188 |
163 case 8: | 189 enumrect = calloc(1, sizeof(struct DirectFBEnumRect)); |
164 case 15: | 190 if (!enumrect) |
165 case 16: | 191 { |
166 case 24: | 192 SDL_OutOfMemory(); |
167 case 32: | 193 return DFENUM_CANCEL; |
168 bpp /= 8; --bpp; | 194 } |
169 ++HIDDEN->SDL_nummodes[bpp]; | 195 |
170 enumrect = (struct DirectFBEnumRect*)malloc(sizeof(struct DirectFBEnumRect)); | 196 enumrect->r.w = width; |
171 if ( !enumrect ) | 197 enumrect->r.h = height; |
172 { | 198 enumrect->next = enumlist; |
173 SDL_OutOfMemory(); | 199 |
174 return DFENUM_CANCEL; | 200 enumlist = enumrect; |
175 } | |
176 enumrect->r.x = 0; | |
177 enumrect->r.y = 0; | |
178 enumrect->r.w = width; | |
179 enumrect->r.h = height; | |
180 enumrect->next = enumlists[bpp]; | |
181 enumlists[bpp] = enumrect; | |
182 break; | |
183 } | |
184 | 201 |
185 return DFENUM_OK; | 202 return DFENUM_OK; |
186 } | 203 } |
187 | 204 |
188 struct private_hwdata { | 205 struct private_hwdata { |
217 format->Gmask == 0x03E0 && | 234 format->Gmask == 0x03E0 && |
218 format->Bmask == 0x001F) | 235 format->Bmask == 0x001F) |
219 return DSPF_RGB15; | 236 return DSPF_RGB15; |
220 break; | 237 break; |
221 | 238 |
239 case 8: | |
240 if (format->Rmask == 0xE0 && | |
241 format->Gmask == 0x1C && | |
242 format->Bmask == 0x03) | |
243 return DSPF_RGB332; | |
244 break; | |
245 | |
222 case 24: | 246 case 24: |
223 if (format->Rmask == 0xFF0000 && | 247 if (format->Rmask == 0xFF0000 && |
224 format->Gmask == 0x00FF00 && | 248 format->Gmask == 0x00FF00 && |
225 format->Bmask == 0x0000FF) | 249 format->Bmask == 0x0000FF) |
226 return DSPF_RGB24; | 250 return DSPF_RGB24; |
227 break; | 251 break; |
228 | 252 |
229 case 32: | 253 case 32: |
230 if (format->Rmask == 0xFF0000 && | 254 if (format->Rmask == 0xFF0000 && |
231 format->Gmask == 0x00FF00 && | 255 format->Gmask == 0x00FF00 && |
232 format->Bmask == 0x0000FF) | 256 format->Bmask == 0x0000FF) |
233 { | 257 { |
241 } | 265 } |
242 else | 266 else |
243 { | 267 { |
244 switch (format->BitsPerPixel) | 268 switch (format->BitsPerPixel) |
245 { | 269 { |
270 case 8: | |
271 return DSPF_RGB332; | |
246 case 15: | 272 case 15: |
247 return DSPF_RGB15; | 273 return DSPF_RGB15; |
248 case 16: | 274 case 16: |
249 return DSPF_RGB16; | 275 return DSPF_RGB16; |
250 case 24: | 276 case 24: |
255 } | 281 } |
256 | 282 |
257 return DSPF_UNKNOWN; | 283 return DSPF_UNKNOWN; |
258 } | 284 } |
259 | 285 |
286 static const __u8 lookup3to8[] = { 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff }; | |
287 static const __u8 lookup2to8[] = { 0x00, 0x55, 0xaa, 0xff }; | |
288 | |
289 static SDL_Palette *GenerateRGB332Palette() | |
290 { | |
291 int i; | |
292 SDL_Palette *palette; | |
293 SDL_Color *colors; | |
294 | |
295 palette = calloc (1, sizeof(SDL_Palette)); | |
296 if (!palette) | |
297 { | |
298 SDL_OutOfMemory(); | |
299 return NULL; | |
300 } | |
301 | |
302 colors = calloc (256, sizeof(SDL_Color)); | |
303 if (!colors) | |
304 { | |
305 SDL_OutOfMemory(); | |
306 return NULL; | |
307 } | |
308 | |
309 for (i=0; i<256; i++) | |
310 { | |
311 colors[i].r = lookup3to8[ i >> 5 ]; | |
312 colors[i].g = lookup3to8[ (i >> 2) & 7 ]; | |
313 colors[i].g = lookup2to8[ i & 3 ]; | |
314 } | |
315 | |
316 palette->ncolors = 256; | |
317 palette->colors = colors; | |
318 | |
319 return palette; | |
320 } | |
321 | |
260 static int DFBToSDLPixelFormat (DFBSurfacePixelFormat pixelformat, SDL_PixelFormat *format) | 322 static int DFBToSDLPixelFormat (DFBSurfacePixelFormat pixelformat, SDL_PixelFormat *format) |
261 { | 323 { |
262 format->BitsPerPixel = 0; | |
263 format->Amask = format->Rmask = format->Gmask = format->Bmask = 0; | 324 format->Amask = format->Rmask = format->Gmask = format->Bmask = 0; |
325 format->BitsPerPixel = format->BytesPerPixel = 0; | |
264 | 326 |
265 switch (pixelformat) | 327 switch (pixelformat) |
266 { | 328 { |
267 case DSPF_A8: | 329 case DSPF_A8: |
268 format->Amask = 0x000000FF; | 330 format->Amask = 0x000000FF; |
269 break; | 331 break; |
332 | |
270 case DSPF_RGB15: | 333 case DSPF_RGB15: |
271 format->Rmask = 0x00007C00; | 334 format->Rmask = 0x00007C00; |
272 format->Gmask = 0x000003E0; | 335 format->Gmask = 0x000003E0; |
273 format->Bmask = 0x0000001F; | 336 format->Bmask = 0x0000001F; |
274 break; | 337 break; |
338 | |
275 case DSPF_RGB16: | 339 case DSPF_RGB16: |
276 format->Rmask = 0x0000F800; | 340 format->Rmask = 0x0000F800; |
277 format->Gmask = 0x000007E0; | 341 format->Gmask = 0x000007E0; |
278 format->Bmask = 0x0000001F; | 342 format->Bmask = 0x0000001F; |
279 break; | 343 break; |
344 | |
280 case DSPF_ARGB: | 345 case DSPF_ARGB: |
281 format->Amask = 0xFF000000; | 346 format->Amask = 0; /* apps don't seem to like that: 0xFF000000; */ |
282 /* fall through */ | 347 /* fall through */ |
283 case DSPF_RGB24: | 348 case DSPF_RGB24: |
284 case DSPF_RGB32: | 349 case DSPF_RGB32: |
285 format->Rmask = 0x00FF0000; | 350 format->Rmask = 0x00FF0000; |
286 format->Gmask = 0x0000FF00; | 351 format->Gmask = 0x0000FF00; |
287 format->Bmask = 0x000000FF; | 352 format->Bmask = 0x000000FF; |
288 break; | 353 break; |
354 | |
355 case DSPF_RGB332: | |
356 format->Rmask = 0x000000E0; | |
357 format->Gmask = 0x0000001C; | |
358 format->Bmask = 0x00000003; | |
359 | |
360 format->palette = GenerateRGB332Palette(); | |
361 break; | |
362 | |
289 default: | 363 default: |
290 return -1; | 364 return -1; |
291 } | 365 } |
292 | 366 |
293 format->BitsPerPixel = DFB_BITS_PER_PIXEL(pixelformat); | 367 format->BitsPerPixel = DFB_BYTES_PER_PIXEL(pixelformat) * 8; |
368 format->BytesPerPixel = DFB_BYTES_PER_PIXEL(pixelformat); | |
294 | 369 |
295 return 0; | 370 return 0; |
296 } | 371 } |
297 | 372 |
298 | 373 |
299 int DirectFB_VideoInit(_THIS, SDL_PixelFormat *vformat) | 374 int DirectFB_VideoInit(_THIS, SDL_PixelFormat *vformat) |
300 { | 375 { |
301 int i, j; | 376 int i; |
302 DFBResult ret; | 377 DFBResult ret; |
303 IDirectFB *dfb; | 378 DFBCardCapabilities caps; |
304 DFBCardCapabilities caps; | 379 DFBDisplayLayerConfig dlc; |
305 IDirectFBDisplayLayer *layer; | 380 DFBSurfacePixelFormat format; |
306 DFBDisplayLayerConfig dlc; | 381 struct DirectFBEnumRect *rect; |
307 IDirectFBEventBuffer *eventbuffer; | 382 IDirectFB *dfb = NULL; |
383 IDirectFBDisplayLayer *layer = NULL; | |
384 IDirectFBEventBuffer *events = NULL; | |
308 | 385 |
309 | 386 |
310 ret = DirectFBInit (NULL, NULL); | 387 ret = DirectFBInit (NULL, NULL); |
311 if (ret) | 388 if (ret) |
312 { | 389 { |
313 SetDirectFBerror ("DirectFBInit", ret); | 390 SetDirectFBerror ("DirectFBInit", ret); |
314 return -1; | 391 goto error; |
315 } | 392 } |
316 | 393 |
317 ret = DirectFBCreate (&dfb); | 394 ret = DirectFBCreate (&dfb); |
318 if (ret) | 395 if (ret) |
319 { | 396 { |
320 SetDirectFBerror ("DirectFBCreate", ret); | 397 SetDirectFBerror ("DirectFBCreate", ret); |
321 return -1; | 398 goto error; |
322 } | 399 } |
323 | 400 |
324 ret = dfb->GetDisplayLayer (dfb, DLID_PRIMARY, &layer); | 401 ret = dfb->GetDisplayLayer (dfb, DLID_PRIMARY, &layer); |
325 if (ret) | 402 if (ret) |
326 { | 403 { |
327 SetDirectFBerror ("dfb->GetDisplayLayer", ret); | 404 SetDirectFBerror ("dfb->GetDisplayLayer", ret); |
328 dfb->Release (dfb); | 405 goto error; |
329 return -1; | 406 } |
330 } | 407 |
331 | 408 ret = dfb->CreateEventBuffer (dfb, DICAPS_ALL, &events); |
332 ret = dfb->CreateEventBuffer (dfb, DICAPS_ALL, &eventbuffer); | |
333 if (ret) | 409 if (ret) |
334 { | 410 { |
335 SetDirectFBerror ("dfb->CreateEventBuffer", ret); | 411 SetDirectFBerror ("dfb->CreateEventBuffer", ret); |
336 layer->Release (layer); | 412 goto error; |
337 dfb->Release (dfb); | |
338 return -1; | |
339 } | 413 } |
340 | 414 |
341 layer->EnableCursor (layer, 1); | 415 layer->EnableCursor (layer, 1); |
342 | 416 |
343 /* Query layer configuration to determine the current mode and pixelformat */ | 417 /* Query layer configuration to determine the current mode and pixelformat */ |
344 layer->GetConfiguration (layer, &dlc); | 418 layer->GetConfiguration (layer, &dlc); |
345 | 419 |
346 if (DFBToSDLPixelFormat (dlc.pixelformat, vformat)) | 420 /* FIXME: Returning RGB332 as the default mode doesn't work (everything is black) */ |
421 if ((format = dlc.pixelformat) == DSPF_RGB332) | |
422 format = DSPF_RGB16; | |
423 | |
424 if (DFBToSDLPixelFormat (format, vformat)) | |
347 { | 425 { |
348 SDL_SetError ("Unsupported pixelformat"); | 426 SDL_SetError ("Unsupported pixelformat"); |
349 layer->Release (layer); | 427 goto error; |
350 dfb->Release (dfb); | |
351 return -1; | |
352 } | 428 } |
353 | 429 |
354 /* Enumerate the available fullscreen modes */ | 430 /* Enumerate the available fullscreen modes */ |
355 for ( i=0; i<NUM_MODELISTS; ++i ) | |
356 enumlists[i] = NULL; | |
357 | |
358 ret = dfb->EnumVideoModes (dfb, EnumModesCallback, this); | 431 ret = dfb->EnumVideoModes (dfb, EnumModesCallback, this); |
359 if (ret) | 432 if (ret) |
360 { | 433 { |
361 SetDirectFBerror ("dfb->EnumVideoModes", ret); | 434 SetDirectFBerror ("dfb->EnumVideoModes", ret); |
362 layer->Release (layer); | 435 goto error; |
363 dfb->Release (dfb); | 436 } |
364 return(-1); | 437 |
365 } | 438 HIDDEN->modelist = calloc (HIDDEN->nummodes + 1, sizeof(SDL_Rect *)); |
366 for ( i=0; i<NUM_MODELISTS; ++i ) | 439 if (!HIDDEN->modelist) |
367 { | 440 { |
368 struct DirectFBEnumRect *rect; | 441 SDL_OutOfMemory(); |
369 HIDDEN->SDL_modelist[i] = (SDL_Rect **) malloc | 442 goto error; |
370 ((HIDDEN->SDL_nummodes[i]+1)*sizeof(SDL_Rect *)); | 443 } |
371 if ( HIDDEN->SDL_modelist[i] == NULL ) | 444 |
372 { | 445 for (i = 0, rect = enumlist; rect; ++i, rect = rect->next ) |
373 SDL_OutOfMemory(); | 446 { |
374 return(-1); | 447 HIDDEN->modelist[i] = &rect->r; |
375 } | 448 } |
376 for ( j = 0, rect = enumlists[i]; rect; ++j, rect = rect->next ) | 449 |
377 { | 450 HIDDEN->modelist[i] = NULL; |
378 HIDDEN->SDL_modelist[i][j]=(SDL_Rect *)rect; | 451 |
379 } | |
380 HIDDEN->SDL_modelist[i][j] = NULL; | |
381 } | |
382 | 452 |
383 /* Query card capabilities to get the video memory size */ | 453 /* Query card capabilities to get the video memory size */ |
384 dfb->GetCardCapabilities (dfb, &caps); | 454 dfb->GetCardCapabilities (dfb, &caps); |
385 | 455 |
386 this->info.wm_available = 1; | 456 this->info.wm_available = 1; |
392 this->info.video_mem = caps.video_memory / 1024; | 462 this->info.video_mem = caps.video_memory / 1024; |
393 | 463 |
394 HIDDEN->initialized = 1; | 464 HIDDEN->initialized = 1; |
395 HIDDEN->dfb = dfb; | 465 HIDDEN->dfb = dfb; |
396 HIDDEN->layer = layer; | 466 HIDDEN->layer = layer; |
397 HIDDEN->eventbuffer = eventbuffer; | 467 HIDDEN->eventbuffer = events; |
398 | 468 |
399 return 0; | 469 return 0; |
470 | |
471 error: | |
472 if (events) | |
473 events->Release (events); | |
474 | |
475 if (layer) | |
476 layer->Release (layer); | |
477 | |
478 if (dfb) | |
479 dfb->Release (dfb); | |
480 | |
481 return -1; | |
400 } | 482 } |
401 | 483 |
402 static SDL_Rect **DirectFB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) | 484 static SDL_Rect **DirectFB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) |
403 { | 485 { |
404 if (flags & SDL_FULLSCREEN) | 486 if (flags & SDL_FULLSCREEN) |
405 return HIDDEN->SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]; | 487 return HIDDEN->modelist; |
406 else | 488 else |
407 if (SDLToDFBPixelFormat (format) != DSPF_UNKNOWN) | 489 if (SDLToDFBPixelFormat (format) != DSPF_UNKNOWN) |
408 return (SDL_Rect**) -1; | 490 return (SDL_Rect**) -1; |
409 | 491 |
410 return NULL; | 492 return NULL; |
411 } | 493 } |
412 | 494 |
413 SDL_Surface *DirectFB_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags) | 495 static SDL_Surface *DirectFB_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags) |
414 { | 496 { |
415 DFBResult ret; | 497 DFBResult ret; |
416 DFBSurfaceDescription dsc; | 498 DFBSurfaceDescription dsc; |
417 DFBSurfacePixelFormat pixelformat; | 499 DFBSurfacePixelFormat pixelformat; |
418 | 500 |
428 current->hwdata->surface = NULL; | 510 current->hwdata->surface = NULL; |
429 } | 511 } |
430 else if (!current->hwdata) | 512 else if (!current->hwdata) |
431 { | 513 { |
432 /* Allocate the hardware acceleration data */ | 514 /* Allocate the hardware acceleration data */ |
433 current->hwdata = (struct private_hwdata *) malloc (sizeof(*current->hwdata)); | 515 current->hwdata = (struct private_hwdata *) calloc (1, sizeof(*current->hwdata)); |
434 if (!current->hwdata) | 516 if (!current->hwdata) |
435 { | 517 { |
436 SDL_OutOfMemory(); | 518 SDL_OutOfMemory(); |
437 return NULL; | 519 return NULL; |
438 } | 520 } |
439 memset (current->hwdata, 0, sizeof(*current->hwdata)); | |
440 } | 521 } |
441 | 522 |
442 /* Set cooperative level depending on flag SDL_FULLSCREEN */ | 523 /* Set cooperative level depending on flag SDL_FULLSCREEN */ |
443 if (flags & SDL_FULLSCREEN) | 524 if (flags & SDL_FULLSCREEN) |
444 { | 525 { |
469 return NULL; | 550 return NULL; |
470 } | 551 } |
471 } | 552 } |
472 | 553 |
473 /* Create primary surface */ | 554 /* Create primary surface */ |
474 dsc.flags = DSDESC_CAPS; | 555 dsc.flags = DSDESC_CAPS | DSDESC_PIXELFORMAT; |
475 dsc.caps = DSCAPS_PRIMARY | ((flags & SDL_DOUBLEBUF) ? DSCAPS_FLIPPING : 0); | 556 dsc.caps = DSCAPS_PRIMARY | ((flags & SDL_DOUBLEBUF) ? DSCAPS_FLIPPING : 0); |
557 dsc.pixelformat = GetFormatForBpp (bpp, HIDDEN->layer); | |
476 | 558 |
477 ret = HIDDEN->dfb->CreateSurface (HIDDEN->dfb, &dsc, ¤t->hwdata->surface); | 559 ret = HIDDEN->dfb->CreateSurface (HIDDEN->dfb, &dsc, ¤t->hwdata->surface); |
478 if (ret && (flags & SDL_DOUBLEBUF)) | 560 if (ret && (flags & SDL_DOUBLEBUF)) |
479 { | 561 { |
480 /* Try without double buffering */ | 562 /* Try without double buffering */ |
522 | 604 |
523 /* fill surface description */ | 605 /* fill surface description */ |
524 dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS; | 606 dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS; |
525 dsc.width = surface->w; | 607 dsc.width = surface->w; |
526 dsc.height = surface->h; | 608 dsc.height = surface->h; |
527 dsc.caps = surface->flags & SDL_DOUBLEBUF ? DSCAPS_FLIPPING : 0; | 609 dsc.caps = (surface->flags & SDL_DOUBLEBUF) ? DSCAPS_FLIPPING : 0; |
528 | 610 |
529 /* find the right pixelformat */ | 611 /* find the right pixelformat */ |
530 dsc.pixelformat = SDLToDFBPixelFormat (surface->format); | 612 dsc.pixelformat = SDLToDFBPixelFormat (surface->format); |
531 if (dsc.pixelformat == DSPF_UNKNOWN) | 613 if (dsc.pixelformat == DSPF_UNKNOWN) |
532 return -1; | 614 return -1; |
533 | 615 |
534 /* Allocate the hardware acceleration data */ | 616 /* Allocate the hardware acceleration data */ |
535 surface->hwdata = (struct private_hwdata *) malloc (sizeof(*surface->hwdata)); | 617 surface->hwdata = (struct private_hwdata *) calloc (1, sizeof(*surface->hwdata)); |
536 if (surface->hwdata == NULL) | 618 if (surface->hwdata == NULL) |
537 { | 619 { |
538 SDL_OutOfMemory(); | 620 SDL_OutOfMemory(); |
539 return -1; | 621 return -1; |
540 } | 622 } |
579 } | 661 } |
580 | 662 |
581 static int DirectFB_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect, | 663 static int DirectFB_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect, |
582 SDL_Surface *dst, SDL_Rect *dstrect) | 664 SDL_Surface *dst, SDL_Rect *dstrect) |
583 { | 665 { |
584 DFBRectangle sr, dr; | 666 DFBSurfaceBlittingFlags flags = DSBLIT_NOFX; |
585 IDirectFBSurface *surface; | 667 |
586 DFBSurfaceBlittingFlags flags = DSBLIT_NOFX; | 668 DFBRectangle sr = { srcrect->x, srcrect->y, srcrect->w, srcrect->h }; |
587 | 669 DFBRectangle dr = { dstrect->x, dstrect->y, dstrect->w, dstrect->h }; |
588 sr.x = srcrect->x; | 670 |
589 sr.y = srcrect->y; | 671 IDirectFBSurface *surface = dst->hwdata->surface; |
590 sr.w = srcrect->w; | |
591 sr.h = srcrect->h; | |
592 | |
593 dr.x = dstrect->x; | |
594 dr.y = dstrect->y; | |
595 dr.w = dstrect->w; | |
596 dr.h = dstrect->h; | |
597 | |
598 surface = dst->hwdata->surface; | |
599 | 672 |
600 if (src->flags & SDL_SRCCOLORKEY) | 673 if (src->flags & SDL_SRCCOLORKEY) |
601 { | 674 { |
602 flags |= DSBLIT_SRC_COLORKEY; | 675 flags |= DSBLIT_SRC_COLORKEY; |
603 DirectFB_SetHWColorKey (NULL, src, src->format->colorkey); | 676 DirectFB_SetHWColorKey (NULL, src, src->format->colorkey); |
735 } | 808 } |
736 | 809 |
737 int DirectFB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) | 810 int DirectFB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) |
738 { | 811 { |
739 fprintf(stderr, "SDL: Unimplemented DirectFB_SetColors!\n"); | 812 fprintf(stderr, "SDL: Unimplemented DirectFB_SetColors!\n"); |
740 return 0; | 813 return -1; |
741 } | 814 } |
742 | 815 |
743 void DirectFB_VideoQuit(_THIS) | 816 void DirectFB_VideoQuit(_THIS) |
744 { | 817 { |
745 int i, j; | 818 struct DirectFBEnumRect *rect = enumlist; |
746 | 819 |
747 HIDDEN->eventbuffer->Release (HIDDEN->eventbuffer); | 820 if (HIDDEN->eventbuffer) |
748 HIDDEN->layer->Release (HIDDEN->layer); | 821 { |
749 HIDDEN->dfb->Release (HIDDEN->dfb); | 822 HIDDEN->eventbuffer->Release (HIDDEN->eventbuffer); |
750 | 823 HIDDEN->eventbuffer = NULL; |
751 /* Free video mode lists */ | 824 } |
752 for ( i=0; i<NUM_MODELISTS; ++i ) | 825 |
753 { | 826 if (HIDDEN->layer) |
754 if ( HIDDEN->SDL_modelist[i] != NULL ) | 827 { |
755 { | 828 HIDDEN->layer->Release (HIDDEN->layer); |
756 for ( j=0; HIDDEN->SDL_modelist[i][j]; ++j ) | 829 HIDDEN->layer = NULL; |
757 free(HIDDEN->SDL_modelist[i][j]); | 830 } |
758 free(HIDDEN->SDL_modelist[i]); | 831 |
759 HIDDEN->SDL_modelist[i] = NULL; | 832 if (HIDDEN->dfb) |
760 } | 833 { |
761 } | 834 HIDDEN->dfb->Release (HIDDEN->dfb); |
835 HIDDEN->dfb = NULL; | |
836 } | |
837 | |
838 /* Free video mode list */ | |
839 if (HIDDEN->modelist) | |
840 { | |
841 free (HIDDEN->modelist); | |
842 HIDDEN->modelist = NULL; | |
843 } | |
844 | |
845 /* Free mode enumeration list */ | |
846 while (rect) | |
847 { | |
848 struct DirectFBEnumRect *next = rect->next; | |
849 free (rect); | |
850 rect = next; | |
851 } | |
852 enumlist = NULL; | |
762 | 853 |
763 HIDDEN->initialized = 0; | 854 HIDDEN->initialized = 0; |
764 } | 855 } |
765 | 856 |
766 void DirectFB_FinalQuit(void) | 857 void DirectFB_FinalQuit(void) |