summaryrefslogtreecommitdiff
path: root/src/cairo-traps-compositor.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-08-24 17:22:34 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-01-03 15:07:18 +0000
commit5bc1b1f6aac108d9a3963352ad774bb4fcd69e28 (patch)
treebb5cded7a588e82b5481a0486f76c4c7bf7dca40 /src/cairo-traps-compositor.c
parent74941f822015cc50cd8477d0cf97f1a70dbff60b (diff)
downloadcairo-5bc1b1f6aac108d9a3963352ad774bb4fcd69e28.tar.gz
stroke: Make the incremental trapezoid stroker optionally available again
Whilst it cannot handle self-intersecting strokes (which includes the antialias region of neighbouring lines and joints), it is about 3x faster to use than the more robust algorithm. As some backends delegate the rendering, the quality may still be preserved and so they should be responsible for choosing the appropriate method for generation of the stroke geometry. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/cairo-traps-compositor.c')
-rw-r--r--src/cairo-traps-compositor.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/src/cairo-traps-compositor.c b/src/cairo-traps-compositor.c
index eeee20c80..02fbe7514 100644
--- a/src/cairo-traps-compositor.c
+++ b/src/cairo-traps-compositor.c
@@ -1570,7 +1570,7 @@ clip_and_composite_polygon (const cairo_traps_compositor_t *compositor,
* The clip will trim that overestimate to our expectations.
*/
if (! extents->is_bounded)
- flags |= FORCE_CLIP_REGION;
+ flags |= FORCE_CLIP_REGION;
traps.antialias = antialias;
status = clip_and_composite (compositor, extents,
@@ -1791,7 +1791,8 @@ composite_traps_as_boxes (const cairo_traps_compositor_t *compositor,
static cairo_int_status_t
clip_and_composite_traps (const cairo_traps_compositor_t *compositor,
cairo_composite_rectangles_t *extents,
- composite_traps_info_t *info)
+ composite_traps_info_t *info,
+ unsigned flags)
{
cairo_int_status_t status;
@@ -1801,10 +1802,10 @@ clip_and_composite_traps (const cairo_traps_compositor_t *compositor,
if (unlikely (status != CAIRO_INT_STATUS_SUCCESS))
return status;
- status = composite_traps_as_boxes (compositor, extents, info);
+ status = CAIRO_INT_STATUS_UNSUPPORTED;
+ if ((flags & FORCE_CLIP_REGION) == 0)
+ status = composite_traps_as_boxes (compositor, extents, info);
if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
- unsigned int flags = 0;
-
/* For unbounded operations, the X11 server will estimate the
* affected rectangle and apply the operation to that. However,
* there are cases where this is an overestimate (e.g. the
@@ -2152,16 +2153,32 @@ _cairo_traps_compositor_stroke (const cairo_compositor_t *_compositor,
}
if (status == CAIRO_INT_STATUS_UNSUPPORTED) {
+ cairo_int_status_t (*func) (const cairo_path_fixed_t *path,
+ const cairo_stroke_style_t *stroke_style,
+ const cairo_matrix_t *ctm,
+ const cairo_matrix_t *ctm_inverse,
+ double tolerance,
+ cairo_traps_t *traps);
composite_traps_info_t info;
+ unsigned flags = 0;
+
+ if (antialias == CAIRO_ANTIALIAS_BEST || antialias == CAIRO_ANTIALIAS_GOOD) {
+ func = _cairo_path_fixed_stroke_polygon_to_traps;
+ } else {
+ func = _cairo_path_fixed_stroke_to_traps;
+ if (extents->clip->num_boxes > 1 ||
+ extents->mask.width > extents->unbounded.width ||
+ extents->mask.height > extents->unbounded.height)
+ {
+ flags = NEED_CLIP_REGION | FORCE_CLIP_REGION;
+ }
+ }
info.antialias = antialias;
_cairo_traps_init_with_clip (&info.traps, extents->clip);
- status = _cairo_path_fixed_stroke_to_traps (path, style,
- ctm, ctm_inverse,
- tolerance,
- &info.traps);
+ status = func (path, style, ctm, ctm_inverse, tolerance, &info.traps);
if (likely (status == CAIRO_INT_STATUS_SUCCESS))
- status = clip_and_composite_traps (compositor, extents, &info);
+ status = clip_and_composite_traps (compositor, extents, &info, flags);
_cairo_traps_fini (&info.traps);
}