Always advertise hardware palette, since Windows will remap colors for us. SDL-1.2
authorSam Lantinga <slouken@libsdl.org>
Mon, 16 Jul 2007 05:08:20 +0000
branchSDL-1.2
changeset 4079fda6e33893b7
parent 4078 5e6f2972f963
child 4080 e1098effe318
Always advertise hardware palette, since Windows will remap colors for us.
We do grab the system colors if the application requested fullscreen or a
real hardware palette.

This allows gamma fading, etc. to work, and is what previous versions did.
src/video/windib/SDL_dibvideo.c
src/video/windib/SDL_dibvideo.h
     1.1 --- a/src/video/windib/SDL_dibvideo.c	Mon Jul 16 03:27:26 2007 +0000
     1.2 +++ b/src/video/windib/SDL_dibvideo.c	Mon Jul 16 05:08:20 2007 +0000
     1.3 @@ -637,10 +637,11 @@
     1.4  #endif /* !NO_CHANGEDISPLAYSETTINGS */
     1.5  
     1.6  	/* Reset the palette and create a new one if necessary */
     1.7 +	if ( grab_palette ) {
     1.8 +		DIB_ReleaseStaticColors(SDL_Window);
     1.9 +		grab_palette = FALSE;
    1.10 +	}
    1.11  	if ( screen_pal != NULL ) {
    1.12 -		if ( video->flags & SDL_HWPALETTE ) {
    1.13 -			DIB_ReleaseStaticColors(SDL_Window);
    1.14 -		}
    1.15  	/*	RJR: March 28, 2000
    1.16  		delete identity palette if switching from a palettized mode */
    1.17  		DeleteObject(screen_pal);
    1.18 @@ -650,6 +651,7 @@
    1.19  		SDL_free(screen_logpal);
    1.20  		screen_logpal = NULL;
    1.21  	}
    1.22 +
    1.23  	if ( bpp <= 8 )
    1.24  	{
    1.25  	/*	RJR: March 28, 2000
    1.26 @@ -755,10 +757,11 @@
    1.27  		this->UpdateRects = DIB_NormalUpdate;
    1.28  
    1.29  		/* Set video surface flags */
    1.30 -		if ( (flags & (SDL_FULLSCREEN|SDL_HWPALETTE)) != 0 ) {
    1.31 -			/* BitBlt() maps colors for us */
    1.32 -			video->flags |= SDL_HWPALETTE;
    1.33 +		if ( screen_pal && (flags & (SDL_FULLSCREEN|SDL_HWPALETTE)) ) {
    1.34 +			grab_palette = TRUE;
    1.35  		}
    1.36 +		/* BitBlt() maps colors for us */
    1.37 +		video->flags |= SDL_HWPALETTE;
    1.38  	}
    1.39  #ifndef _WIN32_WCE
    1.40  	/* Resize the window */
    1.41 @@ -976,7 +979,7 @@
    1.42  	mdc = CreateCompatibleDC(hdc);
    1.43  	SelectObject(mdc, screen_bmp);
    1.44  	SetDIBColorTable(mdc, firstcolor, ncolors, pal);
    1.45 -	if ( moved_entries || !(this->screen->flags & SDL_HWPALETTE) ) {
    1.46 +	if ( moved_entries || !grab_palette ) {
    1.47  		BitBlt(hdc, 0, 0, this->screen->w, this->screen->h,
    1.48  		       mdc, 0, 0, SRCCOPY);
    1.49  	}
    1.50 @@ -1098,7 +1101,7 @@
    1.51  	if ( SDL_Window ) {
    1.52  		/* Delete the screen bitmap (also frees screen->pixels) */
    1.53  		if ( this->screen ) {
    1.54 -			if ( this->screen->flags & SDL_HWPALETTE ) {
    1.55 +			if ( grab_palette ) {
    1.56  				DIB_ReleaseStaticColors(SDL_Window);
    1.57  			}
    1.58  #ifndef NO_CHANGEDISPLAYSETTINGS
    1.59 @@ -1183,7 +1186,7 @@
    1.60  }
    1.61  static void DIB_Activate(_THIS, BOOL active, BOOL minimized)
    1.62  {
    1.63 -	if ( screen_pal && (this->screen->flags & SDL_HWPALETTE) ) {
    1.64 +	if ( grab_palette ) {
    1.65  		if ( !active ) {
    1.66  			DIB_ReleaseStaticColors(SDL_Window);
    1.67  			DIB_RealizePalette(this);
     2.1 --- a/src/video/windib/SDL_dibvideo.h	Mon Jul 16 03:27:26 2007 +0000
     2.2 +++ b/src/video/windib/SDL_dibvideo.h	Mon Jul 16 05:08:20 2007 +0000
     2.3 @@ -41,6 +41,7 @@
     2.4      HBITMAP screen_bmp;
     2.5      HPALETTE screen_pal;
     2.6      LOGPALETTE *screen_logpal;
     2.7 +    BOOL grab_palette;
     2.8  
     2.9      int allow_screensaver;
    2.10  
    2.11 @@ -60,6 +61,7 @@
    2.12  #define screen_bmp		(this->hidden->screen_bmp)
    2.13  #define screen_pal		(this->hidden->screen_pal)
    2.14  #define screen_logpal		(this->hidden->screen_logpal)
    2.15 +#define grab_palette		(this->hidden->grab_palette)
    2.16  #define SDL_nummodes		(this->hidden->SDL_nummodes)
    2.17  #define SDL_modelist		(this->hidden->SDL_modelist)
    2.18