src/video/SDL_surface.c
branchSDL-1.3
changeset 1678 90bf530ced8e
parent 1672 8e754b82cecc
child 1682 7ae8018b2e5d
equal deleted inserted replaced
1677:5e4c5e095925 1678:90bf530ced8e
   132     SDL_Surface *surface;
   132     SDL_Surface *surface;
   133     Uint32 format;
   133     Uint32 format;
   134     int w, h;
   134     int w, h;
   135     int bpp;
   135     int bpp;
   136     Uint32 Rmask, Gmask, Bmask, Amask;
   136     Uint32 Rmask, Gmask, Bmask, Amask;
       
   137     void *pixels;
       
   138     int pitch;
   137 
   139 
   138     if (SDL_QueryTexture(textureID, &format, NULL, &w, &h) < 0) {
   140     if (SDL_QueryTexture(textureID, &format, NULL, &w, &h) < 0) {
   139         return NULL;
   141         return NULL;
   140     }
   142     }
   141 
   143 
   143         (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
   145         (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) {
   144         SDL_SetError("Unknown texture format");
   146         SDL_SetError("Unknown texture format");
   145         return NULL;
   147         return NULL;
   146     }
   148     }
   147 
   149 
   148     surface = SDL_CreateRGBSurface(0, 0, 0, bpp, Rmask, Gmask, Bmask, Amask);
   150     if (SDL_QueryTexturePixels(textureID, &pixels, &pitch) == 0) {
   149     if (surface != NULL) {
   151         surface =
   150         surface->flags |= (SDL_HWSURFACE | SDL_PREALLOC);
   152             SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch, Rmask, Gmask,
   151         surface->w = w;
   153                                      Bmask, Amask);
   152         surface->h = h;
   154     } else {
   153         surface->lock_data = (void *) textureID;
   155         surface =
   154         SDL_SetClipRect(surface, NULL);
   156             SDL_CreateRGBSurface(0, 0, 0, bpp, Rmask, Gmask, Bmask, Amask);
   155     }
   157         if (surface) {
       
   158             surface->flags |= SDL_HWSURFACE;
       
   159             surface->w = w;
       
   160             surface->h = h;
       
   161             surface->lock_data = (void *) textureID;
       
   162             SDL_SetClipRect(surface, NULL);
       
   163         }
       
   164     }
       
   165 
   156     return surface;
   166     return surface;
   157 }
   167 }
   158 
   168 
   159 /*
   169 /*
   160  * Set the palette in a blittable surface
   170  * Set the palette in a blittable surface