From c54277d9b1a888d467d839444d2de62e5f3702fc Mon Sep 17 00:00:00 2001 From: handa Date: Sat, 13 Mar 2004 00:20:30 +0000 Subject: [PATCH] *** empty log message *** --- src/m17n-X.c | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/src/m17n-X.c b/src/m17n-X.c index 7ef4b42..d8a1aa2 100644 --- a/src/m17n-X.c +++ b/src/m17n-X.c @@ -84,6 +84,12 @@ typedef struct /* Anchor of the chain of MDisplayInfo objects. */ static MPlist *display_info_list; +typedef struct +{ + unsigned short r, g, b; + GC gc; +} MColorGC; + struct MWDevice { /* Common header for the m17n object. */ @@ -107,6 +113,8 @@ struct MWDevice /** List of pointers to realized fontsets on the frame. */ MPlist *realized_fontset_list; + /** List of XColors vs GCs on the frame. */ + MPlist *gc_list; }; static MPlist *device_list; @@ -1389,6 +1397,39 @@ struct { } while (0) +static GC +get_gc (MWDevice *device, XColor *color) +{ + MPlist *plist; + unsigned long valuemask = GCForeground; + XGCValues values; + GC gc; + MColorGC *color_gc; + + MPLIST_DO (plist, device->gc_list) + { + color_gc = MPLIST_VAL (plist); + + if (color->red == color_gc->r + && color->green == color_gc->g + && color->blue == color_gc->b) + return color_gc->gc; + } + if (! XAllocColor (device->display_info->display, device->cmap, color)) + return DefaultGC (device->display_info->display, device->screen_num); + values.foreground = color->pixel; + gc = XCreateGC (device->display_info->display, device->drawable, + valuemask, &values); + color_gc = malloc (sizeof (MColorGC)); + color_gc->r = color->red; + color_gc->g = color->green; + color_gc->b = color->blue; + color_gc->gc = gc; + mplist_push (plist, Mt, color_gc); + return gc; +} + + void mwin__realize_face (MRealizedFace *rface) { @@ -1722,12 +1763,12 @@ mwin__draw_pixmap (MFrame *frame, MDrawWindow win, MRealizedFace *rface, for (j = 0; j < width; j++) if (pmp[j]) { - float ratio = (float) (pmp[j] >> 5) / 32; + int fore_ratio = pmp[j] >> 5, back_ratio = 7 - fore_ratio; color = fore_color; - color.red = fore_color.red * ratio + back_color.red * (1 - ratio); - color.green = fore_color.green * ratio + back_color.green * (1 - ratio); - color.blue = fore_color.blue * ratio + back_color.blue * (1 - ratio); + color.red = ((fore_color.red * fore_ratio) + (back_color.red * back_ratio)) / 7; + color.green = ((fore_color.green * fore_ratio) + (back_color.green * back_ratio)) / 7; + color.blue = ((fore_color.blue * fore_ratio) + (back_color.blue * back_ratio)) / 7; if (XAllocColor (FRAME_DISPLAY (frame), frame->device->cmap, &color) && fore_color.pixel != color.pixel) { -- 1.7.10.4