summaryrefslogtreecommitdiffstats
path: root/otherlibs/graph/color.c
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/graph/color.c')
-rw-r--r--otherlibs/graph/color.c112
1 files changed, 56 insertions, 56 deletions
diff --git a/otherlibs/graph/color.c b/otherlibs/graph/color.c
index f47fa5814..cf3380a77 100644
--- a/otherlibs/graph/color.c
+++ b/otherlibs/graph/color.c
@@ -34,18 +34,18 @@ static int num_overflows = 0;
/* rgb -> pixel conversion *without* display connection */
-Bool direct_rgb = False;
-int red_l, red_r;
-int green_l, green_r;
-int blue_l, blue_r;
-unsigned long red_mask, green_mask, blue_mask;
+Bool caml_gr_direct_rgb = False;
+int caml_gr_red_l, caml_gr_red_r;
+int caml_gr_green_l, caml_gr_green_r;
+int caml_gr_blue_l, caml_gr_blue_r;
+unsigned long caml_gr_red_mask, caml_gr_green_mask, caml_gr_blue_mask;
/* rgb -> pixel table */
-unsigned long red_vals[256];
-unsigned long green_vals[256];
-unsigned long blue_vals[256];
+unsigned long caml_gr_red_vals[256];
+unsigned long caml_gr_green_vals[256];
+unsigned long caml_gr_blue_vals[256];
-void get_shifts( unsigned long mask, int *lsl, int *lsr )
+void caml_gr_get_shifts( unsigned long mask, int *lsl, int *lsr )
{
int l = 0;
int r = 0;
@@ -66,86 +66,86 @@ void get_shifts( unsigned long mask, int *lsl, int *lsr )
*lsr = 16 - (r - l);
}
-void gr_init_direct_rgb_to_pixel(void)
+void caml_gr_init_direct_rgb_to_pixel(void)
{
Visual *visual;
int i;
- visual = DefaultVisual(grdisplay,grscreen);
+ visual = DefaultVisual(caml_gr_display,caml_gr_screen);
if ( visual->class == TrueColor || visual->class == DirectColor ){
int lsl, lsr;
- red_mask = visual->red_mask;
- green_mask = visual->green_mask;
- blue_mask = visual->blue_mask;
+ caml_gr_red_mask = visual->red_mask;
+ caml_gr_green_mask = visual->green_mask;
+ caml_gr_blue_mask = visual->blue_mask;
#ifdef QUICKCOLORDEBUG
fprintf(stderr, "visual %lx %lx %lx\n",
- red_mask,
- green_mask,
- blue_mask);
+ caml_gr_red_mask,
+ caml_gr_green_mask,
+ caml_gr_blue_mask);
#endif
- get_shifts(red_mask, &red_l, &red_r);
+ caml_gr_get_shifts(caml_gr_red_mask, &caml_gr_red_l, &caml_gr_red_r);
#ifdef QUICKCOLORDEBUG
- fprintf(stderr, "red %d %d\n", red_l, red_r);
+ fprintf(stderr, "red %d %d\n", caml_gr_red_l, caml_gr_red_r);
#endif
for(i=0; i<256; i++){
- red_vals[i] = (((i << 8) + i) >> red_r) << red_l;
+ caml_gr_red_vals[i] = (((i << 8) + i) >> caml_gr_red_r) << caml_gr_red_l;
}
- get_shifts(green_mask, &green_l, &green_r);
+ caml_gr_get_shifts(caml_gr_green_mask, &caml_gr_green_l, &caml_gr_green_r);
#ifdef QUICKCOLORDEBUG
- fprintf(stderr, "green %d %d\n", green_l, green_r);
+ fprintf(stderr, "green %d %d\n", caml_gr_green_l, caml_gr_green_r);
#endif
for(i=0; i<256; i++){
- green_vals[i] = (((i << 8) + i) >> green_r) << green_l;
+ caml_gr_green_vals[i] = (((i << 8) + i) >> caml_gr_green_r) << caml_gr_green_l;
}
- get_shifts(blue_mask, &blue_l, &blue_r);
+ caml_gr_get_shifts(caml_gr_blue_mask, &caml_gr_blue_l, &caml_gr_blue_r);
#ifdef QUICKCOLORDEBUG
- fprintf(stderr, "blue %d %d\n", blue_l, blue_r);
+ fprintf(stderr, "blue %d %d\n", caml_gr_blue_l, caml_gr_blue_r);
#endif
for(i=0; i<256; i++){
- blue_vals[i] = (((i << 8) + i) >> blue_r) << blue_l;
+ caml_gr_blue_vals[i] = (((i << 8) + i) >> caml_gr_blue_r) << caml_gr_blue_l;
}
- if( red_l < 0 || red_r < 0 ||
- green_l < 0 || green_r < 0 ||
- blue_l < 0 || blue_r < 0 ){
+ if( caml_gr_red_l < 0 || caml_gr_red_r < 0 ||
+ caml_gr_green_l < 0 || caml_gr_green_r < 0 ||
+ caml_gr_blue_l < 0 || caml_gr_blue_r < 0 ){
#ifdef QUICKCOLORDEBUG
fprintf(stderr, "Damn, boost failed\n");
#endif
- direct_rgb = False;
+ caml_gr_direct_rgb = False;
} else {
#ifdef QUICKCOLORDEBUG
fprintf(stderr, "Boost ok\n");
#endif
- direct_rgb = True;
+ caml_gr_direct_rgb = True;
}
} else {
/* we cannot use direct_rgb_to_pixel */
#ifdef QUICKCOLORDEBUG
fprintf(stderr, "No boost!\n");
#endif
- direct_rgb = False;
+ caml_gr_direct_rgb = False;
}
}
-void gr_init_color_cache(void)
+void caml_gr_init_color_cache(void)
{
int i;
for (i = 0; i < Color_cache_size; i++) color_cache[i].rgb = Empty;
i = Hash_rgb(0, 0, 0);
color_cache[i].rgb = 0;
- color_cache[i].pixel = grblack;
+ color_cache[i].pixel = caml_gr_black;
i = Hash_rgb(0xFF, 0xFF, 0xFF);
color_cache[i].rgb = 0xFFFFFF;
- color_cache[i].pixel = grwhite;
+ color_cache[i].pixel = caml_gr_white;
}
-unsigned long gr_pixel_rgb(int rgb)
+unsigned long caml_gr_pixel_rgb(int rgb)
{
unsigned int r, g, b;
int h, i;
@@ -156,8 +156,8 @@ unsigned long gr_pixel_rgb(int rgb)
g = (rgb >> 8) & 0xFF;
b = rgb & 0xFF;
- if (direct_rgb){
- return red_vals[r] | green_vals[g] | blue_vals[b];
+ if (caml_gr_direct_rgb){
+ return caml_gr_red_vals[r] | caml_gr_green_vals[g] | caml_gr_blue_vals[b];
}
h = Hash_rgb(r, g, b);
@@ -179,28 +179,28 @@ unsigned long gr_pixel_rgb(int rgb)
color.red = r * 0x101;
color.green = g * 0x101;
color.blue = b * 0x101;
- XAllocColor(grdisplay, grcolormap, &color);
+ XAllocColor(caml_gr_display, caml_gr_colormap, &color);
color_cache[i].rgb = rgb;
color_cache[i].pixel = color.pixel;
return color.pixel;
}
-int gr_rgb_pixel(long unsigned int pixel)
+int caml_gr_rgb_pixel(long unsigned int pixel)
{
register int r,g,b;
XColor color;
int i;
- if (direct_rgb) {
- r = (((pixel & red_mask) >> red_l) << 8) >> (16 - red_r);
- g = (((pixel & green_mask) >> green_l) << 8) >> (16 - green_r);
- b = (((pixel & blue_mask) >> blue_l) << 8) >> (16 - blue_r);
+ if (caml_gr_direct_rgb) {
+ r = (((pixel & caml_gr_red_mask) >> caml_gr_red_l) << 8) >> (16 - caml_gr_red_r);
+ g = (((pixel & caml_gr_green_mask) >> caml_gr_green_l) << 8) >> (16 - caml_gr_green_r);
+ b = (((pixel & caml_gr_blue_mask) >> caml_gr_blue_l) << 8) >> (16 - caml_gr_blue_r);
return (r << 16) + (g << 8) + b;
}
- if (pixel == grblack) return 0;
- if (pixel == grwhite) return 0xFFFFFF;
+ if (pixel == caml_gr_black) return 0;
+ if (pixel == caml_gr_white) return 0xFFFFFF;
/* Probably faster to do a linear search than to query the X server. */
for (i = 0; i < Color_cache_size; i++) {
@@ -208,23 +208,23 @@ int gr_rgb_pixel(long unsigned int pixel)
return color_cache[i].rgb;
}
color.pixel = pixel;
- XQueryColor(grdisplay, grcolormap, &color);
+ XQueryColor(caml_gr_display, caml_gr_colormap, &color);
return
((color.red >> 8) << 16) + ((color.green >> 8) << 8) + (color.blue >> 8);
}
-value gr_set_color(value vrgb)
+value caml_gr_set_color(value vrgb)
{
int xcolor;
- gr_check_open();
- grcolor = Int_val(vrgb);
- if (grcolor >= 0 ){
- xcolor = gr_pixel_rgb(Int_val(vrgb));
- XSetForeground(grdisplay, grwindow.gc, xcolor);
- XSetForeground(grdisplay, grbstore.gc, xcolor);
+ caml_gr_check_open();
+ caml_gr_color = Int_val(vrgb);
+ if (caml_gr_color >= 0 ){
+ xcolor = caml_gr_pixel_rgb(Int_val(vrgb));
+ XSetForeground(caml_gr_display, caml_gr_window.gc, xcolor);
+ XSetForeground(caml_gr_display, caml_gr_bstore.gc, xcolor);
} else {
- XSetForeground(grdisplay, grwindow.gc, grbackground);
- XSetForeground(grdisplay, grbstore.gc, grbackground);
+ XSetForeground(caml_gr_display, caml_gr_window.gc, caml_gr_background);
+ XSetForeground(caml_gr_display, caml_gr_bstore.gc, caml_gr_background);
}
return Val_unit;
}