Commit d5f0576c authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor
Browse files

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".
parent 63489392
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> Thu Aug 1 19:09:39 2002 Owen Taylor <otaylor@redhat.com>
* demos/gtk-demo/changedisplay.c: New demo for * demos/gtk-demo/changedisplay.c: New demo for
......
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> Thu Aug 1 19:09:39 2002 Owen Taylor <otaylor@redhat.com>
* demos/gtk-demo/changedisplay.c: New demo for * demos/gtk-demo/changedisplay.c: New demo for
......
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> Thu Aug 1 19:09:39 2002 Owen Taylor <otaylor@redhat.com>
* demos/gtk-demo/changedisplay.c: New demo for * demos/gtk-demo/changedisplay.c: New demo for
......
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> Thu Aug 1 19:09:39 2002 Owen Taylor <otaylor@redhat.com>
* demos/gtk-demo/changedisplay.c: New demo for * demos/gtk-demo/changedisplay.c: New demo for
......
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> Thu Aug 1 19:09:39 2002 Owen Taylor <otaylor@redhat.com>
* demos/gtk-demo/changedisplay.c: New demo for * demos/gtk-demo/changedisplay.c: New demo for
......
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> Thu Aug 1 19:09:39 2002 Owen Taylor <otaylor@redhat.com>
* demos/gtk-demo/changedisplay.c: New demo for * demos/gtk-demo/changedisplay.c: New demo for
......
...@@ -958,6 +958,10 @@ if test "x$gdktarget" = "xx11"; then ...@@ -958,6 +958,10 @@ if test "x$gdktarget" = "xx11"; then
AM_CONDITIONAL(HAVE_XFT, $have_xft) 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 # If Pango included the shared library dependencies from X11 in
# the pkg-config output, then we use that (to avoid duplicates). # the pkg-config output, then we use that (to avoid duplicates).
......
...@@ -236,51 +236,55 @@ _gdk_x11_have_render (GdkDisplay *display) ...@@ -236,51 +236,55 @@ _gdk_x11_have_render (GdkDisplay *display)
&event_base, &error_base); &event_base, &error_base);
} }
static Picture static XftDraw *
gdk_x11_drawable_get_picture (GdkDrawable *drawable) gdk_x11_drawable_get_xft_draw (GdkDrawable *drawable)
{ {
GdkDrawableImplX11 *impl = GDK_DRAWABLE_IMPL_X11 (drawable); GdkDrawableImplX11 *impl = GDK_DRAWABLE_IMPL_X11 (drawable);
if (!_gdk_x11_have_render (gdk_drawable_get_display (drawable))) if (impl->xft_draw == NULL)
return None;
if (impl->picture == None)
{ {
GdkVisual *visual = gdk_drawable_get_visual (drawable); GdkColormap *colormap = gdk_drawable_get_colormap (drawable);
XRenderPictFormat *format; GdkVisual *visual;
if (!visual) if (!colormap)
{ {
g_warning ("Using Xft rendering requires the drawable argument to\n" g_warning ("Using Xft rendering requires the drawable argument to\n"
"have a specified colormap. All windows have a colormap,\n" "have a specified colormap. All windows have a colormap,\n"
"however, pixmaps only have colormap by default if they\n" "however, pixmaps only have colormap by default if they\n"
"were created with a non-NULL window argument. Otherwise\n" "were created with a non-NULL window argument. Otherwise\n"
"a colormap must be set on them with gdk_drawable_set_colormap"); "a colormap must be set on them with gdk_drawable_set_colormap");
return None; return NULL;
} }
format = XRenderFindVisualFormat (GDK_SCREEN_XDISPLAY (impl->screen), visual = gdk_colormap_get_visual (colormap);
gdk_x11_visual_get_xvisual(visual));
if (format) impl->xft_draw = XftDrawCreate (GDK_SCREEN_XDISPLAY (impl->screen), impl->xid,
impl->picture = XRenderCreatePicture (GDK_SCREEN_XDISPLAY (impl->screen), GDK_VISUAL_XVISUAL (visual), GDK_COLORMAP_XCOLORMAP (colormap));
impl->xid, format, 0, NULL);
} }
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 static void
gdk_x11_drawable_update_picture_clip (GdkDrawable *drawable, gdk_x11_drawable_update_xft_clip (GdkDrawable *drawable,
GdkGC *gc) GdkGC *gc)
{ {
GdkGCX11 *gc_private = gc ? GDK_GC_X11 (gc) : NULL; GdkGCX11 *gc_private = gc ? GDK_GC_X11 (gc) : NULL;
GdkDrawableImplX11 *impl = GDK_DRAWABLE_IMPL_X11 (drawable); XftDraw *xft_draw = gdk_x11_drawable_get_xft_draw (drawable);
Picture picture = gdk_x11_drawable_get_picture (drawable);
if (gc && gc_private->clip_region) if (gc && gc_private->clip_region)
{ {
GdkRegionBox *boxes = gc_private->clip_region->rects; GdkRegionBox *boxes = gc_private->clip_region->rects;
gint n_boxes = gc_private->clip_region->numRects; gint n_boxes = gc_private->clip_region->numRects;
#if 0 /* Until XftDrawSetClipRectangles is there */
XRectangle *rects = g_new (XRectangle, n_boxes); XRectangle *rects = g_new (XRectangle, n_boxes);
int i; int i;
...@@ -291,18 +295,32 @@ gdk_x11_drawable_update_picture_clip (GdkDrawable *drawable, ...@@ -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].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; rects[i].height = CLAMP (boxes[i].y2 + gc->clip_y_origin, G_MINSHORT, G_MAXSHORT) - rects[i].y;
} }
XftDrawSetClipRectangles (xft_draw, 0, 0, rects, n_boxes);
XRenderSetPictureClipRectangles (GDK_SCREEN_XDISPLAY (impl->screen),
picture, 0, 0, rects, n_boxes);
g_free (rects); 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 else
{ {
XRenderPictureAttributes pa; XftDrawSetClip (xft_draw, NULL);
pa.clip_mask = None;
XRenderChangePicture (GDK_SCREEN_XDISPLAY (impl->screen),
picture, CPClipMask, &pa);
} }
} }
#endif #endif
...@@ -704,17 +722,15 @@ gdk_x11_draw_glyphs (GdkDrawable *drawable, ...@@ -704,17 +722,15 @@ gdk_x11_draw_glyphs (GdkDrawable *drawable,
#if HAVE_XFT #if HAVE_XFT
if (PANGO_XFT_IS_FONT (font)) if (PANGO_XFT_IS_FONT (font))
{ {
Picture src_picture; XftColor color;
Picture dest_picture; XftDraw *draw;
src_picture = _gdk_x11_gc_get_fg_picture (gc); _gdk_gc_x11_get_fg_xft_color (gc, &color);
gdk_x11_drawable_update_picture_clip (drawable, gc); gdk_x11_drawable_update_xft_clip (drawable, gc);
dest_picture = gdk_x11_drawable_get_picture (drawable); draw = gdk_x11_drawable_get_xft_draw (drawable);
pango_xft_picture_render (GDK_SCREEN_XDISPLAY (impl->screen), pango_xft_render (draw, &color, font, glyphs, x, y);
src_picture, dest_picture,
font, glyphs, x, y);
} }
else else
#endif /* !HAVE_XFT */ #endif /* !HAVE_XFT */
...@@ -1330,7 +1346,7 @@ gdk_x11_draw_pixbuf (GdkDrawable *drawable, ...@@ -1330,7 +1346,7 @@ gdk_x11_draw_pixbuf (GdkDrawable *drawable,
return; return;
} }
gdk_x11_drawable_update_picture_clip (drawable, gc); gdk_x11_drawable_update_xft_clip (drawable, gc);
rowstride = gdk_pixbuf_get_rowstride (pixbuf); rowstride = gdk_pixbuf_get_rowstride (pixbuf);
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include <X11/Xlib.h> #include <X11/Xlib.h>
#ifdef HAVE_XFT #ifdef HAVE_XFT
#include <X11/extensions/Xrender.h> #include <X11/Xft/Xft.h>
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
...@@ -66,7 +66,7 @@ struct _GdkDrawableImplX11 ...@@ -66,7 +66,7 @@ struct _GdkDrawableImplX11
GdkScreen *screen; GdkScreen *screen;
#ifdef HAVE_XFT #ifdef HAVE_XFT
Picture picture; XftDraw *xft_draw;
#endif #endif
}; };
......
...@@ -818,7 +818,7 @@ Picture ...@@ -818,7 +818,7 @@ Picture
_gdk_x11_gc_get_fg_picture (GdkGC *gc) _gdk_x11_gc_get_fg_picture (GdkGC *gc)
{ {
GdkGCX11 *x11_gc; GdkGCX11 *x11_gc;
GdkColormap *cmap = gdk_gc_get_colormap (gc); GdkColormap *cmap;
gboolean new = FALSE; gboolean new = FALSE;
GdkColor color; GdkColor color;
...@@ -828,6 +828,7 @@ _gdk_x11_gc_get_fg_picture (GdkGC *gc) ...@@ -828,6 +828,7 @@ _gdk_x11_gc_get_fg_picture (GdkGC *gc)
return None; return None;
x11_gc = GDK_GC_X11 (gc); x11_gc = GDK_GC_X11 (gc);
cmap = gdk_gc_get_colormap (gc);
if (x11_gc->fg_picture == None) if (x11_gc->fg_picture == None)
{ {
...@@ -870,4 +871,34 @@ _gdk_x11_gc_get_fg_picture (GdkGC *gc) ...@@ -870,4 +871,34 @@ _gdk_x11_gc_get_fg_picture (GdkGC *gc)
return x11_gc->fg_picture; 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 */ #endif /* HAVE_XFT */
...@@ -59,9 +59,19 @@ gdk_pango_context_get_for_screen (GdkScreen *screen) ...@@ -59,9 +59,19 @@ gdk_pango_context_get_for_screen (GdkScreen *screen)
if (display_x11->use_xft == -1) if (display_x11->use_xft == -1)
{ {
const char *val = g_getenv ("GDK_USE_XFT"); 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) && display_x11->use_xft = val && (atoi (val) != 0) &&
_gdk_x11_have_render (GDK_SCREEN_DISPLAY (screen)); _gdk_x11_have_render (GDK_SCREEN_DISPLAY (screen));
# endif /* HAVE_XFT2 */
} }
if (display_x11->use_xft) if (display_x11->use_xft)
......
...@@ -133,8 +133,8 @@ gdk_pixmap_impl_x11_finalize (GObject *object) ...@@ -133,8 +133,8 @@ gdk_pixmap_impl_x11_finalize (GObject *object)
{ {
GdkDrawableImplX11 *draw_impl = GDK_DRAWABLE_IMPL_X11 (impl); GdkDrawableImplX11 *draw_impl = GDK_DRAWABLE_IMPL_X11 (impl);
if (draw_impl->picture) if (draw_impl->xft_draw)
XRenderFreePicture (GDK_DISPLAY_XDISPLAY (display), draw_impl->picture); XftDrawDestroy (draw_impl->xft_draw);
} }
#endif /* HAVE_XFT */ #endif /* HAVE_XFT */
......
...@@ -106,8 +106,10 @@ gint _gdk_send_xevent (GdkDisplay *display, ...@@ -106,8 +106,10 @@ gint _gdk_send_xevent (GdkDisplay *display,
GType _gdk_gc_x11_get_type (void); GType _gdk_gc_x11_get_type (void);
#ifdef HAVE_XFT #ifdef HAVE_XFT
gboolean _gdk_x11_have_render (GdkDisplay *display); gboolean _gdk_x11_have_render (GdkDisplay *display);
Picture _gdk_x11_gc_get_fg_picture (GdkGC *gc); Picture _gdk_x11_gc_get_fg_picture (GdkGC *gc);
void _gdk_gc_x11_get_fg_xft_color (GdkGC *gc,
XftColor *xftcolor);
#endif /* HAVE_XFT */ #endif /* HAVE_XFT */
GdkGC *_gdk_x11_gc_new (GdkDrawable *drawable, GdkGC *_gdk_x11_gc_new (GdkDrawable *drawable,
......
...@@ -820,8 +820,8 @@ _gdk_windowing_window_destroy (GdkWindow *window, ...@@ -820,8 +820,8 @@ _gdk_windowing_window_destroy (GdkWindow *window,
{ {
GdkDrawableImplX11 *draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl); GdkDrawableImplX11 *draw_impl = GDK_DRAWABLE_IMPL_X11 (private->impl);
if (draw_impl->picture) if (draw_impl->xft_draw)
XRenderFreePicture (GDK_WINDOW_XDISPLAY (window), draw_impl->picture); XftDrawDestroy (draw_impl->xft_draw);
} }
#endif /* HAVE_XFT */ #endif /* HAVE_XFT */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment