diff options
author | fluxgen <fluxgen> | 2004-01-02 22:19:39 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2004-01-02 22:19:39 (GMT) |
commit | a5be2ef67d91f2cba7551e3a52a6b989c87e8611 (patch) | |
tree | f51caab62bb1b3994f649dafbd79848bd23d7f9c /src | |
parent | b9049cefad82bd62a663e4ae4048d7574563bdfc (diff) | |
download | fluxbox_paul-a5be2ef67d91f2cba7551e3a52a6b989c87e8611.zip fluxbox_paul-a5be2ef67d91f2cba7551e3a52a6b989c87e8611.tar.bz2 |
textured pixmap cache fix
Diffstat (limited to 'src')
-rw-r--r-- | src/FbTk/ImageControl.cc | 31 | ||||
-rw-r--r-- | src/FbTk/ImageControl.hh | 18 |
2 files changed, 29 insertions, 20 deletions
diff --git a/src/FbTk/ImageControl.cc b/src/FbTk/ImageControl.cc index 783f7a7..977d899 100644 --- a/src/FbTk/ImageControl.cc +++ b/src/FbTk/ImageControl.cc | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: ImageControl.cc,v 1.7 2004/01/02 13:28:00 fluxgen Exp $ | 25 | // $Id: ImageControl.cc,v 1.8 2004/01/02 22:19:39 fluxgen Exp $ |
26 | 26 | ||
27 | #include "ImageControl.hh" | 27 | #include "ImageControl.hh" |
28 | 28 | ||
@@ -150,15 +150,27 @@ ImageControl::~ImageControl() { | |||
150 | 150 | ||
151 | 151 | ||
152 | Pixmap ImageControl::searchCache(unsigned int width, unsigned int height, | 152 | Pixmap ImageControl::searchCache(unsigned int width, unsigned int height, |
153 | unsigned long texture_type, | 153 | const Texture &text) const { |
154 | const FbTk::Color &color, const FbTk::Color &color_to) const { | ||
155 | 154 | ||
155 | if (text.pixmap().drawable() != None) { | ||
156 | // do comparsion with width/height and texture_pixmap | ||
157 | CacheList::iterator it = cache.begin(); | ||
158 | CacheList::iterator it_end = cache.end(); | ||
159 | for (; it != it_end; ++it) { | ||
160 | if ((*it)->texture_pixmap = text.pixmap().drawable() && | ||
161 | (*it)->width == width && (*it)->height == height) | ||
162 | return (*it)->pixmap; | ||
163 | } | ||
164 | return None; | ||
165 | } | ||
166 | |||
156 | Cache tmp; | 167 | Cache tmp; |
168 | tmp.texture_pixmap = text.pixmap().drawable(); | ||
157 | tmp.width = width; | 169 | tmp.width = width; |
158 | tmp.height = height; | 170 | tmp.height = height; |
159 | tmp.texture = texture_type; | 171 | tmp.texture = text.type(); |
160 | tmp.pixel1 = color.pixel(); | 172 | tmp.pixel1 = text.color().pixel(); |
161 | tmp.pixel2 = color_to.pixel(); | 173 | tmp.pixel2 = text.colorTo().pixel(); |
162 | CacheList::iterator it = cache.find(&tmp); | 174 | CacheList::iterator it = cache.find(&tmp); |
163 | if (it == cache.end()) { | 175 | if (it == cache.end()) { |
164 | return None; | 176 | return None; |
@@ -179,10 +191,10 @@ Pixmap ImageControl::renderImage(unsigned int width, unsigned int height, | |||
179 | return ParentRelative; | 191 | return ParentRelative; |
180 | 192 | ||
181 | // search cache first | 193 | // search cache first |
182 | Pixmap pixmap = searchCache(width, height, texture.type(), | 194 | Pixmap pixmap = searchCache(width, height, texture); |
183 | texture.color(), texture.colorTo()); | 195 | if (pixmap) { |
184 | if (pixmap) | ||
185 | return pixmap; // return cache item | 196 | return pixmap; // return cache item |
197 | } | ||
186 | 198 | ||
187 | // render new image | 199 | // render new image |
188 | TextureRender image(*this, width, height, m_colors, m_num_colors); | 200 | TextureRender image(*this, width, height, m_colors, m_num_colors); |
@@ -194,6 +206,7 @@ Pixmap ImageControl::renderImage(unsigned int width, unsigned int height, | |||
194 | Cache *tmp = new Cache; | 206 | Cache *tmp = new Cache; |
195 | 207 | ||
196 | tmp->pixmap = pixmap; | 208 | tmp->pixmap = pixmap; |
209 | tmp->texture_pixmap = texture.pixmap().drawable(); | ||
197 | tmp->width = width; | 210 | tmp->width = width; |
198 | tmp->height = height; | 211 | tmp->height = height; |
199 | tmp->count = 1; | 212 | tmp->count = 1; |
diff --git a/src/FbTk/ImageControl.hh b/src/FbTk/ImageControl.hh index 0ccb928..087cd69 100644 --- a/src/FbTk/ImageControl.hh +++ b/src/FbTk/ImageControl.hh | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: ImageControl.hh,v 1.7 2004/01/02 13:27:29 fluxgen Exp $ | 25 | // $Id: ImageControl.hh,v 1.8 2004/01/02 22:19:39 fluxgen Exp $ |
26 | 26 | ||
27 | #ifndef FBTK_IMAGECONTROL_HH | 27 | #ifndef FBTK_IMAGECONTROL_HH |
28 | #define FBTK_IMAGECONTROL_HH | 28 | #define FBTK_IMAGECONTROL_HH |
@@ -79,8 +79,7 @@ private: | |||
79 | Search cache for a specific pixmap | 79 | Search cache for a specific pixmap |
80 | @return None if no cache was found | 80 | @return None if no cache was found |
81 | */ | 81 | */ |
82 | Pixmap searchCache(unsigned int width, unsigned int height, unsigned long texture_type, | 82 | Pixmap searchCache(unsigned int width, unsigned int height, const Texture &text) const; |
83 | const FbTk::Color &color, const FbTk::Color &color_to) const; | ||
84 | 83 | ||
85 | void createColorTable(); | 84 | void createColorTable(); |
86 | bool m_dither; | 85 | bool m_dither; |
@@ -109,24 +108,21 @@ private: | |||
109 | 108 | ||
110 | typedef struct Cache { | 109 | typedef struct Cache { |
111 | Pixmap pixmap; | 110 | Pixmap pixmap; |
112 | 111 | Pixmap texture_pixmap; | |
113 | unsigned int count, width, height; | 112 | unsigned int count, width, height; |
114 | unsigned long pixel1, pixel2, texture; | 113 | unsigned long pixel1, pixel2, texture; |
115 | } Cache; | 114 | } Cache; |
116 | 115 | ||
117 | struct ltCacheEntry | 116 | struct ltCacheEntry { |
118 | { | 117 | bool operator()(const Cache* s1, const Cache* s2) const { |
119 | bool operator()(const Cache* s1, const Cache* s2) const | 118 | return (s1->width < s2->width || s1->width == s2->width && |
120 | { | ||
121 | return | ||
122 | (s1->width < s2->width || s1->width == s2->width && | ||
123 | (s1->height < s2->height || s1->height == s2->height && | 119 | (s1->height < s2->height || s1->height == s2->height && |
124 | (s1->texture < s2->texture || s1->texture == s2->texture && | 120 | (s1->texture < s2->texture || s1->texture == s2->texture && |
125 | s1->pixel1 < s2->pixel1 || s1->pixel1 == s2->pixel1 && | 121 | s1->pixel1 < s2->pixel1 || s1->pixel1 == s2->pixel1 && |
126 | (s1->texture & FbTk::Texture::GRADIENT) && | 122 | (s1->texture & FbTk::Texture::GRADIENT) && |
127 | s1->pixel2 < s2->pixel2) | 123 | s1->pixel2 < s2->pixel2) |
128 | )); | 124 | )); |
129 | } | 125 | } |
130 | }; | 126 | }; |
131 | 127 | ||
132 | 128 | ||