mail[Wesnoth-commits] r27223 - in /trunk/src: image.cpp image.hpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by alinktomine on June 16, 2008 - 17:30:
Author: alink
Date: Mon Jun 16 17:30:31 2008
New Revision: 27223

URL: http://svn.gna.org/viewcvs/wesnoth?rev=27223&view=rev
Log:
Optimize fullscreen toggle and windows resizing:
Stop always flushing the image cache, do it only when RGB/bpp details change.
PS: optimization not yet activated for 8bpp mode

Modified:
    trunk/src/image.cpp
    trunk/src/image.hpp

Modified: trunk/src/image.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/image.cpp?rev=27223&r1=27222&r2=27223&view=diff
==============================================================================
--- trunk/src/image.cpp (original)
+++ trunk/src/image.cpp Mon Jun 16 17:30:31 2008
@@ -35,6 +35,7 @@
 #include <string>
 
 #define ERR_DP LOG_STREAM(err, display)
+#define INFO_DP LOG_STREAM(info, display)
 
 namespace {
 
@@ -505,12 +506,28 @@
 #endif
 }
 
-SDL_PixelFormat* pixel_format = NULL;
+SDL_PixelFormat last_pixel_format;
 
 void set_pixel_format(SDL_PixelFormat* format)
 {
-       pixel_format = format;
-       flush_cache();
+       assert(format != NULL);
+       
+       SDL_PixelFormat &f = *format;
+       SDL_PixelFormat &l = last_pixel_format;
+       // if the pixel format change, we clear the cache,
+       // because some images are now optimized for the wrong display format
+       // FIXME: 8 bpp use palette, need to compare them. For now assume a 
change
+       if (format->BitsPerPixel == 8 ||
+               f.BitsPerPixel != l.BitsPerPixel || f.BytesPerPixel != 
l.BytesPerPixel ||
+               f.Rmask != l.Rmask || f.Gmask != l.Gmask || f.Bmask != 
l.Bmask ||
+               f.Rloss != l.Rloss || f.Gloss != l.Gloss || f.Bloss != 
l.Bloss ||
+               f.Rshift != l.Rshift || f.Gshift != l.Gshift || f.Bshift != 
l.Bshift ||
+               f.colorkey != l.colorkey || f.alpha != l.alpha)
+       {
+               INFO_DP << "detected a new display format\n";
+               flush_cache();
+       }
+       last_pixel_format = *format;
 }
 
 void set_colour_adjustment(int r, int g, int b)

Modified: trunk/src/image.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/image.hpp?rev=27223&r1=27222&r2=27223&view=diff
==============================================================================
--- trunk/src/image.hpp (original)
+++ trunk/src/image.hpp Mon Jun 16 17:30:31 2008
@@ -183,8 +183,6 @@
        ///the 'mask' is blitted onto all scaled images.
        void set_image_mask(const std::string& image_name);
 
-       extern SDL_PixelFormat* pixel_format;
-
        ///sets the pixel format used by the images. Is called every time the
        ///video mode changes. Invalidates all images.
        void set_pixel_format(SDL_PixelFormat* format);




Related Messages


Powered by MHonArc, Updated Mon Jun 16 18:42:15 2008