Author: alink
Date: Tue Apr 29 20:48:23 2008
New Revision: 26233

URL: http://svn.gna.org/viewcvs/wesnoth?rev=26233&view=rev
Log:
Generalize optional RLE-optimization in sdl_utils calls
and stop using it where not needed.
(rle-optmization is still the default)

Modified:
    trunk/src/display.cpp
    trunk/src/font.cpp
    trunk/src/sdl_utils.cpp
    trunk/src/sdl_utils.hpp
    trunk/src/show_dialog.cpp

Modified: trunk/src/display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.cpp?rev=26233&r1=26232&r2=26233&view=diff
==============================================================================
--- trunk/src/display.cpp (original)
+++ trunk/src/display.cpp Tue Apr 29 20:48:23 2008
@@ -988,22 +988,22 @@
                surf = image::reverse_image(surf);
        }
        if(vreverse) {
-               surf = flop_surface(surf);
+               surf = flop_surface(surf, false);
        }
 
        if(greyscale) {
-               surf = greyscale_image(surf);
+               surf = greyscale_image(surf, false);
        }
 
        if(blend_ratio != 0) {
-               surf = blend_surface(surf, blend_ratio, blendto);
+               surf = blend_surface(surf, blend_ratio, blendto, false);
        }
        if(alpha > ftofxp(1.0)) {
-               surf = brighten_image(surf,alpha);
+               surf = brighten_image(surf, alpha, false);
        //} else if(alpha != 1.0 && blendto != 0) {
        //      surf.assign(blend_surface(surf,1.0-alpha,blendto));
        } else if(alpha != ftofxp(1.0)) {
-               surf = adjust_surface_alpha(surf,alpha,false);
+               surf = adjust_surface_alpha(surf, alpha, false);
        }
 
        if(surf == NULL) {

Modified: trunk/src/font.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/font.cpp?rev=26233&r1=26232&r2=26233&view=diff
==============================================================================
--- trunk/src/font.cpp (original)
+++ trunk/src/font.cpp Tue Apr 29 20:48:23 2008
@@ -859,7 +859,7 @@
                        surf_.assign(tmp);
                } else {
                        surface background = font::render_text(text_, 
font_size_, font::BLACK_COLOUR, 0);
-                       background = blur_alpha_surface(background,2);
+                       background = blur_alpha_surface(background,2,false);
                        background = adjust_surface_alpha(background, 
ftofxp(4.0));
 
                        surf_.assign(background);

Modified: trunk/src/sdl_utils.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/sdl_utils.cpp?rev=26233&r1=26232&r2=26233&view=diff
==============================================================================
--- trunk/src/sdl_utils.cpp (original)
+++ trunk/src/sdl_utils.cpp Tue Apr 29 20:48:23 2008
@@ -265,7 +265,7 @@
 
 
 // NOTE: Don't pass this function 0 scaling arguments.
-surface scale_surface(surface const &surf, int w, int h)
+surface scale_surface(surface const &surf, int w, int h, bool optimize)
 {
        // Since SDL version 1.1.5 0 is transparent, before 255 was transparent.
        assert(SDL_ALPHA_TRANSPARENT==0);
@@ -422,10 +422,10 @@
                }
        }
 
-       return create_optimized_surface(dst);
-}
-
-surface scale_surface_blended(surface const &surf, int w, int h)
+       return optimize ? create_optimized_surface(dst) : dst;
+}
+
+surface scale_surface_blended(surface const &surf, int w, int h, bool optimize)
 {
        if(surf== NULL)
                return NULL;
@@ -506,10 +506,10 @@
                }
        }
 
-       return create_optimized_surface(dst);
-}
-
-surface adjust_surface_colour(surface const &surf, int red, int green, int 
blue)
+       return optimize ? create_optimized_surface(dst) : dst;
+}
+
+surface adjust_surface_colour(surface const &surf, int red, int green, int 
blue, bool optimize)
 {
        if((red == 0 && green == 0 && blue == 0) || surf == NULL)
                return create_optimized_surface(surf);
@@ -546,10 +546,10 @@
                }
        }
 
