Added double-buffering support for SVGAlib (thanks Kutak!)
authorSam Lantinga <slouken@libsdl.org>
Sun, 14 Oct 2001 19:49:02 +0000
changeset 20513161d3d349d
parent 204 62bad9a82022
child 206 b69bb2a368a0
Added double-buffering support for SVGAlib (thanks Kutak!)
docs.html
src/video/svga/SDL_svgavideo.c
src/video/svga/SDL_svgavideo.h
     1.1 --- a/docs.html	Mon Oct 08 18:54:06 2001 +0000
     1.2 +++ b/docs.html	Sun Oct 14 19:49:02 2001 +0000
     1.3 @@ -16,6 +16,7 @@
     1.4  Major changes since SDL 1.0.0:
     1.5  </H2>
     1.6  <UL>
     1.7 +	<LI> 1.2.3: Added double-buffering support for SVGAlib (thanks Kutak!)
     1.8  	<LI> 1.2.3: Fixed crash when using double-buffering with DGA
     1.9  	<LI> 1.2.3: Fixed resuming a paused CD on Win2K (thanks Aragorn)
    1.10  	<LI> 1.2.3: Improved MacOS international keyboard handling (thanks Max!)
     2.1 --- a/src/video/svga/SDL_svgavideo.c	Mon Oct 08 18:54:06 2001 +0000
     2.2 +++ b/src/video/svga/SDL_svgavideo.c	Sun Oct 14 19:49:02 2001 +0000
     2.3 @@ -145,7 +145,7 @@
     2.4  	device->SetHWAlpha = NULL;
     2.5  	device->LockHWSurface = SVGA_LockHWSurface;
     2.6  	device->UnlockHWSurface = SVGA_UnlockHWSurface;
     2.7 -	device->FlipHWSurface = NULL;
     2.8 +	device->FlipHWSurface = SVGA_FlipHWSurface;
     2.9  	device->FreeHWSurface = SVGA_FreeHWSurface;
    2.10  	device->SetCaption = NULL;
    2.11  	device->SetIcon = NULL;
    2.12 @@ -223,10 +223,7 @@
    2.13  	this->info.wm_available = 0;
    2.14  	this->info.hw_available = 1;
    2.15  	modeinfo = vga_getmodeinfo(vga_getcurrentmode());
    2.16 -	this->info.video_mem = (modeinfo->maxpixels/1024);
    2.17 -	if ( modeinfo->bytesperpixel > 0 ) {
    2.18 -		this->info.video_mem *= modeinfo->bytesperpixel;
    2.19 -	}
    2.20 +	this->info.video_mem = modeinfo->memory;
    2.21  	/* FIXME: Add hardware accelerated blit information */
    2.22  #if 0
    2.23  printf("Hardware accelerated blit: %savailable\n", modeinfo->haveblit ? "" : "not ");
    2.24 @@ -347,6 +344,7 @@
    2.25  	int mode;
    2.26  	int vgamode;
    2.27  	vga_modeinfo *modeinfo;
    2.28 +	int screenpage_len;
    2.29  
    2.30  	/* Try to set the requested linear video mode */
    2.31  	bpp = (bpp+7)/8-1;
    2.32 @@ -393,6 +391,34 @@
    2.33  	current->pitch = modeinfo->linewidth;
    2.34  	current->pixels = vga_getgraphmem();
    2.35  
    2.36 +	/* set double-buffering */
    2.37 +	if ( flags & SDL_DOUBLEBUF )
    2.38 +	{
    2.39 +	    /* length of one screen page in bytes */
    2.40 +	    screenpage_len=current->h*modeinfo->linewidth;
    2.41 +
    2.42 +	    /* if start address should be aligned */
    2.43 +	    if ( modeinfo->linewidth_unit )
    2.44 +	    {
    2.45 +		if ( screenpage_len % modeinfo->linewidth_unit )    
    2.46 +		{
    2.47 +		    screenpage_len += modeinfo->linewidth_unit - ( screenpage_len % modeinfo->linewidth_unit );
    2.48 +		}
    2.49 +	    }
    2.50 +
    2.51 +	    /* if we heve enough videomemory =  ak je dost videopamete  */
    2.52 +	    if ( modeinfo->memory > ( screenpage_len * 2 / 1024 ) )
    2.53 +	    {
    2.54 +		current->flags |= SDL_DOUBLEBUF;
    2.55 +		flip_page = 0;
    2.56 +		flip_offset[0] = 0;
    2.57 +		flip_offset[1] = screenpage_len;
    2.58 +		flip_address[0] = vga_getgraphmem();
    2.59 +		flip_address[1] = flip_address[0]+screenpage_len;
    2.60 +		SVGA_FlipHWSurface(this,current);
    2.61 +	    }
    2.62 +	} 
    2.63 +
    2.64  	/* Set the blit function */
    2.65  	this->UpdateRects = SVGA_DirectUpdate;
    2.66  
    2.67 @@ -416,9 +442,7 @@
    2.68  /* We need to wait for vertical retrace on page flipped displays */
    2.69  static int SVGA_LockHWSurface(_THIS, SDL_Surface *surface)
    2.70  {
    2.71 -	if ( (surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
    2.72 -		vga_waitretrace();
    2.73 -	}
    2.74 +	/* The waiting is done in SVGA_FlipHWSurface() */
    2.75  	return(0);
    2.76  }
    2.77  static void SVGA_UnlockHWSurface(_THIS, SDL_Surface *surface)
    2.78 @@ -426,9 +450,12 @@
    2.79  	return;
    2.80  }
    2.81  
    2.82 -/* FIXME: How is this done with SVGAlib? */
    2.83  static int SVGA_FlipHWSurface(_THIS, SDL_Surface *surface)
    2.84  {
    2.85 +	vga_setdisplaystart(flip_offset[flip_page]);
    2.86 +	flip_page=!flip_page;
    2.87 +	surface->pixels=flip_address[flip_page];
    2.88 +	vga_waitretrace();
    2.89  	return(0);
    2.90  }
    2.91  
    2.92 @@ -487,3 +514,4 @@
    2.93  		this->screen->pixels = NULL;
    2.94  	}
    2.95  }
    2.96 +
     3.1 --- a/src/video/svga/SDL_svgavideo.h	Mon Oct 08 18:54:06 2001 +0000
     3.2 +++ b/src/video/svga/SDL_svgavideo.h	Sun Oct 14 19:49:02 2001 +0000
     3.3 @@ -40,10 +40,19 @@
     3.4  	int SDL_nummodes[NUM_MODELISTS];
     3.5  	SDL_Rect **SDL_modelist[NUM_MODELISTS];
     3.6  	int *SDL_vgamode[NUM_MODELISTS];
     3.7 +
     3.8 +	/* information for double-buffering */
     3.9 +	int flip_page;
    3.10 +	int flip_offset[2];
    3.11 +	Uint8 *flip_address[2];
    3.12  };
    3.13  /* Old variable names */
    3.14  #define SDL_nummodes		(this->hidden->SDL_nummodes)
    3.15  #define SDL_modelist		(this->hidden->SDL_modelist)
    3.16  #define SDL_vgamode		(this->hidden->SDL_vgamode)
    3.17 +#define flip_page		(this->hidden->flip_page)
    3.18 +#define flip_offset		(this->hidden->flip_offset)
    3.19 +#define flip_address		(this->hidden->flip_address)
    3.20  
    3.21  #endif /* _SDL_svgavideo_h */
    3.22 +