diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index b50bf4066..2edf169f7 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -374,6 +374,8 @@ gboolean _gdk_rgb_composite (GdkColormap *colormap, const guchar *rgba, gint rowstride, GdkRgbDither dither); +gboolean _gdk_rgb_prefers_own_blending (GdkColormap *colormap, + GdkRgbDither dither); void _gdk_gc_update_context (GdkGC *gc, cairo_t *cr, diff --git a/gdk/gdkrgb.c b/gdk/gdkrgb.c index 424a10ff3..edc20366c 100644 --- a/gdk/gdkrgb.c +++ b/gdk/gdkrgb.c @@ -2004,6 +2004,27 @@ _gdk_rgb_composite (GdkColormap *colormap, return TRUE; } +/** + * _gdk_rgb_prefers_own_blending: + * @colormap: a colormap + * @dither: the dithering asked for + * + * Whether pixbufs with alpha look better blended by GdkRGB than by + * the RENDER extension: for palettes and gray levels, which RENDER + * maps to its nearest colors, and for dithering, which RENDER doesn't do. + */ +gboolean +_gdk_rgb_prefers_own_blending (GdkColormap *colormap, + GdkRgbDither dither) +{ + GdkRgbInfo *info = gdk_rgb_get_info_from_colormap (colormap); + + if (!info->tables) + return TRUE; + + return dither == GDK_RGB_DITHER_MAX && info->ditherable; +} + static GdkRgbInfo * gdk_rgb_get_info_from_drawable (GdkDrawable *drawable) { diff --git a/gdk/x11/gdkdrawable-x11.c b/gdk/x11/gdkdrawable-x11.c index d27a03ebb..00b39b769 100644 --- a/gdk/x11/gdkdrawable-x11.c +++ b/gdk/x11/gdkdrawable-x11.c @@ -1476,6 +1476,7 @@ gdk_x11_draw_pixbuf (GdkDrawable *drawable, gint x_dither, gint y_dither) { + GdkColormap *colormap = gdk_drawable_get_colormap (drawable); GdkX11FormatType format_type; XRenderPictFormat *format, *mask_format; gint rowstride; @@ -1489,7 +1490,8 @@ gdk_x11_draw_pixbuf (GdkDrawable *drawable, if (format_type == GDK_X11_FORMAT_NONE || !gdk_pixbuf_get_has_alpha (pixbuf) || gdk_drawable_get_depth (drawable) == 1 || - (dither == GDK_RGB_DITHER_MAX && gdk_drawable_get_depth (drawable) != 24) || + (colormap ? _gdk_rgb_prefers_own_blending (colormap, dither) + : dither == GDK_RGB_DITHER_MAX && gdk_drawable_get_depth (drawable) != 24) || gdk_x11_drawable_get_picture (drawable) == None) { GdkDrawable *wrapper = GDK_DRAWABLE_IMPL_X11 (drawable)->wrapper;