-       return create_optimized_surface(nsurf);
-}
-
-surface greyscale_image(surface const &surf)
+       return optimize ? create_optimized_surface(nsurf) : nsurf;
+}
+
+surface greyscale_image(surface const &surf, bool optimize)
 {
        if(surf == NULL)
                return NULL;
@@ -591,10 +591,10 @@
                }
        }
 
-       return create_optimized_surface(nsurf);
-}
-
-surface darken_image(surface const &surf)
+       return optimize ? create_optimized_surface(nsurf) : nsurf;
+}
+
+surface darken_image(surface const &surf, bool optimize)
 {
        if(surf == NULL)
                return NULL;
@@ -641,10 +641,10 @@
                }
        }
 
-       return create_optimized_surface(nsurf);
-}
-
-surface recolor_image(surface surf, const std::map<Uint32, Uint32>& map_rgb){
+       return optimize ? create_optimized_surface(nsurf) : nsurf;
+}
+
+surface recolor_image(surface surf, const std::map<Uint32, Uint32>& map_rgb, 
bool optimize){
        if(map_rgb.size()){
                if(surf == NULL)
                return NULL;
@@ -674,12 +674,13 @@
                        }
                ++beg;
                }
-               return create_optimized_surface(nsurf);
+
+               return optimize ? create_optimized_surface(nsurf) : nsurf;
        }
        return surf;
 }
 
-surface brighten_image(surface const &surf, fixed_t amount)
+surface brighten_image(surface const &surf, fixed_t amount, bool optimize)
 {
        if(surf == NULL) {
                return NULL;
@@ -718,7 +719,7 @@
                }
        }
 
-       return create_optimized_surface(nsurf);
+       return optimize ? create_optimized_surface(nsurf) : nsurf;
 }
 
 surface adjust_surface_alpha(surface const &surf, fixed_t amount, bool 
optimize)
@@ -757,11 +758,7 @@
                }
        }
 
-       if (optimize) {
-               return create_optimized_surface(nsurf);
-       } else {
-               return nsurf;
-       }
+       return optimize ? create_optimized_surface(nsurf) : nsurf;
 }
 
 surface adjust_surface_alpha_add(surface const &surf, int amount, bool 
optimize)
@@ -860,7 +857,7 @@
 }
 
 //! Cross-fades a surface.
-surface blur_surface(surface const &surf, int depth)
+surface blur_surface(surface const &surf, int depth, bool optimize)
 {
        if(surf == NULL) {
                return NULL;
@@ -973,13 +970,13 @@
                }
        }
 
-       return create_optimized_surface(res);
+       return optimize ? create_optimized_surface(res) : res;
 }
 
 //! Cross-fades a surface with alpha channel.
 //! @todo FIXME: This is just an adapted copy-paste
 //! of the normal blur but with blur alpha channel too
-surface blur_alpha_surface(surface const &surf, int depth)
+surface blur_alpha_surface(surface const &surf, int depth, bool optimize)
 {
        if(surf == NULL) {
                return NULL;
@@ -1098,7 +1095,7 @@
                }
        }
 
-       return create_optimized_surface(res);
+       return optimize ? create_optimized_surface(res) : res;
 }
 
 //! Cuts a rectangle from a surface.
@@ -1153,7 +1150,7 @@
        return res;
 }
 
-surface blend_surface(surface const &surf, double amount, Uint32 colour)
+surface blend_surface(surface const &surf, double amount, Uint32 colour, bool 
optimize)
 {
        if(surf== NULL) {
                return NULL;
@@ -1197,10 +1194,10 @@
                }
        }
 
-       return create_optimized_surface(nsurf);
-}
-
-surface flip_surface(surface const &surf)
+       return optimize ? create_optimized_surface(nsurf) : nsurf;
+}
+
+surface flip_surface(surface const &surf, bool optimize)
 {
        if(surf == NULL) {
                return NULL;
@@ -1226,10 +1223,10 @@
                }
        }
 
