Switch back to using XftDraw so that we take advantage of the

Fri Aug  2 00:43:15 2002  Owen Taylor  <otaylor@redhat.com>

	* gdk/x11/gdkdrawable-x11.[ch] gdk/x11/gdkgc-x11.c
	gdk/x11/gdkpango-x11.c gdk/x11/gdkpixmap-x11.c
	gdk/x11/gdkprivate-x11.h gdk/x11/gdkwindow-x11.c:
	Switch back to using XftDraw so that we take
	advantage of the draw-to-non-RENDER capabilities
	of Xft2.

	* demos/gtk-demo/changedisplay.c (query_for_toplevel):
	Fix the case where the user clicks on the "click on
	a window popup".
This commit is contained in:
Owen Taylor 2002-08-02 04:57:53 +00:00 committed by Owen Taylor
parent 63489392e6
commit d5f0576cf4
14 changed files with 189 additions and 48 deletions

View File

@ -1,3 +1,16 @@
Fri Aug 2 00:43:15 2002 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkdrawable-x11.[ch] gdk/x11/gdkgc-x11.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkpixmap-x11.c
gdk/x11/gdkprivate-x11.h gdk/x11/gdkwindow-x11.c:
Switch back to using XftDraw so that we take
advantage of the draw-to-non-RENDER capabilities
of Xft2.
* demos/gtk-demo/changedisplay.c (query_for_toplevel):
Fix the case where the user clicks on the "click on
a window popup".
Thu Aug 1 19:09:39 2002 Owen Taylor <otaylor@redhat.com>
* demos/gtk-demo/changedisplay.c: New demo for

View File

@ -1,3 +1,16 @@
Fri Aug 2 00:43:15 2002 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkdrawable-x11.[ch] gdk/x11/gdkgc-x11.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkpixmap-x11.c
gdk/x11/gdkprivate-x11.h gdk/x11/gdkwindow-x11.c:
Switch back to using XftDraw so that we take
advantage of the draw-to-non-RENDER capabilities
of Xft2.
* demos/gtk-demo/changedisplay.c (query_for_toplevel):
Fix the case where the user clicks on the "click on
a window popup".
Thu Aug 1 19:09:39 2002 Owen Taylor <otaylor@redhat.com>
* demos/gtk-demo/changedisplay.c: New demo for

View File

@ -1,3 +1,16 @@
Fri Aug 2 00:43:15 2002 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkdrawable-x11.[ch] gdk/x11/gdkgc-x11.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkpixmap-x11.c
gdk/x11/gdkprivate-x11.h gdk/x11/gdkwindow-x11.c:
Switch back to using XftDraw so that we take
advantage of the draw-to-non-RENDER capabilities
of Xft2.
* demos/gtk-demo/changedisplay.c (query_for_toplevel):
Fix the case where the user clicks on the "click on
a window popup".
Thu Aug 1 19:09:39 2002 Owen Taylor <otaylor@redhat.com>
* demos/gtk-demo/changedisplay.c: New demo for

View File

@ -1,3 +1,16 @@
Fri Aug 2 00:43:15 2002 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkdrawable-x11.[ch] gdk/x11/gdkgc-x11.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkpixmap-x11.c
gdk/x11/gdkprivate-x11.h gdk/x11/gdkwindow-x11.c:
Switch back to using XftDraw so that we take
advantage of the draw-to-non-RENDER capabilities
of Xft2.
* demos/gtk-demo/changedisplay.c (query_for_toplevel):
Fix the case where the user clicks on the "click on
a window popup".
Thu Aug 1 19:09:39 2002 Owen Taylor <otaylor@redhat.com>
* demos/gtk-demo/changedisplay.c: New demo for

View File

