Mercurial > sdl-ios-xcode
comparison src/video/svga/SDL_svgavideo.c @ 205:13161d3d349d
Added double-buffering support for SVGAlib (thanks Kutak!)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 14 Oct 2001 19:49:02 +0000 |
parents | 3647c809813d |
children | bb72c418a1f9 |
comparison
equal
deleted
inserted
replaced
204:62bad9a82022 | 205:13161d3d349d |
---|---|
143 device->FillHWRect = NULL; | 143 device->FillHWRect = NULL; |
144 device->SetHWColorKey = NULL; | 144 device->SetHWColorKey = NULL; |
145 device->SetHWAlpha = NULL; | 145 device->SetHWAlpha = NULL; |
146 device->LockHWSurface = SVGA_LockHWSurface; | 146 device->LockHWSurface = SVGA_LockHWSurface; |
147 device->UnlockHWSurface = SVGA_UnlockHWSurface; | 147 device->UnlockHWSurface = SVGA_UnlockHWSurface; |
148 device->FlipHWSurface = NULL; | 148 device->FlipHWSurface = SVGA_FlipHWSurface; |
149 device->FreeHWSurface = SVGA_FreeHWSurface; | 149 device->FreeHWSurface = SVGA_FreeHWSurface; |
150 device->SetCaption = NULL; | 150 device->SetCaption = NULL; |
151 device->SetIcon = NULL; | 151 device->SetIcon = NULL; |
152 device->IconifyWindow = NULL; | 152 device->IconifyWindow = NULL; |
153 device->GrabInput = NULL; | 153 device->GrabInput = NULL; |
221 vga_modeinfo *modeinfo; | 221 vga_modeinfo *modeinfo; |
222 | 222 |
223 this->info.wm_available = 0; | 223 this->info.wm_available = 0; |
224 this->info.hw_available = 1; | 224 this->info.hw_available = 1; |
225 modeinfo = vga_getmodeinfo(vga_getcurrentmode()); | 225 modeinfo = vga_getmodeinfo(vga_getcurrentmode()); |
226 this->info.video_mem = (modeinfo->maxpixels/1024); | 226 this->info.video_mem = modeinfo->memory; |
227 if ( modeinfo->bytesperpixel > 0 ) { | |
228 this->info.video_mem *= modeinfo->bytesperpixel; | |
229 } | |
230 /* FIXME: Add hardware accelerated blit information */ | 227 /* FIXME: Add hardware accelerated blit information */ |
231 #if 0 | 228 #if 0 |
232 printf("Hardware accelerated blit: %savailable\n", modeinfo->haveblit ? "" : "not "); | 229 printf("Hardware accelerated blit: %savailable\n", modeinfo->haveblit ? "" : "not "); |
233 #endif | 230 #endif |
234 } | 231 } |
345 int width, int height, int bpp, Uint32 flags) | 342 int width, int height, int bpp, Uint32 flags) |
346 { | 343 { |
347 int mode; | 344 int mode; |
348 int vgamode; | 345 int vgamode; |
349 vga_modeinfo *modeinfo; | 346 vga_modeinfo *modeinfo; |
347 int screenpage_len; | |
350 | 348 |
351 /* Try to set the requested linear video mode */ | 349 /* Try to set the requested linear video mode */ |
352 bpp = (bpp+7)/8-1; | 350 bpp = (bpp+7)/8-1; |
353 for ( mode=0; SDL_modelist[bpp][mode]; ++mode ) { | 351 for ( mode=0; SDL_modelist[bpp][mode]; ++mode ) { |
354 if ( (SDL_modelist[bpp][mode]->w == width) && | 352 if ( (SDL_modelist[bpp][mode]->w == width) && |
391 current->w = width; | 389 current->w = width; |
392 current->h = height; | 390 current->h = height; |
393 current->pitch = modeinfo->linewidth; | 391 current->pitch = modeinfo->linewidth; |
394 current->pixels = vga_getgraphmem(); | 392 current->pixels = vga_getgraphmem(); |
395 | 393 |
394 /* set double-buffering */ | |
395 if ( flags & SDL_DOUBLEBUF ) | |
396 { | |
397 /* length of one screen page in bytes */ | |
398 screenpage_len=current->h*modeinfo->linewidth; | |
399 | |
400 /* if start address should be aligned */ | |
401 if ( modeinfo->linewidth_unit ) | |
402 { | |
403 if ( screenpage_len % modeinfo->linewidth_unit ) | |
404 { | |
405 screenpage_len += modeinfo->linewidth_unit - ( screenpage_len % modeinfo->linewidth_unit ); | |
406 } | |
407 } | |
408 | |
409 /* if we heve enough videomemory = ak je dost videopamete */ | |
410 if ( modeinfo->memory > ( screenpage_len * 2 / 1024 ) ) | |
411 { | |
412 current->flags |= SDL_DOUBLEBUF; | |
413 flip_page = 0; | |
414 flip_offset[0] = 0; | |
415 flip_offset[1] = screenpage_len; | |
416 flip_address[0] = vga_getgraphmem(); | |
417 flip_address[1] = flip_address[0]+screenpage_len; | |
418 SVGA_FlipHWSurface(this,current); | |
419 } | |
420 } | |
421 | |
396 /* Set the blit function */ | 422 /* Set the blit function */ |
397 this->UpdateRects = SVGA_DirectUpdate; | 423 this->UpdateRects = SVGA_DirectUpdate; |
398 | 424 |
399 /* Set up the mouse handler again (buggy SVGAlib 1.40) */ | 425 /* Set up the mouse handler again (buggy SVGAlib 1.40) */ |
400 mouse_seteventhandler(SVGA_mousecallback); | 426 mouse_seteventhandler(SVGA_mousecallback); |
414 } | 440 } |
415 | 441 |
416 /* We need to wait for vertical retrace on page flipped displays */ | 442 /* We need to wait for vertical retrace on page flipped displays */ |
417 static int SVGA_LockHWSurface(_THIS, SDL_Surface *surface) | 443 static int SVGA_LockHWSurface(_THIS, SDL_Surface *surface) |
418 { | 444 { |
419 if ( (surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) { | 445 /* The waiting is done in SVGA_FlipHWSurface() */ |
420 vga_waitretrace(); | |
421 } | |
422 return(0); | 446 return(0); |
423 } | 447 } |
424 static void SVGA_UnlockHWSurface(_THIS, SDL_Surface *surface) | 448 static void SVGA_UnlockHWSurface(_THIS, SDL_Surface *surface) |
425 { | 449 { |
426 return; | 450 return; |
427 } | 451 } |
428 | 452 |
429 /* FIXME: How is this done with SVGAlib? */ | |
430 static int SVGA_FlipHWSurface(_THIS, SDL_Surface *surface) | 453 static int SVGA_FlipHWSurface(_THIS, SDL_Surface *surface) |
431 { | 454 { |
455 vga_setdisplaystart(flip_offset[flip_page]); | |
456 flip_page=!flip_page; | |
457 surface->pixels=flip_address[flip_page]; | |
458 vga_waitretrace(); | |
432 return(0); | 459 return(0); |
433 } | 460 } |
434 | 461 |
435 static void SVGA_DirectUpdate(_THIS, int numrects, SDL_Rect *rects) | 462 static void SVGA_DirectUpdate(_THIS, int numrects, SDL_Rect *rects) |
436 { | 463 { |
485 if ( this->screen && (this->screen->flags & SDL_HWSURFACE) ) { | 512 if ( this->screen && (this->screen->flags & SDL_HWSURFACE) ) { |
486 /* Direct screen access, no memory buffer */ | 513 /* Direct screen access, no memory buffer */ |
487 this->screen->pixels = NULL; | 514 this->screen->pixels = NULL; |
488 } | 515 } |
489 } | 516 } |
517 |