-       return create_optimized_surface(nsurf);
-}
-
-surface flop_surface(surface const &surf)
+       return optimize ? create_optimized_surface(nsurf) : nsurf;
+}
+
+surface flop_surface(surface const &surf, bool optimize)
 {
        if(surf == NULL) {
                return NULL;
@@ -1255,7 +1252,7 @@
                }
        }
 
-       return create_optimized_surface(nsurf);
+       return optimize ? create_optimized_surface(nsurf) : nsurf;
 }
 
 

Modified: trunk/src/sdl_utils.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/sdl_utils.hpp?rev=26233&r1=26232&r2=26233&view=diff
==============================================================================
--- trunk/src/sdl_utils.hpp (original)
+++ trunk/src/sdl_utils.hpp Tue Apr 29 20:48:23 2008
@@ -126,25 +126,25 @@
 //! Streches a surface in the vertical direction.
 surface stretch_surface_vertical(const surface& surf, const unsigned h);
 
-surface scale_surface(surface const &surf, int w, int h);
-surface scale_surface_blended(surface const &surf, int w, int h);
-surface adjust_surface_colour(surface const &surf, int r, int g, int b);
-surface greyscale_image(surface const &surf);
-surface darken_image(surface const &surf);
-surface recolor_image(surface surf, const std::map<Uint32, Uint32>& map_rgb);
-
-surface brighten_image(surface const &surf, fixed_t amount);
+surface scale_surface(surface const &surf, int w, int h, bool optimize=true);
+surface scale_surface_blended(surface const &surf, int w, int h, bool 
optimize=true);
+surface adjust_surface_colour(surface const &surf, int r, int g, int b, bool 
optimize=true);
+surface greyscale_image(surface const &surf, bool optimize=true);
+surface darken_image(surface const &surf, bool optimize=true);
+surface recolor_image(surface surf, const std::map<Uint32, Uint32>& map_rgb, 
bool optimize=true);
+
+surface brighten_image(surface const &surf, fixed_t amount, bool 
optimize=true);
 // send NULL if the portion is outside of the surface
 surface get_surface_portion(surface const &surf, SDL_Rect &rect);
 surface adjust_surface_alpha(surface const &surf, fixed_t amount, bool 
optimize=true);
 surface adjust_surface_alpha_add(surface const &surf, int amount, bool 
optimize=true);
 surface mask_surface(surface const &surf, surface const &mask);
-surface blur_surface(surface const &surf, int depth = 1);
-surface blur_alpha_surface(surface const &surf, int depth = 1);
+surface blur_surface(surface const &surf, int depth = 1, bool optimize=true);
+surface blur_alpha_surface(surface const &surf, int depth = 1, bool 
optimize=true);
 surface cut_surface(surface const &surf, SDL_Rect const &r);
-surface blend_surface(surface const &surf, double amount, Uint32 colour);
-surface flip_surface(surface const &surf);
-surface flop_surface(surface const &surf);
+surface blend_surface(surface const &surf, double amount, Uint32 colour, bool 
optimize=true);
+surface flip_surface(surface const &surf, bool optimize=true);
+surface flop_surface(surface const &surf, bool optimize=true);
 surface create_compatible_surface(surface const &surf, int width = -1, int 
height = -1);
 //! Replacement for SDL_BlitSurface.
 void blit_surface(const surface& src, 

Modified: trunk/src/show_dialog.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/show_dialog.cpp?rev=26233&r1=26232&r2=26233&view=diff
==============================================================================
--- trunk/src/show_dialog.cpp (original)
+++ trunk/src/show_dialog.cpp Tue Apr 29 20:48:23 2008
@@ -273,7 +273,7 @@
 
        if (dialog_style_.blur_radius) {
                surface surf = ::get_surface_portion(video_.getSurface(), 
dim_.exterior);
-               surf = blur_surface(surf, dialog_style_.blur_radius);
+               surf = blur_surface(surf, dialog_style_.blur_radius, false);
                SDL_BlitSurface(surf, NULL, video_.getSurface(), 
&dim_.exterior);
        }
 


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to