summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-09-21 03:10:53 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-09-21 04:26:01 +0100
commit378b1e73d9f27e9b54ea01b10e588b361848d0cd (patch)
tree38adf9a1945fa98bd5877914225f8903f924c46b
parent35daf95db8aa4f0c254891f180aa4996dd464a60 (diff)
[fallback] Special case single composite rectangle
Avoid the overhead of region-from-traps extraction for the very frequent case of using a single (possibly clipped) rectangle with a pattern source.
-rw-r--r--src/cairo-surface-fallback.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index 35befa53..77ae0ede 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -715,6 +715,44 @@ _fill_rectangles (cairo_surface_t *dst,
return status;
}
+/* fast-path for very common composite of a single rectangle */
+static cairo_status_t
+_composite_rectangle (cairo_surface_t *dst,
+ cairo_operator_t op,
+ const cairo_pattern_t *src,
+ cairo_traps_t *traps,
+ cairo_clip_t *clip)
+{
+ cairo_rectangle_int_t rect;
+
+ if (clip != NULL)
+ return CAIRO_INT_STATUS_UNSUPPORTED;
+
+ if (traps->num_traps > 1 || ! traps->is_rectilinear || ! traps->maybe_region)
+ return CAIRO_INT_STATUS_UNSUPPORTED;
+
+ if (! _cairo_fixed_is_integer (traps->traps[0].top) ||
+ ! _cairo_fixed_is_integer (traps->traps[0].bottom) ||
+ ! _cairo_fixed_is_integer (traps->traps[0].left.p1.x) ||
+ ! _cairo_fixed_is_integer (traps->traps[0].right.p1.x))
+ {
+ traps->maybe_region = FALSE;
+ return CAIRO_INT_STATUS_UNSUPPORTED;
+ }
+
+ rect.x = _cairo_fixed_integer_part (traps->traps[0].left.p1.x);
+ rect.y = _cairo_fixed_integer_part (traps->traps[0].top);
+ rect.width = _cairo_fixed_integer_part (traps->traps[0].right.p1.x) - rect.x;
+ rect.height = _cairo_fixed_integer_part (traps->traps[0].bottom) - rect.y;
+
+ return _cairo_surface_composite (op, src, NULL, dst,
+ rect.x, rect.y,
+ 0, 0,
+ rect.x, rect.y,
+ rect.width, rect.height,
+ NULL);
+}
+
/* Warning: This call modifies the coordinates of traps */
static cairo_status_t
_clip_and_composite_trapezoids (const cairo_pattern_t *src,
@@ -756,6 +794,10 @@ _clip_and_composite_trapezoids (const cairo_pattern_t *src,
if (status != CAIRO_INT_STATUS_UNSUPPORTED)
return status;
+ status = _composite_rectangle (dst, op, src, traps, clip);
+ if (status != CAIRO_INT_STATUS_UNSUPPORTED)
+ return status;
+
status = _cairo_traps_extract_region (traps, &trap_region);
if (unlikely (_cairo_status_is_error (status)))
return status;