@ -1,3 +1,16 @@
Fri Aug 2 00:43:15 2002 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkdrawable-x11.[ch] gdk/x11/gdkgc-x11.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkpixmap-x11.c
gdk/x11/gdkprivate-x11.h gdk/x11/gdkwindow-x11.c:
Switch back to using XftDraw so that we take
advantage of the draw-to-non-RENDER capabilities
of Xft2.
* demos/gtk-demo/changedisplay.c (query_for_toplevel):
Fix the case where the user clicks on the "click on
a window popup".
Thu Aug 1 19:09:39 2002 Owen Taylor <otaylor@redhat.com>
* demos/gtk-demo/changedisplay.c: New demo for

View File

@ -1,3 +1,16 @@
Fri Aug 2 00:43:15 2002 Owen Taylor <otaylor@redhat.com>
* gdk/x11/gdkdrawable-x11.[ch] gdk/x11/gdkgc-x11.c
gdk/x11/gdkpango-x11.c gdk/x11/gdkpixmap-x11.c
gdk/x11/gdkprivate-x11.h gdk/x11/gdkwindow-x11.c:
Switch back to using XftDraw so that we take
advantage of the draw-to-non-RENDER capabilities
of Xft2.
* demos/gtk-demo/changedisplay.c (query_for_toplevel):
Fix the case where the user clicks on the "click on
a window popup".
Thu Aug 1 19:09:39 2002 Owen Taylor <otaylor@redhat.com>
* demos/gtk-demo/changedisplay.c: New demo for

View File

@ -958,6 +958,10 @@ if test "x$gdktarget" = "xx11"; then
AM_CONDITIONAL(HAVE_XFT, $have_xft)
if $PKG_CONFIG --exists xft ; then
AC_DEFINE(HAVE_XFT2, 1, [Define if we have Xft, version 2])
fi
#
# If Pango included the shared library dependencies from X11 in
# the pkg-config output, then we use that (to avoid duplicates).

View File

