From 0a6ae06c35d99e5e8397c58ee94291e7ee45eb4e Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Tue, 13 Mar 2007 17:39:48 -0700 Subject: [PATCH] Add new skew-extreme test case. This test currently fails, demonstrating the bug reported here: Skew transforms were broken by the cairo update in December https://bugzilla.mozilla.org/show_bug.cgi?id=373632 --- test/.gitignore | 1 + test/Makefile.am | 1 + test/skew-extreme-ref.png | Bin 0 -> 1012 bytes test/skew-extreme.c | 126 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 test/skew-extreme-ref.png create mode 100644 test/skew-extreme.c diff --git a/test/.gitignore b/test/.gitignore index e514f5d87..6c4adfc57 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -121,6 +121,7 @@ self-intersecting set-source show-glyphs-many show-text-current-point +skew-extreme source-clip source-clip-scale source-surface-scale-paint diff --git a/test/Makefile.am b/test/Makefile.am index 05f3620ec..54928cf32 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -85,6 +85,7 @@ self-copy \ self-intersecting \ set-source \ show-text-current-point \ +skew-extreme \ source-clip \ source-clip-scale \ source-surface-scale-paint \ diff --git a/test/skew-extreme-ref.png b/test/skew-extreme-ref.png new file mode 100644 index 0000000000000000000000000000000000000000..14083956c0dfadc3b1be2379ad56fea37bb52003 GIT binary patch literal 1012 zcmeAS@N?(olHy`uVBq!ia0vp^ML=A`!3HF^UVp+1q}Y|gW!U_%O?Xx*h@Tp zUD>ZQ^D(Fj)!)*pW?*2R=IP=XQZeW4+{C;`1|n?sVbz^aB$i%p(7qVg8MpY0#7Dy$ z^4dYJhKhwUzinqsobYS;)YT7{D$lyH`}Nl<(H+nI-?BQ${kymC#V)_;r&B+0DfaAJ zm>d1}`|pFRGiNR8ZZq7y(p$UeuYsl!TT$+&h!mbD*VMaDNSx3;ou-tmP;TAT)zf&# zCPZA4dFN?EkfP;<%0ROIrE8nOyhqckLwD{yv3|Y2EMNPr*Ed_jC*1D-^XJc%mnEzA z&P%eHeJAe8$BHXIYu4?Zx2j^=?e3i0VX@akV|!fpoOtW{uFSeLHvI40r;Oc2>`LdK zf4lEQ$80tzV_+-^VZ(%* z@w>l&?^byUByJ@s%#C|;`}S;=m(QOshw$q5PgjZ6o1WF(Si<)IZ^rFuKrQwYeJ`)b zlxh`Nbd+VAq>Yiohaag5lOB9L?Vxh-@$`eX)-3(;Y{H&E(JwVXk;xN1nvSb0Ph{!$ zcQe-zwy~4+1&O{$6JY7LU!=q-SMTB~Wb?1XuGjU$4`nN$I{SC;YJluV>wp@?%Yl;n zcKm)}dGK-fZjh--MYH{zj`L3j>a_RiQmOc3u=70M!N=_P~vF@$8$&N*r>x&&&gAHS6wsrdsi4lLt`ibXTC(-8xp%-48aNUIfy*$zzGj zhltdTK!s}EK>cQsH3Aw3lP4bqy7xxPMvu-18$BigCFMMUI;&OYR{4Fnp_~b3cTVAu z%U0=DsmPhA1GLjM=#2+Uzv(1(5PK6y;}I=jh{%S4teGHVEp#xsGZbWM;#832p)8;z zZx~4X2CXucrsG_zK{^j+O#~`z)KTJ`_bWxv^TU<&QjoE%n|xFb2G7?~Qf*ppcGE@3 zru3xRqz5a#r`?#yG4EE&Y>%epdN*CXSp0oA0mJpx#89B>{+x}_*Z}E@comUa+HKlZ9chF^wekmFFUr$S?wqb24-3YPgg&ebxsLQ0Es@+ A + */ + +#include "cairo-test.h" + +/* This test case is designed to exercise the following bug: + * + * Skew transforms were broken by the cairo update in December + * https://bugzilla.mozilla.org/show_bug.cgi?id=373632 + * + * What's happening is that the rectangle is being skewed into the + * following shape: + * + * a__b + * \ \ + * \ \ + * \ \ + * \ \ + * \ \ + * d\_\c + * + * and the bug is that _cairo_traps_tessellate_convex_quad is + * comparing b.x as less then d.x and therfore determining that the bc + * edge is left of the ad edge. The fix is simply to compare c.x to + * d.x instead of b.x to d.x . + */ + +#define PAD 2 +#define LINE_WIDTH 10 +#define LINE_LENGTH (2 * LINE_WIDTH) +#define SKEW_FACTOR 5.0 +#define WIDTH (PAD + (LINE_LENGTH * SKEW_FACTOR) + LINE_WIDTH + PAD) +#define HEIGHT (PAD + LINE_WIDTH + (LINE_LENGTH * SKEW_FACTOR) + LINE_WIDTH + PAD) + +static cairo_test_draw_function_t draw; + +cairo_test_t test = { + "skew-extreme", + "Test cases of extreme skew.", + WIDTH, HEIGHT, + draw +}; + +static cairo_test_status_t +draw (cairo_t *cr, int width, int height) +{ + /* We draw in the default black, so paint white first. */ + cairo_save (cr); + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */ + cairo_paint (cr); + cairo_restore (cr); + + cairo_translate (cr, PAD, PAD); + + cairo_set_line_width (cr, LINE_WIDTH); + cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT); + + cairo_save (cr); + { + cairo_matrix_t skew_x = { + 1.0, 0.0, + SKEW_FACTOR, 1.0, + 0.0, 0.0 + }; + + cairo_translate (cr, LINE_WIDTH / 2.0, 0.0); + + cairo_transform (cr, &skew_x); + + cairo_move_to (cr, 0.0, 0.0); + cairo_line_to (cr, 0.0, LINE_LENGTH); + cairo_stroke (cr); + } + cairo_restore (cr); + + cairo_translate (cr, 0.0, LINE_WIDTH); + + cairo_save (cr); + { + cairo_matrix_t skew_y = { + 1.0, SKEW_FACTOR, + 0.0, 1.0, + 0.0, 0.0 + }; + + cairo_translate (cr, 0.0, LINE_WIDTH / 2.0); + + cairo_transform (cr, &skew_y); + + cairo_move_to (cr, 0.0, 0.0); + cairo_line_to (cr, LINE_LENGTH, 0.0); + cairo_stroke (cr); + } + cairo_restore (cr); + + return CAIRO_TEST_SUCCESS; +} + +int +main (void) +{ + return cairo_test (&test); +}