From 3c5e57e694d1a8a0a48a66e0d61d8257c23a780e Mon Sep 17 00:00:00 2001 From: Nis Martensen Date: Tue, 16 Jun 2009 23:38:50 +0200 Subject: [PATCH] [test] Verify current point position after subpath closure Make sure cairo_close_path always takes the current point where it should be. --- test/Makefile.am | 1 + test/Makefile.sources | 1 + test/close-path-current-point.c | 95 ++++++++++++++++++++++++++ test/close-path-current-point.ref.png | Bin 0 -> 1916 bytes 4 files changed, 97 insertions(+) create mode 100644 test/close-path-current-point.c create mode 100644 test/close-path-current-point.ref.png diff --git a/test/Makefile.am b/test/Makefile.am index 1472c5c43..155077da9 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -218,6 +218,7 @@ REFERENCE_IMAGES = \ close-path.ps2.ref.png \ close-path.ps3.ref.png \ close-path.ref.png \ + close-path-current-point.ref.png \ composite-integer-translate-over.ps2.ref.png \ composite-integer-translate-over.ps3.ref.png \ composite-integer-translate-over.ref.png \ diff --git a/test/Makefile.sources b/test/Makefile.sources index 23596f8fd..4604b1fff 100644 --- a/test/Makefile.sources +++ b/test/Makefile.sources @@ -24,6 +24,7 @@ test_sources = \ clipped-group.c \ clipped-surface.c \ close-path.c \ + close-path-current-point.c \ composite-integer-translate-source.c \ composite-integer-translate-over.c \ composite-integer-translate-over-repeat.c \ diff --git a/test/close-path-current-point.c b/test/close-path-current-point.c new file mode 100644 index 000000000..35f8d423b --- /dev/null +++ b/test/close-path-current-point.c @@ -0,0 +1,95 @@ +/* + * Copyright © 2009 Nis Martensen + * + * 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 the copyright holder + * not be used in advertising or publicity pertaining to distribution of + * the software without specific, written prior permission. The + * copyright holder makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without + * express or implied warranty. + * + * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDER 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: Nis Martensen + */ + +#include "cairo-test.h" + +#define SIZE 20 + +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); + + /* subpath starts with cairo_move_to */ + cairo_new_sub_path (cr); + cairo_move_to (cr, SIZE, SIZE); + cairo_rel_line_to (cr, SIZE, 0); + cairo_rel_line_to (cr, 0, SIZE); + cairo_close_path (cr); + cairo_rel_line_to (cr, 0.5 * SIZE, SIZE); + + /* subpath starts with cairo_line_to */ + cairo_new_sub_path (cr); + cairo_line_to (cr, SIZE, 3 * SIZE); + cairo_rel_line_to (cr, SIZE, 0); + cairo_rel_line_to (cr, 0, SIZE); + cairo_close_path (cr); + cairo_rel_line_to (cr, 0, SIZE); + + /* subpath starts with cairo_curve_to */ + cairo_new_sub_path (cr); + cairo_curve_to (cr, + SIZE, 5 * SIZE, + 1.5 * SIZE, 6 * SIZE, + 2 * SIZE, 5 * SIZE); + cairo_rel_line_to (cr, 0, SIZE); + cairo_close_path (cr); + cairo_rel_line_to (cr, -0.5 * SIZE, SIZE); + + /* subpath starts with cairo_arc */ + cairo_new_sub_path (cr); + cairo_arc (cr, + 1.5 * SIZE, 7 * SIZE, + 0.5 * SIZE, + M_PI, 2 * M_PI); + cairo_rel_line_to (cr, 0, SIZE); + cairo_close_path (cr); + cairo_rel_line_to (cr, -0.7 * SIZE, 0.7 * SIZE); + + /* subpath starts with cairo_arc_negative */ + cairo_new_sub_path (cr); + cairo_arc_negative (cr, + 1.5 * SIZE, 9 * SIZE, + 0.5 * SIZE, + M_PI, 2 * M_PI); + cairo_rel_line_to (cr, 0, SIZE); + cairo_close_path (cr); + cairo_rel_line_to (cr, -0.8 * SIZE, 0.3 * SIZE); + + cairo_stroke (cr); + + return CAIRO_TEST_SUCCESS; +} + +CAIRO_TEST (close_path_current_point, + "Test some corner cases related to cairo path operations and the current point", + "path", /* keywords */ + NULL, /* requirements */ + 3 * SIZE, 11 * SIZE, + NULL, draw) diff --git a/test/close-path-current-point.ref.png b/test/close-path-current-point.ref.png new file mode 100644 index 0000000000000000000000000000000000000000..f30002c6bb2859f2e74d687a49a776573a08dc74 GIT binary patch literal 1916 zcmZWqc~sKr8veDYja@V+w_HohH8)ZzaUTTKYRa&56f061OL5F)P*bcKN6m#w$)M0O z(J@OKHw-~7bH8e!xC<)diVnHt0%Dixp8Lm~`+ev8-uJwJyyrd7bDsA}KX(=ZQq)oe z0088Pg!#y#qwJ0C+b#QFjQEzwf;`3>0Rz7LeV?&PasWWV#uMg-!arSl+Ut$FtlHEo z!Ia6rUjV6|^f)89fBwGb6>D~}uc@U$WfpGavvFON%F!Q>$+@*BuU(6k7OGo!+lz_Rca_$<5RfQGP-zCiC4zLE{@aYt2xz zOj|WLMbYp~%7fzf$O~7CO07AlFzwK`$ZTCGc1zwOd@^4}w=Et1V(yjBn!xl{+)%BP zwRIB#hr{I;6kIo(c)0VOssE{Rp}oERN=9{cwMm@hbQUoO;v&qz1_Cjj*KMdaiFKgLTIVe*U8a!K zMq|*2A}or!GP*U(gs)R<11^VM>7TeD)P_5RDI@+cn+G`o39R>rMyxm!^4h!iam-LWV#fs7W$svIqI9 z^NgP&qED`bj=5wDhHA4iKxamjN3p4<(f?yPs8aAA3(W>j|}ptRiwXJ&1FDA$5}URr37!&V`U-A~Iv%5GVJ~ zk)9uy{xuG5i`+K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