Mercurial > sdl-ios-xcode
comparison src/video/windib/SDL_dibvideo.c @ 4079:fda6e33893b7 SDL-1.2
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.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 16 Jul 2007 05:08:20 +0000 |
parents | 0207ca19fd8f |
children | 51486c979189 |
comparison
equal
deleted
inserted
replaced
4078:5e6f2972f963 | 4079:fda6e33893b7 |
---|---|
635 | 635 |
636 } | 636 } |
637 #endif /* !NO_CHANGEDISPLAYSETTINGS */ | 637 #endif /* !NO_CHANGEDISPLAYSETTINGS */ |
638 | 638 |
639 /* Reset the palette and create a new one if necessary */ | 639 /* Reset the palette and create a new one if necessary */ |
640 if ( grab_palette ) { | |
641 DIB_ReleaseStaticColors(SDL_Window); | |
642 grab_palette = FALSE; | |
643 } | |
640 if ( screen_pal != NULL ) { | 644 if ( screen_pal != NULL ) { |
641 if ( video->flags & SDL_HWPALETTE ) { | |
642 DIB_ReleaseStaticColors(SDL_Window); | |
643 } | |
644 /* RJR: March 28, 2000 | 645 /* RJR: March 28, 2000 |
645 delete identity palette if switching from a palettized mode */ | 646 delete identity palette if switching from a palettized mode */ |
646 DeleteObject(screen_pal); | 647 DeleteObject(screen_pal); |
647 screen_pal = NULL; | 648 screen_pal = NULL; |
648 } | 649 } |
649 if ( screen_logpal != NULL ) { | 650 if ( screen_logpal != NULL ) { |
650 SDL_free(screen_logpal); | 651 SDL_free(screen_logpal); |
651 screen_logpal = NULL; | 652 screen_logpal = NULL; |
652 } | 653 } |
654 | |
653 if ( bpp <= 8 ) | 655 if ( bpp <= 8 ) |
654 { | 656 { |
655 /* RJR: March 28, 2000 | 657 /* RJR: March 28, 2000 |
656 create identity palette switching to a palettized mode */ | 658 create identity palette switching to a palettized mode */ |
657 DIB_CreatePalette(this, bpp); | 659 DIB_CreatePalette(this, bpp); |
753 return(NULL); | 755 return(NULL); |
754 } | 756 } |
755 this->UpdateRects = DIB_NormalUpdate; | 757 this->UpdateRects = DIB_NormalUpdate; |
756 | 758 |
757 /* Set video surface flags */ | 759 /* Set video surface flags */ |
758 if ( (flags & (SDL_FULLSCREEN|SDL_HWPALETTE)) != 0 ) { | 760 if ( screen_pal && (flags & (SDL_FULLSCREEN|SDL_HWPALETTE)) ) { |
759 /* BitBlt() maps colors for us */ | 761 grab_palette = TRUE; |
760 video->flags |= SDL_HWPALETTE; | 762 } |
761 } | 763 /* BitBlt() maps colors for us */ |
764 video->flags |= SDL_HWPALETTE; | |
762 } | 765 } |
763 #ifndef _WIN32_WCE | 766 #ifndef _WIN32_WCE |
764 /* Resize the window */ | 767 /* Resize the window */ |
765 if ( !SDL_windowid && !IsZoomed(SDL_Window) ) { | 768 if ( !SDL_windowid && !IsZoomed(SDL_Window) ) { |
766 #else | 769 #else |
974 | 977 |
975 /* Set the DIB palette and update the display */ | 978 /* Set the DIB palette and update the display */ |
976 mdc = CreateCompatibleDC(hdc); | 979 mdc = CreateCompatibleDC(hdc); |
977 SelectObject(mdc, screen_bmp); | 980 SelectObject(mdc, screen_bmp); |
978 SetDIBColorTable(mdc, firstcolor, ncolors, pal); | 981 SetDIBColorTable(mdc, firstcolor, ncolors, pal); |
979 if ( moved_entries || !(this->screen->flags & SDL_HWPALETTE) ) { | 982 if ( moved_entries || !grab_palette ) { |
980 BitBlt(hdc, 0, 0, this->screen->w, this->screen->h, | 983 BitBlt(hdc, 0, 0, this->screen->w, this->screen->h, |
981 mdc, 0, 0, SRCCOPY); | 984 mdc, 0, 0, SRCCOPY); |
982 } | 985 } |
983 DeleteDC(mdc); | 986 DeleteDC(mdc); |
984 SDL_stack_free(pal); | 987 SDL_stack_free(pal); |
1096 | 1099 |
1097 /* Destroy the window and everything associated with it */ | 1100 /* Destroy the window and everything associated with it */ |
1098 if ( SDL_Window ) { | 1101 if ( SDL_Window ) { |
1099 /* Delete the screen bitmap (also frees screen->pixels) */ | 1102 /* Delete the screen bitmap (also frees screen->pixels) */ |
1100 if ( this->screen ) { | 1103 if ( this->screen ) { |
1101 if ( this->screen->flags & SDL_HWPALETTE ) { | 1104 if ( grab_palette ) { |
1102 DIB_ReleaseStaticColors(SDL_Window); | 1105 DIB_ReleaseStaticColors(SDL_Window); |
1103 } | 1106 } |
1104 #ifndef NO_CHANGEDISPLAYSETTINGS | 1107 #ifndef NO_CHANGEDISPLAYSETTINGS |
1105 if ( this->screen->flags & SDL_FULLSCREEN ) { | 1108 if ( this->screen->flags & SDL_FULLSCREEN ) { |
1106 ChangeDisplaySettings(NULL, 0); | 1109 ChangeDisplaySettings(NULL, 0); |
1181 ReleaseDC(window, hdc); | 1184 ReleaseDC(window, hdc); |
1182 #endif | 1185 #endif |
1183 } | 1186 } |
1184 static void DIB_Activate(_THIS, BOOL active, BOOL minimized) | 1187 static void DIB_Activate(_THIS, BOOL active, BOOL minimized) |
1185 { | 1188 { |
1186 if ( screen_pal && (this->screen->flags & SDL_HWPALETTE) ) { | 1189 if ( grab_palette ) { |
1187 if ( !active ) { | 1190 if ( !active ) { |
1188 DIB_ReleaseStaticColors(SDL_Window); | 1191 DIB_ReleaseStaticColors(SDL_Window); |
1189 DIB_RealizePalette(this); | 1192 DIB_RealizePalette(this); |
1190 } else if ( !minimized ) { | 1193 } else if ( !minimized ) { |
1191 DIB_GrabStaticColors(SDL_Window); | 1194 DIB_GrabStaticColors(SDL_Window); |