@ -236,51 +236,55 @@ _gdk_x11_have_render (GdkDisplay *display)
&event_base, &error_base);
}
static Picture
gdk_x11_drawable_get_picture (GdkDrawable *drawable)
static XftDraw *
gdk_x11_drawable_get_xft_draw (GdkDrawable *drawable)
{
GdkDrawableImplX11 *impl = GDK_DRAWABLE_IMPL_X11 (drawable);
if (!_gdk_x11_have_render (gdk_drawable_get_display (drawable)))
return None;
if (impl->picture == None)
if (impl->xft_draw == NULL)
{
GdkVisual *visual = gdk_drawable_get_visual (drawable);
XRenderPictFormat *format;
GdkColormap *colormap = gdk_drawable_get_colormap (drawable);
GdkVisual *visual;
if (!visual)
if (!colormap)
{
g_warning ("Using Xft rendering requires the drawable argument to\n"
"have a specified colormap. All windows have a colormap,\n"
"however, pixmaps only have colormap by default if they\n"
"were created with a non-NULL window argument. Otherwise\n"
"a colormap must be set on them with gdk_drawable_set_colormap");
return None;
return NULL;
}
format = XRenderFindVisualFormat (GDK_SCREEN_XDISPLAY (impl->screen),
gdk_x11_visual_get_xvisual(visual));
if (format)
impl->picture = XRenderCreatePicture (GDK_SCREEN_XDISPLAY (impl->screen),
impl->xid, format, 0, NULL);
visual = gdk_colormap_get_visual (colormap);
impl->xft_draw = XftDrawCreate (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid,
GDK_VISUAL_XVISUAL (visual), GDK_COLORMAP_XCOLORMAP (colormap));
}
return impl->picture;
return impl->xft_draw;
}
static Picture
gdk_x11_drawable_get_picture (GdkDrawable *drawable)
{
XftDraw *draw = gdk_x11_drawable_get_xft_draw (drawable);
return draw ? XftDrawPicture (draw) : None;
}
static void
gdk_x11_drawable_update_picture_clip (GdkDrawable *drawable,
GdkGC *gc)
gdk_x11_drawable_update_xft_clip (GdkDrawable *drawable,
GdkGC *gc)
{
GdkGCX11 *gc_private = gc ? GDK_GC_X11 (gc) : NULL;
GdkDrawableImplX11 *impl = GDK_DRAWABLE_IMPL_X11 (drawable);
Picture picture = gdk_x11_drawable_get_picture (drawable);
XftDraw *xft_draw = gdk_x11_drawable_get_xft_draw (drawable);
if (gc && gc_private->clip_region)
{
GdkRegionBox *boxes = gc_private->clip_region->rects;
gint n_boxes = gc_private->clip_region->numRects;
#if 0 /* Until XftDrawSetClipRectangles is there */
XRectangle *rects = g_new (XRectangle, n_boxes);
int i;
@ -291,18 +295,32 @@ gdk_x11_drawable_update_picture_clip (GdkDrawable *drawable,
rects[i].width = CLAMP (boxes[i].x2 + gc->clip_x_origin, G_MINSHORT, G_MAXSHORT) - rects[i].x;
rects[i].height = CLAMP (boxes[i].y2 + gc->clip_y_origin, G_MINSHORT, G_MAXSHORT) - rects[i].y;
}
XRenderSetPictureClipRectangles (GDK_SCREEN_XDISPLAY (impl->screen),
picture, 0, 0, rects, n_boxes);
XftDrawSetClipRectangles (xft_draw, 0, 0, rects, n_boxes);
g_free (rects);
#else
Region xregion = XCreateRegion ();
int i;
for (i=0; i < n_boxes; i++)
{
XRectangle rect;
rect.x = CLAMP (boxes[i].x1 + gc->clip_x_origin, G_MINSHORT, G_MAXSHORT);
rect.y = CLAMP (boxes[i].y1 + gc->clip_y_origin, G_MINSHORT, G_MAXSHORT);
rect.width = CLAMP (boxes[i].x2 + gc->clip_x_origin, G_MINSHORT, G_MAXSHORT) - rect.x;
rect.height = CLAMP (boxes[i].y2 + gc->clip_y_origin, G_MINSHORT, G_MAXSHORT) - rect.y;
XUnionRectWithRegion (&rect, xregion, xregion);
}
XftDrawSetClip (xft_draw, xregion);
XDestroyRegion (xregion);
#endif
}
else
{
XRenderPictureAttributes pa;
pa.clip_mask = None;
XRenderChangePicture (GDK_SCREEN_XDISPLAY (impl->screen),
picture, CPClipMask, &pa);
XftDrawSetClip (xft_draw, NULL);
}
}
#endif
@ -704,17 +722,15 @@ gdk_x11_draw_glyphs (GdkDrawable *drawable,
#if HAVE_XFT
if (PANGO_XFT_IS_FONT (font))
{
Picture src_picture;
Picture dest_picture;
src_picture = _gdk_x11_gc_get_fg_picture (gc);
gdk_x11_drawable_update_picture_clip (drawable, gc);
dest_picture = gdk_x11_drawable_get_picture (drawable);
XftColor color;
XftDraw *draw;
_gdk_gc_x11_get_fg_xft_color (gc, &color);
gdk_x11_drawable_update_xft_clip (drawable, gc);
draw = gdk_x11_drawable_get_xft_draw (drawable);
pango_xft_picture_render (GDK_SCREEN_XDISPLAY (impl->screen),
src_picture, dest_picture,
font, glyphs, x, y);
pango_xft_render (draw, &color, font, glyphs, x, y);
}
else
#endif /* !HAVE_XFT */
@ -1330,7 +1346,7 @@ gdk_x11_draw_pixbuf (GdkDrawable *drawable,
return;
}
gdk_x11_drawable_update_picture_clip (drawable, gc);
gdk_x11_drawable_update_xft_clip (drawable, gc);
rowstride = gdk_pixbuf_get_rowstride (pixbuf);

View File

@ -34,7 +34,7 @@
#include <X11/Xlib.h>
#ifdef HAVE_XFT
#include <X11/extensions/Xrender.h>
#include <X11/Xft/Xft.h>
#endif
#ifdef __cplusplus
@ -66,7 +66,7 @@ struct _GdkDrawableImplX11
GdkScreen *screen;
#ifdef HAVE_XFT
Picture picture;
XftDraw *xft_draw;
#endif
};

