comparison src/video/directfb/SDL_DirectFB_video.c @ 286:3ea69fd0b095

Updated for DirectFB 0.9.9
author Sam Lantinga <slouken@libsdl.org>
date Tue, 26 Feb 2002 14:38:53 +0000
parents 80b647695abd
children f6ffac90895c
comparison
equal deleted inserted replaced
285:e5a489f0288c 286:3ea69fd0b095
302 DFBResult ret; 302 DFBResult ret;
303 IDirectFB *dfb; 303 IDirectFB *dfb;
304 DFBCardCapabilities caps; 304 DFBCardCapabilities caps;
305 IDirectFBDisplayLayer *layer; 305 IDirectFBDisplayLayer *layer;
306 DFBDisplayLayerConfig dlc; 306 DFBDisplayLayerConfig dlc;
307 IDirectFBInputBuffer *inputbuffer; 307 IDirectFBEventBuffer *eventbuffer;
308 308
309 309
310 ret = DirectFBInit (NULL, NULL); 310 ret = DirectFBInit (NULL, NULL);
311 if (ret) 311 if (ret)
312 { 312 {
327 SetDirectFBerror ("dfb->GetDisplayLayer", ret); 327 SetDirectFBerror ("dfb->GetDisplayLayer", ret);
328 dfb->Release (dfb); 328 dfb->Release (dfb);
329 return -1; 329 return -1;
330 } 330 }
331 331
332 ret = dfb->CreateInputBuffer (dfb, DICAPS_BUTTONS | DICAPS_AXIS | DICAPS_KEYS, 332 ret = dfb->CreateEventBuffer (dfb, DICAPS_ALL, &eventbuffer);
333 &inputbuffer); 333 if (ret)
334 if (ret) 334 {
335 { 335 SetDirectFBerror ("dfb->CreateEventBuffer", ret);
336 SetDirectFBerror ("dfb->CreateInputBuffer", ret);
337 layer->Release (layer); 336 layer->Release (layer);
338 dfb->Release (dfb); 337 dfb->Release (dfb);
339 return -1; 338 return -1;
340 } 339 }
341 340
393 this->info.video_mem = caps.video_memory / 1024; 392 this->info.video_mem = caps.video_memory / 1024;
394 393
395 HIDDEN->initialized = 1; 394 HIDDEN->initialized = 1;
396 HIDDEN->dfb = dfb; 395 HIDDEN->dfb = dfb;
397 HIDDEN->layer = layer; 396 HIDDEN->layer = layer;
398 HIDDEN->inputbuffer = inputbuffer; 397 HIDDEN->eventbuffer = eventbuffer;
399 398
400 return 0; 399 return 0;
401 } 400 }
402 401
403 static SDL_Rect **DirectFB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) 402 static SDL_Rect **DirectFB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
689 { 688 {
690 } 689 }
691 690
692 static void DirectFB_WindowedUpdate(_THIS, int numrects, SDL_Rect *rects) 691 static void DirectFB_WindowedUpdate(_THIS, int numrects, SDL_Rect *rects)
693 { 692 {
693 DFBRegion region;
694 int i;
695 int region_valid = 0;
694 IDirectFBSurface *surface = this->screen->hwdata->surface; 696 IDirectFBSurface *surface = this->screen->hwdata->surface;
695 DFBRegion region = { rects->x, rects->y, 697
696 rects->x + rects->w - 1, 698 for (i=0; i<numrects; ++i)
697 rects->y + rects->h - 1 };
698
699 while (--numrects)
700 { 699 {
701 int x2, y2; 700 int x2, y2;
702 701
703 rects++; 702 if ( ! rects[i].w ) /* Clipped? */
704 703 continue;
705 if (rects->x < region.x1) 704
706 region.x1 = rects->x; 705 x2 = rects[i].x + rects[i].w - 1;
707 706 y2 = rects[i].y + rects[i].h - 1;
708 if (rects->y < region.y1) 707
709 region.y1 = rects->y; 708 if (region_valid)
710 709 {
711 x2 = rects->x + rects->w - 1; 710 if (rects[i].x < region.x1)
712 y2 = rects->y + rects->h - 1; 711 region.x1 = rects[i].x;
713 712
714 if (x2 > region.x2) 713 if (rects[i].y < region.y1)
715 region.x2 = x2; 714 region.y1 = rects[i].y;
716 715
717 if (y2 > region.y2) 716 if (x2 > region.x2)
718 region.y2 = y2; 717 region.x2 = x2;
719 } 718
720 719 if (y2 > region.y2)
721 surface->Flip (surface, &region, DSFLIP_WAITFORSYNC); 720 region.y2 = y2;
721 }
722 else
723 {
724 region.x1 = rects[i].x;
725 region.y1 = rects[i].y;
726 region.x2 = x2;
727 region.y2 = y2;
728
729 region_valid = 1;
730 }
731 }
732
733 if (region_valid)
734 surface->Flip (surface, &region, DSFLIP_WAITFORSYNC);
722 } 735 }
723 736
724 int DirectFB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) 737 int DirectFB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
725 { 738 {
726 fprintf(stderr, "SDL: Unimplemented DirectFB_SetColors!\n"); 739 fprintf(stderr, "SDL: Unimplemented DirectFB_SetColors!\n");
729 742
730 void DirectFB_VideoQuit(_THIS) 743 void DirectFB_VideoQuit(_THIS)
731 { 744 {
732 int i, j; 745 int i, j;
733 746
734 HIDDEN->inputbuffer->Release (HIDDEN->inputbuffer); 747 HIDDEN->eventbuffer->Release (HIDDEN->eventbuffer);
735 HIDDEN->layer->Release (HIDDEN->layer); 748 HIDDEN->layer->Release (HIDDEN->layer);
736 HIDDEN->dfb->Release (HIDDEN->dfb); 749 HIDDEN->dfb->Release (HIDDEN->dfb);
737 750
738 /* Free video mode lists */ 751 /* Free video mode lists */
739 for ( i=0; i<NUM_MODELISTS; ++i ) 752 for ( i=0; i<NUM_MODELISTS; ++i )