From c00a9a84ea0333fa49fa5cfa447c4afc29861a6e Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 18 Nov 1999 22:03:24 +0000 Subject: [PATCH] Also for truecolor drawables use just the pixel field in the foreground 1999-11-18 Tor Lillqvist * gdk/win32/gdkgc-win32.c (gdk_gc_predraw): Also for truecolor drawables use just the pixel field in the foreground and background GdkColor of the GdkGC. gdk_gc_set_{fore,back}ground() are called in the GIMP with GdkColors containing uninitialized (red,green,blue) fields, and just the pixel field filled in, and furthermore in the visual-dependent format as returned by gdk_rgb_xpixel_from_rgb(). It thus turns out that we really don't need to have the full GdkColor for fg and bg in GdkGCWin32Data after all. Will change it later to have just the pixel values. (Note that this version of gdkgc-win32.c still is the old gdkgc.c, it won't compile in the reorganised directory structure.) --- ChangeLog | 14 ++++++++++++++ ChangeLog.pre-2-0 | 14 ++++++++++++++ ChangeLog.pre-2-10 | 14 ++++++++++++++ ChangeLog.pre-2-2 | 14 ++++++++++++++ ChangeLog.pre-2-4 | 14 ++++++++++++++ ChangeLog.pre-2-6 | 14 ++++++++++++++ ChangeLog.pre-2-8 | 14 ++++++++++++++ gdk/win32/gdkgc-win32.c | 35 +++++++++++++++++++++++------------ 8 files changed, 121 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 72fcff84ec..5642940c77 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +1999-11-18 Tor Lillqvist + + * gdk/win32/gdkgc-win32.c (gdk_gc_predraw): Also for truecolor + drawables use just the pixel field in the foreground and + background GdkColor of the GdkGC. + + gdk_gc_set_{fore,back}ground() are called in the GIMP with + GdkColors containing uninitialized (red,green,blue) fields, and + just the pixel field filled in, and furthermore in the + visual-dependent format as returned by gdk_rgb_xpixel_from_rgb(). + It thus turns out that we really don't need to have the full + GdkColor for fg and bg in GdkGCWin32Data after all. Will change + it later to have just the pixel values. + Mon Nov 15 17:17:51 GMT 1999 Tony Gale * docs/gtkfaq.sgml: s/gtk_main_iteration/g_main_iteration/ diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 72fcff84ec..5642940c77 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,17 @@ +1999-11-18 Tor Lillqvist + + * gdk/win32/gdkgc-win32.c (gdk_gc_predraw): Also for truecolor + drawables use just the pixel field in the foreground and + background GdkColor of the GdkGC. + + gdk_gc_set_{fore,back}ground() are called in the GIMP with + GdkColors containing uninitialized (red,green,blue) fields, and + just the pixel field filled in, and furthermore in the + visual-dependent format as returned by gdk_rgb_xpixel_from_rgb(). + It thus turns out that we really don't need to have the full + GdkColor for fg and bg in GdkGCWin32Data after all. Will change + it later to have just the pixel values. + Mon Nov 15 17:17:51 GMT 1999 Tony Gale * docs/gtkfaq.sgml: s/gtk_main_iteration/g_main_iteration/ diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 72fcff84ec..5642940c77 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,17 @@ +1999-11-18 Tor Lillqvist + + * gdk/win32/gdkgc-win32.c (gdk_gc_predraw): Also for truecolor + drawables use just the pixel field in the foreground and + background GdkColor of the GdkGC. + + gdk_gc_set_{fore,back}ground() are called in the GIMP with + GdkColors containing uninitialized (red,green,blue) fields, and + just the pixel field filled in, and furthermore in the + visual-dependent format as returned by gdk_rgb_xpixel_from_rgb(). + It thus turns out that we really don't need to have the full + GdkColor for fg and bg in GdkGCWin32Data after all. Will change + it later to have just the pixel values. + Mon Nov 15 17:17:51 GMT 1999 Tony Gale * docs/gtkfaq.sgml: s/gtk_main_iteration/g_main_iteration/ diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 72fcff84ec..5642940c77 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,17 @@ +1999-11-18 Tor Lillqvist + + * gdk/win32/gdkgc-win32.c (gdk_gc_predraw): Also for truecolor + drawables use just the pixel field in the foreground and + background GdkColor of the GdkGC. + + gdk_gc_set_{fore,back}ground() are called in the GIMP with + GdkColors containing uninitialized (red,green,blue) fields, and + just the pixel field filled in, and furthermore in the + visual-dependent format as returned by gdk_rgb_xpixel_from_rgb(). + It thus turns out that we really don't need to have the full + GdkColor for fg and bg in GdkGCWin32Data after all. Will change + it later to have just the pixel values. + Mon Nov 15 17:17:51 GMT 1999 Tony Gale * docs/gtkfaq.sgml: s/gtk_main_iteration/g_main_iteration/ diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 72fcff84ec..5642940c77 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,17 @@ +1999-11-18 Tor Lillqvist + + * gdk/win32/gdkgc-win32.c (gdk_gc_predraw): Also for truecolor + drawables use just the pixel field in the foreground and + background GdkColor of the GdkGC. + + gdk_gc_set_{fore,back}ground() are called in the GIMP with + GdkColors containing uninitialized (red,green,blue) fields, and + just the pixel field filled in, and furthermore in the + visual-dependent format as returned by gdk_rgb_xpixel_from_rgb(). + It thus turns out that we really don't need to have the full + GdkColor for fg and bg in GdkGCWin32Data after all. Will change + it later to have just the pixel values. + Mon Nov 15 17:17:51 GMT 1999 Tony Gale * docs/gtkfaq.sgml: s/gtk_main_iteration/g_main_iteration/ diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 72fcff84ec..5642940c77 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,17 @@ +1999-11-18 Tor Lillqvist + + * gdk/win32/gdkgc-win32.c (gdk_gc_predraw): Also for truecolor + drawables use just the pixel field in the foreground and + background GdkColor of the GdkGC. + + gdk_gc_set_{fore,back}ground() are called in the GIMP with + GdkColors containing uninitialized (red,green,blue) fields, and + just the pixel field filled in, and furthermore in the + visual-dependent format as returned by gdk_rgb_xpixel_from_rgb(). + It thus turns out that we really don't need to have the full + GdkColor for fg and bg in GdkGCWin32Data after all. Will change + it later to have just the pixel values. + Mon Nov 15 17:17:51 GMT 1999 Tony Gale * docs/gtkfaq.sgml: s/gtk_main_iteration/g_main_iteration/ diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 72fcff84ec..5642940c77 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,17 @@ +1999-11-18 Tor Lillqvist + + * gdk/win32/gdkgc-win32.c (gdk_gc_predraw): Also for truecolor + drawables use just the pixel field in the foreground and + background GdkColor of the GdkGC. + + gdk_gc_set_{fore,back}ground() are called in the GIMP with + GdkColors containing uninitialized (red,green,blue) fields, and + just the pixel field filled in, and furthermore in the + visual-dependent format as returned by gdk_rgb_xpixel_from_rgb(). + It thus turns out that we really don't need to have the full + GdkColor for fg and bg in GdkGCWin32Data after all. Will change + it later to have just the pixel values. + Mon Nov 15 17:17:51 GMT 1999 Tony Gale * docs/gtkfaq.sgml: s/gtk_main_iteration/g_main_iteration/ diff --git a/gdk/win32/gdkgc-win32.c b/gdk/win32/gdkgc-win32.c index 9066dcd900..e0fca11dbb 100644 --- a/gdk/win32/gdkgc-win32.c +++ b/gdk/win32/gdkgc-win32.c @@ -905,11 +905,14 @@ gdk_gc_predraw (GdkDrawable *drawable, GdkDrawablePrivate *drawable_private = (GdkDrawablePrivate *) drawable; GdkColormapPrivate *colormap_private = (GdkColormapPrivate *) drawable_private->colormap; + GdkVisual *visual; COLORREF bg; COLORREF fg; LOGBRUSH logbrush; HPEN hpen; HBRUSH hbr; + guchar r, g, b; + static guint mask[9] = { 0, 1, 3, 7, 15, 31, 63, 127, 255 }; g_assert (gc_private->xgc == NULL); @@ -966,8 +969,7 @@ gdk_gc_predraw (GdkDrawable *drawable, RealizePalette (gc_private->xgc); fg = PALETTEINDEX (gc_private->foreground.pixel); } - else if (colormap_private != NULL - && colormap_private->xcolormap->rc_palette) + else if (colormap_private->xcolormap->rc_palette) { int k; if (SelectPalette (gc_private->xgc, @@ -987,10 +989,15 @@ gdk_gc_predraw (GdkDrawable *drawable, } else { - COLORREF foreground = RGB (gc_private->foreground.red >> 8, - gc_private->foreground.green >> 8, - gc_private->foreground.blue >> 8); - fg = GetNearestColor (gc_private->xgc, foreground); + visual = colormap_private->visual; + r = (gc_private->foreground.pixel & visual->red_mask) >> visual->red_shift; + r = (r * 255) / mask[visual->red_prec]; + g = (gc_private->foreground.pixel & visual->green_mask) >> visual->green_shift; + g = (g * 255) / mask[visual->green_prec]; + b = (gc_private->foreground.pixel & visual->blue_mask) >> visual->blue_shift; + b = (b * 255) / mask[visual->blue_prec]; + + fg = GetNearestColor (gc_private->xgc, RGB (r, g, b)); } logbrush.lbStyle = BS_SOLID; logbrush.lbColor = fg; @@ -1044,17 +1051,21 @@ gdk_gc_predraw (GdkDrawable *drawable, /* a bitmap */ bg = PALETTEINDEX (gc_private->background.pixel); } - else if (colormap_private != NULL - && colormap_private->xcolormap->rc_palette) + else if (colormap_private->xcolormap->rc_palette) { bg = PALETTEINDEX (gc_private->background.pixel); } else { - COLORREF background = RGB (gc_private->background.red >> 8, - gc_private->background.green >> 8, - gc_private->background.blue >> 8); - bg = GetNearestColor (gc_private->xgc, background); + visual = colormap_private->visual; + r = (gc_private->background.pixel & visual->red_mask) >> visual->red_shift; + r = (r * 255) / mask[visual->red_prec]; + g = (gc_private->background.pixel & visual->green_mask) >> visual->green_shift; + g = (g * 255) / mask[visual->green_prec]; + b = (gc_private->background.pixel & visual->blue_mask) >> visual->blue_shift; + b = (b * 255) / mask[visual->green_prec]; + + fg = GetNearestColor (gc_private->xgc, RGB (r, g, b)); } if (SetBkColor (gc_private->xgc, bg) == CLR_INVALID) g_warning ("gdk_gc_predraw: SetBkColor failed");