[cairo-spans] Hook up filling paths with spans to cairo-surface-fallback.c.
This speeds up the mask generation step in cairo_fill() for the image surface by up to 10x in especially favourable cases. image-rgba twin-800 7757.80 0.20% -> 749.41 0.29%: 10.36x speedup image-rgba spiral-diag-pixalign-nonzero-fill-512 15.16 0.44% -> 3.45 8.80%: 5.54x speedup More typical simple non-rectilinear geometries are sped up by 30-50%. This patch does not affect any stroking operations or any fill operations of pixel aligned rectilinear geometries; those are still rendered using trapezoids.
|
|
@ -670,6 +670,53 @@ out:
|
|||
return status;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
cairo_path_fixed_t *path;
|
||||
cairo_fill_rule_t fill_rule;
|
||||
double tolerance;
|
||||
cairo_antialias_t antialias;
|
||||
} cairo_composite_spans_fill_info_t;
|
||||
|
||||
static cairo_status_t
|
||||
_composite_spans_fill_func (void *closure,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *src,
|
||||
cairo_surface_t *dst,
|
||||
int dst_x,
|
||||
int dst_y,
|
||||
const cairo_rectangle_int_t *extents)
|
||||
{
|
||||
cairo_composite_rectangles_t rects;
|
||||
cairo_composite_spans_fill_info_t *info = closure;
|
||||
cairo_pattern_union_t pattern;
|
||||
cairo_status_t status = CAIRO_STATUS_SUCCESS;
|
||||
|
||||
_cairo_composite_rectangles_init (
|
||||
&rects, extents->x, extents->y,
|
||||
extents->width, extents->height);
|
||||
|
||||
/* The incoming dst_x/y are where we're pretending the origin of
|
||||
* the dst surface is -- *not* the offset of a rectangle where
|
||||
* we'd like to place the result. */
|
||||
rects.dst.x -= dst_x;
|
||||
rects.dst.y -= dst_y;
|
||||
|
||||
/* We're called without a source pattern from
|
||||
* _create_composite_mask_pattern(). */
|
||||
_cairo_pattern_init_solid (&pattern.solid, CAIRO_COLOR_WHITE,
|
||||
CAIRO_CONTENT_COLOR);
|
||||
if (src == NULL)
|
||||
src = &pattern.base;
|
||||
|
||||
status = _cairo_path_fixed_fill_using_spans (
|
||||
op, src, info->path, dst,
|
||||
info->fill_rule, info->tolerance, info->antialias,
|
||||
&rects);
|
||||
|
||||
_cairo_pattern_fini (&pattern.base);
|
||||
return status;
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
_cairo_surface_fallback_paint (cairo_surface_t *surface,
|
||||
cairo_operator_t op,
|
||||
|
|
@ -886,8 +933,45 @@ _cairo_surface_fallback_fill (cairo_surface_t *surface,
|
|||
if (extents.width == 0 || extents.height == 0)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
_cairo_box_from_rectangle (&box, &extents);
|
||||
/* Ask if the surface would like to render this combination of
|
||||
* op/source/dst/antialias with spans or not, but don't actually
|
||||
* make a renderer yet. We'll try to hit the region optimisations
|
||||
* in _clip_and_composite_trapezoids() if it looks like the path
|
||||
* is a region. */
|
||||
/* TODO: Until we have a mono scan converter we won't even try
|
||||
* to use spans for CAIRO_ANTIALIAS_NONE. */
|
||||
/* TODO: The region filling code should be lifted from
|
||||
* _clip_and_composite_trapezoids() and given first priority
|
||||
* explicitly before deciding between spans and trapezoids. */
|
||||
if (antialias != CAIRO_ANTIALIAS_NONE &&
|
||||
!_cairo_path_fixed_is_box (path, &box) &&
|
||||
!_cairo_path_fixed_is_region (path) &&
|
||||
_cairo_surface_check_span_renderer (
|
||||
op, source, surface, antialias, NULL))
|
||||
{
|
||||
cairo_composite_spans_fill_info_t info;
|
||||
info.path = path;
|
||||
info.fill_rule = fill_rule;
|
||||
info.tolerance = tolerance;
|
||||
info.antialias = antialias;
|
||||
|
||||
if (_cairo_operator_bounded_by_mask (op)) {
|
||||
cairo_rectangle_int_t path_extents;
|
||||
_cairo_path_fixed_approximate_extents (path, &path_extents);
|
||||
if (! _cairo_rectangle_intersect (&extents, &path_extents))
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
return _clip_and_composite (
|
||||
surface->clip, op, source,
|
||||
_composite_spans_fill_func,
|
||||
&info,
|
||||
surface,
|
||||
&extents);
|
||||
}
|
||||
|
||||
/* Fall back to trapezoid fills. */
|
||||
_cairo_box_from_rectangle (&box, &extents);
|
||||
_cairo_traps_init (&traps);
|
||||
_cairo_traps_limit (&traps, &box);
|
||||
|
||||
|
|
|
|||
BIN
test/clip-fill-rule.test-fallback.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 361 B |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.6 KiB |
BIN
test/clip-operator.ps3.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
BIN
test/clip-operator.test-fallback.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 8.1 KiB |
BIN
test/clip-operator.test-fallback.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
test/clip-operator.xlib-fallback.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
test/clip-operator.xlib.ref.png
Normal file
|
After Width: | Height: | Size: 8.1 KiB |
BIN
test/clip-operator.xlib.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
test/clip-twice.pdf.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
test/clipped-group.pdf.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 298 B |
BIN
test/clipped-group.pdf.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 298 B |
|
Before Width: | Height: | Size: 616 B After Width: | Height: | Size: 544 B |
BIN
test/degenerate-arc.test-fallback.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 547 B |
BIN
test/degenerate-arc.test-fallback.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 547 B |
BIN
test/degenerate-arc.xlib.ref.png
Normal file
|
After Width: | Height: | Size: 616 B |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.7 KiB |
BIN
test/fill-alpha-pattern.ps3.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 4 KiB |
BIN
test/fill-alpha-pattern.ps3.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.3 KiB |
BIN
test/fill-alpha-pattern.test-fallback.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
test/fill-alpha-pattern.test-fallback.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
test/fill-alpha-pattern.xlib.ref.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.7 KiB |
BIN
test/fill-alpha.test-fallback.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
test/fill-alpha.test-fallback.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
test/fill-alpha.xlib.ref.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 2 KiB |
BIN
test/fill-degenerate-sort-order.test-fallback.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
test/fill-degenerate-sort-order.test-fallback.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 2 KiB |
BIN
test/fill-degenerate-sort-order.xlib.ref.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
test/fill-degenerate-sort-order.xlib.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 2 KiB |
BIN
test/fill-missed-stop.pdf.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 452 B |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 2 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
BIN
test/fill-rule.test-fallback.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
test/fill-rule.test-fallback.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
test/fill-rule.xlib.ref.png
Normal file
|
After Width: | Height: | Size: 1.9 KiB |
BIN
test/fill-rule.xlib.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
test/finer-grained-fallbacks.ps2.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
BIN
test/finer-grained-fallbacks.ps3.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 839 B |
BIN
test/finer-grained-fallbacks.test-fallback.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
test/finer-grained-fallbacks.test-fallback.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 854 B |
BIN
test/finer-grained-fallbacks.xlib.ref.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
test/finer-grained-fallbacks.xlib.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
test/font-matrix-translation.svg11.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 857 B |
BIN
test/font-matrix-translation.svg11.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 857 B |
BIN
test/font-matrix-translation.svg12.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 857 B |
BIN
test/font-matrix-translation.svg12.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 857 B |
BIN
test/ft-show-glyphs-table.svg11.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 9.7 KiB |
BIN
test/ft-show-glyphs-table.svg11.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 9.7 KiB |
BIN
test/ft-show-glyphs-table.svg12.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 9.7 KiB |
BIN
test/ft-show-glyphs-table.svg12.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 9.7 KiB |
BIN
test/ft-text-vertical-layout-type1.pdf.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
test/ft-text-vertical-layout-type1.pdf.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.6 KiB |
BIN
test/ft-text-vertical-layout-type1.svg11.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
test/ft-text-vertical-layout-type1.svg11.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
test/ft-text-vertical-layout-type1.svg12.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
test/ft-text-vertical-layout-type1.svg12.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
test/ft-text-vertical-layout-type1.test-fallback.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
test/ft-text-vertical-layout-type1.test-fallback.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
test/ft-text-vertical-layout-type1.xlib.ref.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
test/ft-text-vertical-layout-type3.pdf.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
test/ft-text-vertical-layout-type3.pdf.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.5 KiB |
BIN
test/ft-text-vertical-layout-type3.svg11.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
test/ft-text-vertical-layout-type3.svg11.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
test/ft-text-vertical-layout-type3.svg12.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
test/ft-text-vertical-layout-type3.svg12.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
test/ft-text-vertical-layout-type3.test-fallback.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
test/ft-text-vertical-layout-type3.test-fallback.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
test/ft-text-vertical-layout-type3.xlib.ref.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
test/huge-pattern.pdf.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
BIN
test/linear-gradient.pdf.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
BIN
test/linear-gradient.pdf.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1,021 B After Width: | Height: | Size: 983 B |
BIN
test/linear-gradient.svg11.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 988 B |
BIN
test/linear-gradient.svg11.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 988 B |
BIN
test/linear-gradient.svg12.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 988 B |
BIN
test/linear-gradient.svg12.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 988 B |
BIN
test/linear-gradient.test-fallback.argb32.ref.png
Normal file
|
After Width: | Height: | Size: 923 B |
BIN
test/linear-gradient.test-fallback.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 923 B |
BIN
test/linear-gradient.xlib.ref.png
Normal file
|
After Width: | Height: | Size: 1,021 B |
|
Before Width: | Height: | Size: 640 B After Width: | Height: | Size: 643 B |
|
Before Width: | Height: | Size: 615 B After Width: | Height: | Size: 642 B |
BIN
test/mask-alpha.svg11.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 592 B |
|
Before Width: | Height: | Size: 615 B After Width: | Height: | Size: 642 B |
BIN
test/mask-alpha.svg12.rgb24.ref.png
Normal file
|
After Width: | Height: | Size: 592 B |