diff options
author | Vladimir Vukicevic <vladimir@pobox.com> | 2006-09-19 12:17:34 -0700 |
---|---|---|
committer | U-CYCLONE\Vladimir Vukicevic <vladimir@cyclone.(none)> | 2006-09-19 12:19:21 -0700 |
commit | 303b52919519854b9b5bbc38a9ac115e422dddad (patch) | |
tree | 33d1519689aea3a5ef7bf4dd93be10ad077a554a /test/get-and-set.c | |
parent | a56b962428c487d1c341f86e6719bad86374386c (diff) |
dash and pattern getter functions
Adds API functions for inspecting the current dash state, as well as
the contents of pattern objects:
cairo_get_dash
cairo_get_dash_count
cairo_pattern_get_rgba
cairo_pattern_get_surface
cairo_pattern_get_color_stop_rgba
cairo_pattern_get_color_stop_count
cairo_pattern_get_linear_points
cairo_pattern_get_radial_circles
Diffstat (limited to 'test/get-and-set.c')
-rw-r--r-- | test/get-and-set.c | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/test/get-and-set.c b/test/get-and-set.c index ae17cc894..ec35834fe 100644 --- a/test/get-and-set.c +++ b/test/get-and-set.c @@ -1,3 +1,4 @@ +/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */ /* * Copyright © 2005 Red Hat, Inc. * @@ -43,6 +44,8 @@ typedef struct { cairo_line_join_t line_join; double miter_limit; cairo_matrix_t matrix; + double dash[5]; + double dash_offset; } settings_t; /* Two sets of settings, no defaults */ @@ -55,7 +58,9 @@ settings_t settings[] = { CAIRO_LINE_CAP_SQUARE, CAIRO_LINE_JOIN_ROUND, 3.14, - {2.0, 0.0, 0.0, 2.0, 5.0, 5.0} + {2.0, 0.0, 0.0, 2.0, 5.0, 5.0}, + {0.1, 0.2, 0.3, 0.4, 0.5}, + 2.0 }, { CAIRO_OPERATOR_ATOP, @@ -65,7 +70,9 @@ settings_t settings[] = { CAIRO_LINE_CAP_ROUND, CAIRO_LINE_JOIN_BEVEL, 1000.0, - {-3.0, 1.0, 1.0, -3.0, -4, -4} + {-3.0, 1.0, 1.0, -3.0, -4, -4}, + {1.0, 2.0, 3.0, 4.0, 5.0}, + 3.0 } }; @@ -80,9 +87,10 @@ settings_set (cairo_t *cr, settings_t *settings) cairo_set_line_join (cr, settings->line_join); cairo_set_miter_limit (cr, settings->miter_limit); cairo_set_matrix (cr, &settings->matrix); + cairo_set_dash (cr, settings->dash, 5, settings->dash_offset); } -static void +static int settings_get (cairo_t *cr, settings_t *settings) { settings->op = cairo_get_operator (cr); @@ -93,6 +101,21 @@ settings_get (cairo_t *cr, settings_t *settings) settings->line_join = cairo_get_line_join (cr); settings->miter_limit = cairo_get_miter_limit (cr); cairo_get_matrix (cr, &settings->matrix); + + { + cairo_status_t status; + int count; + + status = cairo_get_dash_count (cr, &count); + if (status || count != 5) + return -1; + + status = cairo_get_dash (cr, settings->dash, &settings->dash_offset); + if (status) + return -1; + } + + return 0; } static int @@ -110,7 +133,9 @@ settings_equal (settings_t *a, settings_t *b) a->matrix.x0 == b->matrix.x0 && a->matrix.yx == b->matrix.yx && a->matrix.yy == b->matrix.yy && - a->matrix.y0 == b->matrix.y0); + a->matrix.y0 == b->matrix.y0 && + memcmp(a->dash, b->dash, sizeof(a->dash)) == 0 && + a->dash_offset == b->dash_offset); } static cairo_test_status_t @@ -123,14 +148,16 @@ draw (cairo_t *cr, int width, int height) cairo_save (cr); { settings_set (cr, &settings[1]); - settings_get (cr, &check); + if (settings_get (cr, &check)) + return CAIRO_TEST_FAILURE; if (!settings_equal (&settings[1], &check)) return CAIRO_TEST_FAILURE; } cairo_restore (cr); - settings_get (cr, &check); + if (settings_get (cr, &check)) + return CAIRO_TEST_FAILURE; if (!settings_equal (&settings[0], &check)) return CAIRO_TEST_FAILURE; |