From ae185f803a95248bcb6a8232cabedbc992b66502 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sat, 25 Aug 2007 18:57:46 -0700 Subject: [PATCH] Add four new test to exercise interactions of native and fallback objects The new tests are: over-above-source, over-around-source, over-below-source, and over-between-source --- test/.gitignore | 4 ++ test/Makefile.am | 4 ++ test/over-above-source-ref.png | Bin 0 -> 538 bytes test/over-above-source-rgb24-ref.png | Bin 0 -> 461 bytes test/over-above-source.c | 80 ++++++++++++++++++++++ test/over-around-source-ref.png | Bin 0 -> 614 bytes test/over-around-source-rgb24-ref.png | Bin 0 -> 503 bytes test/over-around-source.c | 91 +++++++++++++++++++++++++ test/over-below-source-ref.png | Bin 0 -> 434 bytes test/over-below-source-rgb24-ref.png | Bin 0 -> 392 bytes test/over-below-source.c | 80 ++++++++++++++++++++++ test/over-between-source-ref.png | Bin 0 -> 575 bytes test/over-between-source-rgb24-ref.png | Bin 0 -> 473 bytes test/over-between-source.c | 91 +++++++++++++++++++++++++ 14 files changed, 350 insertions(+) create mode 100644 test/over-above-source-ref.png create mode 100644 test/over-above-source-rgb24-ref.png create mode 100644 test/over-above-source.c create mode 100644 test/over-around-source-ref.png create mode 100644 test/over-around-source-rgb24-ref.png create mode 100644 test/over-around-source.c create mode 100644 test/over-below-source-ref.png create mode 100644 test/over-below-source-rgb24-ref.png create mode 100644 test/over-below-source.c create mode 100644 test/over-between-source-ref.png create mode 100644 test/over-between-source-rgb24-ref.png create mode 100644 test/over-between-source.c diff --git a/test/.gitignore b/test/.gitignore index 875c1c935..bc4c41bcc 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -86,6 +86,10 @@ new-sub-path nil-surface operator-clear operator-source +over-above-source +over-around-source +over-below-source +over-between-source paint paint-repeat paint-source-alpha diff --git a/test/Makefile.am b/test/Makefile.am index 4d9f5f51a..ed1035272 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -66,6 +66,10 @@ new-sub-path \ nil-surface \ operator-clear \ operator-source \ +over-above-source \ +over-around-source \ +over-below-source \ +over-between-source \ paint \ paint-repeat \ paint-source-alpha \ diff --git a/test/over-above-source-ref.png b/test/over-above-source-ref.png new file mode 100644 index 0000000000000000000000000000000000000000..f3a49f617f63b95fe0868051e64253af17a79889 GIT binary patch literal 538 zcmV+#0_FXQP)E02${w0}{^46nFu;Ko^UpZYzCZ#RX6TQXV_UKoyIQPCL1< zA_f$IT)<=tsAKUZX&aM-93-+hnS!*bOxV5#64@0wr$%6c3)?SPNz!bCl2a=Xk`vD0 z{et-+<kKyMl}>**2p;mbYX=Cgg$^!W&{i{dU)BRHx^rp2s0_l8{{>>fFE=!)W zpz}Ly&$Cq&1AGkd$qDmvg`V_eSLpw7SaeW4vGIv?^uaPQ~^~y zq2SiXwm`C=cZYQeEDQS+7RkbXgvGKDy|9)nL@TT<3(*OOA`8(7hb9ZV7Y<@-00006VoOIv0RI60 z0RN!9r;`8x00(qQO+^RS2pIqeDbs!1NB{r8kiYG}+0#E8@q5tcRX2sDUH zEeNs_#7}`3v4KR5=qEIbW4%-$MgTLIDg>8P&Wi)xBtSPs7vMv0_wiMkp#MZ8H_G=2 zl!z_NVFlg7l_HM_GOi!Fcvc8-a=p8UlQpd+VM>@v&%wcnVjj#(5&?>XsgF=lAwn*w z3ZW8Ig3t=wBP;}t5q1KX2y1~e#32GV8UF3-|5e@r2s%!N*=ATw00000NkvXXu0mjf DsxG=s literal 0 HcmV?d00001 diff --git a/test/over-above-source.c b/test/over-above-source.c new file mode 100644 index 000000000..8999e4ad3 --- /dev/null +++ b/test/over-above-source.c @@ -0,0 +1,80 @@ +/* + * Copyright © 2007 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: Carl D. Worth + */ + +#include "cairo-test.h" + +static cairo_test_draw_function_t draw; + +#define SIZE 40 +#define PAD 2 +#define WIDTH (PAD + SIZE + PAD) +#define HEIGHT WIDTH + +/* This test is designed to explore the interactions of "native" and + * "fallback" objects. For the ps surface, OVER with non-1.0 opacity + * will be a fallback while SOURCE will be native. For the pdf + * surface, it's the reverse where OVER is native while SOURCE is a + * fallback. */ + +cairo_test_t test = { + "over-above-source", + "A simple test drawing a circle with OVER after a triangle drawn with SOURCE", + WIDTH, HEIGHT, + draw +}; + +static cairo_test_status_t +draw (cairo_t *cr, int width, int height) +{ + cairo_translate (cr, PAD, PAD); + + /* A red triangle with SOURCE */ + cairo_move_to (cr, SIZE / 2, SIZE / 2); + cairo_rel_line_to (cr, SIZE / 2, 0); + cairo_rel_line_to (cr, -SIZE / 2, SIZE / 2); + cairo_close_path (cr); + + cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); + cairo_set_source_rgba (cr, 1., 0., 0., 0.5); /* 50% red */ + + cairo_fill (cr); + + /* A green circle with OVER */ + cairo_arc (cr, SIZE / 2, SIZE / 2, SIZE / 4, 0., 2. * M_PI); + + cairo_set_operator (cr, CAIRO_OPERATOR_OVER); + cairo_set_source_rgba (cr, 0., 1., 0., 0.5); /* 50% green */ + + cairo_fill (cr); + + return CAIRO_TEST_SUCCESS; +} + +int +main (void) +{ + return cairo_test (&test); +} diff --git a/test/over-around-source-ref.png b/test/over-around-source-ref.png new file mode 100644 index 0000000000000000000000000000000000000000..ccae9514716a8c71d98772c6948b1b5378b61df9 GIT binary patch literal 614 zcmV-s0-61ZP)})(_AJ`^4znO<&$h_}DMn*WQQ0?U(RvWsBob%|3LKrhXa#2@B|zv_zhI?YlBekCg>h7a%Q@-eG*?B4m1^< z;MWBUz${RB9Oco=bAMZ)b6ui!K2OW!%nn#DCG@&%agX;FU2`9!hV-q3v+ojVk@&mB zFohG#!tjKx$ii@ht;s_A!d7L|Ma8#B8UG`H0HAk}jFv*~DgXcg07*qoM6N<$f?He= Ar~m)} literal 0 HcmV?d00001 diff --git a/test/over-around-source-rgb24-ref.png b/test/over-around-source-rgb24-ref.png new file mode 100644 index 0000000000000000000000000000000000000000..943a28e35c42a0dca8779428b531e7b0957272c1 GIT binary patch literal 503 zcmV<@-00006VoOIv0RI60 z0RN!9r;`8x00(qQO+^RS2pIqcHf%$*KL7v$nMp)JR9J=W*3D|dKoo}Iw`vywap6uE zU60T^a1*dDdRN|67il3Ny#z^GXd4Pu3gSYA&|+#A{ZX2vIWtZulzgkeoMfJ44l{u& zRjO2}BFj<1_{j9ZKKRnwn&~9g1VF=Jih6u&i>N0IJq^J}hQ*7mgHT~^C;pN)D7y%=*hF-vhKR03M00J3Xv)e=cFZ5~N4Z0r zf;&I=R?(MO3*RV}SAjr^m + */ + +#include "cairo-test.h" + +static cairo_test_draw_function_t draw; + +#define SIZE 40 +#define PAD 2 +#define WIDTH (PAD + SIZE + PAD) +#define HEIGHT WIDTH + +/* This test is designed to explore the interactions of "native" and + * "fallback" objects. For the ps surface, OVER with non-1.0 opacity + * will be a fallback while SOURCE will be native. For the pdf + * surface, it's the reverse where OVER is native while SOURCE is a + * fallback. */ + +cairo_test_t test = { + "over-around-source", + "A simple test drawing a triangle with SOURCE between two circles drawn with OVER", + WIDTH, HEIGHT, + draw +}; + +static cairo_test_status_t +draw (cairo_t *cr, int width, int height) +{ + cairo_translate (cr, PAD, PAD); + + /* A green triangle with OVER */ + cairo_move_to (cr, SIZE / 5, SIZE / 5); + cairo_rel_line_to (cr, SIZE / 2, 0); + cairo_rel_line_to (cr, -SIZE / 2, SIZE / 2); + cairo_close_path (cr); + + cairo_set_operator (cr, CAIRO_OPERATOR_OVER); + cairo_set_source_rgba (cr, 0., 1., 0., 0.5); /* 50% green */ + + cairo_fill (cr); + + /* A red circle with SOURCE */ + cairo_arc (cr, SIZE / 2, SIZE / 2, SIZE / 4, 0., 2. * M_PI); + + cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); + cairo_set_source_rgba (cr, 1., 0., 0., 0.5); /* 50% red */ + + cairo_fill (cr); + + /* Another green triangle with OVER */ + cairo_move_to (cr, SIZE / 2, SIZE / 2); + cairo_rel_line_to (cr, SIZE / 2, 0); + cairo_rel_line_to (cr, -SIZE / 2, SIZE / 2); + cairo_close_path (cr); + + cairo_set_operator (cr, CAIRO_OPERATOR_OVER); + cairo_set_source_rgba (cr, 0., 1., 0., 0.5); /* 50% green */ + + cairo_fill (cr); + + return CAIRO_TEST_SUCCESS; +} + +int +main (void) +{ + return cairo_test (&test); +} diff --git a/test/over-below-source-ref.png b/test/over-below-source-ref.png new file mode 100644 index 0000000000000000000000000000000000000000..cd7efd629de3e34d2ff9293aa0652da59a42070d GIT binary patch literal 434 zcmV;j0ZsmiP)0VTG7{^BftrB3yqM^Tcx&}y|>tyZh0=S)`d zTmY-^xdm>*H*dfz&;vb=kJ7Em!Jd1d1D27IM_`NNxnw&X>{$RCV4XSh0PJvlD%&oU zNg)MGn6ptg)xg7TpkPm}!y4J;gNFyKQ#Sim7uL#3xxy>r4_HdeuvS(o*s3bvJ7JF5 zS_=4Dm}9n9{(IQ-2wX*n+5Co{+B?{Tc7@+fDe=Cspn+fPEYW^oK?C-g(#BCvHtbehfo+XAO;z0zBHHw9@)7lPObQB8{9^f>e&H8w>M+B`nMXma$MDT!e+X;9@M)1Djx>4%iF}(}PX1ljh-J cZbM7y3r}xFvb<@-00006VoOIv0RI60 z0RN!9r;`8x00(qQO+^RS2pIqf4QS>gRsaA2DoI2^R9J=W)-g&0K@KCI zvX?W|p`qcJBk;@vOO~vE0Wn}if5X)kQx<7Ub`rY#3>nkg-05+~0e8IBKnyvLHBaes zTO2W99PNHO9(f9N_d~4?qZGkMM$vnWA)3u6aZCC%Wf6HPi8#qc#0F!C!(2pcu$#O5 zS0abHmoMl34|QV^?Jf-qvuw3Z-@z=G>4f)oU<@*P_QiHKLG zTqd87?E*O;s|7dTe(!b=WFfF-&ivTBqk`Rh=>bnA(8}D5UGOlhzvntM4q4| mB3n=lv5TNgF8+4=f0cJPdOxJ4oDBg00000 + */ + +#include "cairo-test.h" + +static cairo_test_draw_function_t draw; + +#define SIZE 40 +#define PAD 2 +#define WIDTH (PAD + SIZE + PAD) +#define HEIGHT WIDTH + +/* This test is designed to explore the interactions of "native" and + * "fallback" objects. For the ps surface, OVER with non-1.0 opacity + * will be a fallback while SOURCE will be native. For the pdf + * surface, it's the reverse where OVER is native while SOURCE is a + * fallback. */ + +cairo_test_t test = { + "over-below-source", + "A simple test drawing a circle with OVER before a triangle drawn with SOURCE", + WIDTH, HEIGHT, + draw +}; + +static cairo_test_status_t +draw (cairo_t *cr, int width, int height) +{ + cairo_translate (cr, PAD, PAD); + + /* A green circle with OVER */ + cairo_arc (cr, SIZE / 2, SIZE / 2, SIZE / 4, 0., 2. * M_PI); + + cairo_set_operator (cr, CAIRO_OPERATOR_OVER); + cairo_set_source_rgba (cr, 0., 1., 0., 0.5); /* 50% green */ + + cairo_fill (cr); + + /* A red triangle with SOURCE */ + cairo_move_to (cr, SIZE / 2, SIZE / 2); + cairo_line_to (cr, SIZE, SIZE / 2); + cairo_line_to (cr, SIZE / 2, SIZE); + cairo_close_path (cr); + + cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); + cairo_set_source_rgba (cr, 1., 0., 0., 0.5); /* 50% red */ + + cairo_fill (cr); + + return CAIRO_TEST_SUCCESS; +} + +int +main (void) +{ + return cairo_test (&test); +} diff --git a/test/over-between-source-ref.png b/test/over-between-source-ref.png new file mode 100644 index 0000000000000000000000000000000000000000..79ea75e954da6c0050ef34e0421a50e47d68e282 GIT binary patch literal 575 zcmV-F0>J%=P)j6qOn0W+1T+r<&1N(6 z*re=CASWj$Cnx7GV{9jeuMN%yxZT%2xjfZze~7GM@wk>(c*2R>fXbxYZZ(F@egaSI7cPOY=L~>EdKVyDe!FyBg(lI~T8T@tIEVxpHMC^wl0>;rSb$qTgxDfYOQHP?tpsYeCx=?Jw zR-K6c!9{edu5G%t!Pl@XvUS@uyfE-lb*+3Hb3i#X@jGG+q8`tUa154Rwzwh9qHB&& zb* literal 0 HcmV?d00001 diff --git a/test/over-between-source-rgb24-ref.png b/test/over-between-source-rgb24-ref.png new file mode 100644 index 0000000000000000000000000000000000000000..602f2d26f6c33035be4c71d640e6043a61eece40 GIT binary patch literal 473 zcmV;~0Ve*5P)<@-00006VoOIv0RI60 z0RN!9r;`8x00(qQO+^RS2pIqg4RQSv7XSbOdr3q=R9J=W)=z4}KorOEZ?%6AtP9D; zo*;qt1a1WDqPOxoJ%bcP=n*7RBm^ogRB_RYrKM^Y7XMYvo97ILlHV%H%zN`836nsY zG-=YLk>zOra9!KC2~F|jjCK`k0^nG&#x%>oXW%m`@lgOcdnNyj*TL)1nwSYRh<-p+ z!raAoCqmLa;Pd&5_5`{Wp+99+T)#4wX04Bm;T%42!w zXbkbz!kzs-~?eRu#Zp(EF*LRn+UbQ8sZRvomBpI`G1vfJ-2zSB|6e{ P00000NkvXXu0mjf;Nr+1 literal 0 HcmV?d00001 diff --git a/test/over-between-source.c b/test/over-between-source.c new file mode 100644 index 000000000..9c60bbda8 --- /dev/null +++ b/test/over-between-source.c @@ -0,0 +1,91 @@ +/* + * Copyright © 2007 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: Carl D. Worth + */ + +#include "cairo-test.h" + +static cairo_test_draw_function_t draw; + +#define SIZE 40 +#define PAD 2 +#define WIDTH (PAD + SIZE + PAD) +#define HEIGHT WIDTH + +/* This test is designed to explore the interactions of "native" and + * "fallback" objects. For the ps surface, OVER with non-1.0 opacity + * will be a fallback while SOURCE will be native. For the pdf + * surface, it's the reverse where OVER is native while SOURCE is a + * fallback. */ + +cairo_test_t test = { + "over-between-source", + "A simple test drawing a circle with OVER between two triangles drawn with SOURCE", + WIDTH, HEIGHT, + draw +}; + +static cairo_test_status_t +draw (cairo_t *cr, int width, int height) +{ + cairo_translate (cr, PAD, PAD); + + /* A red triangle with SOURCE */ + cairo_move_to (cr, SIZE / 5, SIZE / 5); + cairo_rel_line_to (cr, SIZE / 2, 0); + cairo_rel_line_to (cr, -SIZE / 2, SIZE / 2); + cairo_close_path (cr); + + cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); + cairo_set_source_rgba (cr, 1., 0., 0., 0.5); /* 50% red */ + + cairo_fill (cr); + + /* A green circle with OVER */ + cairo_arc (cr, SIZE / 2, SIZE / 2, SIZE / 4, 0., 2. * M_PI); + + cairo_set_operator (cr, CAIRO_OPERATOR_OVER); + cairo_set_source_rgba (cr, 0., 1., 0., 0.5); /* 50% green */ + + cairo_fill (cr); + + /* Another red triangle with SOURCE */ + cairo_move_to (cr, SIZE / 2, SIZE / 2); + cairo_rel_line_to (cr, SIZE / 2, 0); + cairo_rel_line_to (cr, -SIZE / 2, SIZE / 2); + cairo_close_path (cr); + + cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); + cairo_set_source_rgba (cr, 1., 0., 0., 0.5); /* 50% red */ + + cairo_fill (cr); + + return CAIRO_TEST_SUCCESS; +} + +int +main (void) +{ + return cairo_test (&test); +}