[cairo-commit] 5 commits - src/cairo.c src/cairo-font-face.c
src/cairo-font-options.c src/cairo-gstate.c src/cairoint.h
src/cairo-pattern.c src/cairo-scaled-font.c
src/cairo-surface.c test/fallback-resolution.c
test/in-fill-empty-trapezoid.c
Chris Wilson
ickle at kemper.freedesktop.org
Tue May 8 14:10:52 PDT 2007
src/cairo-font-face.c | 5 +++++
src/cairo-font-options.c | 7 ++++++-
src/cairo-gstate.c | 4 +---
src/cairo-pattern.c | 3 ++-
src/cairo-scaled-font.c | 10 ++++++++++
src/cairo-surface.c | 8 ++++++++
src/cairo.c | 12 ++++++++----
src/cairoint.h | 3 ++-
test/fallback-resolution.c | 6 ++++--
test/in-fill-empty-trapezoid.c | 8 +++++---
10 files changed, 51 insertions(+), 15 deletions(-)
New commits:
diff-tree 069514a10ff2ca9ac86cc3dc1703aa19caa538e2 (from 43645eb486da1af91b3264af6c84ac18a1eddcaa)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue May 8 18:19:56 2007 +0100
[test/in-fill-empty-trapezoid] Cleanup after test failure.
Ensure that the failure path also calls cairo_test_fini().
diff --git a/test/in-fill-empty-trapezoid.c b/test/in-fill-empty-trapezoid.c
index 61fdb70..45051f8 100644
--- a/test/in-fill-empty-trapezoid.c
+++ b/test/in-fill-empty-trapezoid.c
@@ -47,6 +47,7 @@ main (void)
cairo_status_t status;
char const * description =
"Test that the tessellator isn't producing obviously empty trapezoids";
+ cairo_test_status_t ret;
cairo_test_init ("in-fill-empty-trapezoid");
cairo_test_log ("%s\n", description);
@@ -81,20 +82,21 @@ main (void)
cairo_surface_destroy (surf);
/* Check that everything went well. */
+ ret = CAIRO_TEST_SUCCESS;
if (CAIRO_STATUS_SUCCESS != status) {
cairo_test_log ("Failed to create a test surface and path: %s\n",
cairo_status_to_string (status));
- return CAIRO_TEST_FAILURE;
+ ret = CAIRO_TEST_FAILURE;
}
if (0 != false_positive_count) {
cairo_test_log ("Point sampling found %d false positives "
"from cairo_in_fill()\n",
false_positive_count);
- return CAIRO_TEST_FAILURE;
+ ret = CAIRO_TEST_FAILURE;
}
cairo_test_fini ();
- return CAIRO_TEST_SUCCESS;
+ return ret;
}
diff-tree 43645eb486da1af91b3264af6c84ac18a1eddcaa (from 21c6643b09c771454f913b444b6b040aaaacd3a8)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue May 8 20:25:21 2007 +0100
[test/fallback-resolution] Cleanup after test failure
Be valgrind clean even for test failures.
diff --git a/test/fallback-resolution.c b/test/fallback-resolution.c
index 37fd591..10ed964 100644
--- a/test/fallback-resolution.c
+++ b/test/fallback-resolution.c
@@ -88,6 +88,7 @@ main (void)
cairo_surface_t *surface = NULL;
cairo_t *cr;
cairo_status_t status;
+ cairo_test_status_t ret = CAIRO_TEST_SUCCESS;
double ppi[] = { 600., 300., 150., 75., 37.5 };
backend_t backend;
int page, num_pages;
@@ -138,7 +139,8 @@ main (void)
cairo_test_log ("Failed to create pdf surface for file %s: %s\n",
backend_filename[backend],
cairo_status_to_string (status));
- return CAIRO_TEST_FAILURE;
+ ret = CAIRO_TEST_FAILURE;
+ break;
}
printf ("fallback-resolution: Please check %s to ensure it looks correct.\n",
@@ -147,5 +149,5 @@ main (void)
cairo_test_fini ();
- return CAIRO_TEST_SUCCESS;
+ return ret;
}
diff-tree 21c6643b09c771454f913b444b6b040aaaacd3a8 (from ede76a97ea5b68c3bd042dc6a93ecb1aa7c9761c)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue May 8 21:28:48 2007 +0100
[cairo-surface] Check for errors when generating the scaled font.
cairo_surface_show_glyphs() attempts to generate a device specific
scaled font and so needs to check for failure before attempting to use
it.
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index d4ecabe..94bb405 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -1853,6 +1853,11 @@ _cairo_surface_show_glyphs (cairo_surfac
font_options);
cairo_font_options_destroy (font_options);
}
+ status = cairo_scaled_font_status (dev_scaled_font);
+ if (status) {
+ _cairo_pattern_fini (&dev_source.base);
+ return status;
+ }
CAIRO_MUTEX_LOCK (dev_scaled_font->mutex);
diff-tree ede76a97ea5b68c3bd042dc6a93ecb1aa7c9761c (from c441938569ed78123a57662a70ef5a74dcf73851)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue May 8 17:26:22 2007 +0100
[cairo-font-options] Check for the nil-object.
The design is for the user to create a cairo_font_options_t object with
cairo_font_options_create() and then is free to use it with any Cairo
operation. This requires us to check when we may be about to overwrite
the read-only nil object.
diff --git a/src/cairo-font-face.c b/src/cairo-font-face.c
index f254c3b..3b6dab3 100644
--- a/src/cairo-font-face.c
+++ b/src/cairo-font-face.c
@@ -455,6 +455,11 @@ _cairo_toy_font_face_scaled_font_create
{
cairo_toy_font_face_t *font_face = abstract_font_face;
const cairo_scaled_font_backend_t * backend = CAIRO_SCALED_FONT_BACKEND_DEFAULT;
+ cairo_status_t status;
+
+ status = cairo_font_options_status ((cairo_font_options_t *) options);
+ if (status)
+ return status;
return backend->create_toy (font_face,
font_matrix, ctm, options, scaled_font);
diff --git a/src/cairo-font-options.c b/src/cairo-font-options.c
index ccdffa9..33b021d 100644
--- a/src/cairo-font-options.c
+++ b/src/cairo-font-options.c
@@ -113,8 +113,12 @@ slim_hidden_def (cairo_font_options_crea
cairo_font_options_t *
cairo_font_options_copy (const cairo_font_options_t *original)
{
- cairo_font_options_t *options = malloc (sizeof (cairo_font_options_t));
+ cairo_font_options_t *options;
+ if (original == &_cairo_font_options_nil)
+ return (cairo_font_options_t *)&_cairo_font_options_nil;
+
+ options = malloc (sizeof (cairo_font_options_t));
if (!options)
return (cairo_font_options_t *)&_cairo_font_options_nil;
@@ -157,6 +161,7 @@ cairo_font_options_status (cairo_font_op
else
return CAIRO_STATUS_SUCCESS;
}
+slim_hidden_def (cairo_font_options_status);
/**
* cairo_font_options_merge:
diff --git a/src/cairo-gstate.c b/src/cairo-gstate.c
index a048fbb..0a77df4 100644
--- a/src/cairo-gstate.c
+++ b/src/cairo-gstate.c
@@ -1286,15 +1286,13 @@ _cairo_gstate_get_font_matrix (cairo_gst
*matrix = gstate->font_matrix;
}
-cairo_status_t
+void
_cairo_gstate_set_font_options (cairo_gstate_t *gstate,
const cairo_font_options_t *options)
{
_cairo_gstate_unset_scaled_font (gstate);
gstate->font_options = *options;
-
- return CAIRO_STATUS_SUCCESS;
}
void
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 1e05563..f29835d 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -348,6 +348,10 @@ _cairo_scaled_font_init (cairo_scaled_fo
cairo_matrix_t inverse;
cairo_status_t status;
+ status = cairo_font_options_status ((cairo_font_options_t *) options);
+ if (status)
+ return status;
+
/* Initialize scaled_font->scale early for easier bail out on an
* invalid matrix. */
_cairo_scaled_font_init_key (scaled_font, font_face,
@@ -480,6 +484,9 @@ cairo_scaled_font_create (cairo_font_fac
if (font_face->status)
return (cairo_scaled_font_t *)&_cairo_scaled_font_nil;
+ if (cairo_font_options_status ((cairo_font_options_t *) options))
+ return (cairo_scaled_font_t *)&_cairo_scaled_font_nil;
+
font_map = _cairo_scaled_font_map_lock ();
if (font_map == NULL)
return (cairo_scaled_font_t *)&_cairo_scaled_font_nil;
@@ -1644,6 +1651,9 @@ void
cairo_scaled_font_get_font_options (cairo_scaled_font_t *scaled_font,
cairo_font_options_t *options)
{
+ if (cairo_font_options_status (options))
+ return;
+
if (scaled_font->status) {
_cairo_font_options_init_default (options);
return;
diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index 7c8a1e3..d4ecabe 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -603,6 +603,9 @@ void
cairo_surface_get_font_options (cairo_surface_t *surface,
cairo_font_options_t *options)
{
+ if (cairo_font_options_status (options))
+ return;
+
if (!surface->has_font_options) {
surface->has_font_options = TRUE;
diff --git a/src/cairo.c b/src/cairo.c
index 69dfee2..a77dfdd 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -2641,9 +2641,11 @@ cairo_set_font_options (cairo_t
if (cr->status)
return;
- status = _cairo_gstate_set_font_options (cr->gstate, options);
+ status = cairo_font_options_status ((cairo_font_options_t *) options);
if (status)
_cairo_set_error (cr, status);
+
+ _cairo_gstate_set_font_options (cr->gstate, options);
}
/**
@@ -2661,6 +2663,10 @@ void
cairo_get_font_options (cairo_t *cr,
cairo_font_options_t *options)
{
+ /* check that we aren't trying to overwrite the nil object */
+ if (cairo_font_options_status (options))
+ return;
+
_cairo_gstate_get_font_options (cr->gstate, options);
}
@@ -2698,9 +2704,7 @@ cairo_set_scaled_font (cairo_t
if (status)
goto BAIL;
- status = _cairo_gstate_set_font_options (cr->gstate, &scaled_font->options);
- if (status)
- goto BAIL;
+ _cairo_gstate_set_font_options (cr->gstate, &scaled_font->options);
return;
diff --git a/src/cairoint.h b/src/cairoint.h
index 43c9ca5..a5bbb63 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1346,7 +1346,7 @@ cairo_private void
_cairo_gstate_get_font_options (cairo_gstate_t *gstate,
cairo_font_options_t *options);
-cairo_private cairo_status_t
+cairo_private void
_cairo_gstate_set_font_options (cairo_gstate_t *gstate,
const cairo_font_options_t *options);
@@ -2378,6 +2378,7 @@ slim_hidden_proto (cairo_font_options_se
slim_hidden_proto (cairo_font_options_set_hint_metrics);
slim_hidden_proto (cairo_font_options_set_hint_style);
slim_hidden_proto (cairo_font_options_set_subpixel_order);
+slim_hidden_proto (cairo_font_options_status);
slim_hidden_proto (cairo_get_current_point);
slim_hidden_proto (cairo_get_matrix);
slim_hidden_proto (cairo_get_tolerance);
diff-tree c441938569ed78123a57662a70ef5a74dcf73851 (from 409f9734297be250de5e462e2d52e653bd893125)
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue May 8 21:40:26 2007 +0100
[cairo-pattern] Cleanly handle an invalid pattern in cairo_pattern_transform()
Simply return without writing to potentially read-only members of an
invalid pattern rather than assert. This is cleaner than tracking down
all the error paths that may call into cairo_pattern_transform()...
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 2f65261..3c2382c 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -1039,7 +1039,8 @@ void
_cairo_pattern_transform (cairo_pattern_t *pattern,
const cairo_matrix_t *ctm_inverse)
{
- assert (pattern->status == CAIRO_STATUS_SUCCESS);
+ if (pattern->status)
+ return;
cairo_matrix_multiply (&pattern->matrix, ctm_inverse, &pattern->matrix);
}
More information about the cairo-commit
mailing list