From 30eac7b2c5a3a2a9c5de4886cdd38666ef19cddb Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 29 Sep 2011 00:22:34 +0100 Subject: [PATCH] test: Add line-width-large-overlap Exercise the case of stroking a box with a pen wider than the box itself, a variation on line-width-overlap suggested by Paulo Zanoni. Signed-off-by: Chris Wilson --- test/Makefile.sources | 1 + test/line-width-large-overlap.c | 149 ++++++++++++++++++ ...clip-fill-nz-unbounded.traps.rgb24.ref.png | Bin 0 -> 3198 bytes .../line-width-large-overlap-dashed.ref.png | Bin 0 -> 338 bytes .../line-width-large-overlap-dashed.xfail.png | Bin 0 -> 343 bytes .../line-width-large-overlap-flipped.ref.png | Bin 0 -> 305 bytes .../line-width-large-overlap-flopped.ref.png | Bin 0 -> 305 bytes .../line-width-large-overlap-offset.ref.png | Bin 0 -> 305 bytes ...e-width-large-overlap-rotated.base.ref.png | Bin 0 -> 404 bytes .../line-width-large-overlap-rotated.ref.png | Bin 0 -> 406 bytes ...-width-large-overlap-rotated.traps.ref.png | Bin 0 -> 404 bytes .../line-width-large-overlap.ref.png | Bin 0 -> 305 bytes ...-width-overlap-offset.traps.argb32.ref.png | Bin 408 -> 0 bytes .../line-width-overlap-offset.traps.ref.png | Bin 0 -> 365 bytes ...e-width-overlap-offset.traps.rgb24.ref.png | Bin 408 -> 0 bytes 15 files changed, 150 insertions(+) create mode 100644 test/line-width-large-overlap.c create mode 100644 test/reference/clip-fill-nz-unbounded.traps.rgb24.ref.png create mode 100644 test/reference/line-width-large-overlap-dashed.ref.png create mode 100644 test/reference/line-width-large-overlap-dashed.xfail.png create mode 100644 test/reference/line-width-large-overlap-flipped.ref.png create mode 100644 test/reference/line-width-large-overlap-flopped.ref.png create mode 100644 test/reference/line-width-large-overlap-offset.ref.png create mode 100644 test/reference/line-width-large-overlap-rotated.base.ref.png create mode 100644 test/reference/line-width-large-overlap-rotated.ref.png create mode 100644 test/reference/line-width-large-overlap-rotated.traps.ref.png create mode 100644 test/reference/line-width-large-overlap.ref.png delete mode 100644 test/reference/line-width-overlap-offset.traps.argb32.ref.png create mode 100644 test/reference/line-width-overlap-offset.traps.ref.png delete mode 100644 test/reference/line-width-overlap-offset.traps.rgb24.ref.png diff --git a/test/Makefile.sources b/test/Makefile.sources index f9aa66ccf..5ef777aaa 100644 --- a/test/Makefile.sources +++ b/test/Makefile.sources @@ -169,6 +169,7 @@ test_sources = \ leaky-dashed-stroke.c \ leaky-polygon.c \ line-width.c \ + line-width-large-overlap.c \ line-width-overlap.c \ line-width-scale.c \ line-width-tolerance.c \ diff --git a/test/line-width-large-overlap.c b/test/line-width-large-overlap.c new file mode 100644 index 000000000..767734f6b --- /dev/null +++ b/test/line-width-large-overlap.c @@ -0,0 +1,149 @@ +/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ +/* + * Copyright 2011 Red Hat Inc. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Author: Benjamin Otte + */ + +/* + * Test case taken from the WebKit test suite, failure originally reported + * by Zan Dobersek . WebKit test is + * LayoutTests/canvas/philip/tests/2d.path.rect.selfintersect.html + */ + +#include "cairo-test.h" + +#include + +#define LINE_WIDTH 120 +#define SIZE 100 +#define RECT_SIZE 10 + +static cairo_test_status_t +draw (cairo_t *cr, int width, int height) +{ + /* fill with green so RGB and RGBA tests can share the ref image */ + cairo_set_source_rgb (cr, 0, 1, 0); + cairo_paint (cr); + + /* red to see eventual bugs immediately */ + cairo_set_source_rgb (cr, 1, 0, 0); + + /* big line width */ + cairo_set_line_width (cr, LINE_WIDTH); + + /* rectangle that is smaller than the line width in center of image */ + cairo_rectangle (cr, + (SIZE - RECT_SIZE) / 2, + (SIZE - RECT_SIZE) / 2, + RECT_SIZE, + RECT_SIZE); + + cairo_stroke (cr); + + return CAIRO_TEST_SUCCESS; +} + +/* and again slightly offset to trigger another path */ +static cairo_test_status_t +draw_offset (cairo_t *cr, int width, int height) +{ + cairo_translate (cr, .5, .5); + return draw (cr, width, height); +} + +static cairo_test_status_t +draw_rotated (cairo_t *cr, int width, int height) +{ + cairo_translate (cr, SIZE/2, SIZE/2); + cairo_rotate (cr, M_PI/4); + cairo_translate (cr, -SIZE/2, -SIZE/2); + + return draw (cr, width, height); +} + +static cairo_test_status_t +draw_flipped (cairo_t *cr, int width, int height) +{ + cairo_translate (cr, SIZE/2, SIZE/2); + cairo_scale (cr, -1, 1); + cairo_translate (cr, -SIZE/2, -SIZE/2); + + return draw (cr, width, height); +} + +static cairo_test_status_t +draw_flopped (cairo_t *cr, int width, int height) +{ + cairo_translate (cr, SIZE/2, SIZE/2); + cairo_scale (cr, 1, -1); + cairo_translate (cr, -SIZE/2, -SIZE/2); + + return draw (cr, width, height); +} + +static cairo_test_status_t +draw_dashed (cairo_t *cr, int width, int height) +{ + const double dashes[] = { 4 }; + cairo_set_dash (cr, dashes, 1, 0); + cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT); + return draw (cr, width, height); +} + +CAIRO_TEST (line_width_large_overlap, + "Test overlapping lines due to large line width", + "stroke", /* keywords */ + NULL, /* requirements */ + SIZE, SIZE, + NULL, draw) +CAIRO_TEST (line_width_large_overlap_offset, + "Test overlapping lines due to large line width", + "stroke", /* keywords */ + NULL, /* requirements */ + SIZE, SIZE, + NULL, draw_offset) +CAIRO_TEST (line_width_large_overlap_rotated, + "Test overlapping lines due to large line width", + "stroke", /* keywords */ + NULL, /* requirements */ + SIZE, SIZE, + NULL, draw_rotated) +CAIRO_TEST (line_width_large_overlap_flipped, + "Test overlapping lines due to large line width", + "stroke", /* keywords */ + NULL, /* requirements */ + SIZE, SIZE, + NULL, draw_flipped) +CAIRO_TEST (line_width_large_overlap_flopped, + "Test overlapping lines due to large line width", + "stroke", /* keywords */ + NULL, /* requirements */ + SIZE, SIZE, + NULL, draw_flopped) +CAIRO_TEST (line_width_large_overlap_dashed, + "Test overlapping lines due to large line width", + "stroke", /* keywords */ + NULL, /* requirements */ + SIZE, SIZE, + NULL, draw_dashed) diff --git a/test/reference/clip-fill-nz-unbounded.traps.rgb24.ref.png b/test/reference/clip-fill-nz-unbounded.traps.rgb24.ref.png new file mode 100644 index 0000000000000000000000000000000000000000..1ad0b176beab61c36b770cb44e02f25ecf8b7756 GIT binary patch literal 3198 zcmbVPS5On$7DW*e2`D{OY0`_d0Mdj|3=nGYic~?G1Vwray@`M&6a}vei9||JLhphU zDWQZKQJPXC5Df$g23~yS@6G#obISTSbM{)Z_nLj?+_$r_;5aLEmWhdp19H{Wfq_wf z)|r!xz2S688Us#ySy`Ae9se1x+A&BbCV&RS)EE}^eCuySFzRCL_u?6<{vn4Q4)7+$SaZdBl%->$dy{ z*hP6$*o-YqqSzoJ%4(Kv()6!)RAVD!TSq%S|+K=h1ttv%|mZiKz!+#>LKqRRRyaTfD#Kod`&nS3kI z@M@b|M_Ca^ey)G7GFd1N-BPJ^or7a(&;*>O*w7Ky({HLS4apqLW za)#fY;%S^GYS+W{j8T%u`o9h}P#EI|_zxfKNdZaPtOmPSq9TFj`Z3Y*a$V*!5Fg{a z%kA9Ca=WJ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bFTQZaNw0^5fi@h2b=E_;l`a@{;Hs+1%gS2Y+ZnUG%r`P% zf=eyxH|?W8mGeAy@^RSyoMz||Y%E{A8-?n7_Mimr0L`YmKQbetF|94h%CF&sSoX7$ zw3+SC&s^++#do~=Z4dR*_bxmQR@r!4l2K_uwl1( zJr5dFq8-&!@)TMm`qOH8V2>2rt+g*r`DQ_qYFSZn1;XWhknU|UPHy=OR=(j|!OnS5 zTKGEBS-x0PO9N+uxb#->289*XA~_AX^M(=5j0B^mGptmgi2aPIBb-XdLHN{ma15;r z>~1gZ2W8r$)YW;&)k9KJ8E?K-OFdRpjgw28lJh}wPPBmksTPa4{{!4QWRoIMDLgi8iYpJ z)6o^ZFEKd>ZzG32+8-=fRlcn#a^}^&$C)}JosWZH(Egu;)bgMT$w@76MkN?Ma;oO9b~x1Q(psoz<9(r^4dq29H)UnVGV2W? zpxroJzc|e5l2&Nm%v>04Hxq*Nx_iOYcH_+R!<8;e;-K9K<^xbS`e(xvZVvoJz4@~f z35i-uGs`|i^h)4NR#SEw5nYyhdHE8Gxk`R?R?S%9_?jQG0Q$0HFLl)x%u=INJo(Ig zKYp(L`_zCF4_d>AgoCj6E{^YQ5-`2UbSyPeJ`{`4U1Whcz&9D~2N2IKyd{$N% zEiYXQ6V;v&^ZUnZmj)oQoi^^VTPOzL*RgUEETimhJQ=oT_P}0ECsb9b8XgXltHXtY z9t`#1*O}HfH$fxMkSbKS%H5tG+3hyRZzZbXyLp_#J6FpqajEg0ol7~|x!Yf2+iGf> zYbn2{DofsW9y~$bwSo)`3_ox5GNTUW7sS!=Im2~q`^B~Y^Wptrl&HzmQyaxC!1z!w NLCkDSt4%zU{{fb(NEiSB literal 0 HcmV?d00001 diff --git a/test/reference/line-width-large-overlap-dashed.ref.png b/test/reference/line-width-large-overlap-dashed.ref.png new file mode 100644 index 0000000000000000000000000000000000000000..e6cdcc2f7578eb5e364aa8b9603146340c46bccf GIT binary patch literal 338 zcmeAS@N?(olHy`uVBq!ia0vp^DImL3ftfl8njf>}QzyI+=^>4=bAe{gj zz=CUXR=QU<9hfP5`Ir6F>UkG*Z`Pk?^4@pTd<)#R3-w|dkqaVd0UxmK;Njn|xxFY0 P7)T7Bu6{1-oD!M<{=t2Z literal 0 HcmV?d00001 diff --git a/test/reference/line-width-large-overlap-dashed.xfail.png b/test/reference/line-width-large-overlap-dashed.xfail.png new file mode 100644 index 0000000000000000000000000000000000000000..8cd4d31e151e72f619b9943153c20cd772e2e7a8 GIT binary patch literal 343 zcmeAS@N?(olHy`uVBq!ia0vp^DIm|r#^2_gyO7fO{j&Iv*VV0gC;pg6CY+c(ci~B*J>Uq-H3z8aX0r_jD Wa33vpst^N)6oaR$pUXO@geCxrfOPu+ literal 0 HcmV?d00001 diff --git a/test/reference/line-width-large-overlap-flipped.ref.png b/test/reference/line-width-large-overlap-flipped.ref.png new file mode 100644 index 0000000000000000000000000000000000000000..3c3464bed87bd0bf7cf0cbcf601f2a77fbaeb8e5 GIT binary patch literal 305 zcmeAS@N?(olHy`uVBq!ia0vp^DIm2C3ipImdKI;Vst0N`7b*8l(j literal 0 HcmV?d00001 diff --git a/test/reference/line-width-large-overlap-rotated.ref.png b/test/reference/line-width-large-overlap-rotated.ref.png new file mode 100644 index 0000000000000000000000000000000000000000..8ffa0db6db34cb14fec3d17cfe3722d16a1e78c5 GIT binary patch literal 406 zcmeAS@N?(olHy`uVBq!ia0vp^DIm?q)H@u;BU(g3#98D0y7FSDiwa49|%j9@x)bKmcaCqMn3m0>QqH)FGG zvef6B@_usnkJQ-p9Pc+S|GfD6^ta~s%J#iGe)%_-PSEr{9<2I72fIT)D2eXL`#E(( zUEll8-I*D=yVr{ESeDQ__+eT8@3rAOCe7nd=7~S4bM}3>(Q)Ru(?RwTd!{Y@m-I1e u!mswDuP0rR>AoJha&m2C3ipImdKI;Vst0N`7b*8l(j literal 0 HcmV?d00001 diff --git a/test/reference/line-width-large-overlap.ref.png b/test/reference/line-width-large-overlap.ref.png new file mode 100644 index 0000000000000000000000000000000000000000..3c3464bed87bd0bf7cf0cbcf601f2a77fbaeb8e5 GIT binary patch literal 305 zcmeAS@N?(olHy`uVBq!ia0vp^DIm8N0Wx z`JGcJQ>8fbMfaEQzbk%UtetoFOF`o~0TFIm!iY7cH`BWx-?2-$k(9f6?WaHM)Fs~W zIHLHe;cr~(y<;zT-PUuzkyfF%HR69vI!6~Pc38()Dld8TXUx@4z@TREboFyt=akR{ E0Ku(}SO5S3 diff --git a/test/reference/line-width-overlap-offset.traps.ref.png b/test/reference/line-width-overlap-offset.traps.ref.png new file mode 100644 index 0000000000000000000000000000000000000000..13a138b9a155d3d5f5d9dc3820b8f85a4ba7106a GIT binary patch literal 365 zcmeAS@N?(olHy`uVBq!ia0vp^DImBwm;5Y~OoaEc@QEzXzN5-OO%^uyqd584S?iV!QljGrjZuxt52_ m`k$x1-+1&_F>c3wU<*j*KW=tmkrgof7(8A5T-G@yGywo93VK2S literal 0 HcmV?d00001 diff --git a/test/reference/line-width-overlap-offset.traps.rgb24.ref.png b/test/reference/line-width-overlap-offset.traps.rgb24.ref.png deleted file mode 100644 index cf8495bbb62f42808b10ff112c7566175211ba32..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 408 zcmeAS@N?(olHy`uVBq!ia0vp^DIm8N0Wx z`JGcJQ>8fbMfaEQzbk%UtetoFOF`o~0TFIm!iY7cH`BWx-?2-$k(9f6?WaHM)Fs~W zIHLHe;cr~(y<;zT-PUuzkyfF%HR69vI!6~Pc38()Dld8TXUx@4z@TREboFyt=akR{ E0Ku(}SO5S3