diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-07-30 17:28:21 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-09-12 08:29:48 +0100 |
commit | af9fbd176b145f042408ef5391eef2a51d7531f8 (patch) | |
tree | 5f75d1087d4325a013af6f0a4204a666fb4ca4f0 /src/cairo-spline.c | |
parent | 0540bf384aed344899417d3b0313bd6704679c1c (diff) | |
download | cairo-af9fbd176b145f042408ef5391eef2a51d7531f8.tar.gz |
Introduce a new compositor architecture
Having spent the last dev cycle looking at how we could specialize the
compositors for various backends, we once again look for the
commonalities in order to reduce the duplication. In part this is
motivated by the idea that spans is a good interface for both the
existent GL backend and pixman, and so they deserve a dedicated
compositor. xcb/xlib target an identical rendering system and so they
should be using the same compositor, and it should be possible to run
that same compositor locally against pixman to generate reference tests.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
P.S. This brings massive upheaval (read breakage) I've tried delaying in
order to fix as many things as possible but now this one patch does far,
far, far too much. Apologies in advance for breaking your favourite
backend, but trust me in that the end result will be much better. :)
Diffstat (limited to 'src/cairo-spline.c')
-rw-r--r-- | src/cairo-spline.c | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/src/cairo-spline.c b/src/cairo-spline.c index 2467178fd..34ad58560 100644 --- a/src/cairo-spline.c +++ b/src/cairo-spline.c @@ -36,15 +36,61 @@ #include "cairoint.h" +#include "cairo-box-private.h" #include "cairo-slope-private.h" cairo_bool_t +_cairo_spline_intersects (const cairo_point_t *a, + const cairo_point_t *b, + const cairo_point_t *c, + const cairo_point_t *d, + const cairo_box_t *box) +{ + cairo_box_t bounds; + + if (_cairo_box_contains_point (box, a) || + _cairo_box_contains_point (box, b) || + _cairo_box_contains_point (box, c) || + _cairo_box_contains_point (box, d)) + { + return TRUE; + } + + bounds.p2 = bounds.p1 = *a; + _cairo_box_add_point (&bounds, b); + _cairo_box_add_point (&bounds, c); + _cairo_box_add_point (&bounds, d); + + if (bounds.p2.x <= box->p1.x || bounds.p1.x >= box->p2.x || + bounds.p2.y <= box->p1.y || bounds.p1.y >= box->p2.y) + { + return FALSE; + } + +#if 0 /* worth refining? */ + bounds.p2 = bounds.p1 = *a; + _cairo_box_add_curve_to (&bounds, b, c, d); + if (bounds.p2.x <= box->p1.x || bounds.p1.x >= box->p2.x || + bounds.p2.y <= box->p1.y || bounds.p1.y >= box->p2.y) + { + return FALSE; + } +#endif + + return TRUE; +} + +cairo_bool_t _cairo_spline_init (cairo_spline_t *spline, cairo_spline_add_point_func_t add_point_func, void *closure, const cairo_point_t *a, const cairo_point_t *b, const cairo_point_t *c, const cairo_point_t *d) { + /* If both tangents are zero, this is just a straight line */ + if (a->x == b->x && a->y == b->y && c->x == d->x && c->y == d->y) + return FALSE; + spline->add_point_func = add_point_func; spline->closure = closure; @@ -69,6 +115,8 @@ _cairo_spline_init (cairo_spline_t *spline, else return FALSE; /* just treat this as a straight-line from a -> d */ + /* XXX if the initial, final and vector are all equal, this is just a line */ + return TRUE; } @@ -213,7 +261,6 @@ _cairo_spline_decompose (cairo_spline_t *spline, double tolerance) { cairo_spline_knots_t s1; cairo_status_t status; - cairo_slope_t slope; s1 = spline->knots; spline->last_point = s1.a; @@ -221,8 +268,8 @@ _cairo_spline_decompose (cairo_spline_t *spline, double tolerance) if (unlikely (status)) return status; - _cairo_slope_init (&slope, &spline->knots.c, &spline->knots.d); - return spline->add_point_func (spline->closure, &spline->knots.d, &slope); + return spline->add_point_func (spline->closure, + &spline->knots.d, &spline->final_slope); } /* Note: this function is only good for computing bounds in device space. */ |