From 2edd2adafc471f4aa9c417d4bc76cc38466a9ed0 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 19 Jan 2010 22:45:59 +0000 Subject: [PATCH] test: Exercise scan converters with large rounded rectangles. Having added a specialised scan converter on the premise that it should be better at handling rounded rectangles, ensure that they are indeed rendered correctly. --- test/Makefile.am | 2 + test/Makefile.sources | 2 + test/rounded-rectangle-fill.c | 65 +++++++++++++++++++++ test/rounded-rectangle-fill.xlib.ref.png | Bin 0 -> 890 bytes test/rounded-rectangle-stroke.c | 64 ++++++++++++++++++++ test/rounded-rectangle-stroke.xlib.ref.png | Bin 0 -> 860 bytes 6 files changed, 133 insertions(+) create mode 100644 test/rounded-rectangle-fill.c create mode 100644 test/rounded-rectangle-fill.xlib.ref.png create mode 100644 test/rounded-rectangle-stroke.c create mode 100644 test/rounded-rectangle-stroke.xlib.ref.png diff --git a/test/Makefile.am b/test/Makefile.am index 5f3f42908..607402860 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -836,6 +836,8 @@ REFERENCE_IMAGES = \ rotated-clip.ref.png \ rotated-clip.ps.ref.png \ rotated-clip.xlib.ref.png \ + rounded-rectangle-fill.xlib.ref.png \ + rounded-rectangle-stroke.xlib.ref.png \ scale-down-source-surface-paint.ref.png \ scale-offset-image.gl.ref.png \ scale-offset-image.pdf.argb32.ref.png \ diff --git a/test/Makefile.sources b/test/Makefile.sources index d90f04a1c..69628b0d6 100644 --- a/test/Makefile.sources +++ b/test/Makefile.sources @@ -182,6 +182,8 @@ test_sources = \ rgb24-ignore-alpha.c \ rotate-image-surface-paint.c \ rotated-clip.c \ + rounded-rectangle-fill.c \ + rounded-rectangle-stroke.c \ scale-down-source-surface-paint.c \ scale-offset-image.c \ scale-offset-similar.c \ diff --git a/test/rounded-rectangle-fill.c b/test/rounded-rectangle-fill.c new file mode 100644 index 000000000..d211cf626 --- /dev/null +++ b/test/rounded-rectangle-fill.c @@ -0,0 +1,65 @@ +/* + * Copyright © 2009 Chris Wilson + * + * 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: Chris Wilson + */ + +#include "cairo-test.h" + +#define SIZE 80 + +/* A very simple test to exercise the scan rasterisers with constant regions. */ + +static void +rounded_rectangle (cairo_t *cr, int x, int y, int w, int h, int r) +{ + cairo_new_sub_path (cr); + cairo_arc (cr, x + r, y + r, r, M_PI, 3 * M_PI / 2); + cairo_arc (cr, x + w - r, y + r, r, 3 *M_PI / 2, 2 * M_PI); + cairo_arc (cr, x + w - r, y + h - r, r, 0, M_PI / 2); + cairo_arc (cr, x + r, y + h - r, r, M_PI / 2, M_PI); + cairo_close_path (cr); +} + +static cairo_test_status_t +draw (cairo_t *cr, int width, int height) +{ + /* Paint background white, then draw in black. */ + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */ + cairo_paint (cr); + cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); /* black */ + + cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); + rounded_rectangle (cr, 5, 5, width-10, height-10, 15); + rounded_rectangle (cr, 15, 15, width-30, height-30, 5); + cairo_fill (cr); + + return CAIRO_TEST_SUCCESS; +} + +CAIRO_TEST (rounded_rectangle_fill, + "Tests handling of rounded rectangles, the UI designers favourite", + "fill, rounded-rectangle", /* keywords */ + NULL, /* requirements */ + SIZE, SIZE, + NULL, draw) diff --git a/test/rounded-rectangle-fill.xlib.ref.png b/test/rounded-rectangle-fill.xlib.ref.png new file mode 100644 index 0000000000000000000000000000000000000000..52a355dbcf3353e820d7e10d424ce9ed658374b3 GIT binary patch literal 890 zcmeAS@N?(olHy`uVBq!ia0vp^0U*r51SA=YQ-1*|wj^(N7l!{JxM1({$qWq4`kpS1 zAr*7p&N=A!$U)+GdBQ?=VIKBd%nQ|6hgTH-uBt||Nej|qnZ2(635oZDm^G?SikVllFh}3 z_P^zC73e$uc=qhsA1nR zbx*q8e0QaZsp*n!mG$-izjJ8uFdR6Om-B?_hS$vUJjMpD$$X+}vRXb?Au~!=7`zNf zyaWtj=T^^l!V)VAEM$)L)YaCO8uti4`)v74=di&E!H|mjdimi0U%ouinO5zyJowB_ zSJ@DYsa}b%)~{bb_h?c7>ebq3ZkAZ}$~d;NIv%)k|K7d0m>3K1XKYuqzP@|MXM7-~ z*kIGm5)-M&IJNob`PrIp<~%!^7ipZf`R3ohwR+Px_x$?tqvOh~Eer)R>6RD65^gay z+`DuzVMB=4&q?`jr<{K3knnKt?ux@1v!;2d{PEb~$H&L_X4^-JHpSCMb;6(8m>FJ_ z?OvAU9sNJsx9k4N)(@XNIpVo_X`+OHljo#uFYd81glLKO ztZn@upAz}3@?O4pcE!B+U#q5Bl|?_2?mc#F-+aryY_r*B(T^^!6XV&n&R=bE-TwdI z{rL@e?biwMwJ*Myp*2;A#Zly_k6QAleX)nQ4yA1P%*}8F7|PG3TU3%a^am7J0y7hX Mr>mdKI;Vst0E;l7rT_o{ literal 0 HcmV?d00001 diff --git a/test/rounded-rectangle-stroke.c b/test/rounded-rectangle-stroke.c new file mode 100644 index 000000000..22bc51557 --- /dev/null +++ b/test/rounded-rectangle-stroke.c @@ -0,0 +1,64 @@ +/* + * Copyright © 2009 Chris Wilson + * + * 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: Chris Wilson + */ + +#include "cairo-test.h" + +#define SIZE 80 + +/* A very simple test to exercise the scan rasterisers with constant regions. */ + +static void +rounded_rectangle (cairo_t *cr, int x, int y, int w, int h, int r) +{ + cairo_new_sub_path (cr); + cairo_arc (cr, x + r, y + r, r, M_PI, 3 * M_PI / 2); + cairo_arc (cr, x + w - r, y + r, r, 3 *M_PI / 2, 2 * M_PI); + cairo_arc (cr, x + w - r, y + h - r, r, 0, M_PI / 2); + cairo_arc (cr, x + r, y + h - r, r, M_PI / 2, M_PI); + cairo_close_path (cr); +} + +static cairo_test_status_t +draw (cairo_t *cr, int width, int height) +{ + /* Paint background white, then draw in black. */ + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */ + cairo_paint (cr); + cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); /* black */ + + cairo_set_line_width (cr, 10); + rounded_rectangle (cr, 10, 10, width-20, height-20, 10); + cairo_stroke (cr); + + return CAIRO_TEST_SUCCESS; +} + +CAIRO_TEST (rounded_rectangle_stroke, + "Tests handling of rounded rectangles, the UI designers favourite", + "stroke, rounded-rectangle", /* keywords */ + NULL, /* requirements */ + SIZE, SIZE, + NULL, draw) diff --git a/test/rounded-rectangle-stroke.xlib.ref.png b/test/rounded-rectangle-stroke.xlib.ref.png new file mode 100644 index 0000000000000000000000000000000000000000..c7a6554f115ee5fca30fbc347ba728d39f2bf24e GIT binary patch literal 860 zcmeAS@N?(olHy`uVBq!ia0vp^0U*r51SA=YQ-1*|wj^(N7l!{JxM1({$qWq4f}Spp zAr*7p&N-X)%0Z&7zujw>{#Bo@+`X+_c`dsHo35np&mMBxm5xt0s-lOLJCX2?@+seJyT#s9@} zCyx8~@2|d^wf_3+@4uT5CTxs&qbJGeIq6T`|EpK8o;~ZUG_k{Naoqap+av-FX8Lfo zHl2TddueO&pSt>u5p#UhO!U4TdRipOa3JcG9D~Eon0p=)PBTuXM0BrdUzRE0q<%=? z(C^>X*M82O;G@QQPP>)=-R8f2%Q9bcPWMv1Hq-p50Z-J!mnB-Kjb0y^&BQR{Y+A^n zpEdJJZ@vBS;X{IcPUN+F|L(2p);S#?A8&SO{rdIW)Pq8|Ud`%tTf8)0NL-@Vt=G*t zH1zh0{QUd~UA>&&1=mXNs_Jr;#Huepn_?8fsVCFv!twQE#T{MosHBY&iXYy-)iskB z-?wj{+Li55y4zhcGR zOM1)Ea^do2;Y23|fdg&@4+|`OR^*$_-ez4E%dEKMwN+(vxrRto(6_l|yK}2mLqlJG z{Z(Lb=WpE2r#$V4qt3&XbIs@V?t0UUZ}|P@KWxDFNOGCRsne&s*YbsW|H(1a7VECQ-Kcr`)8ogF zpFdac<-T{-iNWc{%aT=Bv$o%U`~A1PygW~Q6$8VLJ$rasoyyD0FJ^ps((>&sZ#Kv0 jgBSG~3i<_}&9$HKB29$T{&zhvyD)gV`njxgN@xNA@mHB6 literal 0 HcmV?d00001