[cairo-commit] 2 commits - src/cairo-path-fixed.c test/Makefile.sources test/path-currentpoint.c
Behdad Esfahbod
behdad at kemper.freedesktop.org
Mon Jan 27 14:34:16 PST 2014
src/cairo-path-fixed.c | 3 +
test/Makefile.sources | 1
test/path-currentpoint.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 93 insertions(+)
New commits:
commit 5de25951a43f51cade42549ae60e52ffb391d61e
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Jan 27 17:34:00 2014 -0500
Preserve current-point in copy_path()/append_path() sequence
Fixes path-currentpoint test.
diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c
index 14913fd..4bbf496 100644
--- a/src/cairo-path-fixed.c
+++ b/src/cairo-path-fixed.c
@@ -847,6 +847,9 @@ _cairo_path_fixed_interpret (const cairo_path_fixed_t *path,
}
} cairo_path_foreach_buf_end (buf, path);
+ if (path->needs_move_to && path->has_current_point)
+ return (*move_to) (closure, &path->current_point);
+
return CAIRO_STATUS_SUCCESS;
}
commit 8d2e24479a1efbeeddced3574c1d9e92b8ee578d
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Jan 27 17:31:12 2014 -0500
[tests] Add path-currentpoint
Checks whether copy_path()/append_path() preserves current-point.
Currently failing.
diff --git a/test/Makefile.sources b/test/Makefile.sources
index 534a426..916d91a 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -244,6 +244,7 @@ test_sources = \
partial-coverage.c \
pass-through.c \
path-append.c \
+ path-currentpoint.c \
path-stroke-twice.c \
path-precision.c \
pattern-get-type.c \
diff --git a/test/path-currentpoint.c b/test/path-currentpoint.c
new file mode 100644
index 0000000..ccd44b1
--- /dev/null
+++ b/test/path-currentpoint.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright © 2014 Google, Inc.
+ *
+ * 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
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. 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.
+ */
+
+#include "cairo-test.h"
+
+#include <assert.h>
+
+static void
+assert_point (cairo_t *cr, double expected_x, double expected_y) {
+ double x, y;
+ assert (cairo_has_current_point (cr));
+ cairo_get_current_point (cr, &x, &y);
+ assert (x == expected_x);
+ assert (y == expected_y);
+}
+
+static void
+assert_point_maintained (cairo_t *cr, double expected_x, double expected_y) {
+ cairo_path_t *path;
+
+ assert_point (cr, expected_x, expected_y);
+
+ path = cairo_copy_path (cr);
+
+ cairo_new_path (cr);
+ cairo_rectangle (cr, 5, 5, 10, 20);
+ cairo_stroke (cr);
+
+ cairo_new_path (cr);
+ cairo_append_path (cr, path);
+ cairo_path_destroy (path);
+
+ assert_point (cr, expected_x, expected_y);
+}
+
+static cairo_test_status_t
+preamble (cairo_test_context_t *ctx)
+{
+ cairo_surface_t *surface;
+ cairo_t *cr;
+
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 20, 20);
+ cr = cairo_create (surface);
+
+ cairo_new_path (cr);
+ cairo_move_to (cr, 1., 2.);
+ assert_point_maintained (cr, 1., 2.);
+
+ cairo_line_to (cr, 4., 5.);
+ cairo_move_to (cr, 2., 1.);
+ assert_point_maintained (cr, 2., 1.);
+
+ cairo_move_to (cr, 5, 5);
+ cairo_arc (cr, 5, 5, 10, 0, M_PI / 3);
+ cairo_close_path (cr);
+ assert_point_maintained (cr, 5, 5);
+
+ cairo_destroy (cr);
+ cairo_surface_destroy (surface);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+CAIRO_TEST (path_currentpoint,
+ "Test save/restore path maintains current point",
+ "api", /* keywords */
+ NULL, /* requirements */
+ 0, 0,
+ preamble, NULL)
More information about the cairo-commit
mailing list