SDL_SetVideoMode() compiles now... SDL-1.3
authorSam Lantinga <slouken@libsdl.org>
Wed, 14 Jun 2006 06:14:26 +0000
branchSDL-1.3
changeset 167890bf530ced8e
parent 1677 5e4c5e095925
child 1679 153477a6cc31
SDL_SetVideoMode() compiles now...
include/SDL_video.h
src/SDL_compat.c
src/video/SDL_renderer_sw.c
src/video/SDL_surface.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/dummy/SDL_nullrender.c
     1.1 --- a/include/SDL_video.h	Tue Jun 13 04:37:45 2006 +0000
     1.2 +++ b/include/SDL_video.h	Wed Jun 14 06:14:26 2006 +0000
     1.3 @@ -767,7 +767,7 @@
     1.4  /**
     1.5   * \fn SDL_TextureID SDL_CreateTextureFromSurface(Uint32 format, int access, SDL_Surface *surface)
     1.6   *
     1.7 - * \brief Create a texture from an existing surface
     1.8 + * \brief Create a texture from an existing surface.
     1.9   *
    1.10   * \param format The format of the texture, or 0 to pick an appropriate format
    1.11   * \param access One of the enumerated values in SDL_TextureAccess
    1.12 @@ -804,6 +804,20 @@
    1.13                                               int *w, int *h);
    1.14  
    1.15  /**
    1.16 + * \fn int SDL_QueryTexturePixels(SDL_TextureID textureID, void **pixels, int pitch)
    1.17 + *
    1.18 + * \brief Query the pixels of a texture, if the texture does not need to be locked for pixel access.
    1.19 + *
    1.20 + * \param texture A texture to be queried, which was created with SDL_TextureAccess_Local
    1.21 + * \param pixels A pointer filled with a pointer to the pixels for the texture 
    1.22 + * \param pitch A pointer filled in with the pitch of the pixel data
    1.23 + *
    1.24 + * \return 0 on success, or -1 if the texture is not valid, or must be locked for pixel access.
    1.25 + */
    1.26 +extern DECLSPEC int SDLCALL SDL_QueryTexturePixels(SDL_TextureID textureID,
    1.27 +                                                   void **pixels, int *pitch);
    1.28 +
    1.29 +/**
    1.30   * \fn int SDL_SetTexturePalette(SDL_TextureID textureID, SDL_Color * colors, int firstcolor, int ncolors)
    1.31   *
    1.32   * \brief Update an indexed texture with a color palette
     2.1 --- a/src/SDL_compat.c	Tue Jun 13 04:37:45 2006 +0000
     2.2 +++ b/src/SDL_compat.c	Wed Jun 14 06:14:26 2006 +0000
     2.3 @@ -25,10 +25,14 @@
     2.4  
     2.5  #include "SDL.h"
     2.6  
     2.7 -#include "video/SDL_sysvideo.h"
     2.8 +#include "video/SDL_pixels_c.h"
     2.9  
    2.10  
    2.11 -static SDL_WindowID window;
    2.12 +static SDL_WindowID SDL_VideoWindow;
    2.13 +static SDL_TextureID SDL_VideoTexture;
    2.14 +static SDL_Surface *SDL_VideoSurface;
    2.15 +static SDL_Surface *SDL_ShadowSurface;
    2.16 +static SDL_Surface *SDL_PublicSurface;
    2.17  static char *wm_title;
    2.18  
    2.19  char *
    2.20 @@ -213,6 +217,7 @@
    2.21      Uint32 window_flags;
    2.22      Uint32 desktop_format;
    2.23      Uint32 desired_format;
    2.24 +    Uint32 texture_format;
    2.25  
    2.26      if (!SDL_GetVideoDevice()) {
    2.27          if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) {
    2.28 @@ -221,7 +226,16 @@
    2.29      }
    2.30  
    2.31      /* Destroy existing window */
    2.32 -    SDL_DestroyWindow(window);
    2.33 +    SDL_PublicSurface = NULL;
    2.34 +    if (SDL_ShadowSurface) {
    2.35 +        SDL_FreeSurface(SDL_ShadowSurface);
    2.36 +        SDL_ShadowSurface = NULL;
    2.37 +    }
    2.38 +    if (SDL_VideoSurface) {
    2.39 +        SDL_FreeSurface(SDL_ShadowSurface);
    2.40 +        SDL_VideoSurface = NULL;
    2.41 +    }
    2.42 +    SDL_DestroyWindow(SDL_VideoWindow);
    2.43  
    2.44      /* Set up the event filter */
    2.45      filter = SDL_GetEventFilter();
    2.46 @@ -244,8 +258,9 @@
    2.47      if (flags & SDL_NOFRAME) {
    2.48          window_flags |= SDL_WINDOW_BORDERLESS;
    2.49      }
    2.50 -    window = SDL_CreateWindow(wm_title, 0, 0, width, height, window_flags);
    2.51 -    if (!window) {
    2.52 +    SDL_VideoWindow =
    2.53 +        SDL_CreateWindow(wm_title, 0, 0, width, height, window_flags);
    2.54 +    if (!SDL_VideoWindow) {
    2.55          return NULL;
    2.56      }
    2.57  
    2.58 @@ -308,101 +323,82 @@
    2.59          return NULL;
    2.60      }
    2.61  
    2.62 -    /* Create the display surface */
    2.63 -    return SDL_CreateWindowSurface(window, desired_format, flags);
    2.64 -}
    2.65 -
    2.66 -SDL_Surface *
    2.67 -SDL_CreateWindowSurface(SDL_WindowID windowID, Uint32 format, Uint32 flags)
    2.68 -{
    2.69 -    SDL_Window *window = SDL_GetWindowFromID(windowID);
    2.70 -    Uint32 black;
    2.71 -    SDL_Surface *surface;
    2.72 -
    2.73 -    if (!window) {
    2.74 +    /* Create a renderer for the window */
    2.75 +    if (SDL_CreateRenderer(SDL_VideoWindow, -1, 0) < 0) {
    2.76          return NULL;
    2.77      }
    2.78  
    2.79 -    if (!_this->CreateWindowSurface) {
    2.80 +    /* Create a texture for the screen surface */
    2.81 +    SDL_VideoTexture =
    2.82 +        SDL_CreateTexture(desired_format, SDL_TextureAccess_Local, width,
    2.83 +                          height);
    2.84 +    if (!SDL_VideoTexture) {
    2.85 +        SDL_VideoTexture =
    2.86 +            SDL_CreateTexture(0, SDL_TextureAccess_Local, width, height);
    2.87 +    }
    2.88 +    if (!SDL_VideoTexture) {
    2.89          return NULL;
    2.90      }
    2.91  
    2.92 -    if (!window->surface) {
    2.93 -        _this->CreateWindowSurface(_this, window, flags);
    2.94 -        if (!window->surface) {
    2.95 -            return NULL;
    2.96 -        }
    2.97 -        window->surface->flags |= SDL_SCREEN_SURFACE;
    2.98 +    /* Create the screen surface */
    2.99 +    SDL_VideoSurface = SDL_CreateRGBSurfaceFromTexture(SDL_VideoTexture);
   2.100 +    if (!SDL_VideoSurface) {
   2.101 +        return NULL;
   2.102 +    }
   2.103  
   2.104 -        /* If we have a palettized surface, create a default palette */
   2.105 -        if (window->surface->format->palette) {
   2.106 -            SDL_Color colors[256];
   2.107 -            SDL_PixelFormat *vf = window->surface->format;
   2.108 -            SDL_DitherColors(colors, vf->BitsPerPixel);
   2.109 -            SDL_SetColors(window->surface, colors, 0, vf->palette->ncolors);
   2.110 -        }
   2.111 -    }
   2.112 -    surface = window->surface;
   2.113 -
   2.114 -    if (window->shadow) {
   2.115 -        SDL_FreeSurface(window->shadow);
   2.116 -        window->shadow = NULL;
   2.117 +    /* Set a default screen palette */
   2.118 +    if (SDL_VideoSurface->format->palette) {
   2.119 +        SDL_VideoSurface->flags |= SDL_HWPALETTE;
   2.120 +        SDL_DitherColors(SDL_VideoSurface->format->palette->colors,
   2.121 +                         SDL_VideoSurface->format->BitsPerPixel);
   2.122 +        SDL_SetTexturePalette(SDL_VideoTexture,
   2.123 +                              SDL_VideoSurface->format->palette->colors, 0,
   2.124 +                              SDL_VideoSurface->format->palette->ncolors);
   2.125      }
   2.126  
   2.127      /* Create a shadow surface if necessary */
   2.128 -    if ((!(flags & SDL_ANYFORMAT)
   2.129 -         && (format != SDL_GetCurrentDisplayMode()->format))
   2.130 -        || ((flags & SDL_HWPALETTE)
   2.131 -            && !(window->surface->flags & SDL_HWPALETTE))) {
   2.132 -        int bpp;
   2.133 -        Uint32 Rmask, Gmask, Bmask, Amask;
   2.134 -
   2.135 -        SDL_PixelFormatEnumToMasks(format, &bpp, &Amask, &Gmask, &Bmask,
   2.136 -                                   &Amask);
   2.137 -        window->shadow =
   2.138 -            SDL_CreateRGBSurface(SDL_SWSURFACE, surface->w, surface->h, bpp,
   2.139 -                                 Rmask, Gmask, Bmask, Amask);
   2.140 -        if (window->shadow == NULL) {
   2.141 +    if (((bpp != SDL_VideoSurface->format->BitsPerPixel)
   2.142 +         && !(flags & SDL_ANYFORMAT))
   2.143 +        || ((SDL_VideoSurface->flags & SDL_HWSURFACE)
   2.144 +            && !(flags & SDL_HWSURFACE))) {
   2.145 +        if ((bpp == SDL_VideoSurface->format->BitsPerPixel)
   2.146 +            || (flags & SDL_ANYFORMAT)) {
   2.147 +            SDL_ShadowSurface =
   2.148 +                SDL_CreateRGBSurface(0, width, height,
   2.149 +                                     SDL_VideoSurface->format->BitsPerPixel,
   2.150 +                                     SDL_VideoSurface->format->Rmask,
   2.151 +                                     SDL_VideoSurface->format->Gmask,
   2.152 +                                     SDL_VideoSurface->format->Bmask,
   2.153 +                                     SDL_VideoSurface->format->Amask);
   2.154 +        } else {
   2.155 +            SDL_ShadowSurface =
   2.156 +                SDL_CreateRGBSurface(0, width, height, bpp, 0, 0, 0, 0);
   2.157 +        }
   2.158 +        if (!SDL_ShadowSurface) {
   2.159              return NULL;
   2.160          }
   2.161 -        window->shadow->flags |= SDL_SHADOW_SURFACE;
   2.162  
   2.163 -        surface = window->shadow;
   2.164 -
   2.165 -        /* 8-bit shadow surfaces report that they have exclusive palette */
   2.166 -        if (surface->format->palette) {
   2.167 -            surface->flags |= SDL_HWPALETTE;
   2.168 -            if (format == SDL_GetCurrentDisplayMode()->format) {
   2.169 -                SDL_memcpy(surface->format->palette->colors,
   2.170 -                           window->surface->format->palette->colors,
   2.171 -                           window->surface->format->palette->ncolors *
   2.172 -                           sizeof(SDL_Color));
   2.173 -            } else {
   2.174 -                SDL_DitherColors(surface->format->palette->colors, bpp);
   2.175 -            }
   2.176 +        /* 8-bit SDL_ShadowSurface surfaces report that they have exclusive palette */
   2.177 +        if (SDL_ShadowSurface->format->palette) {
   2.178 +            SDL_ShadowSurface->flags |= SDL_HWPALETTE;
   2.179 +            SDL_DitherColors(SDL_ShadowSurface->format->palette->colors,
   2.180 +                             SDL_ShadowSurface->format->BitsPerPixel);
   2.181          }
   2.182      }
   2.183 +    SDL_PublicSurface =
   2.184 +        (SDL_ShadowSurface ? SDL_ShadowSurface : SDL_VideoSurface);
   2.185  
   2.186      /* Clear the surface for display */
   2.187 -    {
   2.188 -        Uint32 black = SDL_MapRGB(surface->format, 0, 0, 0);
   2.189 -        SDL_FillRect(surface, NULL, black);
   2.190 -        if (surface->flags & SDL_DOUBLEBUF) {
   2.191 -            SDL_Flip(surface);
   2.192 -            SDL_FillRect(surface, NULL, black);
   2.193 -        }
   2.194 -        SDL_Flip(surface);
   2.195 -    }
   2.196 +    SDL_FillRect(SDL_PublicSurface, NULL, 0);
   2.197  
   2.198 -    return surface;
   2.199 +    /* We're finally done! */
   2.200 +    return SDL_PublicSurface;
   2.201  }
   2.202  
   2.203  SDL_Surface *
   2.204  SDL_GetVideoSurface(void)
   2.205  {
   2.206 -    SDL_VideoDevice *_this = SDL_GetVideoDevice();
   2.207 -
   2.208 -    return SDL_VideoSurface;
   2.209 +    return SDL_PublicSurface;
   2.210  }
   2.211  
   2.212  SDL_Surface *
   2.213 @@ -412,14 +408,11 @@
   2.214  
   2.215      if (!SDL_PublicSurface) {
   2.216          SDL_SetError("No video mode has been set");
   2.217 -        return (NULL);
   2.218 +        return NULL;
   2.219      }
   2.220 +
   2.221      /* Set the flags appropriate for copying to display surface */
   2.222 -    if (((SDL_PublicSurface->flags & SDL_HWSURFACE) == SDL_HWSURFACE)
   2.223 -        && _this->info.blit_hw)
   2.224 -        flags = SDL_HWSURFACE;
   2.225 -    else
   2.226 -        flags = SDL_SWSURFACE;
   2.227 +    flags = SDL_SWSURFACE;
   2.228  #ifdef AUTORLE_DISPLAYFORMAT
   2.229      flags |= (surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA));
   2.230      flags |= SDL_RLEACCELOK;
   2.231 @@ -427,7 +420,7 @@
   2.232      flags |=
   2.233          surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA | SDL_RLEACCELOK);
   2.234  #endif
   2.235 -    return (SDL_ConvertSurface(surface, SDL_PublicSurface->format, flags));
   2.236 +    return SDL_ConvertSurface(surface, SDL_PublicSurface->format, flags);
   2.237  }
   2.238  
   2.239  SDL_Surface *
   2.240 @@ -445,7 +438,7 @@
   2.241  
   2.242      if (!SDL_PublicSurface) {
   2.243          SDL_SetError("No video mode has been set");
   2.244 -        return (NULL);
   2.245 +        return NULL;
   2.246      }
   2.247      vf = SDL_PublicSurface->format;
   2.248  
   2.249 @@ -481,7 +474,14 @@
   2.250      flags |= surface->flags & (SDL_SRCALPHA | SDL_RLEACCELOK);
   2.251      converted = SDL_ConvertSurface(surface, format, flags);
   2.252      SDL_FreeFormat(format);
   2.253 -    return (converted);
   2.254 +    return converted;
   2.255 +}
   2.256 +
   2.257 +int
   2.258 +SDL_Flip(SDL_Surface * screen)
   2.259 +{
   2.260 +    SDL_UpdateRect(screen, 0, 0, 0, 0);
   2.261 +    return 0;
   2.262  }
   2.263  
   2.264  void
   2.265 @@ -512,94 +512,26 @@
   2.266  SDL_UpdateRects(SDL_Surface * screen, int numrects, SDL_Rect * rects)
   2.267  {
   2.268      int i;
   2.269 -    SDL_Window *window;
   2.270  
   2.271 -    /* Find the window corresponding to this surface */
   2.272 -    window = SDL_GetWindowFromSurface(screen);
   2.273 -    if (!window) {
   2.274 -        SDL_SetError("Couldn't find window associated with surface");
   2.275 -        return;
   2.276 -    }
   2.277 -
   2.278 -    if (screen->flags & SDL_SHADOW_SURFACE) {
   2.279 -        if (SHOULD_DRAWCURSOR(SDL_cursorstate)) {
   2.280 -            SDL_LockCursor();
   2.281 -            SDL_DrawCursor(screen);
   2.282 -            for (i = 0; i < numrects; ++i) {
   2.283 -                SDL_LowerBlit(screen, &rects[i], window->surface, &rects[i]);
   2.284 -            }
   2.285 -            SDL_EraseCursor(screen);
   2.286 -            SDL_UnlockCursor();
   2.287 -        } else {
   2.288 -            for (i = 0; i < numrects; ++i) {
   2.289 -                SDL_LowerBlit(screen, &rects[i], window->surface, &rects[i]);
   2.290 -            }
   2.291 +    if (screen == SDL_ShadowSurface) {
   2.292 +        for (i = 0; i < numrects; ++i) {
   2.293 +            SDL_LowerBlit(SDL_ShadowSurface, &rects[i], SDL_VideoSurface,
   2.294 +                          &rects[i]);
   2.295          }
   2.296  
   2.297          /* Fall through to video surface update */
   2.298 -        screen = window->surface;
   2.299 +        screen = SDL_VideoSurface;
   2.300      }
   2.301 -    if ((screen->flags & SDL_SCREEN_SURFACE) && _this->UpdateWindowSurface) {
   2.302 -        /* Update the video surface */
   2.303 -        if (screen->offset) {
   2.304 -            int offset_y = screen->offset / screen->pitch;
   2.305 -            int offset_x = screen->offset % screen->pitch;
   2.306 -            for (i = 0; i < numrects; ++i) {
   2.307 -                rects[i].x += offset_x;
   2.308 -                rects[i].y += offset_y;
   2.309 -            }
   2.310 -            _this->UpdateWindowSurface(_this, window, numrects, rects);
   2.311 -            for (i = 0; i < numrects; ++i) {
   2.312 -                rects[i].x -= offset_x;
   2.313 -                rects[i].y -= offset_y;
   2.314 -            }
   2.315 -        } else {
   2.316 -            _this->UpdateWindowSurface(_this, window, numrects, rects);
   2.317 +    if (screen == SDL_VideoSurface) {
   2.318 +        for (i = 0; i < numrects; ++i) {
   2.319 +            SDL_RenderCopy(SDL_VideoTexture, &rects[i], &rects[i],
   2.320 +                           SDL_TextureBlendMode_None,
   2.321 +                           SDL_TextureScaleMode_None);
   2.322          }
   2.323 +        SDL_RenderPresent();
   2.324      }
   2.325  }
   2.326  
   2.327 -int
   2.328 -SDL_Flip(SDL_Surface * screen)
   2.329 -{
   2.330 -    SDL_Window *window;
   2.331 -
   2.332 -    /* Find the window corresponding to this surface */
   2.333 -    window = SDL_GetWindowFromSurface(screen);
   2.334 -    if (!window) {
   2.335 -        SDL_SetError("Couldn't find window associated with surface");
   2.336 -        return;
   2.337 -    }
   2.338 -
   2.339 -    /* Copy the shadow surface to the video surface */
   2.340 -    if (screen->flags & SDL_SHADOW_SURFACE) {
   2.341 -        SDL_Rect rect;
   2.342 -
   2.343 -        rect.x = 0;
   2.344 -        rect.y = 0;
   2.345 -        rect.w = screen->w;
   2.346 -        rect.h = screen->h;
   2.347 -        if (SHOULD_DRAWCURSOR(SDL_cursorstate)) {
   2.348 -            SDL_LockCursor();
   2.349 -            SDL_DrawCursor(screen);
   2.350 -            SDL_LowerBlit(screen, &rect, window->surface, &rect);
   2.351 -            SDL_EraseCursor(screen);
   2.352 -            SDL_UnlockCursor();
   2.353 -        } else {
   2.354 -            SDL_LowerBlit(screen, &rect, window->surface, &rect);
   2.355 -        }
   2.356 -
   2.357 -        /* Fall through to video surface update */
   2.358 -        screen = window->surface;
   2.359 -    }
   2.360 -    if (screen->flags & SDL_DOUBLEBUF) {
   2.361 -        _this->FlipWindowSurface(_this, window);
   2.362 -    } else {
   2.363 -        SDL_UpdateRect(screen, 0, 0, 0, 0);
   2.364 -    }
   2.365 -    return (0);
   2.366 -}
   2.367 -
   2.368  void
   2.369  SDL_WM_SetCaption(const char *title, const char *icon)
   2.370  {
   2.371 @@ -608,7 +540,7 @@
   2.372      } else {
   2.373          wm_title = SDL_strdup(title);
   2.374      }
   2.375 -    SDL_SetWindowTitle(window, wm_title);
   2.376 +    SDL_SetWindowTitle(SDL_VideoWindow, wm_title);
   2.377  }
   2.378  
   2.379  void
   2.380 @@ -631,7 +563,7 @@
   2.381  int
   2.382  SDL_WM_IconifyWindow(void)
   2.383  {
   2.384 -    SDL_MinimizeWindow(window);
   2.385 +    SDL_MinimizeWindow(SDL_VideoWindow);
   2.386  }
   2.387  
   2.388  int
   2.389 @@ -644,9 +576,9 @@
   2.390  SDL_WM_GrabInput(SDL_GrabMode mode)
   2.391  {
   2.392      if (mode != SDL_GRAB_QUERY) {
   2.393 -        SDL_SetWindowGrab(window, mode);
   2.394 +        SDL_SetWindowGrab(SDL_VideoWindow, mode);
   2.395      }
   2.396 -    return (SDL_GrabMode) SDL_GetWindowGrab(window);
   2.397 +    return (SDL_GrabMode) SDL_GetWindowGrab(SDL_VideoWindow);
   2.398  }
   2.399  
   2.400  Uint8
   2.401 @@ -655,7 +587,7 @@
   2.402      Uint8 state = 0;
   2.403      Uint32 flags = 0;
   2.404  
   2.405 -    flags = SDL_GetWindowFlags(window);
   2.406 +    flags = SDL_GetWindowFlags(SDL_VideoWindow);
   2.407      if ((flags & SDL_WINDOW_SHOWN) && !(flags & SDL_WINDOW_MINIMIZED)) {
   2.408          state |= SDL_APPACTIVE;
   2.409      }
   2.410 @@ -687,7 +619,6 @@
   2.411  SDL_SetScreenColors(SDL_Surface * screen, SDL_Color * colors, int firstcolor,
   2.412                      int ncolors)
   2.413  {
   2.414 -    SDL_Window *window = NULL;
   2.415      SDL_Palette *pal;
   2.416      int gotall;
   2.417      int palsize;
   2.418 @@ -704,17 +635,10 @@
   2.419          gotall = 0;
   2.420      }
   2.421  
   2.422 -    if (screen->flags & (SDL_SHADOW_SURFACE | SDL_SCREEN_SURFACE)) {
   2.423 -        window = SDL_GetWindowFromSurface(screen);
   2.424 -        if (!window) {
   2.425 -            return 0;
   2.426 -        }
   2.427 -    }
   2.428 -
   2.429 -    if (screen->flags & SDL_SHADOW_SURFACE) {
   2.430 +    if (screen == SDL_ShadowSurface) {
   2.431          SDL_Palette *vidpal;
   2.432  
   2.433 -        vidpal = window->surface->format->palette;
   2.434 +        vidpal = SDL_VideoSurface->format->palette;
   2.435          if (vidpal && vidpal->ncolors == pal->ncolors) {
   2.436              /* This is a shadow surface, and the physical
   2.437               * framebuffer is also indexed. Propagate the
   2.438 @@ -724,28 +648,18 @@
   2.439              SDL_memcpy(vidpal->colors + firstcolor, colors,
   2.440                         ncolors * sizeof(*colors));
   2.441          }
   2.442 -        if (window->surface->flags & SDL_HWPALETTE) {
   2.443 +        if (SDL_VideoSurface->flags & SDL_HWPALETTE) {
   2.444              /* Set the physical palette */
   2.445 -            screen = window->surface;
   2.446 +            screen = SDL_VideoSurface;
   2.447          } else {
   2.448              SDL_UpdateRect(screen, 0, 0, 0, 0);
   2.449          }
   2.450      }
   2.451  
   2.452 -    if (screen->flags & SDL_SCREEN_SURFACE) {
   2.453 -        if (_this->SetWindowColors) {
   2.454 -            gotall =
   2.455 -                _this->SetWindowColors(_this, window, firstcolor, ncolors,
   2.456 -                                       colors);
   2.457 -            if (!gotall) {
   2.458 -                /* The video flags shouldn't have SDL_HWPALETTE, and
   2.459 -                   the video driver is responsible for copying back the
   2.460 -                   correct colors into the video surface palette.
   2.461 -                 */
   2.462 -                ;
   2.463 -            }
   2.464 -        }
   2.465 -        SDL_CursorPaletteChanged();
   2.466 +    if (screen == SDL_VideoSurface) {
   2.467 +        SDL_SetTexturePalette(SDL_VideoTexture,
   2.468 +                              SDL_VideoSurface->format->palette->colors, 0,
   2.469 +                              SDL_VideoSurface->format->palette->ncolors);
   2.470      }
   2.471  
   2.472      return gotall;
   2.473 @@ -754,9 +668,10 @@
   2.474  int
   2.475  SDL_GetWMInfo(SDL_SysWMinfo * info)
   2.476  {
   2.477 -    return SDL_GetWindowWMInfo(window, info);
   2.478 +    return SDL_GetWindowWMInfo(SDL_VideoWindow, info);
   2.479  }
   2.480  
   2.481 +#if 0
   2.482  void
   2.483  SDL_MoveCursor(int x, int y)
   2.484  {
   2.485 @@ -1349,5 +1264,6 @@
   2.486          SDL_free(overlay);
   2.487      }
   2.488  }
   2.489 +#endif
   2.490  
   2.491  /* vi: set ts=4 sw=4 expandtab: */
     3.1 --- a/src/video/SDL_renderer_sw.c	Tue Jun 13 04:37:45 2006 +0000
     3.2 +++ b/src/video/SDL_renderer_sw.c	Wed Jun 14 06:14:26 2006 +0000
     3.3 @@ -30,6 +30,9 @@
     3.4  static SDL_Renderer *SDL_SW_CreateRenderer(SDL_Window * window, Uint32 flags);
     3.5  static int SDL_SW_CreateTexture(SDL_Renderer * renderer,
     3.6                                  SDL_Texture * texture);
     3.7 +static int SDL_SW_QueryTexturePixels(SDL_Renderer * renderer,
     3.8 +                                     SDL_Texture * texture, void **pixels,
     3.9 +                                     int *pitch);
    3.10  static int SDL_SW_UpdateTexture(SDL_Renderer * renderer,
    3.11                                  SDL_Texture * texture, SDL_Rect * rect,
    3.12                                  const void *pixels, int pitch);
    3.13 @@ -126,6 +129,7 @@
    3.14      SDL_zerop(data);
    3.15  
    3.16      renderer->CreateTexture = SDL_SW_CreateTexture;
    3.17 +    renderer->QueryTexturePixels = SDL_SW_QueryTexturePixels;
    3.18      renderer->UpdateTexture = SDL_SW_UpdateTexture;
    3.19      renderer->LockTexture = SDL_SW_LockTexture;
    3.20      renderer->UnlockTexture = SDL_SW_UnlockTexture;
    3.21 @@ -215,6 +219,17 @@
    3.22  }
    3.23  
    3.24  int
    3.25 +SDL_SW_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture,
    3.26 +                          void **pixels, int *pitch)
    3.27 +{
    3.28 +    SDL_Surface *surface = (SDL_Surface *) texture->driverdata;
    3.29 +
    3.30 +    *pixels = surface->pixels;
    3.31 +    *pitch = surface->pitch;
    3.32 +    return 0;
    3.33 +}
    3.34 +
    3.35 +int
    3.36  SDL_SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
    3.37                       SDL_Rect * rect, const void *pixels, int pitch)
    3.38  {
     4.1 --- a/src/video/SDL_surface.c	Tue Jun 13 04:37:45 2006 +0000
     4.2 +++ b/src/video/SDL_surface.c	Wed Jun 14 06:14:26 2006 +0000
     4.3 @@ -134,6 +134,8 @@
     4.4      int w, h;
     4.5      int bpp;
     4.6      Uint32 Rmask, Gmask, Bmask, Amask;
     4.7 +    void *pixels;
     4.8 +    int pitch;
     4.9  
    4.10      if (SDL_QueryTexture(textureID, &format, NULL, &w, &h) < 0) {
    4.11          return NULL;
    4.12 @@ -145,14 +147,22 @@
    4.13          return NULL;
    4.14      }
    4.15  
    4.16 -    surface = SDL_CreateRGBSurface(0, 0, 0, bpp, Rmask, Gmask, Bmask, Amask);
    4.17 -    if (surface != NULL) {
    4.18 -        surface->flags |= (SDL_HWSURFACE | SDL_PREALLOC);
    4.19 -        surface->w = w;
    4.20 -        surface->h = h;
    4.21 -        surface->lock_data = (void *) textureID;
    4.22 -        SDL_SetClipRect(surface, NULL);
    4.23 +    if (SDL_QueryTexturePixels(textureID, &pixels, &pitch) == 0) {
    4.24 +        surface =
    4.25 +            SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch, Rmask, Gmask,
    4.26 +                                     Bmask, Amask);
    4.27 +    } else {
    4.28 +        surface =
    4.29 +            SDL_CreateRGBSurface(0, 0, 0, bpp, Rmask, Gmask, Bmask, Amask);
    4.30 +        if (surface) {
    4.31 +            surface->flags |= SDL_HWSURFACE;
    4.32 +            surface->w = w;
    4.33 +            surface->h = h;
    4.34 +            surface->lock_data = (void *) textureID;
    4.35 +            SDL_SetClipRect(surface, NULL);
    4.36 +        }
    4.37      }
    4.38 +
    4.39      return surface;
    4.40  }
    4.41  
     5.1 --- a/src/video/SDL_sysvideo.h	Tue Jun 13 04:37:45 2006 +0000
     5.2 +++ b/src/video/SDL_sysvideo.h	Wed Jun 14 06:14:26 2006 +0000
     5.3 @@ -67,6 +67,8 @@
     5.4  struct SDL_Renderer
     5.5  {
     5.6      int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture);
     5.7 +    int (*QueryTexturePixels) (SDL_Renderer * renderer, SDL_Texture * texture,
     5.8 +                               void **pixels, int *pitch);
     5.9      int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
    5.10                            SDL_Rect * rect, const void *pixels, int pitch);
    5.11      int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture,
     6.1 --- a/src/video/SDL_video.c	Tue Jun 13 04:37:45 2006 +0000
     6.2 +++ b/src/video/SDL_video.c	Wed Jun 14 06:14:26 2006 +0000
     6.3 @@ -1286,6 +1286,23 @@
     6.4  }
     6.5  
     6.6  int
     6.7 +SDL_QueryTexturePixels(SDL_TextureID textureID, void **pixels, int *pitch)
     6.8 +{
     6.9 +    SDL_Texture *texture = SDL_GetTextureFromID(textureID);
    6.10 +    SDL_Renderer *renderer;
    6.11 +
    6.12 +    if (!texture) {
    6.13 +        return -1;
    6.14 +    }
    6.15 +
    6.16 +    renderer = texture->renderer;
    6.17 +    if (!renderer->QueryTexturePixels) {
    6.18 +        return -1;
    6.19 +    }
    6.20 +    return renderer->QueryTexturePixels(renderer, texture, pixels, pitch);
    6.21 +}
    6.22 +
    6.23 +int
    6.24  SDL_UpdateTexture(SDL_TextureID textureID, SDL_Rect * rect,
    6.25                    const void *pixels, int pitch)
    6.26  {
     7.1 --- a/src/video/dummy/SDL_nullrender.c	Tue Jun 13 04:37:45 2006 +0000
     7.2 +++ b/src/video/dummy/SDL_nullrender.c	Wed Jun 14 06:14:26 2006 +0000
     7.3 @@ -45,7 +45,8 @@
     7.4      SDL_DUMMY_CreateRenderer,
     7.5      {
     7.6       "minimal",
     7.7 -     (SDL_Renderer_Minimal | SDL_Renderer_PresentCopy),
     7.8 +     (SDL_Renderer_Minimal | SDL_Renderer_PresentDiscard |
     7.9 +      SDL_Renderer_PresentCopy),
    7.10       SDL_TextureBlendMode_None,
    7.11       SDL_TextureScaleMode_None,
    7.12       0,
    7.13 @@ -167,7 +168,7 @@
    7.14  
    7.15      if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) {
    7.16          char file[128];
    7.17 -        SDL_snprintf(file, sizeof(file), "SDL_screen-%8.8d.bmp",
    7.18 +        SDL_snprintf(file, sizeof(file), "SDL_frame-%8.8d.bmp",
    7.19                       ++frame_number);
    7.20          SDL_SaveBMP(surface, file);
    7.21      }