[cairo-commit] 4 commits - src/cairo-path-stroke.c src/cairo-spans-compositor.c src/cairo-xlib-private.h util/show-polygon.c
Chris Wilson
ickle at kemper.freedesktop.org
Thu Nov 1 01:50:46 PDT 2012
src/cairo-path-stroke.c | 17 +++++++-------
src/cairo-spans-compositor.c | 8 ++++--
src/cairo-xlib-private.h | 1
util/show-polygon.c | 52 +++++++++++++++++++++++++++++++++++++++----
4 files changed, 64 insertions(+), 14 deletions(-)
New commits:
commit 0c1ff1572f1fc4c11b429e39f7de798030530740
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu Nov 1 08:45:37 2012 +0000
xlib: Fixup standalone header compilation for 'make check'
Missing include of string.h
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/cairo-xlib-private.h b/src/cairo-xlib-private.h
index c328302..000798a 100644
--- a/src/cairo-xlib-private.h
+++ b/src/cairo-xlib-private.h
@@ -50,6 +50,7 @@
#include "cairo-surface-private.h"
#include <pixman.h>
+#include <string.h>
typedef struct _cairo_xlib_display cairo_xlib_display_t;
typedef struct _cairo_xlib_shm_display cairo_xlib_shm_display_t;
commit b6daf47fa08c74d9672040b2b98ac6dd1f841429
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu Nov 1 08:39:01 2012 +0000
spans: Do not assume that we manage to perform the clip geometrically
Even for bounded masks, we may fail to perform the clipping
geometrically for a variety of reasons, the prime one being that the
clip has a mixture of antialias settings. So when compositing the
polygon, we need to check whether a clip path still remains and so
requires a clipmask.
Fixes regression from
commit cd1004ce19c7ea28c7fedb6464562a08416586c0
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri May 11 21:20:35 2012 +0100
traps,spans-compositor: Avoid mistreating unaligned clips as aligned
and
commit 4ea3ace6c810ba090464e48795fac5456f6cdc24
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri May 11 21:51:44 2012 +0100
spans: Only fallback for a clipmask if unbounded
Reported-by: Dominik Röttsches <dominik.rottsches at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=56574
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/cairo-spans-compositor.c b/src/cairo-spans-compositor.c
index a2b88ef..cb3e973 100644
--- a/src/cairo-spans-compositor.c
+++ b/src/cairo-spans-compositor.c
@@ -744,8 +744,10 @@ composite_polygon (const cairo_spans_compositor_t *compositor,
cairo_bool_t needs_clip;
cairo_int_status_t status;
- needs_clip = ! extents->is_bounded &&
- (! _clip_is_region (extents->clip) || extents->clip->num_boxes > 1);
+ if (extents->is_bounded)
+ needs_clip = extents->clip->path != NULL;
+ else
+ needs_clip = !_clip_is_region (extents->clip) || extents->clip->num_boxes > 1;
TRACE ((stderr, "%s - needs_clip=%d\n", __FUNCTION__, needs_clip));
if (needs_clip) {
TRACE ((stderr, "%s: unsupported clip\n", __FUNCTION__));
@@ -999,7 +1001,9 @@ _cairo_spans_compositor_stroke (const cairo_compositor_t *_compositor,
const cairo_spans_compositor_t *compositor = (cairo_spans_compositor_t*)_compositor;
cairo_int_status_t status;
+ TRACE ((stderr, "%s\n", __FUNCTION__));
TRACE_ (_cairo_debug_print_path (stderr, path));
+ TRACE_ (_cairo_debug_print_clip (stderr, extents->clip));
status = CAIRO_INT_STATUS_UNSUPPORTED;
if (_cairo_path_fixed_stroke_is_rectilinear (path)) {
commit 5844dead01db9ddab7f10a4d685bc5ee874d0eba
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu Nov 1 08:37:58 2012 +0000
util/show-polygon: Show the limited range of each edge
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/util/show-polygon.c b/util/show-polygon.c
index fc1444d..35c0014 100644
--- a/util/show-polygon.c
+++ b/util/show-polygon.c
@@ -55,17 +55,35 @@ static void draw_edges (cairo_t *cr, polygon_t *p, gdouble sf, int dir)
{
int n;
+ if (dir < 0)
+ cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
+ else
+ cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
+
for (n = 0; n < p->num_edges; n++) {
const edge_t *e = &p->edges[n];
+ double dx, dy;
+ double x1, x2;
if (e->dir != dir)
continue;
- cairo_arc (cr, e->p1.x, e->p1.y, 2/sf, 0, 2*M_PI);
- cairo_arc (cr, e->p2.x, e->p2.y, 2/sf, 0, 2*M_PI);
+ dx = e->p2.x - e->p1.x;
+ dy = e->p2.y - e->p1.y;
+
+ x1 = e->p1.x + (e->top - e->p1.y) / dy * dx;
+ x2 = e->p1.x + (e->bot - e->p1.y) / dy * dx;
+
+ cairo_arc (cr, x1, e->top, 2/sf, 0, 2*M_PI);
+ cairo_arc (cr, x2, e->bot, 2/sf, 0, 2*M_PI);
cairo_fill (cr);
}
+ if (dir < 0)
+ cairo_set_source_rgba (cr, 0.0, 0.0, 1.0, 0.5);
+ else
+ cairo_set_source_rgba (cr, 1.0, 0.0, 0.0, 0.5);
+
for (n = 0; n < p->num_edges; n++) {
const edge_t *e = &p->edges[n];
@@ -80,14 +98,40 @@ static void draw_edges (cairo_t *cr, polygon_t *p, gdouble sf, int dir)
cairo_set_line_width (cr, 1.);
cairo_stroke (cr);
} cairo_restore (cr);
+
+ if (dir < 0)
+ cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
+ else
+ cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
+
+ for (n = 0; n < p->num_edges; n++) {
+ const edge_t *e = &p->edges[n];
+ double dx, dy;
+ double x1, x2;
+
+ if (e->dir != dir)
+ continue;
+
+ dx = e->p2.x - e->p1.x;
+ dy = e->p2.y - e->p1.y;
+
+ x1 = e->p1.x + (e->top - e->p1.y) / dy * dx;
+ x2 = e->p1.x + (e->bot - e->p1.y) / dy * dx;
+
+ cairo_move_to (cr, x1, e->top);
+ cairo_line_to (cr, x2, e->bot);
+ }
+ cairo_save (cr); {
+ cairo_identity_matrix (cr);
+ cairo_set_line_width (cr, 1.);
+ cairo_stroke (cr);
+ } cairo_restore (cr);
}
static void draw_polygon (cairo_t *cr, polygon_t *p, gdouble sf)
{
- cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
draw_edges (cr, p, sf, -1);
- cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
draw_edges (cr, p, sf, +1);
}
commit 03adea2f50aa10d49ff578389927e7b37e265918
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Thu Nov 1 08:37:01 2012 +0000
stroke: Precompute the line half-width
As we regularly recompute stroke->line_width/2 we may as compute it once
during initialisation.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c
index 66ab3bd..a81e3bc 100644
--- a/src/cairo-path-stroke.c
+++ b/src/cairo-path-stroke.c
@@ -52,6 +52,7 @@ typedef struct cairo_stroker {
const cairo_matrix_t *ctm;
const cairo_matrix_t *ctm_inverse;
+ double half_line_width;
double tolerance;
double ctm_determinant;
cairo_bool_t ctm_det_positive;
@@ -134,13 +135,13 @@ _cairo_stroker_init (cairo_stroker_t *stroker,
stroker->ctm = ctm;
stroker->ctm_inverse = ctm_inverse;
stroker->tolerance = tolerance;
+ stroker->half_line_width = stroke_style->line_width / 2.0;
stroker->ctm_determinant = _cairo_matrix_compute_determinant (stroker->ctm);
stroker->ctm_det_positive = stroker->ctm_determinant >= 0.0;
status = _cairo_pen_init (&stroker->pen,
- stroke_style->line_width / 2.0,
- tolerance, ctm);
+ stroker->half_line_width, tolerance, ctm);
if (unlikely (status))
return status;
@@ -637,8 +638,8 @@ _cairo_stroker_add_cap (cairo_stroker_t *stroker,
dx = f->usr_vector.x;
dy = f->usr_vector.y;
- dx *= stroker->style.line_width / 2.0;
- dy *= stroker->style.line_width / 2.0;
+ dx *= stroker->half_line_width;
+ dy *= stroker->half_line_width;
cairo_matrix_transform_distance (stroker->ctm, &dx, &dy);
fvector.dx = _cairo_fixed_from_double (dx);
fvector.dy = _cairo_fixed_from_double (dy);
@@ -776,13 +777,13 @@ _compute_face (const cairo_point_t *point, cairo_slope_t *dev_slope,
*/
if (stroker->ctm_det_positive)
{
- face_dx = - slope_dy * (stroker->style.line_width / 2.0);
- face_dy = slope_dx * (stroker->style.line_width / 2.0);
+ face_dx = - slope_dy * stroker->half_line_width;
+ face_dy = slope_dx * stroker->half_line_width;
}
else
{
- face_dx = slope_dy * (stroker->style.line_width / 2.0);
- face_dy = - slope_dx * (stroker->style.line_width / 2.0);
+ face_dx = slope_dy * stroker->half_line_width;
+ face_dy = - slope_dx * stroker->half_line_width;
}
/* back to device space */
More information about the cairo-commit
mailing list