Some work on using accelerated alpha blits with hardware surfaces.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 17 Apr 2005 10:40:41 +0000
changeset 105268f607298ca9
parent 1051 091350827e08
child 1053 f596fa4f17a6
Some work on using accelerated alpha blits with hardware surfaces.

From Stephane Marchesin's fork, don't know who originally wrote it.
src/video/SDL_blit.c
src/video/SDL_surface.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
     1.1 --- a/src/video/SDL_blit.c	Sun Apr 17 10:36:03 2005 +0000
     1.2 +++ b/src/video/SDL_blit.c	Sun Apr 17 10:40:41 2005 +0000
     1.3 @@ -280,6 +280,17 @@
     1.4  			video->CheckHWBlit(this, surface, surface->map->dst);
     1.5  		}
     1.6  	}
     1.7 +	
     1.8 +	/* if an alpha pixel format is specified, we can accelerate alpha blits */
     1.9 +	if (((surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE )&&(current_video->displayformatalphapixel)) 
    1.10 +	{
    1.11 +		if ( (surface->flags & SDL_SRCALPHA) ) 
    1.12 +			if ( current_video->info.blit_hw_A ) {
    1.13 +				SDL_VideoDevice *video = current_video;
    1.14 +				SDL_VideoDevice *this  = current_video;
    1.15 +				video->CheckHWBlit(this, surface, surface->map->dst);
    1.16 +			}
    1.17 +	}
    1.18  
    1.19  	/* Get the blit function index, based on surface mode */
    1.20  	/* { 0 = nothing, 1 = colorkey, 2 = alpha, 3 = colorkey+alpha } */
     2.1 --- a/src/video/SDL_surface.c	Sun Apr 17 10:36:03 2005 +0000
     2.2 +++ b/src/video/SDL_surface.c	Sun Apr 17 10:40:41 2005 +0000
     2.3 @@ -91,11 +91,22 @@
     2.4  	}
     2.5  	surface->flags = SDL_SWSURFACE;
     2.6  	if ( (flags & SDL_HWSURFACE) == SDL_HWSURFACE ) {
     2.7 -		depth = screen->format->BitsPerPixel;
     2.8 -		Rmask = screen->format->Rmask;
     2.9 -		Gmask = screen->format->Gmask;
    2.10 -		Bmask = screen->format->Bmask;
    2.11 -		Amask = screen->format->Amask;
    2.12 +		if ((Amask) && (video->displayformatalphapixel))
    2.13 +		{
    2.14 +			depth = video->displayformatalphapixel->BitsPerPixel;
    2.15 +			Rmask = video->displayformatalphapixel->Rmask;
    2.16 +			Gmask = video->displayformatalphapixel->Gmask;
    2.17 +			Bmask = video->displayformatalphapixel->Bmask;
    2.18 +			Amask = video->displayformatalphapixel->Amask;
    2.19 +		}
    2.20 +		else
    2.21 +		{
    2.22 +			depth = screen->format->BitsPerPixel;
    2.23 +			Rmask = screen->format->Rmask;
    2.24 +			Gmask = screen->format->Gmask;
    2.25 +			Bmask = screen->format->Bmask;
    2.26 +			Amask = screen->format->Amask;
    2.27 +		}
    2.28  	}
    2.29  	surface->format = SDL_AllocFormat(depth, Rmask, Gmask, Bmask, Amask);
    2.30  	if ( surface->format == NULL ) {
     3.1 --- a/src/video/SDL_sysvideo.h	Sun Apr 17 10:36:03 2005 +0000
     3.2 +++ b/src/video/SDL_sysvideo.h	Sun Apr 17 10:40:41 2005 +0000
     3.3 @@ -134,6 +134,9 @@
     3.4  	/* Information about the video hardware */
     3.5  	SDL_VideoInfo info;
     3.6  
     3.7 +	/* The pixel format used when SDL_CreateRGBSurface creates SDL_HWSURFACEs with alpha */
     3.8 +	SDL_PixelFormat* displayformatalphapixel;
     3.9 +	
    3.10  	/* Allocates a surface in video memory */
    3.11  	int (*AllocHWSurface)(_THIS, SDL_Surface *surface);
    3.12  
     4.1 --- a/src/video/SDL_video.c	Sun Apr 17 10:36:03 2005 +0000
     4.2 +++ b/src/video/SDL_video.c	Sun Apr 17 10:40:41 2005 +0000
     4.3 @@ -212,6 +212,8 @@
     4.4  	video->offset_x = 0;
     4.5  	video->offset_y = 0;
     4.6  	memset(&video->info, 0, (sizeof video->info));
     4.7 +	
     4.8 +	video->displayformatalphapixel = NULL;
     4.9  
    4.10  	/* Set some very sane GL defaults */
    4.11  	video->gl_config.driver_loaded = 0;