From 89567f9278c002ac5e4e25ddccec88b1b1eea420 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 4 Apr 2008 18:28:23 -0700 Subject: [PATCH] Add new filter-bilinear-extents test This test exercises code that computes the extents of a surface pattern with CAIRO_FILTER_BILINEAR, (where the filtering effectively increases the extents of the pattern). The original bug was reported by Owen Taylor here: bad clipping with EXTEND_NONE http://bugs.freedesktop.org/show_bug.cgi?id=15349 --- test/.gitignore | 1 + test/Makefile.am | 2 + test/filter-bilinear-extents-ref.png | Bin 0 -> 1340 bytes test/filter-bilinear-extents.c | 91 +++++++++++++++++++++++++++ 4 files changed, 94 insertions(+) create mode 100644 test/filter-bilinear-extents-ref.png create mode 100644 test/filter-bilinear-extents.c diff --git a/test/.gitignore b/test/.gitignore index af0387a7d..564a8ed84 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -63,6 +63,7 @@ fill-and-stroke-alpha-add fill-degenerate-sort-order fill-missed-stop fill-rule +filter-bilinear-extents filter-nearest-offset finer-grained-fallbacks ft-text-antialias-none diff --git a/test/Makefile.am b/test/Makefile.am index f02a5acc1..a6f0bd9b5 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -51,6 +51,7 @@ fill-and-stroke-alpha-add$(EXEEXT) \ fill-degenerate-sort-order$(EXEEXT) \ fill-missed-stop$(EXEEXT) \ fill-rule$(EXEEXT) \ +filter-bilinear-extents$(EXEEXT) \ filter-nearest-offset$(EXEEXT) \ finer-grained-fallbacks$(EXEEXT) \ font-face-get-type$(EXEEXT) \ @@ -383,6 +384,7 @@ REFERENCE_IMAGES = \ fill-rule-ref.png \ fill-rule-rgb24-ref.png \ fill-rule-ps-rgb24-ref.png \ + filter-bilinear-extents-ref.png \ filter-nearest-offset-ref.png \ finer-grained-fallbacks-ref.png \ finer-grained-fallbacks-rgb24-ref.png \ diff --git a/test/filter-bilinear-extents-ref.png b/test/filter-bilinear-extents-ref.png new file mode 100644 index 0000000000000000000000000000000000000000..61e416b39eb08eb093b787a66864dc949320f942 GIT binary patch literal 1340 zcmV-C1;hG@P)9$M=wY)*c>N5 zlimOS?=~kB&%pw{AjE!9$p{%IoBc9rPPvOt7r#+U|7ifr_S*rdmfiWDNc8d>JIfYxS%B&ncD^%r1$7rt z5mtUMCeg`t3avt?)G6Zo=s75yK^NA}#?yBZsq=k6=?u{32S%!vtCebNwT;F`9Ug;? zQ+QG@tciXCbDBfAAE7c9e!%ulpGZ`4mBPVB;XxK2XIm!^lJKMoJH)MKvD!JnBAMd&Gj{E06}q|$&s68J%5=io`{S>{hkc;2RIip(Kydy3i* zB6N>K6QD2ncSMNHS>a@(v30alc~W?m`yvg`u}uVSa5R#xAwe{U+uO2nl z&N7*^QtQ#HUhX3CXwdtr_f79bZ||(qtMxj)Uhi@P>ITs82B=UgRSKmdcGIZWXNBCx ztH&Easli&~(W}J8%E{57^G)k7ofn4h-8!H>xLV;J- zny^-BkV*~8I1W}$HfoJt?IrAQwY`;tT8+-2cly!cdQDlW4h2qaLuam$ zkiMmCtx@Rw;pi;W=~VVAdk1@ky-bDLS?8pG$D((D#tRi1n>Y@3A$mKFoui#nA#;`* zq=vWg%IRjV)7hw$Dk}$R93g{Rr`77EhW{l(MI4k@1s+B3N#)7fN~yKhy!9)mcXPeQ zTCGsa)DpEp?WES|)IW>RMCvxQ`fRJS(}V(-o)w;L#ugfqruUj(d**VYYdJqaXcidn_thbxEy}~=whsKJ7Z~38Bevf zc|9|FebxD<_M)=4QCX|4bdjd<&cEUtUa*fV*0I8EHGLP*a0k#-O3Y;wzI0+yx_&Wd{el0@FlohT| zW7m3S^xEs})uF(tDs-lc-83$>U)V3E>|(54I%Dm!tn|iuW+Z;44F%3-3VhOP^p26T zd5J&u|3}KE2+hGvWoH#$wN4!e + * Owen Taylor + */ + +#include "cairo-test.h" + +static cairo_test_draw_function_t draw; + +/* This test exercises code that computes the extents of a surface + * pattern with CAIRO_FILTER_BILINEAR, (where the filtering + * effectively increases the extents of the pattern). + * + * The original bug was reported by Owen Taylor here: + * + * bad clipping with EXTEND_NONE + * http://bugs.freedesktop.org/show_bug.cgi?id=15349 + */ + +#define SCALE 10 +#define PAD 3 +#define WIDTH (PAD + 3 * SCALE + PAD) +#define HEIGHT WIDTH + +cairo_test_t test = { + "filter-bilinear-extents", + "Test that pattern extents are properly computed for CAIRO_FILTER_BILINEAR", + WIDTH, HEIGHT, + draw +}; + +static cairo_test_status_t +draw (cairo_t *cr, int width, int height) +{ + cairo_surface_t *checker; + cairo_t *cr2; + + /* Create a 2x2 blue+red checker */ + checker = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 2, 2); + cr2 = cairo_create (checker); + + cairo_set_source_rgb (cr2, 1, 0 ,0); /* red */ + cairo_paint (cr2); + cairo_set_source_rgb (cr2, 0, 0, 1); /* blue */ + cairo_rectangle (cr2, 0, 1, 1, 1); + cairo_rectangle (cr2, 1, 0, 1, 1); + cairo_fill (cr2); + cairo_destroy (cr2); + + /* Draw our surface scaled with EXTEND_NONE */ + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_paint (cr); + + cairo_save (cr); + cairo_translate (cr, PAD, PAD); + cairo_scale (cr, SCALE, SCALE); + cairo_translate (cr, 0.5, 0.5); + cairo_set_source_surface (cr, checker, 0, 0); + cairo_paint (cr); + cairo_restore (cr); + + return CAIRO_TEST_SUCCESS; +} + +int +main (void) +{ + return cairo_test (&test); +}