From 043a0edf61bfef84dfd42aa225a9f0b9703ebd27 Mon Sep 17 00:00:00 2001 From: Ricardo Cruz Date: Sat, 12 Jun 2004 15:42:24 +0000 Subject: [PATCH] Passed color mask from screen SDL_Surface to the gradients cache one. This fixes the slowness. Still, there are problems when scrolling. This looks like some background issue, but dunno where. SVN-Revision: 1470 --- src/screen/texture.cpp | 61 +++++++++++++++++++------------------------------- 1 file changed, 23 insertions(+), 38 deletions(-) diff --git a/src/screen/texture.cpp b/src/screen/texture.cpp index d84175419..6e9f82eb8 100644 --- a/src/screen/texture.cpp +++ b/src/screen/texture.cpp @@ -366,44 +366,29 @@ sdl_surface_from_gradient(Color top, Color bottom, int w, int h) { SDL_Surface* sdl_surface; - Uint32 rmask, gmask, bmask, amask; - - /* SDL interprets each pixel as a 32-bit number, so our masks must depend - on the endianness (byte order) of the machine */ -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - rmask = 0xff000000; - gmask = 0x00ff0000; - bmask = 0x0000ff00; - amask = 0x000000ff; -#else - rmask = 0x000000ff; - gmask = 0x0000ff00; - bmask = 0x00ff0000; - amask = 0xff000000; -#endif - - sdl_surface = SDL_CreateRGBSurface(screen->flags, w, h, - screen->format->BitsPerPixel, rmask, gmask, bmask, amask); - - if(sdl_surface == NULL) - st_abort("Cannot create surface for the gradient", "SURFACE"); - - float redstep = (float(bottom.red)-float(top.red)) / float(h); - float greenstep = (float(bottom.green)-float(top.green)) / float(h); - float bluestep = (float(bottom.blue) - float(top.blue)) / float(h); - - SDL_Rect rect; - rect.x = 0; - rect.w = w; - rect.h = 1; - for(float y = 0; y < h; y++) - { - rect.y = (int)y; - SDL_FillRect(sdl_surface, &rect, SDL_MapRGB(sdl_surface->format, - int(float(top.red) + redstep * y), - int(float(top.green) + greenstep * y), - int(float(top.blue) + bluestep * y))); - } + sdl_surface = SDL_CreateRGBSurface(screen->flags, w, h, + screen->format->BitsPerPixel, screen->format->Rmask, + screen->format->Gmask, screen->format->Bmask, screen->format->Amask); + + if(sdl_surface == NULL) + st_abort("Cannot create surface for the gradient", "SURFACE"); + + float redstep = (float(bottom.red)-float(top.red)) / float(h); + float greenstep = (float(bottom.green)-float(top.green)) / float(h); + float bluestep = (float(bottom.blue) - float(top.blue)) / float(h); + + SDL_Rect rect; + rect.x = 0; + rect.w = w; + rect.h = 1; + for(float y = 0; y < h; y++) + { + rect.y = (int)y; + SDL_FillRect(sdl_surface, &rect, SDL_MapRGB(sdl_surface->format, + int(float(top.red) + redstep * y), + int(float(top.green) + greenstep * y), + int(float(top.blue) + bluestep * y))); + } return sdl_surface; } -- 2.11.0