From 7db1fb6fa97e0c44e66c0ae533b94fb3f26b273d Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 31 Jul 2009 16:57:14 +0100 Subject: [PATCH] [test] Add clip-text Test applying a complex clip to text. --- test/Makefile.am | 4 ++ test/Makefile.sources | 1 + test/clip-text.c | 88 ++++++++++++++++++++++++++++++++++++ test/clip-text.ps.xfail.png | Bin 0 -> 434 bytes test/clip-text.ref.png | Bin 0 -> 928 bytes test/clip-text.svg.ref.png | Bin 0 -> 933 bytes test/clip-text.xlib.ref.png | Bin 0 -> 900 bytes 7 files changed, 93 insertions(+) create mode 100644 test/clip-text.c create mode 100644 test/clip-text.ps.xfail.png create mode 100644 test/clip-text.ref.png create mode 100644 test/clip-text.svg.ref.png create mode 100644 test/clip-text.xlib.ref.png diff --git a/test/Makefile.am b/test/Makefile.am index 8ef31cab1..783511c16 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -213,6 +213,10 @@ REFERENCE_IMAGES = \ clip-push-group.quartz.ref.png \ clip-push-group.ref.png \ clip-push-group.xlib.ref.png \ + clip-text.ref.png \ + clip-text.ps.xfail.png \ + clip-text.svg.ref.png \ + clip-text.xlib.ref.png \ clip-twice.pdf.argb32.ref.png \ clip-twice.ps2.argb32.ref.png \ clip-twice.ps2.rgb24.ref.png \ diff --git a/test/Makefile.sources b/test/Makefile.sources index dd71856d5..45bf5fd01 100644 --- a/test/Makefile.sources +++ b/test/Makefile.sources @@ -20,6 +20,7 @@ test_sources = \ clip-nesting.c \ clip-operator.c \ clip-push-group.c \ + clip-text.c \ clip-twice.c \ clip-unbounded.c \ clip-zero.c \ diff --git a/test/clip-text.c b/test/clip-text.c new file mode 100644 index 000000000..ed8e10796 --- /dev/null +++ b/test/clip-text.c @@ -0,0 +1,88 @@ +/* + * Copyright 2009 Chris Wilson + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of + * Chris Wilson not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Chris Wilson makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * CHRIS WILSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL CHRIS WILSON BE LIABLE FOR ANY SPECIAL, + * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR + * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Chris Wilson + */ + +#include "cairo-test.h" + +#define WIDTH 20 +#define HEIGHT 20 + +static cairo_test_status_t +draw (cairo_t *cr, int width, int height) +{ + const char *cairo = "Cairo"; + cairo_text_extents_t extents; + double x0, y0; + + cairo_text_extents (cr, cairo, &extents); + x0 = WIDTH/2. - (extents.width/2. + extents.x_bearing); + y0 = HEIGHT/2. - (extents.height/2. + extents.y_bearing); + + cairo_set_source_rgb (cr, 1, 1, 1); + cairo_paint (cr); + + /* aligned-clip */ + cairo_save (cr); + cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); + cairo_rectangle (cr, 0, 0, 20, 20); + cairo_rectangle (cr, 3, 3, 10, 10); + cairo_rectangle (cr, 7, 7, 10, 10); + cairo_clip (cr); + + cairo_set_source_rgb (cr, 0.7, 0, 0); + cairo_paint (cr); + cairo_set_source_rgb (cr, 0, 0, 0); + + cairo_move_to (cr, x0, y0); + cairo_show_text (cr, cairo); + cairo_restore (cr); + + cairo_translate (cr, WIDTH, 0); + + /* force a clip-mask */ + cairo_save (cr); + cairo_arc (cr, 10, 10, 10, 0, 2 * M_PI); + cairo_new_sub_path (cr); + cairo_arc_negative (cr, 10, 10, 5, 2 * M_PI, 0); + cairo_new_sub_path (cr); + cairo_arc (cr, 10, 10, 2, 0, 2 * M_PI); + cairo_clip (cr); + + cairo_set_source_rgb (cr, 0, 0, 0.7); + cairo_paint (cr); + cairo_set_source_rgb (cr, 0, 0, 0); + + cairo_move_to (cr, x0, y0); + cairo_show_text (cr, cairo); + cairo_restore (cr); + + return CAIRO_TEST_SUCCESS; +} + +CAIRO_TEST (clip_text, + "Tests drawing text through complex clips.", + "clip, text", /* keywords */ + NULL, /* requirements */ + 2 * WIDTH, HEIGHT, + NULL, draw) diff --git a/test/clip-text.ps.xfail.png b/test/clip-text.ps.xfail.png new file mode 100644 index 0000000000000000000000000000000000000000..b50217d8893d1b88f6652eb28ec58f537d54633e GIT binary patch literal 434 zcmV;j0ZsmiP)K~zYIy_K<9!$1s$fAOWv0Q6)4_b@;Tr(=K=3_(FjL75^0xTJsz z7YvXAoZbVN-qfNve7>9&+r<8Ol`ZM{oldeOA6$-9HL{50W~6EwSr!v?M@fd>Q2y#4 zRL!t9Mm5%ZbOBb)Ldq|p`Ls0hKb~I14{skpvGZE z3rJ2oz-u1~GSkj5>1wr@35u!3)qS16rTH3e8NYuj5SR*u-pc| zyDM5+wv?0@^kT7E!9zn+XU_Z)jn3s&TCL_wmv(zRTQtUySNFe=PAeT9;e!Xq3Z(*( z$XrXy*vXUObUHg$lU7@_Zj10(h(e`~j_{2e(PD;p^=c%Op|7u&mCsm`VnwE^xPCnn z3{I~!IF-trK0U5ygrL2B`^ZSMEIVY`F*4HJ*0xQ*Sc<}_Q{(gVis=QU!1i9jKHuo% zqy#pw0tSP)bEod`;jNmWsi~}~scirLjYp4$GMVgFPE5#>6f;eO83y5dU60z1rXUEO zg7HSCu(*$P8oPQ{B&>|CoP|cS0}x11ShBslJ0Q zsD@Z9nd3@<#>VV)j~{m>5_5^fY-i`UDpOy-3C7_I)jd1AF@Nwh0DtDKK?pv9&p_KY z6(*BO_olkD0)s)oH?UiE8;y4_6nb#)&Cq0n2O@72J-YkhwWRxxyHBK_Kf$3M>JNiIYyOg0VF%wr3X~ z#gEc57`#{Kd(QK`&pGG)a^53)`TtQQrS{YB4|R9X+HA89$D7x$7lFjY?KwFKB_)Q^ z(tUApik2+4%DAUz_Tt6ynHgVHrqQUse*NIdllzttB`R-25e&+T3g@X)Be7fom&;dL zI#N~T3&1 zJxoq!fE6a-Ii#A+X{%jW11iC4eY|H+e^QeD%9Sn^IeK&fuEAAR{qSK;^cuIp5G+KUgE<(2pTO<* zYw;5&a@0XhO|{1}_v)3ux!Iy31qFxU2e=kipO0=_2QT484C6^S3<_w=2JZubr5y)@ z9#y?uADvDI$;)afmFUJ6NP|!e<9K)rKuXHaFeYJWVBjzH(|*`Zv&9EbS_xzW&?!`5!$VQ$xddD$>%@ zp;c#O%qipW7p9U7RL`fx=Hf!UmX?%b!@*`ELo$D7-?pLTRS z)8@;}jCVS}-js2Xlyv#mSq!t4$_DZS804=hxL`78fU@?M~WQ zqZh4?#>Owa-e7C1>pz*5mBxmK&(-l3^kbb)Sgl#z-MRbs>tk_@Mtx6D?u{E+I^EKi zw(JE0`28W9&E41cVt9CAdfE#dI1rzgmrz)^*JLt8JbnHJfDTE`AH`Lz00000NkvXX Hu0mjfFSo<1 literal 0 HcmV?d00001 diff --git a/test/clip-text.xlib.ref.png b/test/clip-text.xlib.ref.png new file mode 100644 index 0000000000000000000000000000000000000000..be27b9618b59a9faeee9385e68e593b632b350b6 GIT binary patch literal 900 zcmV-~1AF|5P)+}2j=bQWriA*1e}5RWICnu2w8fo!S3`}ZTYwSlIlU_3tl zt|qOPGHxk&AVjuOb93;@mHu2_@$%)65VW_KG4(I@dc!%Us_5tl`Tdcp1}n-~b8}G7 z2tj>)QBTk2Sga}*tLo|5Twh<5GFXj`eZPMvOwT}p<^L6Y{rao^em^XSrGU{WJf5}t z_ASx`c6)){zIMls`G*d@)@C;piuwH!Qxs-{2afAHYBQ=pH#jH$0b2F$-RCe09@qri z8ybrBsT%h0U-b0p=g!WL8Y9aQ!(P}0XD3QM5CK5IoU}$GFbp1uM$41#4S>^`rwZ=e z30bXAES87YuDw*5+S)t_fLnDxe%zUPj!WPi`~d}gY1LnF8dg9!JeuUpz{ZV>)rW?L z-O=dC@bI@2CyuC0MTG_WV2kSh@nb>e;3xot8EfzwR)al_HyHHYCb)$Va1hE=x5>0V zbFc(+K*ok|bSxZpxLkEAbM@+Nz1wEXXBAY!61WIAp%}J8 zVp4QN6|4f6>t2exrNx`Bce~%gGU!fTRjsXFaT^qvn;eKZe1XF`ET7-OIT~NNvTI;q zrsfvn%Yg%Hjvif7UY-y1_I`D{Ki;}Er0*w5=DxmdnRllg*X^B&L|0eD>3lVbI32QF zSzT?J>RP>LkF~L}BzOJElO@&F7WBK59+T`v>1b;!6@reAP%fz#E|jYG)36^KjiSB1 z%;&R7k~y13lFaw-S6;eQW;Bj}(zKmG07V&-<)|!20)elCgFk`d;=Fb1@*NJV!(mA| a`uqhn)>Rpo!@RZt00005 literal 0 HcmV?d00001