View File

@ -818,7 +818,7 @@ Picture
_gdk_x11_gc_get_fg_picture (GdkGC *gc)
{
GdkGCX11 *x11_gc;
GdkColormap *cmap = gdk_gc_get_colormap (gc);
GdkColormap *cmap;
gboolean new = FALSE;
GdkColor color;
@ -828,6 +828,7 @@ _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)
{
@ -870,4 +871,34 @@ _gdk_x11_gc_get_fg_picture (GdkGC *gc)
return x11_gc->fg_picture;
}
/**
* _gdk_gc_x11_get_fg_xft_color:
* @gc: a #GdkGC
* @xftcolor: location to store the color
*
* Gets the foreground color of the GC as a XftColor.
**/
void
_gdk_gc_x11_get_fg_xft_color (GdkGC *gc,
XftColor *xftcolor)
{
GdkGCX11 *x11_gc;
GdkColormap *cmap;
GdkColor color;
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;
}
#endif /* HAVE_XFT */

View File

@ -59,9 +59,19 @@ gdk_pango_context_get_for_screen (GdkScreen *screen)
if (display_x11->use_xft == -1)
{
const char *val = g_getenv ("GDK_USE_XFT");
/* Version 2 of Xft supports rendering FreeType fonts via
* the core X protocol, so we default to it everywhere.
*
* For Xft1, we only enable Xft if the user explicitely
* specifies it, and we have the RENDER extension
*/
# ifdef HAVE_XFT2
display_x11->use_xft = !val || (atoi (val) != 0);
# else
display_x11->use_xft = val && (atoi (val) != 0) &&
_gdk_x11_have_render (GDK_SCREEN_DISPLAY (screen));
# endif /* HAVE_XFT2 */
}
if (display_x11->use_xft)

View File

@ -133,8 +133,8 @@ gdk_pixmap_impl_x11_finalize (GObject *object)
{
GdkDrawableImplX11 *draw_impl = GDK_DRAWABLE_IMPL_X11 (impl);
if (draw_impl->picture)
XRenderFreePicture (GDK_DISPLAY_XDISPLAY (display), draw_impl->picture);
if (draw_impl->xft_draw)
XftDrawDestroy (draw_impl->xft_draw);
}
#endif /* HAVE_XFT */

View File

@ -106,8 +106,10 @@ gint _gdk_send_xevent (GdkDisplay *display,
GType _gdk_gc_x11_get_type (void);
#ifdef HAVE_XFT
gboolean _gdk_x11_have_render (GdkDisplay *display);
Picture _gdk_x11_gc_get_fg_picture (GdkGC *gc);
gboolean _gdk_x11_have_render (GdkDisplay *display);
Picture _gdk_x11_gc_get_fg_picture (GdkGC *gc);
void _gdk_gc_x11_get_fg_xft_color (GdkGC *gc,
XftColor *xftcolor);
#endif /* HAVE_XFT */
GdkGC *_gdk_x11_gc_new (GdkDrawable *drawable,

View File

@ -820,8 +820,8 @@ _gdk_windowing_window_destroy (GdkWindow *window,
{
GdkDrawableImplX11 *draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl);
if (draw_impl->picture)
XRenderFreePicture (GDK_WINDOW_XDISPLAY (window), draw_impl->picture);
if (draw_impl->xft_draw)
XftDrawDestroy (draw_impl->xft_draw);
}
#endif /* HAVE_XFT */