no need to have different sqrt tables for each object

This commit is contained in:
fluxgen 2002-07-22 22:33:45 +00:00
parent 794e2a522e
commit 25a9c7b57a
2 changed files with 27 additions and 26 deletions

View file

@ -25,7 +25,7 @@
// stupid macros needed to access some functions in version 2 of the GNU C
// library
// $Id: Image.cc,v 1.10 2002/07/19 20:30:45 fluxgen Exp $
// $Id: Image.cc,v 1.11 2002/07/22 22:33:45 fluxgen Exp $
//use GNU extensions
#ifndef _GNU_SOURCE
@ -69,6 +69,8 @@ typedef unsigned int u_int32_t;
# include <ctype.h>
#endif // HAVE_CTYPE_H
unsigned long *BImageControl::sqrt_table = 0;
static unsigned long bsqrt(unsigned long x) {
if (x <= 0) return 0;
if (x == 1) return 1;
@ -261,11 +263,10 @@ Pixmap BImage::render_gradient(BTexture *texture) {
if (texture->getTexture() & BImage::BEVEL1) bevel1();
else if (texture->getTexture() & BImage::BEVEL2) bevel2();
if (inverted) invert();
if (inverted)
invert();
Pixmap pixmap = renderPixmap();
return pixmap;
return renderPixmap();
}
@ -1852,8 +1853,6 @@ BImageControl::BImageControl(BaseDisplay *dpy, ScreenInfo *scrn, bool _dither,
grad_xbuffer = grad_ybuffer = (unsigned int *) 0;
grad_buffer_width = grad_buffer_height = 0;
sqrt_table = (unsigned long *) 0;
screen_depth = screeninfo->getDepth();
window = screeninfo->getRootWindow();
screen_number = screeninfo->getScreenNumber();
@ -1957,15 +1956,16 @@ BImageControl::BImageControl(BaseDisplay *dpy, ScreenInfo *scrn, bool _dither,
red_color_table[i] = green_color_table[i] = blue_color_table[i] =
i / bits;
for (r = 0, i = 0; r < colors_per_channel; r++)
for (g = 0; g < colors_per_channel; g++)
for (r = 0, i = 0; r < colors_per_channel; r++) {
for (g = 0; g < colors_per_channel; g++) {
for (b = 0; b < colors_per_channel; b++, i++) {
colors[i].red = (r * 0xffff) / (colors_per_channel - 1);
colors[i].green = (g * 0xffff) / (colors_per_channel - 1);
colors[i].blue = (b * 0xffff) / (colors_per_channel - 1);;
colors[i].flags = DoRed|DoGreen|DoBlue;
}
}
}
basedisplay->grab();
for (i = 0; i < ncolors; i++) {

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: Image.hh,v 1.8 2002/07/19 20:33:15 fluxgen Exp $
// $Id: Image.hh,v 1.9 2002/07/22 22:33:45 fluxgen Exp $
#ifndef IMAGE_HH
#define IMAGE_HH
@ -177,7 +177,7 @@ public:
unsigned long color(const char *colorname);
unsigned long color(const char *, unsigned char *, unsigned char *,
unsigned char *);
unsigned long getSqrt(unsigned int);
unsigned long getSqrt(unsigned int val);
Pixmap renderImage(unsigned int, unsigned int, BTexture *);
@ -188,15 +188,15 @@ public:
void getXColorTable(XColor **, int *);
void getGradientBuffers(unsigned int, unsigned int,
unsigned int **, unsigned int **);
void setDither(Bool d) { dither = d; }
void setColorsPerChannel(int);
void parseTexture(BTexture *, char *);
void parseColor(BColor *, char * = 0);
void setDither(bool d) { dither = d; }
void setColorsPerChannel(int cpc);
void parseTexture(BTexture *ret_texture, char *sval);
void parseColor(BColor *ret_color, char *sval = 0);
virtual void timeout(void);
virtual void timeout();
private:
Bool dither;
bool dither;
BaseDisplay *basedisplay;
ScreenInfo *screeninfo;
#ifdef TIMEDCACHE
@ -214,7 +214,8 @@ private:
blue_color_table[256];
unsigned int *grad_xbuffer, *grad_ybuffer, grad_buffer_width,
grad_buffer_height;
unsigned long *sqrt_table, cache_max;
static unsigned long *sqrt_table;
unsigned long cache_max;
typedef struct Cache {
Pixmap pixmap;