[cairo-commit] src/cairo-compositor-private.h src/cairo-mask-compositor.c src/cairo-xlib-render-compositor.c

Chris Wilson ickle at kemper.freedesktop.org
Fri Jan 11 05:56:57 PST 2013


 src/cairo-compositor-private.h     |    3 +++
 src/cairo-mask-compositor.c        |   27 +++++++++++++++++++++++----
 src/cairo-xlib-render-compositor.c |   24 ++++++++++++------------
 3 files changed, 38 insertions(+), 16 deletions(-)

New commits:
commit 503b6b9e2ea65805a77d527c00cf242ec86d479b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Jan 11 13:10:56 2013 +0000

    xlib: Only fallback through the mask intermediate if we can composite the mask
    
    Before rendering into the mask, we should first check whether the
    subsequent call to composite the mask will trigger a fallback. In that
    case, we should fallback earlier and do the operation in place.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-compositor-private.h b/src/cairo-compositor-private.h
index e5ad367..0199723 100644
--- a/src/cairo-compositor-private.h
+++ b/src/cairo-compositor-private.h
@@ -129,6 +129,9 @@ struct cairo_mask_compositor {
 				 cairo_boxes_t		*boxes);
 
     cairo_int_status_t
+	(*check_composite) (const cairo_composite_rectangles_t *extents);
+
+    cairo_int_status_t
 	(*composite)		(void			*dst,
 				 cairo_operator_t	 op,
 				 cairo_surface_t	*src,
diff --git a/src/cairo-mask-compositor.c b/src/cairo-mask-compositor.c
index 7976a79..b4bc2be 100644
--- a/src/cairo-mask-compositor.c
+++ b/src/cairo-mask-compositor.c
@@ -960,6 +960,10 @@ _cairo_mask_compositor_paint (const cairo_compositor_t *_compositor,
     cairo_boxes_t boxes;
     cairo_int_status_t status;
 
+    status = compositor->check_composite (extents);
+    if (unlikely (status))
+	return status;
+
     _cairo_clip_steal_boxes (extents->clip, &boxes);
     status = clip_and_composite_boxes (compositor, extents, &boxes);
     _cairo_clip_unsteal_boxes (extents->clip, &boxes);
@@ -1210,6 +1214,10 @@ _cairo_mask_compositor_mask (const cairo_compositor_t *_compositor,
     const cairo_mask_compositor_t *compositor = (cairo_mask_compositor_t*)_compositor;
     cairo_int_status_t status = CAIRO_INT_STATUS_UNSUPPORTED;
 
+    status = compositor->check_composite (extents);
+    if (unlikely (status))
+	return status;
+
     if (extents->mask_pattern.base.type == CAIRO_PATTERN_TYPE_SOLID &&
 	extents->clip->path == NULL &&
 	! _cairo_clip_is_region (extents->clip)) {
@@ -1242,9 +1250,12 @@ _cairo_mask_compositor_stroke (const cairo_compositor_t *_compositor,
     const cairo_mask_compositor_t *compositor = (cairo_mask_compositor_t*)_compositor;
     cairo_surface_t *mask;
     cairo_surface_pattern_t pattern;
-    cairo_int_status_t status;
+    cairo_int_status_t status = CAIRO_INT_STATUS_UNSUPPORTED;
+
+    status = compositor->check_composite (extents);
+    if (unlikely (status))
+	return status;
 
-    status = CAIRO_INT_STATUS_UNSUPPORTED;
     if (_cairo_path_fixed_stroke_is_rectilinear (path)) {
 	cairo_boxes_t boxes;
 
@@ -1311,9 +1322,12 @@ _cairo_mask_compositor_fill (const cairo_compositor_t *_compositor,
     const cairo_mask_compositor_t *compositor = (cairo_mask_compositor_t*)_compositor;
     cairo_surface_t *mask;
     cairo_surface_pattern_t pattern;
-    cairo_int_status_t status;
+    cairo_int_status_t status = CAIRO_INT_STATUS_UNSUPPORTED;
+
+    status = compositor->check_composite (extents);
+    if (unlikely (status))
+	return status;
 
-    status = CAIRO_INT_STATUS_UNSUPPORTED;
     if (_cairo_path_fixed_fill_is_rectilinear (path)) {
 	cairo_boxes_t boxes;
 
@@ -1374,10 +1388,15 @@ _cairo_mask_compositor_glyphs (const cairo_compositor_t *_compositor,
 			       int			 num_glyphs,
 			       cairo_bool_t		 overlap)
 {
+    const cairo_mask_compositor_t *compositor = (cairo_mask_compositor_t*)_compositor;
     cairo_surface_t *mask;
     cairo_surface_pattern_t pattern;
     cairo_int_status_t status;
 
+    status = compositor->check_composite (extents);
+    if (unlikely (status))
+	return CAIRO_INT_STATUS_UNSUPPORTED;
+
     mask = cairo_surface_create_similar_image (extents->surface,
 					       CAIRO_FORMAT_A8,
 					       extents->bounded.width,
diff --git a/src/cairo-xlib-render-compositor.c b/src/cairo-xlib-render-compositor.c
index f0068ae..a5f750e 100644
--- a/src/cairo-xlib-render-compositor.c
+++ b/src/cairo-xlib-render-compositor.c
@@ -55,6 +55,17 @@
 #include "cairo-tristrip-private.h"
 
 static cairo_int_status_t
+check_composite (const cairo_composite_rectangles_t *extents)
+{
+    cairo_xlib_display_t *display = ((cairo_xlib_surface_t *)extents->surface)->display;
+
+    if (! CAIRO_RENDER_SUPPORTS_OPERATOR (display, extents->op))
+	return CAIRO_INT_STATUS_UNSUPPORTED;
+
+    return CAIRO_STATUS_SUCCESS;
+}
+
+static cairo_int_status_t
 acquire (void *abstract_dst)
 {
     cairo_xlib_surface_t *dst = abstract_dst;
@@ -1697,7 +1708,7 @@ _cairo_xlib_mask_compositor_get (void)
 	compositor.fill_rectangles = fill_rectangles;
 	compositor.fill_boxes = fill_boxes;
 	compositor.copy_boxes = copy_boxes;
-	//compositor.check_composite = check_composite;
+	compositor.check_composite = check_composite;
 	compositor.composite = composite;
 	//compositor.check_composite_boxes = check_composite_boxes;
 	compositor.composite_boxes = composite_boxes;
@@ -1928,17 +1939,6 @@ composite_tristrip (void		*abstract_dst,
     return CAIRO_STATUS_SUCCESS;
 }
 
-static cairo_int_status_t
-check_composite (const cairo_composite_rectangles_t *extents)
-{
-    cairo_xlib_display_t *display = ((cairo_xlib_surface_t *)extents->surface)->display;
-
-    if (! CAIRO_RENDER_SUPPORTS_OPERATOR (display, extents->op))
-	return CAIRO_INT_STATUS_UNSUPPORTED;
-
-    return CAIRO_STATUS_SUCCESS;
-}
-
 const cairo_compositor_t *
 _cairo_xlib_traps_compositor_get (void)
 {


More information about the cairo-commit mailing list