Commit 62756e27 authored by Sam Lantinga's avatar Sam Lantinga

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.

--HG--
branch : SDL-1.2
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%402550
parent 0d40fac1
...@@ -637,10 +637,11 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -637,10 +637,11 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
#endif /* !NO_CHANGEDISPLAYSETTINGS */ #endif /* !NO_CHANGEDISPLAYSETTINGS */
/* Reset the palette and create a new one if necessary */ /* Reset the palette and create a new one if necessary */
if ( grab_palette ) {
DIB_ReleaseStaticColors(SDL_Window);
grab_palette = FALSE;
}
if ( screen_pal != NULL ) { if ( screen_pal != NULL ) {
if ( video->flags & SDL_HWPALETTE ) {
DIB_ReleaseStaticColors(SDL_Window);
}
/* RJR: March 28, 2000 /* RJR: March 28, 2000
delete identity palette if switching from a palettized mode */ delete identity palette if switching from a palettized mode */
DeleteObject(screen_pal); DeleteObject(screen_pal);
...@@ -650,6 +651,7 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -650,6 +651,7 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
SDL_free(screen_logpal); SDL_free(screen_logpal);
screen_logpal = NULL; screen_logpal = NULL;
} }
if ( bpp <= 8 ) if ( bpp <= 8 )
{ {
/* RJR: March 28, 2000 /* RJR: March 28, 2000
...@@ -755,10 +757,11 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, ...@@ -755,10 +757,11 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
this->UpdateRects = DIB_NormalUpdate; this->UpdateRects = DIB_NormalUpdate;
/* Set video surface flags */ /* Set video surface flags */
if ( (flags & (SDL_FULLSCREEN|SDL_HWPALETTE)) != 0 ) { if ( screen_pal && (flags & (SDL_FULLSCREEN|SDL_HWPALETTE)) ) {
/* BitBlt() maps colors for us */ grab_palette = TRUE;
video->flags |= SDL_HWPALETTE;
} }
/* BitBlt() maps colors for us */
video->flags |= SDL_HWPALETTE;
} }
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
/* Resize the window */ /* Resize the window */
...@@ -976,7 +979,7 @@ int DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) ...@@ -976,7 +979,7 @@ int DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
mdc = CreateCompatibleDC(hdc); mdc = CreateCompatibleDC(hdc);
SelectObject(mdc, screen_bmp); SelectObject(mdc, screen_bmp);
SetDIBColorTable(mdc, firstcolor, ncolors, pal); SetDIBColorTable(mdc, firstcolor, ncolors, pal);
if ( moved_entries || !(this->screen->flags & SDL_HWPALETTE) ) { if ( moved_entries || !grab_palette ) {
BitBlt(hdc, 0, 0, this->screen->w, this->screen->h, BitBlt(hdc, 0, 0, this->screen->w, this->screen->h,
mdc, 0, 0, SRCCOPY); mdc, 0, 0, SRCCOPY);
} }
...@@ -1098,7 +1101,7 @@ void DIB_VideoQuit(_THIS) ...@@ -1098,7 +1101,7 @@ void DIB_VideoQuit(_THIS)
if ( SDL_Window ) { if ( SDL_Window ) {
/* Delete the screen bitmap (also frees screen->pixels) */ /* Delete the screen bitmap (also frees screen->pixels) */
if ( this->screen ) { if ( this->screen ) {
if ( this->screen->flags & SDL_HWPALETTE ) { if ( grab_palette ) {
DIB_ReleaseStaticColors(SDL_Window); DIB_ReleaseStaticColors(SDL_Window);
} }
#ifndef NO_CHANGEDISPLAYSETTINGS #ifndef NO_CHANGEDISPLAYSETTINGS
...@@ -1183,7 +1186,7 @@ static void DIB_ReleaseStaticColors(HWND window) ...@@ -1183,7 +1186,7 @@ static void DIB_ReleaseStaticColors(HWND window)
} }
static void DIB_Activate(_THIS, BOOL active, BOOL minimized) static void DIB_Activate(_THIS, BOOL active, BOOL minimized)
{ {
if ( screen_pal && (this->screen->flags & SDL_HWPALETTE) ) { if ( grab_palette ) {
if ( !active ) { if ( !active ) {
DIB_ReleaseStaticColors(SDL_Window); DIB_ReleaseStaticColors(SDL_Window);
DIB_RealizePalette(this); DIB_RealizePalette(this);
......
...@@ -41,6 +41,7 @@ struct SDL_PrivateVideoData { ...@@ -41,6 +41,7 @@ struct SDL_PrivateVideoData {
HBITMAP screen_bmp; HBITMAP screen_bmp;
HPALETTE screen_pal; HPALETTE screen_pal;
LOGPALETTE *screen_logpal; LOGPALETTE *screen_logpal;
BOOL grab_palette;
int allow_screensaver; int allow_screensaver;
...@@ -60,6 +61,7 @@ struct SDL_PrivateVideoData { ...@@ -60,6 +61,7 @@ struct SDL_PrivateVideoData {
#define screen_bmp (this->hidden->screen_bmp) #define screen_bmp (this->hidden->screen_bmp)
#define screen_pal (this->hidden->screen_pal) #define screen_pal (this->hidden->screen_pal)
#define screen_logpal (this->hidden->screen_logpal) #define screen_logpal (this->hidden->screen_logpal)
#define grab_palette (this->hidden->grab_palette)
#define SDL_nummodes (this->hidden->SDL_nummodes) #define SDL_nummodes (this->hidden->SDL_nummodes)
#define SDL_modelist (this->hidden->SDL_modelist) #define SDL_modelist (this->hidden->SDL_modelist)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment