diff options
author | Carl Worth <cworth@cworth.org> | 2006-08-18 07:56:52 -0700 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2006-08-18 07:59:20 -0700 |
commit | 861f1cb4f70cdbd7702eaf642b999a21ad01037d (patch) | |
tree | 1ee7897c5599231ea106fbdd0695a060445684de | |
parent | c2d92d4397f7ed7a8b7fdfa24a4e339ecb0d6d69 (diff) | |
parent | fbb1758ba8384650157b2bbbc93d161b0c2a05f0 (diff) |
Merge branch 'jrmuizel-stroking-fixes' into cairo
Conflicts:
test/dash-caps-joins-ps-argb32-ref.png
test/degenerate-path-ps-argb32-ref.png
test/degenerate-path.c
-rw-r--r-- | ROADMAP | 1 | ||||
-rw-r--r-- | src/cairo-path-stroke.c | 3 | ||||
-rw-r--r-- | test/dash-caps-joins-ps-argb32-ref.png | bin | 2189 -> 3854 bytes | |||
-rw-r--r-- | test/dash-caps-joins-ref.png | bin | 2583 -> 4680 bytes | |||
-rw-r--r-- | test/dash-caps-joins.c | 45 | ||||
-rw-r--r-- | test/degenerate-path-ps-argb32-ref.png | bin | 264 -> 303 bytes | |||
-rw-r--r-- | test/degenerate-path-ref.png | bin | 193 -> 216 bytes | |||
-rw-r--r-- | test/degenerate-path-rgb24-ref.png | bin | 174 -> 189 bytes | |||
-rw-r--r-- | test/degenerate-path.c | 54 |
9 files changed, 75 insertions, 28 deletions
@@ -39,6 +39,7 @@ cairo-1.2.4 (August 21, 2006): Fix build bugs with 1.2.2 ✓- source-clip-scale - PS/PDF Type1/Type3 problem with rotated font_matrices ✓- close_path behavior (T Rowley's mail) +✓- degenerate-path dashing fixes cairo-1.4 (October 2006): Better performance - New tessellator diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c index 051d06899..792fbfa06 100644 --- a/src/cairo-path-stroke.c +++ b/src/cairo-path-stroke.c @@ -699,6 +699,8 @@ _cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point) cairo_point_t *p2 = point; cairo_slope_t slope; + stroker->has_sub_path = stroker->dash_on; + if (p1->x == p2->x && p1->y == p2->y) return CAIRO_STATUS_SUCCESS; @@ -758,6 +760,7 @@ _cairo_stroker_line_to_dashed (void *closure, cairo_point_t *point) return status; } } + stroker->has_sub_path = TRUE; } if (remain) { /* diff --git a/test/dash-caps-joins-ps-argb32-ref.png b/test/dash-caps-joins-ps-argb32-ref.png Binary files differindex 68d2c6d47..513fb681d 100644 --- a/test/dash-caps-joins-ps-argb32-ref.png +++ b/test/dash-caps-joins-ps-argb32-ref.png diff --git a/test/dash-caps-joins-ref.png b/test/dash-caps-joins-ref.png Binary files differindex 9218ae499..ec1f2f7d3 100644 --- a/test/dash-caps-joins-ref.png +++ b/test/dash-caps-joins-ref.png diff --git a/test/dash-caps-joins.c b/test/dash-caps-joins.c index 722a59d2e..370d05dd5 100644 --- a/test/dash-caps-joins.c +++ b/test/dash-caps-joins.c @@ -41,7 +41,7 @@ cairo_test_t test = { "dash-caps-joins", "Test caps and joins when dashing", 3 * (PAD + SIZE) + PAD, - PAD + SIZE + PAD, + PAD + SIZE + PAD + SIZE + PAD, draw }; @@ -62,6 +62,8 @@ static cairo_test_status_t draw (cairo_t *cr, int width, int height) { double dash[] = {LINE_WIDTH, 1.5 * LINE_WIDTH}; + double dash_offset = -2 * LINE_WIDTH; + int i; /* We draw in the default black, so paint white first. */ cairo_save (cr); @@ -69,29 +71,36 @@ draw (cairo_t *cr, int width, int height) cairo_paint (cr); cairo_restore (cr); - cairo_set_line_width (cr, LINE_WIDTH); - cairo_set_dash (cr, dash, sizeof(dash)/sizeof(dash[0]), - 2 * LINE_WIDTH); + for (i=0; i<2; i++) { + cairo_save (cr); + cairo_set_line_width (cr, LINE_WIDTH); + cairo_set_dash (cr, dash, sizeof(dash)/sizeof(dash[0]), dash_offset); - cairo_translate (cr, PAD, PAD); + cairo_translate (cr, PAD, PAD); - make_path (cr); - cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT); - cairo_set_line_join (cr, CAIRO_LINE_JOIN_BEVEL); - cairo_stroke (cr); + make_path (cr); + cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT); + cairo_set_line_join (cr, CAIRO_LINE_JOIN_BEVEL); + cairo_stroke (cr); - cairo_translate (cr, SIZE + PAD, 0.); + cairo_translate (cr, SIZE + PAD, 0.); - make_path (cr); - cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); - cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND); - cairo_stroke (cr); + make_path (cr); + cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); + cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND); + cairo_stroke (cr); - cairo_translate (cr, SIZE + PAD, 0.); + cairo_translate (cr, SIZE + PAD, 0.); - make_path (cr); - cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); - cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER); - cairo_stroke (cr); + make_path (cr); + cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); + cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER); + cairo_stroke (cr); + + cairo_restore (cr); + cairo_translate (cr, 0., SIZE + PAD); + dash_offset = 0; + } return CAIRO_TEST_SUCCESS; } diff --git a/test/degenerate-path-ps-argb32-ref.png b/test/degenerate-path-ps-argb32-ref.png Binary files differindex 4b3d8e330..bd3c8c6fc 100644 --- a/test/degenerate-path-ps-argb32-ref.png +++ b/test/degenerate-path-ps-argb32-ref.png diff --git a/test/degenerate-path-ref.png b/test/degenerate-path-ref.png Binary files differindex 1b07de4e7..82095fdcf 100644 --- a/test/degenerate-path-ref.png +++ b/test/degenerate-path-ref.png diff --git a/test/degenerate-path-rgb24-ref.png b/test/degenerate-path-rgb24-ref.png Binary files differindex 29f4089e6..54fff7fff 100644 --- a/test/degenerate-path-rgb24-ref.png +++ b/test/degenerate-path-rgb24-ref.png diff --git a/test/degenerate-path.c b/test/degenerate-path.c index 964500fc4..2c1e4c221 100644 --- a/test/degenerate-path.c +++ b/test/degenerate-path.c @@ -25,41 +25,75 @@ #include "cairo-test.h" -#define IMAGE_WIDTH 40 -#define IMAGE_HEIGHT 22 +#define PAD 3.0 +#define LINE_WIDTH 6.0 + +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) static cairo_test_draw_function_t draw; cairo_test_t test = { "degenerate-path", "Tests the behaviour of degenerate paths with different cap types", - IMAGE_WIDTH, IMAGE_HEIGHT, + 3*(PAD+LINE_WIDTH+PAD), 6*(LINE_WIDTH+PAD) + PAD, draw }; -#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) - static cairo_test_status_t draw (cairo_t *cr, int width, int height) { const cairo_line_cap_t cap[] = { CAIRO_LINE_CAP_ROUND, CAIRO_LINE_CAP_SQUARE, CAIRO_LINE_CAP_BUTT }; size_t i; + double dash[] = {2, 2}; cairo_set_source_rgb (cr, 1, 0, 0); for (i=0; i<ARRAY_SIZE(cap); i++) { + cairo_save (cr); + cairo_set_line_cap (cr, cap[i]); - cairo_set_line_width (cr, 6); - cairo_move_to (cr, 6, 6); - cairo_line_to (cr, 6, 6); + /* simple degenerate paths */ + cairo_set_line_width (cr, LINE_WIDTH); + cairo_move_to (cr, LINE_WIDTH, LINE_WIDTH); + cairo_line_to (cr, LINE_WIDTH, LINE_WIDTH); + cairo_stroke (cr); + + cairo_translate (cr, 0, 3*PAD); + cairo_move_to (cr, LINE_WIDTH, LINE_WIDTH); + cairo_close_path (cr); + cairo_stroke (cr); + + /* degenerate paths starting with dash on */ + cairo_set_dash (cr, dash, 2, 0.); + + cairo_translate (cr, 0, 3*PAD); + cairo_move_to (cr, LINE_WIDTH, LINE_WIDTH); + cairo_line_to (cr, LINE_WIDTH, LINE_WIDTH); cairo_stroke (cr); - cairo_move_to (cr, 6, 15); + cairo_translate (cr, 0, 3*PAD); + cairo_move_to (cr, LINE_WIDTH, LINE_WIDTH); cairo_close_path (cr); cairo_stroke (cr); - cairo_translate (cr, 12, 0); + /* degenerate paths starting with dash off */ + /* these should not draw anything */ + cairo_set_dash (cr, dash, 2, 2.); + + cairo_translate (cr, 0, 3*PAD); + cairo_move_to (cr, LINE_WIDTH, LINE_WIDTH); + cairo_line_to (cr, LINE_WIDTH, LINE_WIDTH); + cairo_stroke (cr); + + cairo_translate (cr, 0, 3*PAD); + cairo_move_to (cr, LINE_WIDTH, LINE_WIDTH); + cairo_close_path (cr); + cairo_stroke (cr); + + cairo_restore (cr); + + cairo_translate (cr, PAD+LINE_WIDTH+PAD, 0); } return CAIRO_TEST_SUCCESS; } |