cache shaded meter-background regardless of color
authorRobin Gareus <robin@gareus.org>
Fri, 26 Jul 2013 15:17:05 +0000 (17:17 +0200)
committerRobin Gareus <robin@gareus.org>
Fri, 26 Jul 2013 15:17:05 +0000 (17:17 +0200)
previously, shaded patterns were assumed to have different colors as well.

libs/gtkmm2ext/fastmeter.cc
libs/gtkmm2ext/gtkmm2ext/fastmeter.h

index e7efaa81b9b1f2640f55bb79dbc40580867faa2a..143bbe2b1c9d305519b281efba3ca47fb38ea814 100644 (file)
@@ -357,7 +357,7 @@ FastMeter::request_vertical_background(
        height = min(height, max_pattern_metric_size);
        height += 2;
 
-       const PatternBgMapKey key (width, height, bgc[0], bgc[1]);
+       const PatternBgMapKey key (width, height, bgc[0], bgc[1], shade);
        PatternBgMap::iterator i;
        if ((i = vb_pattern_cache.find (key)) != vb_pattern_cache.end()) {
                return i->second;
@@ -405,7 +405,7 @@ FastMeter::request_horizontal_background(
        width = min(width, max_pattern_metric_size);
        width += 2;
 
-       const PatternBgMapKey key (width, height, bgc[0], bgc[1]);
+       const PatternBgMapKey key (width, height, bgc[0], bgc[1], shade);
        PatternBgMap::iterator i;
        if ((i = hb_pattern_cache.find (key)) != hb_pattern_cache.end()) {
                return i->second;
index 602bea1b383fbf76f1adf3836908d8f69fc65e0b..80707489637ea65442d236e526cb4900abef54cb 100644 (file)
@@ -147,15 +147,17 @@ private:
        typedef std::map<Pattern10MapKey, Cairo::RefPtr<Cairo::Pattern> > Pattern10Map;
 
        struct PatternBgMapKey {
-               PatternBgMapKey (int w, int h, int c0, int c1)
+               PatternBgMapKey (int w, int h, int c0, int c1, bool shade)
                        : dim(w, h)
                        , cols(c0, c1)
+                       , sh(shade)
                {}
                inline bool operator<(const PatternBgMapKey& rhs) const {
-                       return (dim < rhs.dim) || (dim == rhs.dim && cols < rhs.cols);
+                       return (dim < rhs.dim) || (dim == rhs.dim && cols < rhs.cols) || (dim == rhs.dim && cols == rhs.cols && (sh && !rhs.sh));
                }
                boost::tuple<int, int> dim;
                boost::tuple<int, int> cols;
+               bool sh;
        };
        typedef std::map<PatternBgMapKey, Cairo::RefPtr<Cairo::Pattern> > PatternBgMap;