13
0

cache shaded meter-background regardless of color

previously, shaded patterns were assumed to have different colors as well.
This commit is contained in:
Robin Gareus 2013-07-26 17:17:05 +02:00
parent cd35040535
commit 069fd15c79
2 changed files with 6 additions and 4 deletions

View File

@ -357,7 +357,7 @@ FastMeter::request_vertical_background(
height = min(height, max_pattern_metric_size); height = min(height, max_pattern_metric_size);
height += 2; height += 2;
const PatternBgMapKey key (width, height, bgc[0], bgc[1]); const PatternBgMapKey key (width, height, bgc[0], bgc[1], shade);
PatternBgMap::iterator i; PatternBgMap::iterator i;
if ((i = vb_pattern_cache.find (key)) != vb_pattern_cache.end()) { if ((i = vb_pattern_cache.find (key)) != vb_pattern_cache.end()) {
return i->second; return i->second;
@ -405,7 +405,7 @@ FastMeter::request_horizontal_background(
width = min(width, max_pattern_metric_size); width = min(width, max_pattern_metric_size);
width += 2; width += 2;
const PatternBgMapKey key (width, height, bgc[0], bgc[1]); const PatternBgMapKey key (width, height, bgc[0], bgc[1], shade);
PatternBgMap::iterator i; PatternBgMap::iterator i;
if ((i = hb_pattern_cache.find (key)) != hb_pattern_cache.end()) { if ((i = hb_pattern_cache.find (key)) != hb_pattern_cache.end()) {
return i->second; return i->second;

View File

@ -147,15 +147,17 @@ private:
typedef std::map<Pattern10MapKey, Cairo::RefPtr<Cairo::Pattern> > Pattern10Map; typedef std::map<Pattern10MapKey, Cairo::RefPtr<Cairo::Pattern> > Pattern10Map;
struct PatternBgMapKey { 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) : dim(w, h)
, cols(c0, c1) , cols(c0, c1)
, sh(shade)
{} {}
inline bool operator<(const PatternBgMapKey& rhs) const { 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> dim;
boost::tuple<int, int> cols; boost::tuple<int, int> cols;
bool sh;
}; };
typedef std::map<PatternBgMapKey, Cairo::RefPtr<Cairo::Pattern> > PatternBgMap; typedef std::map<PatternBgMapKey, Cairo::RefPtr<Cairo::Pattern> > PatternBgMap;