Fix for #119722, reported by Olexiy Avramchenko, patch by Owen Taylor.
Tue Feb 17 23:02:58 2004 Soeren Sandmann <sandmann@daimi.au.dk> Fix for #119722, reported by Olexiy Avramchenko, patch by Owen Taylor. * gdk/x11/gdkprivate-x11.h (struct _GdkGCX11): Add a depth field * gdk/x11/gdkgc-x11.c (_gdk_x11_gc_new): Keep track of the GC's depth. * gdk/x11/gdkgc-x11.c (_gdk_gc_x11_get_fg_xft_color): First query the colormap, if no colormap, special case depth 1, * gdk/x11/gdkgc-x11.c (_gdk_x11_gc_get_fg_picture): Use _gdk_gc_x11_get_fg_xft_color() to get the foreground color. * gdk/x11/gdkdrawable-x11.c (gdk_x11_drawable_get_xft_draw): Special-case bitmaps without a colormap. * gdk/x11/gdkdrawable-x11.c (gdk_x11_draw_pixbuf): Use inherited draw_pixbuf() implementation in the bitmap case.
This commit is contained in:
committed by
Søren Sandmann Pedersen
parent
fe956696a3
commit
6c8430c0c4
@ -143,6 +143,8 @@ _gdk_x11_gc_new (GdkDrawable *drawable,
|
||||
|
||||
private->screen = GDK_DRAWABLE_IMPL_X11 (drawable)->screen;
|
||||
|
||||
private->depth = gdk_drawable_get_depth (drawable);
|
||||
|
||||
if (values_mask & (GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN))
|
||||
{
|
||||
values_mask &= ~(GDK_GC_CLIP_X_ORIGIN | GDK_GC_CLIP_Y_ORIGIN);
|
||||
@ -857,9 +859,8 @@ Picture
|
||||
_gdk_x11_gc_get_fg_picture (GdkGC *gc)
|
||||
{
|
||||
GdkGCX11 *x11_gc;
|
||||
GdkColormap *cmap;
|
||||
gboolean new = FALSE;
|
||||
GdkColor color;
|
||||
XftColor xftcolor;
|
||||
|
||||
g_return_val_if_fail (GDK_IS_GC_X11 (gc), None);
|
||||
|
||||
@ -867,7 +868,6 @@ _gdk_x11_gc_get_fg_picture (GdkGC *gc)
|
||||
return None;
|
||||
|
||||
x11_gc = GDK_GC_X11 (gc);
|
||||
cmap = gdk_gc_get_colormap (gc);
|
||||
|
||||
if (x11_gc->fg_picture == None)
|
||||
{
|
||||
@ -891,17 +891,16 @@ _gdk_x11_gc_get_fg_picture (GdkGC *gc)
|
||||
new = TRUE;
|
||||
}
|
||||
|
||||
gdk_colormap_query_color (cmap, x11_gc->fg_pixel, &color);
|
||||
|
||||
_gdk_gc_x11_get_fg_xft_color (gc, &xftcolor);
|
||||
|
||||
if (new ||
|
||||
x11_gc->fg_picture_color.red != color.red ||
|
||||
x11_gc->fg_picture_color.green != color.green ||
|
||||
x11_gc->fg_picture_color.blue != color.blue)
|
||||
x11_gc->fg_picture_color.red != xftcolor.color.red ||
|
||||
x11_gc->fg_picture_color.green != xftcolor.color.green ||
|
||||
x11_gc->fg_picture_color.blue != xftcolor.color.blue)
|
||||
{
|
||||
x11_gc->fg_picture_color.red = color.red;
|
||||
x11_gc->fg_picture_color.green = color.green;
|
||||
x11_gc->fg_picture_color.blue = color.blue;
|
||||
x11_gc->fg_picture_color.alpha = 0xffff;
|
||||
x11_gc->fg_picture_color.red = xftcolor.color.red;
|
||||
x11_gc->fg_picture_color.green = xftcolor.color.green;
|
||||
x11_gc->fg_picture_color.blue = xftcolor.color.blue;
|
||||
|
||||
XRenderFillRectangle (GDK_GC_XDISPLAY (gc), PictOpSrc,
|
||||
x11_gc->fg_picture, &x11_gc->fg_picture_color,
|
||||
@ -929,13 +928,46 @@ _gdk_gc_x11_get_fg_xft_color (GdkGC *gc,
|
||||
g_return_if_fail (GDK_IS_GC_X11 (gc));
|
||||
|
||||
x11_gc = GDK_GC_X11 (gc);
|
||||
|
||||
cmap = gdk_gc_get_colormap (gc);
|
||||
|
||||
xftcolor->pixel = x11_gc->fg_pixel;
|
||||
|
||||
gdk_colormap_query_color (cmap, xftcolor->pixel, &color);
|
||||
xftcolor->color.red = color.red;
|
||||
xftcolor->color.green = color.green;
|
||||
xftcolor->color.blue = color.blue;
|
||||
xftcolor->color.alpha = 0xffff;
|
||||
if (cmap)
|
||||
{
|
||||
gdk_colormap_query_color (cmap, xftcolor->pixel, &color);
|
||||
xftcolor->color.alpha = 0xffff;
|
||||
xftcolor->color.red = color.red;
|
||||
xftcolor->color.green = color.green;
|
||||
xftcolor->color.blue = color.blue;
|
||||
}
|
||||
else if (x11_gc->depth == 1)
|
||||
{
|
||||
/* Drawing with Xft on a bitmap is a bit bizzare; it
|
||||
* takes alpha >= 0x8000 to mean 'set to 1' and
|
||||
* alpha < 0x8000 to mean 'set to 0'.
|
||||
*/
|
||||
if (xftcolor->pixel)
|
||||
{
|
||||
xftcolor->color.red = 0xffff;
|
||||
xftcolor->color.green = 0xffff;
|
||||
xftcolor->color.blue = 0xffff;
|
||||
xftcolor->color.alpha = 0xffff;
|
||||
}
|
||||
else
|
||||
{
|
||||
xftcolor->color.red = 0;
|
||||
xftcolor->color.green = 0;
|
||||
xftcolor->color.blue = 0;
|
||||
xftcolor->color.alpha = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Using Xft rendering requires the GC argument to have a\n"
|
||||
"specified colormap. If the GC was created for a drawable\n"
|
||||
"with a colormap, the colormap will be set on the GC\n"
|
||||
"automatically. Otherwise, a colormap must be set on it with"
|
||||
"gdk_gc_set_colormap");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user