comparison src/video/SDL_video.c @ 1666:6e7ec5cb83c3 SDL-1.3

The dummy video driver compiles. :)
author Sam Lantinga <slouken@libsdl.org>
date Sun, 28 May 2006 21:56:07 +0000
parents 782fd950bd46
children 1fddae038bc8
comparison
equal deleted inserted replaced
1665:28193f833b2b 1666:6e7ec5cb83c3
995 995
996 SDL_Surface * 996 SDL_Surface *
997 SDL_CreateWindowSurface (SDL_WindowID windowID, Uint32 format, Uint32 flags) 997 SDL_CreateWindowSurface (SDL_WindowID windowID, Uint32 format, Uint32 flags)
998 { 998 {
999 SDL_Window *window = SDL_GetWindowFromID (windowID); 999 SDL_Window *window = SDL_GetWindowFromID (windowID);
1000 Uint32 black;
1000 SDL_Surface *surface; 1001 SDL_Surface *surface;
1001 SDL_Surface *shadow;
1002 Uint32 surface_format;
1003 Uint32 black;
1004 1002
1005 if (!window) { 1003 if (!window) {
1006 return NULL; 1004 return NULL;
1007 } 1005 }
1008 1006
1009 if (!_this->CreateWindowSurface) { 1007 if (!_this->CreateWindowSurface) {
1010 return NULL; 1008 return NULL;
1011 } 1009 }
1012 1010
1013 if (!window->surface) { 1011 if (!window->surface) {
1014 window->surface = _this->CreateWindowSurface (_this, window); 1012 _this->CreateWindowSurface (_this, window, flags);
1015 if (!window->surface) { 1013 if (!window->surface) {
1016 return NULL; 1014 return NULL;
1017 } 1015 }
1018 } 1016 window->surface->flags |= SDL_SCREEN_SURFACE;
1017 }
1018 surface = window->surface;
1019 1019
1020 if (window->shadow) { 1020 if (window->shadow) {
1021 SDL_FreeSurface (window->shadow); 1021 SDL_FreeSurface (window->shadow);
1022 window->shadow = NULL; 1022 window->shadow = NULL;
1023 } 1023 }
1024 1024
1025 surface = window->surface;
1026 surface_format =
1027 SDL_MasksToPixelFormatEnum (surface->format->BitsPerPixel,
1028 surface->format->Rmask,
1029 surface->format->Gmask,
1030 surface->format->Bmask,
1031 surface->format->Amask);
1032
1033 /* Create a shadow surface if necessary */ 1025 /* Create a shadow surface if necessary */
1034 if ((!(flags & SDL_ANYFORMAT) && (surface_format != format)) || 1026 if ((!(flags & SDL_ANYFORMAT)
1035 ((flags & SDL_HWPALETTE) 1027 && (format != SDL_GetCurrentDisplayMode ()->format))
1036 && !(window->surface->flags & SDL_HWPALETTE))) { 1028 || ((flags & SDL_HWPALETTE)
1029 && !(window->surface->flags & SDL_HWPALETTE))) {
1037 int bpp; 1030 int bpp;
1038 Uint32 Rmask, Gmask, Bmask, Amask; 1031 Uint32 Rmask, Gmask, Bmask, Amask;
1039 1032
1040 SDL_PixelFormatEnumToMasks (format, &bpp, &Rmask, &Gmask, &Bmask, 1033 SDL_PixelFormatEnumToMasks (format, &bpp, &Amask, &Gmask, &Bmask,
1041 &Amask); 1034 &Amask);
1042 shadow = 1035 window->shadow =
1043 SDL_CreateRGBSurface (SDL_SWSURFACE, surface->w, surface->h, 1036 SDL_CreateRGBSurface (SDL_SWSURFACE, surface->w, surface->h, bpp,
1044 bpp, Rmask, Gmask, Bmask, Amask); 1037 Rmask, Gmask, Bmask, Amask);
1045 if (shadow == NULL) { 1038 if (window->shadow == NULL) {
1046 return NULL; 1039 return NULL;
1047 } 1040 }
1041 window->shadow->flags |= SDL_SHADOW_SURFACE;
1042 surface = window->shadow;
1048 1043
1049 /* 8-bit shadow surfaces report that they have exclusive palette */ 1044 /* 8-bit shadow surfaces report that they have exclusive palette */
1050 if (shadow->format->palette) { 1045 if (surface->format->palette) {
1051 shadow->flags |= SDL_HWPALETTE; 1046 surface->flags |= SDL_HWPALETTE;
1052 if (format == surface_format) { 1047 if (format == SDL_GetCurrentDisplayMode ()->format) {
1053 SDL_memcpy (shadow->format->palette->colors, 1048 SDL_memcpy (surface->format->palette->colors,
1054 surface->format->palette->colors, 1049 window->surface->format->palette->colors,
1055 surface->format->palette->ncolors * 1050 window->surface->format->palette->ncolors *
1056 sizeof (SDL_Color)); 1051 sizeof (SDL_Color));
1057 } else { 1052 } else {
1058 SDL_DitherColors (shadow->format->palette->colors, bpp); 1053 SDL_DitherColors (surface->format->palette->colors, bpp);
1059 } 1054 }
1060 } 1055 }
1061 surface = window->shadow = shadow;
1062 } 1056 }
1063 1057
1064 /* Clear the surface for display */ 1058 /* Clear the surface for display */
1065 { 1059 {
1066 Uint32 black = SDL_MapRGB (surface->format, 0, 0, 0); 1060 Uint32 black = SDL_MapRGB (surface->format, 0, 0, 0);