From 00d7b6acdd263f7b46ea98c4a5b777fc93a65be5 Mon Sep 17 00:00:00 2001 From: M Joonas Pihlaja Date: Tue, 5 Dec 2006 11:21:14 +0200 Subject: [PATCH] test: tessellator event comparator test case for degenerate edges. There's currently a regression bug in the tessellation code from switching to the new tessellator. The bug is caused by confusion in the comparator used to order events when there are degenerate edges. This test is derived from the zrusin-another performance test case. --- test/Makefile.am | 3 + test/fill-degenerate-sort-order-ref.png | Bin 0 -> 643 bytes test/fill-degenerate-sort-order-rgb24-ref.png | Bin 0 -> 611 bytes test/fill-degenerate-sort-order.c | 110 ++++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 test/fill-degenerate-sort-order-ref.png create mode 100644 test/fill-degenerate-sort-order-rgb24-ref.png create mode 100644 test/fill-degenerate-sort-order.c diff --git a/test/Makefile.am b/test/Makefile.am index 8033ce81d..ef358522d 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -32,6 +32,7 @@ extend-reflect \ fill-and-stroke \ fill-and-stroke-alpha \ fill-and-stroke-alpha-add \ +fill-degenerate-sort-order \ fill-rule \ filter-nearest-offset \ font-face-get-type \ @@ -216,6 +217,8 @@ fill-and-stroke-ps-argb32-ref.png \ fill-and-stroke-alpha-ref.png \ fill-and-stroke-alpha-svg-ref.png \ fill-and-stroke-alpha-add-ref.png \ +fill-degenerate-sort-order-ref.png \ +fill-degenerate-sort-order-rgb24-ref.png \ fill-rule-ref.png \ fill-rule-rgb24-ref.png \ fill-rule-ps-argb32-ref.png \ diff --git a/test/fill-degenerate-sort-order-ref.png b/test/fill-degenerate-sort-order-ref.png new file mode 100644 index 0000000000000000000000000000000000000000..ca1f575b710efbca862f81e0443bebf1c0143f83 GIT binary patch literal 643 zcmeAS@N?(olHy`uVBq!ia0vp^`+&HDgAGXf9Q7~(Qfx`y?k)`fL2$v|<&%LT>?NMQ zuI$%%SUGuF4LW|lVPIfV^>lFzshIQj?m@rD1|kj@#XkPu&%4GHF!rY|a^EM}k zKh%D$S~cY~D+5Es$**tt3$|=O{q*ho`RfnfKj>9gJx~AqPYVOHhm%!mCdHlq$8f&P zn%QW(``qQy^HsotE&h`}cnaBh9#YTTX*;$0{^whFB~Rb`yk#}BG*~LCF1&rG%+~0q z$J9N4sBq3-@-n^V_qRW7F#XHsf0RG_{hiF~HR&eiAY*{4e9a$M=bu;J@eyk9F3I^j zdq4F&gBkJgdw|CTCT>Kd1bc8E` zO6Km1wmV&YfBlv3pWUtPfB)Fv2zJ=v@=~|ioHx^_V$)+=dp>3A_kH$TZ@oL0^E^GA z-HZb*0Qm18pZ|8R{`}B$=X;@Ha=6z1-N7{NBGm^P_JlfXuse^?pmx6G%|XGcYu~+{>JB*y{>U TVweIj4KaAS`njxgN@xNA!6!K( literal 0 HcmV?d00001 diff --git a/test/fill-degenerate-sort-order-rgb24-ref.png b/test/fill-degenerate-sort-order-rgb24-ref.png new file mode 100644 index 0000000000000000000000000000000000000000..999a09a38931daadc75232957b34a631458796bf GIT binary patch literal 611 zcmeAS@N?(olHy`uVBq!ia0vp^`+&HDg9%6;UVc9rNUq+-t7y9a}A8;CdrzWDOLerDcF1BasIqyFbCSL;Qv z6h4nsp84q;8$&_t`}F#TM~^S>-~NYi+xtTUM-H zyV6-jR_UdHXS;`$%O%B0d>3D6FQ`5*?N)Dm_|B$n?>0m@fy8e;yTg{*G3ZnAy zH>-Q6Z?-};_uhVObLf3~?bf{aFa^rrtj-mcr9hPfc`~mptKEYkwphJg^?YW!<@$p8 zTa#@6%87YLPrtRv(E2d`&d-(n6&rWXI6Fn uzJK>qrcD63=-%GR-pP=FWMKGk)IMv9>hl64zoo!5!r + */ + +/* Bug history + * + * 2006-12-05 M Joonas Pihlaja + * + * There's currently a regression bug in the tessellation code from + * switching to the "new tessellator". The bug is caused by + * confusion in the comparator used to order events when there are + * degenerate edges. + */ + +#include "cairo-test.h" + +static cairo_test_draw_function_t draw; + +cairo_test_t test = { + "fill-degenerate-sort-order", + "Tests the tessellator's event comparator with degenerate input", + 190, 120, + draw +}; + +/* Derived from zrusin's "another" polygon in the performance suite. */ +static cairo_test_status_t +draw (cairo_t *cr_orig, int width, int height) +{ + /* XXX: I wanted to be able to simply fill the nasty path to the + * surface and then use a reference image to catch bugs, but the + * renderer used when testing the postscript backend gets the + * degeneracy wrong, thus leading to an (unfixable?) test case + * failure. Are external renderer bugs our bugs too? Instead, + * tessellate the polygon and render to the surface the results of + * point sampling the tessellated path. If there would be a way + * to XFAIL only some backends we could do that for the .ps + * backend only. */ + int x,y; + int sample_stride; + cairo_surface_t *surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height); + cairo_t *cr = cairo_create (surf); + cairo_set_source_rgb (cr_orig, 1, 0, 0); + + /* The polygon uses (43,103) as its "base point". Closed + * subpaths are simulated by going from the base point to the + * subpath's first point, doing the subpath, and returning to the + * base point. The moving to and from the base point causes + * degenerate edges which shouldn't result in anything visible. */ + cairo_move_to (cr, 43, 103); + + /* First subpath. */ + cairo_line_to (cr, 91, 101); + cairo_line_to (cr, 0, 112); + cairo_line_to (cr, 60, 0); + cairo_line_to (cr, 91, 101); + + cairo_line_to (cr, 43, 103); + + /* Second subpath. */ + cairo_line_to (cr, 176, 110); + cairo_line_to (cr, 116, 100); + cairo_line_to (cr, 176, 0); + cairo_line_to (cr, 176, 110); + + cairo_close_path (cr); + + /* Point sample the tessellated path. The x and y starting offsets + * are chosen to hit the nasty bits while still being able to do a + * relatively sparse sampling. */ + sample_stride = 4; + for (y = 0; y < height; y += sample_stride) { + for (x = 0; x < width; x += sample_stride) { + if (cairo_in_fill (cr, x, y)) { + cairo_rectangle(cr_orig, x, y, sample_stride, sample_stride); + cairo_fill (cr_orig); + } + } + } + cairo_destroy (cr); + cairo_surface_destroy (surf); + return CAIRO_TEST_SUCCESS; +} + +int +main (void) +{ + return cairo_test (&test); +}