diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2012-08-25 08:39:30 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-08-26 11:07:57 +0100 |
commit | bdf83008f4b2c723fd8e65e2a92bc47a2e7bc442 (patch) | |
tree | 60b0f91dcb42ba1870f1e5d6fef02be40ab886a3 /src/cairo-pen.c | |
parent | fc38d7375d4f0342ece91596d71f0ce56aa2c975 (diff) | |
download | cairo-bdf83008f4b2c723fd8e65e2a92bc47a2e7bc442.tar.gz |
compositor: Skip invisible strokes
If the pen is reduced to a single point, it is effectively invisible
when rasterised, so skip the stroke composition.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/cairo-pen.c')
-rw-r--r-- | src/cairo-pen.c | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/src/cairo-pen.c b/src/cairo-pen.c index e71f7b561..d70a06497 100644 --- a/src/cairo-pen.c +++ b/src/cairo-pen.c @@ -41,11 +41,6 @@ #include "cairo-error-private.h" #include "cairo-slope-private.h" -static int -_cairo_pen_vertices_needed (double tolerance, - double radius, - const cairo_matrix_t *matrix); - static void _cairo_pen_compute_slopes (cairo_pen_t *pen); @@ -88,10 +83,12 @@ _cairo_pen_init (cairo_pen_t *pen, * is reflecting */ for (i=0; i < pen->num_vertices; i++) { - double theta = 2 * M_PI * i / (double) pen->num_vertices; - double dx = radius * cos (reflect ? -theta : theta); - double dy = radius * sin (reflect ? -theta : theta); cairo_pen_vertex_t *v = &pen->vertices[i]; + double theta = 2 * M_PI * i / (double) pen->num_vertices, dx, dy; + if (reflect) + theta = -theta; + dx = radius * cos (theta); + dy = radius * sin (theta); cairo_matrix_transform_distance (ctm, &dx, &dy); v->point.x = _cairo_fixed_from_double (dx); v->point.y = _cairo_fixed_from_double (dy); @@ -273,7 +270,7 @@ Note that this also equation works for M == m (a circle) as it doesn't matter where on the circle the error is computed. */ -static int +int _cairo_pen_vertices_needed (double tolerance, double radius, const cairo_matrix_t *matrix) @@ -283,21 +280,16 @@ _cairo_pen_vertices_needed (double tolerance, * compute major axis length for a pen with the specified radius. * we don't need the minor axis length. */ + double major_axis = _cairo_matrix_transformed_circle_major_axis (matrix, + radius); + int num_vertices; - double major_axis = _cairo_matrix_transformed_circle_major_axis (matrix, - radius); - - /* - * compute number of vertices needed - */ - int num_vertices; - - /* Where tolerance / M is > 1, we use 4 points */ - if (tolerance >= major_axis) { + if (tolerance >= 2*major_axis) { + num_vertices = 1; + } else if (tolerance >= major_axis) { num_vertices = 4; } else { - double delta = acos (1 - tolerance / major_axis); - num_vertices = ceil (M_PI / delta); + num_vertices = ceil (2*M_PI / acos (1 - tolerance / major_axis)); /* number of vertices must be even */ if (num_vertices % 2) |