From 249c89c313598487b5eab1a93a06ac9ebcc173b3 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 29 Aug 2011 15:48:42 +0100 Subject: [PATCH] test: Add big-little-triangle A variant on big-little-triangle to exercise the non-rectangular paths. Signed-off-by: Chris Wilson --- test/Makefile.refs | 2 + test/Makefile.sources | 1 + test/big-little-triangle.argb32.ref.png | Bin 0 -> 409 bytes test/big-little-triangle.c | 76 ++++++++++++++++++++++++ test/big-little-triangle.rgb24.ref.png | Bin 0 -> 328 bytes 5 files changed, 79 insertions(+) create mode 100644 test/big-little-triangle.argb32.ref.png create mode 100644 test/big-little-triangle.c create mode 100644 test/big-little-triangle.rgb24.ref.png diff --git a/test/Makefile.refs b/test/Makefile.refs index 0db62088d..ddcbf706a 100644 --- a/test/Makefile.refs +++ b/test/Makefile.refs @@ -51,6 +51,8 @@ REFERENCE_IMAGES = \ big-line.xlib.ref.png \ big-little-box.argb32.ref.png \ big-little-box.rgb24.ref.png \ + big-little-triangle.argb32.ref.png \ + big-little-triangle.rgb24.ref.png \ bilevel-image.ref.png \ bitmap-font.ref.png \ bitmap-font.rgb24.ref.png \ diff --git a/test/Makefile.sources b/test/Makefile.sources index 728961559..25add4ff1 100644 --- a/test/Makefile.sources +++ b/test/Makefile.sources @@ -16,6 +16,7 @@ test_sources = \ api-special-cases.c \ big-line.c \ big-little-box.c \ + big-little-triangle.c \ big-trap.c \ bilevel-image.c \ bug-40410.c \ diff --git a/test/big-little-triangle.argb32.ref.png b/test/big-little-triangle.argb32.ref.png new file mode 100644 index 0000000000000000000000000000000000000000..1c2522fa69a1bb4d7d7e9034107aa51f55d0b495 GIT binary patch literal 409 zcmV;K0cQS*P)lHZsy6_i18>>Wt(5Xr^YFv*qu0h`BKodEN%%7=Ma6zAtB4mStI%WnKFPt2AUp@lo6E00000NkvXXu0mjf Dp2)+k literal 0 HcmV?d00001 diff --git a/test/big-little-triangle.c b/test/big-little-triangle.c new file mode 100644 index 000000000..27eb2325e --- /dev/null +++ b/test/big-little-triangle.c @@ -0,0 +1,76 @@ +/* + * Copyright © 2011 Intel Corporation + * + * 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 + */ + +/* + * A variation on + * + * https://bugzilla.mozilla.org/show_bug.cgi?id=668921 + * + * The issue is that we failed to tighten the initial approximated bounds + * after tessellating the path. + */ + +#include "cairo-test.h" + +#define SIZE 60 + +static void +triangle (cairo_t *cr, double x, double y, double h) +{ + cairo_move_to (cr, x, y); + cairo_line_to (cr, x+h/2, y+h); + cairo_line_to (cr, x+h, y); + cairo_close_path (cr); +} + +static cairo_test_status_t +draw (cairo_t *cr, int width, int height) +{ + cairo_set_source_rgb (cr, 1, 0, 1); + cairo_paint (cr); + + /* Set an unbounded operator so that we can see how accurate the bounded + * extents were. + */ + cairo_set_operator (cr, CAIRO_OPERATOR_IN); + cairo_set_source_rgb (cr, 1, 1, 1); + + /* Wind several triangles together that reduce to just one */ + cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); + triangle (cr, 0, 0, SIZE); + triangle (cr, 0, 0, SIZE); + triangle (cr, SIZE/2-20, SIZE/2 - 20, 40); + cairo_fill (cr); + + return CAIRO_TEST_SUCCESS; +} + +CAIRO_TEST (big_little_triangle, + "Tests that we tighten the bounds after tessellation.", + "fill", /* keywords */ + NULL, /* requirements */ + SIZE, SIZE, + NULL, draw) diff --git a/test/big-little-triangle.rgb24.ref.png b/test/big-little-triangle.rgb24.ref.png new file mode 100644 index 0000000000000000000000000000000000000000..24fc47259198be5fce1b08fb5846df87f8d223b8 GIT binary patch literal 328 zcmeAS@N?(olHy`uVBq!ia0vp^HXzKw1SGf4^HT*z~dVD(9CQu`$eZMLhp~W*}K%7QJKkclU0TVHvFG@v6&(mmQwz?iO*1-bmZ+wj zqn&1S$Sg&zG$%SO=(t(BnrjY!TF{ZQBsI|-`?R2gWvR>Da`Mx%j=VeIbM;2;jFnQm zrHw-qzNakXdUNi~7p~p*#(NL(9rWSfxY*#b^BadVCEc>!GxIhcHoVMQ=90GS0N*K} z!q^C3nRrA{{?yGbeny8 XcB~I;bk