aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-11-27 22:04:02 (GMT)
committerfluxgen <fluxgen>2002-11-27 22:04:02 (GMT)
commit037ece44a91abf65055a65ab5e07e6f1ae3cb23d (patch)
tree104f4cac7736ad9f851c4746808b7bbd0edbb9a0 /src
parent1eed220f986d32d685164767aa7b74eb0ece4f1c (diff)
downloadfluxbox-037ece44a91abf65055a65ab5e07e6f1ae3cb23d.zip
fluxbox-037ece44a91abf65055a65ab5e07e6f1ae3cb23d.tar.bz2
using const ref for texture option in render
Diffstat (limited to 'src')
-rw-r--r--src/Image.cc166
-rw-r--r--src/Image.hh10
2 files changed, 90 insertions, 86 deletions
diff --git a/src/Image.cc b/src/Image.cc
index fe13756..e0bc22f 100644
--- a/src/Image.cc
+++ b/src/Image.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: Image.cc,v 1.18 2002/11/24 20:54:29 fluxgen Exp $ 25// $Id: Image.cc,v 1.19 2002/11/27 22:04:02 fluxgen Exp $
26 26
27#include "Image.hh" 27#include "Image.hh"
28 28
@@ -42,7 +42,6 @@
42#include <sys/types.h> 42#include <sys/types.h>
43#endif // HAVE_SYS_TYPES_H 43#endif // HAVE_SYS_TYPES_H
44 44
45
46#include <cstdlib> 45#include <cstdlib>
47#include <cstring> 46#include <cstring>
48#include <cstdio> 47#include <cstdio>
@@ -107,21 +106,23 @@ BImage::~BImage() {
107} 106}
108 107
109 108
110Pixmap BImage::render(const FbTk::Texture *texture) { 109Pixmap BImage::render(const FbTk::Texture &texture) {
111 using namespace FbTk; 110
112 if (texture->type() & Texture::PARENTRELATIVE) 111 if (texture.type() & FbTk::Texture::PARENTRELATIVE)
113 return ParentRelative; 112 return ParentRelative;
114 else if (texture->type() & Texture::SOLID) 113 else if (texture.type() & FbTk::Texture::SOLID)
115 return renderSolid(texture); 114 return renderSolid(texture);
116 else if (texture->type() & Texture::GRADIENT) 115 else if (texture.type() & FbTk::Texture::GRADIENT)
117 return renderGradient(texture); 116 return renderGradient(texture);
118 117
119 return None; 118 return None;
120} 119}
121 120
122 121
123Pixmap BImage::renderSolid(const FbTk::Texture *texture) { 122Pixmap BImage::renderSolid(const FbTk::Texture &texture) {
124 Display *disp = BaseDisplay::getXDisplay(); 123
124 Display *disp = BaseDisplay::instance()->getXDisplay();
125
125 Pixmap pixmap = XCreatePixmap(disp, 126 Pixmap pixmap = XCreatePixmap(disp,
126 control->drawable(), width, 127 control->drawable(), width,
127 height, control->depth()); 128 height, control->depth());
@@ -136,80 +137,78 @@ Pixmap BImage::renderSolid(const FbTk::Texture *texture) {
136 XGCValues gcv; 137 XGCValues gcv;
137 GC gc, hgc, lgc; 138 GC gc, hgc, lgc;
138 139
139 gcv.foreground = texture->color().pixel(); 140 gcv.foreground = texture.color().pixel();
140 gcv.fill_style = FillSolid; 141 gcv.fill_style = FillSolid;
141 gc = XCreateGC(disp, pixmap, 142 gc = XCreateGC(disp, pixmap,
142 GCForeground | GCFillStyle, &gcv); 143 GCForeground | GCFillStyle, &gcv);
143 144
144 gcv.foreground = texture->hiColor().pixel(); 145 gcv.foreground = texture.hiColor().pixel();
145 hgc = XCreateGC(disp, pixmap, 146 hgc = XCreateGC(disp, pixmap,
146 GCForeground, &gcv); 147 GCForeground, &gcv);
147 148
148 gcv.foreground = texture->loColor().pixel(); 149 gcv.foreground = texture.loColor().pixel();
149 lgc = XCreateGC(disp, pixmap, 150 lgc = XCreateGC(disp, pixmap,
150 GCForeground, &gcv); 151 GCForeground, &gcv);
151 152
152 XFillRectangle(BaseDisplay::getXDisplay(), pixmap, gc, 0, 0, 153 XFillRectangle(disp, pixmap, gc, 0, 0, width, height);
153 width, height); 154
154
155 using namespace FbTk; 155 using namespace FbTk;
156 156
157 if (texture->type() & Texture::INTERLACED) { 157 if (texture.type() & Texture::INTERLACED) {
158 gcv.foreground = texture->colorTo().pixel(); 158 gcv.foreground = texture.colorTo().pixel();
159 GC igc = XCreateGC(disp, pixmap, 159 GC igc = XCreateGC(disp, pixmap,
160 GCForeground, &gcv); 160 GCForeground, &gcv);
161 161
162 register unsigned int i = 0; 162 register unsigned int i = 0;
163 for (; i < height; i += 2) 163 for (; i < height; i += 2)
164 XDrawLine(disp, pixmap, igc, 164 XDrawLine(disp, pixmap, igc, 0, i, width, i);
165 0, i, width, i);
166 165
167 XFreeGC(disp, igc); 166 XFreeGC(disp, igc);
168 } 167 }
169 168
170 if (texture->type() & Texture::BEVEL1) { 169 if (texture.type() & Texture::BEVEL1) {
171 if (texture->type() & Texture::RAISED) { 170 if (texture.type() & Texture::RAISED) {
172 XDrawLine(disp, pixmap, lgc, 171 XDrawLine(disp, pixmap, lgc,
173 0, height - 1, width - 1, height - 1); 172 0, height - 1, width - 1, height - 1);
174 XDrawLine(disp, pixmap, lgc, 173 XDrawLine(disp, pixmap, lgc,
175 width - 1, height - 1, width - 1, 0); 174 width - 1, height - 1, width - 1, 0);
176 175
177 XDrawLine(disp, pixmap, hgc, 176 XDrawLine(disp, pixmap, hgc,
178 0, 0, width - 1, 0); 177 0, 0, width - 1, 0);
179 XDrawLine(disp, pixmap, hgc, 178 XDrawLine(disp, pixmap, hgc,
180 0, height - 1, 0, 0); 179 0, height - 1, 0, 0);
181 } else if (texture->type() & Texture::SUNKEN) { 180 } else if (texture.type() & Texture::SUNKEN) {
182 XDrawLine(disp, pixmap, hgc, 181 XDrawLine(disp, pixmap, hgc,
183 0, height - 1, width - 1, height - 1); 182 0, height - 1, width - 1, height - 1);
184 XDrawLine(disp, pixmap, hgc, 183 XDrawLine(disp, pixmap, hgc,
185 width - 1, height - 1, width - 1, 0); 184 width - 1, height - 1, width - 1, 0);
186 185
187 XDrawLine(disp, pixmap, lgc, 186 XDrawLine(disp, pixmap, lgc,
188 0, 0, width - 1, 0); 187 0, 0, width - 1, 0);
189 XDrawLine(disp, pixmap, lgc, 188 XDrawLine(disp, pixmap, lgc,
190 0, height - 1, 0, 0); 189 0, height - 1, 0, 0);
191 } 190 }
192 } else if (texture->type() & Texture::BEVEL2) { 191 } else if (texture.type() & Texture::BEVEL2) {
193 if (texture->type() & Texture::RAISED) { 192 if (texture.type() & Texture::RAISED) {
194 XDrawLine(disp, pixmap, lgc, 193 XDrawLine(disp, pixmap, lgc,
195 1, height - 3, width - 3, height - 3); 194 1, height - 3, width - 3, height - 3);
196 XDrawLine(disp, pixmap, lgc, 195 XDrawLine(disp, pixmap, lgc,
197 width - 3, height - 3, width - 3, 1); 196 width - 3, height - 3, width - 3, 1);
198 197
199 XDrawLine(disp, pixmap, hgc, 198 XDrawLine(disp, pixmap, hgc,
200 1, 1, width - 3, 1); 199 1, 1, width - 3, 1);
201 XDrawLine(disp, pixmap, hgc, 200 XDrawLine(disp, pixmap, hgc,
202 1, height - 3, 1, 1); 201 1, height - 3, 1, 1);
203 } else if (texture->type() & Texture::SUNKEN) { 202 } else if (texture.type() & Texture::SUNKEN) {
204 XDrawLine(disp, pixmap, hgc, 203 XDrawLine(disp, pixmap, hgc,
205 1, height - 3, width - 3, height - 3); 204 1, height - 3, width - 3, height - 3);
206 XDrawLine(disp, pixmap, hgc, 205 XDrawLine(disp, pixmap, hgc,
207 width - 3, height - 3, width - 3, 1); 206 width - 3, height - 3, width - 3, 1);
208 207
209 XDrawLine(disp, pixmap, lgc, 208 XDrawLine(disp, pixmap, lgc,
210 1, 1, width - 3, 1); 209 1, 1, width - 3, 1);
211 XDrawLine(disp, pixmap, lgc, 210 XDrawLine(disp, pixmap, lgc,
212 1, height - 3, 1, 1); 211 1, height - 3, 1, 1);
213 } 212 }
214 } 213 }
215 214
@@ -221,50 +220,50 @@ Pixmap BImage::renderSolid(const FbTk::Texture *texture) {
221} 220}
222 221
223 222
224Pixmap BImage::renderGradient(const FbTk::Texture *texture) { 223Pixmap BImage::renderGradient(const FbTk::Texture &texture) {
225 224
226 bool inverted = false; 225 bool inverted = false;
227 226
228 using namespace FbTk; 227 using namespace FbTk;
229 228
230 interlaced = texture->type() & Texture::INTERLACED; 229 interlaced = texture.type() & Texture::INTERLACED;
231 230
232 if (texture->type() & Texture::SUNKEN) { 231 if (texture.type() & Texture::SUNKEN) {
233 from = &(texture->colorTo()); 232 from = &(texture.colorTo());
234 to = &(texture->color()); 233 to = &(texture.color());
235 234
236 if (! (texture->type() & Texture::INVERT)) 235 if (! (texture.type() & Texture::INVERT))
237 inverted = true; 236 inverted = true;
238 } else { 237 } else {
239 from = &(texture->color()); 238 from = &(texture.color());
240 to = &(texture->colorTo()); 239 to = &(texture.colorTo());
241 240
242 if (texture->type() & Texture::INVERT) 241 if (texture.type() & Texture::INVERT)
243 inverted = true; 242 inverted = true;
244 } 243 }
245 244
246 control->getGradientBuffers(width, height, &xtable, &ytable); 245 control->getGradientBuffers(width, height, &xtable, &ytable);
247 246
248 if (texture->type() & Texture::DIAGONAL) 247 if (texture.type() & Texture::DIAGONAL)
249 dgradient(); 248 dgradient();
250 else if (texture->type() & Texture::ELLIPTIC) 249 else if (texture.type() & Texture::ELLIPTIC)
251 egradient(); 250 egradient();
252 else if (texture->type() & Texture::HORIZONTAL) 251 else if (texture.type() & Texture::HORIZONTAL)
253 hgradient(); 252 hgradient();
254 else if (texture->type() & Texture::PYRAMID) 253 else if (texture.type() & Texture::PYRAMID)
255 pgradient(); 254 pgradient();
256 else if (texture->type() & Texture::RECTANGLE) 255 else if (texture.type() & Texture::RECTANGLE)
257 rgradient(); 256 rgradient();
258 else if (texture->type() & Texture::VERTICAL) 257 else if (texture.type() & Texture::VERTICAL)
259 vgradient(); 258 vgradient();
260 else if (texture->type() & Texture::CROSSDIAGONAL) 259 else if (texture.type() & Texture::CROSSDIAGONAL)
261 cdgradient(); 260 cdgradient();
262 else if (texture->type() & Texture::PIPECROSS) 261 else if (texture.type() & Texture::PIPECROSS)
263 pcgradient(); 262 pcgradient();
264 263
265 if (texture->type() & Texture::BEVEL1) 264 if (texture.type() & Texture::BEVEL1)
266 bevel1(); 265 bevel1();
267 else if (texture->type() & Texture::BEVEL2) 266 else if (texture.type() & Texture::BEVEL2)
268 bevel2(); 267 bevel2();
269 268
270 if (inverted) 269 if (inverted)
@@ -2180,34 +2179,39 @@ Pixmap BImageControl::searchCache(unsigned int width, unsigned int height,
2180 2179
2181 2180
2182Pixmap BImageControl::renderImage(unsigned int width, unsigned int height, 2181Pixmap BImageControl::renderImage(unsigned int width, unsigned int height,
2183 const FbTk::Texture *texture) { 2182 const FbTk::Texture &texture) {
2184 2183
2185 if (texture->type() & FbTk::Texture::PARENTRELATIVE) 2184 if (texture.type() & FbTk::Texture::PARENTRELATIVE)
2186 return ParentRelative; 2185 return ParentRelative;
2187 2186
2188 Pixmap pixmap = searchCache(width, height, texture->type(), 2187 // search cache first
2189 texture->color(), texture->colorTo()); 2188 Pixmap pixmap = searchCache(width, height, texture.type(),
2190 if (pixmap) return pixmap; 2189 texture.color(), texture.colorTo());
2190 if (pixmap)
2191 return pixmap; // return cache item
2191 2192
2193 // render new image
2192 BImage image(this, width, height); 2194 BImage image(this, width, height);
2193 pixmap = image.render(texture); 2195 pixmap = image.render(texture);
2194 2196
2195 if (pixmap) { 2197 if (pixmap) {
2198 // create new cache item and add it to cache list
2199
2196 Cache *tmp = new Cache; 2200 Cache *tmp = new Cache;
2197 2201
2198 tmp->pixmap = pixmap; 2202 tmp->pixmap = pixmap;
2199 tmp->width = width; 2203 tmp->width = width;
2200 tmp->height = height; 2204 tmp->height = height;
2201 tmp->count = 1; 2205 tmp->count = 1;
2202 tmp->texture = texture->type(); 2206 tmp->texture = texture.type();
2203 tmp->pixel1 = texture->color().pixel(); 2207 tmp->pixel1 = texture.color().pixel();
2204 2208
2205 if (texture->type() & FbTk::Texture::GRADIENT) 2209 if (texture.type() & FbTk::Texture::GRADIENT)
2206 tmp->pixel2 = texture->colorTo().pixel(); 2210 tmp->pixel2 = texture.colorTo().pixel();
2207 else 2211 else
2208 tmp->pixel2 = 0l; 2212 tmp->pixel2 = 0l;
2209 2213
2210 cache.push_back(tmp); 2214 cache.push_back(tmp);
2211 2215
2212 if ((unsigned) cache.size() > cache_max) { 2216 if ((unsigned) cache.size() > cache_max) {
2213#ifdef DEBUG 2217#ifdef DEBUG
diff --git a/src/Image.hh b/src/Image.hh
index 532476a..8ee126c 100644
--- a/src/Image.hh
+++ b/src/Image.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: Image.hh,v 1.16 2002/11/24 20:22:38 fluxgen Exp $ 25// $Id: Image.hh,v 1.17 2002/11/27 22:03:00 fluxgen Exp $
26 26
27#ifndef IMAGE_HH 27#ifndef IMAGE_HH
28#define IMAGE_HH 28#define IMAGE_HH
@@ -47,11 +47,11 @@ public:
47 BImage(BImageControl *ic, unsigned int width, unsigned int height); 47 BImage(BImageControl *ic, unsigned int width, unsigned int height);
48 ~BImage(); 48 ~BImage();
49 /// render to pixmap 49 /// render to pixmap
50 Pixmap render(const FbTk::Texture *src_texture); 50 Pixmap render(const FbTk::Texture &src_texture);
51 /// render solid texture to pixmap 51 /// render solid texture to pixmap
52 Pixmap renderSolid(const FbTk::Texture *src_texture); 52 Pixmap renderSolid(const FbTk::Texture &src_texture);
53 /// render gradient texture to pixmap 53 /// render gradient texture to pixmap
54 Pixmap renderGradient(const FbTk::Texture *src_texture); 54 Pixmap renderGradient(const FbTk::Texture &src_texture);
55 55
56protected: 56protected:
57 /** 57 /**
@@ -125,7 +125,7 @@ public:
125 @return pixmap of the rendered image, on failure None 125 @return pixmap of the rendered image, on failure None
126 */ 126 */
127 Pixmap renderImage(unsigned int width, unsigned int height, 127 Pixmap renderImage(unsigned int width, unsigned int height,
128 const FbTk::Texture *src_texture); 128 const FbTk::Texture &src_texture);
129 129
130 void installRootColormap(); 130 void installRootColormap();
131 void removeImage(Pixmap thepix); 131 void removeImage(Pixmap thepix);