mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-03 20:38:10 +02:00
Make _cairo_stroker_add_sub_edge use tessellate_convex_quad rather than tessellate_polygon
This gives a 17-20% speedup for stroking polygons with many straight line segments as seen in the world_map test case: Speedups ======== image-rgba world_map-800 555.41 0.17% -> 460.69 0.20%: 1.21x speedup ▎ image-rgb world_map-800 554.91 0.25% -> 460.73 0.26%: 1.20x speedup ▎ xlib-rgb world_map-800 669.85 3.70% -> 570.31 0.24%: 1.17x speedup ▏ xlib-rgba world_map-800 663.71 0.46% -> 567.74 0.19%: 1.17x speedup ▏
This commit is contained in:
parent
fefa7d9b99
commit
3d53f623fa
1 changed files with 6 additions and 25 deletions
|
|
@ -573,8 +573,7 @@ _cairo_stroker_add_sub_edge (cairo_stroker_t *stroker, cairo_point_t *p1, cairo_
|
|||
cairo_slope_t *slope, cairo_stroke_face_t *start,
|
||||
cairo_stroke_face_t *end)
|
||||
{
|
||||
cairo_status_t status;
|
||||
cairo_polygon_t polygon;
|
||||
cairo_point_t rectangle[4];
|
||||
|
||||
_compute_face (p1, slope, stroker, start);
|
||||
|
||||
|
|
@ -586,30 +585,12 @@ _cairo_stroker_add_sub_edge (cairo_stroker_t *stroker, cairo_point_t *p1, cairo_
|
|||
if (p1->x == p2->x && p1->y == p2->y)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
/* XXX: I should really check the return value of the
|
||||
move_to/line_to functions here to catch out of memory
|
||||
conditions. But since that would be ugly, I'd prefer to add a
|
||||
status flag to the polygon object that I could check only once
|
||||
at then end of this sequence, (like we do with cairo_t
|
||||
already). */
|
||||
_cairo_polygon_init (&polygon);
|
||||
_cairo_polygon_move_to (&polygon, &start->cw);
|
||||
_cairo_polygon_line_to (&polygon, &start->ccw);
|
||||
_cairo_polygon_line_to (&polygon, &end->ccw);
|
||||
_cairo_polygon_line_to (&polygon, &end->cw);
|
||||
_cairo_polygon_close (&polygon);
|
||||
rectangle[0] = start->cw;
|
||||
rectangle[1] = start->ccw;
|
||||
rectangle[2] = end->ccw;
|
||||
rectangle[3] = end->cw;
|
||||
|
||||
/* XXX: We can't use tessellate_rectangle as the matrix may have
|
||||
skewed this into a non-rectangular shape. Perhaps it would be
|
||||
worth checking the matrix for skew so that the common case
|
||||
could use the faster tessellate_rectangle rather than
|
||||
tessellate_polygon? */
|
||||
status = _cairo_traps_tessellate_polygon (stroker->traps,
|
||||
&polygon, CAIRO_FILL_RULE_WINDING);
|
||||
|
||||
_cairo_polygon_fini (&polygon);
|
||||
|
||||
return status;
|
||||
return _cairo_traps_tessellate_convex_quad (stroker->traps, rectangle);
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue