Some work on using accelerated alpha blits with hardware surfaces.

From Stephane Marchesin's fork, don't know who originally wrote it.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401053
This commit is contained in:
Ryan C. Gordon 2005-04-17 10:40:41 +00:00
parent ec77fa9503
commit 8907a054cf
4 changed files with 32 additions and 5 deletions

View file

@ -281,6 +281,17 @@ int SDL_CalculateBlit(SDL_Surface *surface)
} }
} }
/* if an alpha pixel format is specified, we can accelerate alpha blits */
if (((surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE )&&(current_video->displayformatalphapixel))
{
if ( (surface->flags & SDL_SRCALPHA) )
if ( current_video->info.blit_hw_A ) {
SDL_VideoDevice *video = current_video;
SDL_VideoDevice *this = current_video;
video->CheckHWBlit(this, surface, surface->map->dst);
}
}
/* Get the blit function index, based on surface mode */ /* Get the blit function index, based on surface mode */
/* { 0 = nothing, 1 = colorkey, 2 = alpha, 3 = colorkey+alpha } */ /* { 0 = nothing, 1 = colorkey, 2 = alpha, 3 = colorkey+alpha } */
blit_index = 0; blit_index = 0;

View file

@ -91,12 +91,23 @@ SDL_Surface * SDL_CreateRGBSurface (Uint32 flags,
} }
surface->flags = SDL_SWSURFACE; surface->flags = SDL_SWSURFACE;
if ( (flags & SDL_HWSURFACE) == SDL_HWSURFACE ) { if ( (flags & SDL_HWSURFACE) == SDL_HWSURFACE ) {
if ((Amask) && (video->displayformatalphapixel))
{
depth = video->displayformatalphapixel->BitsPerPixel;
Rmask = video->displayformatalphapixel->Rmask;
Gmask = video->displayformatalphapixel->Gmask;
Bmask = video->displayformatalphapixel->Bmask;
Amask = video->displayformatalphapixel->Amask;
}
else
{
depth = screen->format->BitsPerPixel; depth = screen->format->BitsPerPixel;
Rmask = screen->format->Rmask; Rmask = screen->format->Rmask;
Gmask = screen->format->Gmask; Gmask = screen->format->Gmask;
Bmask = screen->format->Bmask; Bmask = screen->format->Bmask;
Amask = screen->format->Amask; Amask = screen->format->Amask;
} }
}
surface->format = SDL_AllocFormat(depth, Rmask, Gmask, Bmask, Amask); surface->format = SDL_AllocFormat(depth, Rmask, Gmask, Bmask, Amask);
if ( surface->format == NULL ) { if ( surface->format == NULL ) {
free(surface); free(surface);

View file

@ -134,6 +134,9 @@ struct SDL_VideoDevice {
/* Information about the video hardware */ /* Information about the video hardware */
SDL_VideoInfo info; SDL_VideoInfo info;
/* The pixel format used when SDL_CreateRGBSurface creates SDL_HWSURFACEs with alpha */
SDL_PixelFormat* displayformatalphapixel;
/* Allocates a surface in video memory */ /* Allocates a surface in video memory */
int (*AllocHWSurface)(_THIS, SDL_Surface *surface); int (*AllocHWSurface)(_THIS, SDL_Surface *surface);

View file

@ -213,6 +213,8 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags)
video->offset_y = 0; video->offset_y = 0;
memset(&video->info, 0, (sizeof video->info)); memset(&video->info, 0, (sizeof video->info));
video->displayformatalphapixel = NULL;
/* Set some very sane GL defaults */ /* Set some very sane GL defaults */
video->gl_config.driver_loaded = 0; video->gl_config.driver_loaded = 0;
video->gl_config.dll_handle = NULL; video->gl_config.dll_handle = NULL;