diff options
author | Jeff Muizelaar <jmuizelaar@mozilla.com> | 2010-11-05 11:40:00 -0400 |
---|---|---|
committer | Jeff Muizelaar <jmuizelaar@mozilla.com> | 2010-11-05 11:40:00 -0400 |
commit | e9bb70d2dee4ef7a54e3971f09a08df30c2b5287 (patch) | |
tree | 905e60cb696a41fad498ef68f7ae7313306578b5 | |
parent | 91a6fe64236985d30f5794d760698deafd9e6511 (diff) |
Fix degenerate vertical path bounds.
6b77567b6ef28710c7707ab82c7fa95c810152d1 made vertical
path bounds with no area return extents of 0,0. This fixes
the problem by not assuming degenerate path bounds are 0,0
-rw-r--r-- | src/cairo-path-bounds.c | 4 | ||||
-rw-r--r-- | test/get-path-extents.c | 40 |
2 files changed, 35 insertions, 9 deletions
diff --git a/src/cairo-path-bounds.c b/src/cairo-path-bounds.c index d32c2607f..75308c6ec 100644 --- a/src/cairo-path-bounds.c +++ b/src/cairo-path-bounds.c | |||
@@ -331,7 +331,9 @@ _cairo_path_fixed_extents (const cairo_path_fixed_t *path, | |||
331 | 331 | ||
332 | if (! path->has_curve_to) { | 332 | if (! path->has_curve_to) { |
333 | *box = path->extents; | 333 | *box = path->extents; |
334 | return path->extents.p1.x < path->extents.p2.x; | 334 | /* empty extents should still have an origin and should not |
335 | * be {0, 0, 0, 0} */ | ||
336 | return path->extents.p1.x <= path->extents.p2.x; | ||
335 | } | 337 | } |
336 | 338 | ||
337 | _cairo_path_bounder_init (&bounder); | 339 | _cairo_path_bounder_init (&bounder); |
diff --git a/test/get-path-extents.c b/test/get-path-extents.c index a3e9554d1..3a05eff7a 100644 --- a/test/get-path-extents.c +++ b/test/get-path-extents.c | |||
@@ -61,10 +61,6 @@ check_extents (const cairo_test_context_t *ctx, | |||
61 | if (cairo_status (cr)) | 61 | if (cairo_status (cr)) |
62 | return 1; | 62 | return 1; |
63 | 63 | ||
64 | /* let empty rects match */ | ||
65 | if ((ext_x1 == ext_x2 || ext_y1 == ext_y2) && (width == 0 || height == 0)) | ||
66 | return 1; | ||
67 | |||
68 | switch (relation) { | 64 | switch (relation) { |
69 | default: | 65 | default: |
70 | case EQUALS: | 66 | case EQUALS: |
@@ -152,14 +148,16 @@ draw (cairo_t *cr, int width, int height) | |||
152 | phase = "Degenerate arc (R=0)"; | 148 | phase = "Degenerate arc (R=0)"; |
153 | errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0); | 149 | errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0); |
154 | errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 0, 0, 0, 0); | 150 | errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 0, 0, 0, 0); |
155 | errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 200, 400, 0, 0); | 151 | /*XXX: I'd expect these extents to be oriented at 200, 400 */ |
152 | errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 0, 0, 0, 0); | ||
156 | 153 | ||
157 | cairo_new_path (cr2); | 154 | cairo_new_path (cr2); |
158 | cairo_arc (cr2, 200, 400, 10., 0, 0); | 155 | cairo_arc (cr2, 200, 400, 10., 0, 0); |
159 | phase = "Degenerate arc (Θ=0)"; | 156 | phase = "Degenerate arc (Θ=0)"; |
160 | errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0); | 157 | errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0); |
161 | errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 0, 0, 0, 0); | 158 | errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 0, 0, 0, 0); |
162 | errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 200, 400, 0, 0); | 159 | /*XXX: I'd expect these extents to be oriented at 200, 400 */ |
160 | errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 0, 0, 0, 0); | ||
163 | 161 | ||
164 | cairo_new_path (cr2); | 162 | cairo_new_path (cr2); |
165 | cairo_restore (cr2); | 163 | cairo_restore (cr2); |
@@ -191,7 +189,7 @@ draw (cairo_t *cr, int width, int height) | |||
191 | cairo_restore (cr2); | 189 | cairo_restore (cr2); |
192 | 190 | ||
193 | /* http://bugs.freedesktop.org/show_bug.cgi?id=7965 */ | 191 | /* http://bugs.freedesktop.org/show_bug.cgi?id=7965 */ |
194 | phase = "A vertical, open path"; | 192 | phase = "A horizontal, open path"; |
195 | cairo_save (cr2); | 193 | cairo_save (cr2); |
196 | cairo_set_line_cap (cr2, CAIRO_LINE_CAP_ROUND); | 194 | cairo_set_line_cap (cr2, CAIRO_LINE_CAP_ROUND); |
197 | cairo_set_line_join (cr2, CAIRO_LINE_JOIN_ROUND); | 195 | cairo_set_line_join (cr2, CAIRO_LINE_JOIN_ROUND); |
@@ -199,7 +197,33 @@ draw (cairo_t *cr, int width, int height) | |||
199 | cairo_line_to (cr2, 750, 180); | 197 | cairo_line_to (cr2, 750, 180); |
200 | errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0); | 198 | errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0); |
201 | errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, -5, 175, 760, 10); | 199 | errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, -5, 175, 760, 10); |
202 | errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 0, 180, 755, 0); | 200 | errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 0, 180, 750, 0); |
201 | cairo_new_path (cr2); | ||
202 | cairo_restore (cr2); | ||
203 | |||
204 | phase = "A vertical, open path"; | ||
205 | cairo_save (cr2); | ||
206 | cairo_set_line_cap (cr2, CAIRO_LINE_CAP_ROUND); | ||
207 | cairo_set_line_join (cr2, CAIRO_LINE_JOIN_ROUND); | ||
208 | cairo_new_path (cr2); | ||
209 | cairo_move_to (cr2, 180, 0); | ||
210 | cairo_line_to (cr2, 180, 750); | ||
211 | errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0); | ||
212 | errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 175, -5, 10, 760); | ||
213 | errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 180, 0, 0, 750); | ||
214 | cairo_new_path (cr2); | ||
215 | cairo_restore (cr2); | ||
216 | |||
217 | phase = "A degenerate open path"; | ||
218 | cairo_save (cr2); | ||
219 | cairo_set_line_cap (cr2, CAIRO_LINE_CAP_ROUND); | ||
220 | cairo_set_line_join (cr2, CAIRO_LINE_JOIN_ROUND); | ||
221 | cairo_new_path (cr2); | ||
222 | cairo_move_to (cr2, 180, 0); | ||
223 | cairo_line_to (cr2, 180, 0); | ||
224 | errors += !check_extents (ctx, phase, cr2, FILL, EQUALS, 0, 0, 0, 0); | ||
225 | errors += !check_extents (ctx, phase, cr2, STROKE, EQUALS, 175, -5, 10, 10); | ||
226 | errors += !check_extents (ctx, phase, cr2, PATH, EQUALS, 180, 0, 0, 0); | ||
203 | cairo_new_path (cr2); | 227 | cairo_new_path (cr2); |
204 | cairo_restore (cr2); | 228 | cairo_restore (cr2); |
205 | 229 | ||