src/video/SDL_video.c
branchSDL-1.3
changeset 1666 6e7ec5cb83c3
parent 1662 782fd950bd46
child 1667 1fddae038bc8
     1.1 --- a/src/video/SDL_video.c	Sun May 28 18:18:30 2006 +0000
     1.2 +++ b/src/video/SDL_video.c	Sun May 28 21:56:07 2006 +0000
     1.3 @@ -997,10 +997,8 @@
     1.4  SDL_CreateWindowSurface (SDL_WindowID windowID, Uint32 format, Uint32 flags)
     1.5  {
     1.6      SDL_Window *window = SDL_GetWindowFromID (windowID);
     1.7 +    Uint32 black;
     1.8      SDL_Surface *surface;
     1.9 -    SDL_Surface *shadow;
    1.10 -    Uint32 surface_format;
    1.11 -    Uint32 black;
    1.12  
    1.13      if (!window) {
    1.14          return NULL;
    1.15 @@ -1011,54 +1009,50 @@
    1.16      }
    1.17  
    1.18      if (!window->surface) {
    1.19 -        window->surface = _this->CreateWindowSurface (_this, window);
    1.20 +        _this->CreateWindowSurface (_this, window, flags);
    1.21          if (!window->surface) {
    1.22              return NULL;
    1.23          }
    1.24 +        window->surface->flags |= SDL_SCREEN_SURFACE;
    1.25      }
    1.26 +    surface = window->surface;
    1.27  
    1.28      if (window->shadow) {
    1.29          SDL_FreeSurface (window->shadow);
    1.30          window->shadow = NULL;
    1.31      }
    1.32  
    1.33 -    surface = window->surface;
    1.34 -    surface_format =
    1.35 -        SDL_MasksToPixelFormatEnum (surface->format->BitsPerPixel,
    1.36 -                                    surface->format->Rmask,
    1.37 -                                    surface->format->Gmask,
    1.38 -                                    surface->format->Bmask,
    1.39 -                                    surface->format->Amask);
    1.40 -
    1.41      /* Create a shadow surface if necessary */
    1.42 -    if ((!(flags & SDL_ANYFORMAT) && (surface_format != format)) ||
    1.43 -        ((flags & SDL_HWPALETTE)
    1.44 -         && !(window->surface->flags & SDL_HWPALETTE))) {
    1.45 +    if ((!(flags & SDL_ANYFORMAT)
    1.46 +         && (format != SDL_GetCurrentDisplayMode ()->format))
    1.47 +        || ((flags & SDL_HWPALETTE)
    1.48 +            && !(window->surface->flags & SDL_HWPALETTE))) {
    1.49          int bpp;
    1.50          Uint32 Rmask, Gmask, Bmask, Amask;
    1.51  
    1.52 -        SDL_PixelFormatEnumToMasks (format, &bpp, &Rmask, &Gmask, &Bmask,
    1.53 +        SDL_PixelFormatEnumToMasks (format, &bpp, &Amask, &Gmask, &Bmask,
    1.54                                      &Amask);
    1.55 -        shadow =
    1.56 -            SDL_CreateRGBSurface (SDL_SWSURFACE, surface->w, surface->h,
    1.57 -                                  bpp, Rmask, Gmask, Bmask, Amask);
    1.58 -        if (shadow == NULL) {
    1.59 +        window->shadow =
    1.60 +            SDL_CreateRGBSurface (SDL_SWSURFACE, surface->w, surface->h, bpp,
    1.61 +                                  Rmask, Gmask, Bmask, Amask);
    1.62 +        if (window->shadow == NULL) {
    1.63              return NULL;
    1.64          }
    1.65 +        window->shadow->flags |= SDL_SHADOW_SURFACE;
    1.66 +        surface = window->shadow;
    1.67  
    1.68          /* 8-bit shadow surfaces report that they have exclusive palette */
    1.69 -        if (shadow->format->palette) {
    1.70 -            shadow->flags |= SDL_HWPALETTE;
    1.71 -            if (format == surface_format) {
    1.72 -                SDL_memcpy (shadow->format->palette->colors,
    1.73 -                            surface->format->palette->colors,
    1.74 -                            surface->format->palette->ncolors *
    1.75 +        if (surface->format->palette) {
    1.76 +            surface->flags |= SDL_HWPALETTE;
    1.77 +            if (format == SDL_GetCurrentDisplayMode ()->format) {
    1.78 +                SDL_memcpy (surface->format->palette->colors,
    1.79 +                            window->surface->format->palette->colors,
    1.80 +                            window->surface->format->palette->ncolors *
    1.81                              sizeof (SDL_Color));
    1.82              } else {
    1.83 -                SDL_DitherColors (shadow->format->palette->colors, bpp);
    1.84 +                SDL_DitherColors (surface->format->palette->colors, bpp);
    1.85              }
    1.86          }
    1.87 -        surface = window->shadow = shadow;
    1.88      }
    1.89  
    1.90      /* Clear the surface for display */