[cairo] slow path annotations

Jeff Muizelaar jeff at infidigm.net
Thu Mar 15 11:22:03 PDT 2007


Here's an updated patch. It changes raise(5) to raise(SIGTRAP) and makes
cairo_path_with_alpha() a slow path (the explanation is inline).

-Jeff

diff --git a/pixman/src/fbcompose.c b/pixman/src/fbcompose.c
index 233b90c..8f5cb87 100644
--- a/pixman/src/fbcompose.c
+++ b/pixman/src/fbcompose.c
@@ -4206,6 +4206,10 @@ pixman_compositeGeneral (pixman_operator_t	op,
     CARD32 *scanline_buffer = _scanline_buffer;
     FbComposeData compose_data;
 
+    /* Don't treat gradients as a slow path because there is no fast path */
+    if (pSrc->pDrawable)
+	    pixman_slow_path();
+
     if (pSrc->pDrawable)
         srcRepeat = pSrc->repeat == RepeatNormal && !pSrc->transform
                     && (pSrc->pDrawable->width != 1 || pSrc->pDrawable->height != 1);
diff --git a/pixman/src/fbpict.c b/pixman/src/fbpict.c
index 0bd989f..af3ff26 100644
--- a/pixman/src/fbpict.c
+++ b/pixman/src/fbpict.c
@@ -1951,6 +1951,14 @@ pixman_composite (pixman_operator_t	op,
 
     n = pixman_region_num_rects (region);
     pbox = pixman_region_rects (region);
+
+    /* check for compositing a solid surface without a solid varient */
+    if (srcRepeat && pSrc->pDrawable &&
+		    pSrc->pDrawable->height == 1 &&
+		    pSrc->pDrawable->width == 1 &&
+		    (pbox->y2 - pbox->y1 > 1 || pbox->x2 - pbox->x1 > 1))
+	    pixman_slow_path();
+
     while (n--)
     {
 	h = pbox->y2 - pbox->y1;
diff --git a/pixman/src/icint.h b/pixman/src/icint.h
index 47a2220..8669337 100644
--- a/pixman/src/icint.h
+++ b/pixman/src/icint.h
@@ -117,6 +117,12 @@ typedef pixman_triangle_t	xTriangle;
 #define MAXSHORT SHRT_MAX
 #define MINSHORT SHRT_MIN
 
+#include <signal.h>
+static inline void pixman_slow_path(void)
+{
+	raise(SIGTRAP);
+}
+
 /* XXX: What do we need from here?
 #include "picture.h"
 */
diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index 1a7d666..3a0cf0f 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -284,14 +284,15 @@ _clip_and_composite_source (cairo_clip_t                  *clip,
     cairo_surface_pattern_t mask_pattern;
     cairo_status_t status;
 
+    /* Single composite operation becomes two.
+     * Two, that are likely not fast */
+    /* If you hit this maybe you should be using OVER instead of SOURCE */
+    cairo_slow_path();
+
     /* Create a surface that is mask IN clip
      */
-    status = _create_composite_mask_pattern (&mask_pattern,
-					     clip,
-					     draw_func, draw_closure,
-					     dst, extents);
-    if (status)
-	return status;
+    status = _create_composite_mask_pattern (&mask_pattern, clip, draw_func,
+		    draw_closure, dst, extents); if (status) return status;
 
     /* Compute dest' = dest OUT (mask IN clip)
      */
diff --git a/src/cairo.c b/src/cairo.c
index 21303de..3ab3146 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -1870,6 +1870,10 @@ cairo_paint_with_alpha (cairo_t *cr,
     _cairo_color_init_rgba (&color, 1., 1., 1., alpha);
     _cairo_pattern_init_solid (&pattern.solid, &color);
 
+    /* _cairo_pattern_init_solid will create a ARGB32 format surface
+     * masking through ARGB32 surfaces is not a fast path in pixman */
+    cairo_slow_path();
+
     cr->status = _cairo_gstate_mask (cr->gstate, &pattern.base);
     if (cr->status)
 	_cairo_set_error (cr, cr->status);
diff --git a/src/cairoint.h b/src/cairoint.h
index 0ac5961..33e4134 100755
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -272,6 +272,12 @@ typedef cairo_fixed_16_16_t cairo_fixed_t;
 #define CAIRO_BITSWAP8_IF_LITTLE_ENDIAN(c) CAIRO_BITSWAP8(c)
 #endif
 
+#include <signal.h>
+static inline void cairo_slow_path(void)
+{
+	raise(SIGTRAP);
+}
+
 #ifdef WORDS_BIGENDIAN
 
 #define cpu_to_be16(v) (v)


More information about the cairo mailing list