[cairo-commit] src/cairo-xlib-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Thu Apr 19 02:54:12 PDT 2007


 src/cairo-xlib-surface.c |   35 ++++++++++++++++++++++++-----------
 1 files changed, 24 insertions(+), 11 deletions(-)

New commits:
diff-tree ef60e7c65144edd1aa14757b269f2c196df732a2 (from 9cf09556339e64bdf1273e95938b657112df07b6)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Apr 18 18:08:45 2007 +0100

    cairo-xlib-surface - track picture properties.
    
    By tracking picture properties we can dramatically reduce the amount of
    X11 traffic by avoiding redundant changes.

diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index b1790a1..5eef3f1 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -127,8 +127,17 @@ struct _cairo_xlib_surface {
     int num_clip_rects;
 
     XRenderPictFormat *xrender_format;
+    cairo_filter_t filter;
+    int repeat;
+    XTransform xtransform;
 };
 
+static const XTransform identity = { {
+    { 1 << 16, 0x00000, 0x00000 },
+    { 0x00000, 1 << 16, 0x00000 },
+    { 0x00000, 0x00000, 1 << 16 },
+} };
+
 #define CAIRO_SURFACE_RENDER_AT_LEAST(surface, major, minor)	\
 	(((surface)->render_major > major) ||			\
 	 (((surface)->render_major == major) && ((surface)->render_minor >= minor)))
@@ -950,21 +959,14 @@ _cairo_xlib_surface_set_matrix (cairo_xl
     xtransform.matrix[2][1] = 0;
     xtransform.matrix[2][2] = _cairo_fixed_from_double (1);
 
-    if (!CAIRO_SURFACE_RENDER_HAS_PICTURE_TRANSFORM (surface))
-    {
-	static const XTransform identity = { {
-	    { 1 << 16, 0x00000, 0x00000 },
-	    { 0x00000, 1 << 16, 0x00000 },
-	    { 0x00000, 0x00000, 1 << 16 },
-	} };
-
-	if (memcmp (&xtransform, &identity, sizeof (XTransform)) == 0)
-	    return CAIRO_STATUS_SUCCESS;
+    if (memcmp (&xtransform, &surface->xtransform, sizeof (XTransform)) == 0)
+	return CAIRO_STATUS_SUCCESS;
 
+    if (!CAIRO_SURFACE_RENDER_HAS_PICTURE_TRANSFORM (surface))
 	return CAIRO_INT_STATUS_UNSUPPORTED;
-    }
 
     XRenderSetPictureTransform (surface->dpy, surface->src_picture, &xtransform);
+    surface->xtransform = xtransform;
 
     return CAIRO_STATUS_SUCCESS;
 }
@@ -978,6 +980,9 @@ _cairo_xlib_surface_set_filter (cairo_xl
     if (!surface->src_picture)
 	return CAIRO_STATUS_SUCCESS;
 
+    if (surface->filter == filter)
+	return CAIRO_STATUS_SUCCESS;
+
     if (!CAIRO_SURFACE_RENDER_HAS_FILTERS (surface))
     {
 	if (filter == CAIRO_FILTER_FAST || filter == CAIRO_FILTER_NEAREST)
@@ -1015,6 +1020,7 @@ _cairo_xlib_surface_set_filter (cairo_xl
 
     XRenderSetPictureFilter (surface->dpy, surface->src_picture,
 			     (char *) render_filter, NULL, 0);
+    surface->filter = filter;
 
     return CAIRO_STATUS_SUCCESS;
 }
@@ -1028,10 +1034,14 @@ _cairo_xlib_surface_set_repeat (cairo_xl
     if (!surface->src_picture)
 	return CAIRO_STATUS_SUCCESS;
 
+    if (surface->repeat == repeat)
+	return CAIRO_STATUS_SUCCESS;
+
     mask = CPRepeat;
     pa.repeat = repeat;
 
     XRenderChangePicture (surface->dpy, surface->src_picture, mask, &pa);
+    surface->repeat = repeat;
 
     return CAIRO_STATUS_SUCCESS;
 }
@@ -1935,6 +1945,9 @@ _cairo_xlib_surface_create_internal (Dis
     surface->visual = visual;
     surface->xrender_format = xrender_format;
     surface->depth = depth;
+    surface->filter = CAIRO_FILTER_NEAREST;
+    surface->repeat = FALSE;
+    surface->xtransform = identity;
 
     surface->have_clip_rects = FALSE;
     surface->clip_rects = NULL;


More information about the cairo-commit mailing list