]> Pileus Git - ~andy/gtk/commitdiff
Switch back to using XftDraw so that we take advantage of the
authorOwen Taylor <otaylor@redhat.com>
Fri, 2 Aug 2002 04:57:53 +0000 (04:57 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Fri, 2 Aug 2002 04:57:53 +0000 (04:57 +0000)
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".

14 files changed:
ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
configure.in
gdk/x11/gdkdrawable-x11.c
gdk/x11/gdkdrawable-x11.h
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

index b2f732b09256eb9cc8ea8d9929407b7eb1e93303..53e4c337db7551189778e15d588d1c53eb0c9851 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index b2f732b09256eb9cc8ea8d9929407b7eb1e93303..53e4c337db7551189778e15d588d1c53eb0c9851 100644 (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
index b2f732b09256eb9cc8ea8d9929407b7eb1e93303..53e4c337db7551189778e15d588d1c53eb0c9851 100644 (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
index b2f732b09256eb9cc8ea8d9929407b7eb1e93303..53e4c337db7551189778e15d588d1c53eb0c9851 100644 (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
index b2f732b09256eb9cc8ea8d9929407b7eb1e93303..53e4c337db7551189778e15d588d1c53eb0c9851 100644 (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
index b2f732b09256eb9cc8ea8d9929407b7eb1e93303..53e4c337db7551189778e15d588d1c53eb0c9851 100644 (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
index 29d9fa1d517906896dc52a2fd9a176f0ab13ecb2..4dc3754e351334e3ac076d8c7134fccc6fc3bb26 100644 (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).
index 585d1669ee84b3595a6b30fd2bbf5143b91e7a98..14a502e8ad3d44117ed7aea28771682eaeadd84d 100644 (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);
 
index 8b6505912704f87bb11834af7a0b1e09ecadaed7..f2a15f4613fcb9015007c2ceb7cdb664b376ca13 100644 (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  
 };
  
index 8367a650a67737b1afc616fbdd01d9ea8cca6855..ee26f36c2aaacb1e990eb2f2882e5414e0fc4778 100644 (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 */
index bcc43e08d9e0b37962773b05f9f21ba6deedace8..d674889478e5d1cd4867b76562b8041ccd0167c9 100644 (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)
index 7d9c5a016ffbd0cfdeb534ba900be322fd9c35b9..094ab306b96db030fcd3c4d39e3605174e6acd54 100644 (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 */  
 
index e63ba67d11a53dc64d6cd5b734a02b7e364f2ad5..c7e35d86c7613d6ffe4dbcd6e597ca7301d5956a 100644 (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,
index a47c831e85b9939085a66539aefecb8d675b3119..23fe13d4fba6cd1ac624d7a2fb0bcdd840dfd005 100644 (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 */