[cairo-commit] 8 commits - src/cairo-image-surface.c src/cairo-pdf-surface.c src/cairo-ps-surface.c test/bitmap-font.c test/cairo-test.h test/cairo-test-runner.c test/pthread-same-source.c test/pthread-show-text.c test/pthread-similar.c test/user-font-proxy.c
Chris Wilson
ickle at kemper.freedesktop.org
Tue May 4 05:29:01 PDT 2010
src/cairo-image-surface.c | 11 +++++------
src/cairo-pdf-surface.c | 2 ++
src/cairo-ps-surface.c | 19 ++++++++-----------
test/bitmap-font.c | 4 ++--
test/cairo-test-runner.c | 31 +++++++++++++++----------------
test/cairo-test.h | 7 ++++---
test/pthread-same-source.c | 17 +++++++++--------
test/pthread-show-text.c | 17 +++++++++--------
test/pthread-similar.c | 17 +++++++++--------
test/user-font-proxy.c | 14 ++++++++++----
10 files changed, 73 insertions(+), 66 deletions(-)
New commits:
commit 9187c7532755dda8d2677ec792162c71029fb37d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue May 4 13:18:09 2010 +0100
test/bitmap-font: Check for memfault error
diff --git a/test/bitmap-font.c b/test/bitmap-font.c
index e63b70c..26a76db 100644
--- a/test/bitmap-font.c
+++ b/test/bitmap-font.c
@@ -97,7 +97,7 @@ draw (cairo_t *cr, int width, int height)
free (filename);
if (! pattern) {
cairo_test_log (ctx, "FcFreeTypeQuery failed.\n");
- return CAIRO_TEST_FAILURE;
+ return cairo_test_status_from_status (ctx, CAIRO_STATUS_NO_MEMORY);
}
font_face = cairo_ft_font_face_create_for_pattern (pattern);
@@ -108,7 +108,7 @@ draw (cairo_t *cr, int width, int height)
filename,
cairo_status_to_string (status));
FcPatternDestroy (pattern);
- return CAIRO_TEST_FAILURE;
+ return cairo_test_status_from_status (ctx, status);
}
if (cairo_font_face_get_type (font_face) != CAIRO_FONT_TYPE_FT) {
commit 0fced9279227614ede6964e94ede9de49a3a3388
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue May 4 13:17:38 2010 +0100
test/user-font-proxy: Check we install user data on the scaled font
diff --git a/test/user-font-proxy.c b/test/user-font-proxy.c
index 3470a12..41a69e7 100644
--- a/test/user-font-proxy.c
+++ b/test/user-font-proxy.c
@@ -49,14 +49,20 @@ test_scaled_font_init (cairo_scaled_font_t *scaled_font,
cairo_t *cr,
cairo_font_extents_t *extents)
{
+ cairo_status_t status;
+
cairo_set_font_face (cr,
cairo_font_face_get_user_data (cairo_scaled_font_get_font_face (scaled_font),
&fallback_font_key));
- cairo_scaled_font_set_user_data (scaled_font,
- &fallback_font_key,
- cairo_scaled_font_reference (cairo_get_scaled_font (cr)),
- (cairo_destroy_func_t) cairo_scaled_font_destroy);
+ status = cairo_scaled_font_set_user_data (scaled_font,
+ &fallback_font_key,
+ cairo_scaled_font_reference (cairo_get_scaled_font (cr)),
+ (cairo_destroy_func_t) cairo_scaled_font_destroy);
+ if (unlikely (status)) {
+ cairo_scaled_font_destroy (cairo_get_scaled_font (cr));
+ return status;
+ }
cairo_font_extents (cr, extents);
commit 38188961b996c97d344195749b7bec8c93f9bad7
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue May 4 13:17:07 2010 +0100
image: Check for pixman image allocation failure during glyphs
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index f5b5aab..492b8c3 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -3838,21 +3838,19 @@ _composite_glyphs (void *closure,
cairo_scaled_glyph_t *glyph_cache[64];
pixman_op_t pixman_op = _pixman_operator (op);
pixman_image_t *src = NULL;
- int src_x, src_y;
+ int src_x = 0, src_y = 0;
cairo_status_t status;
int i;
if (pattern != NULL) {
src = _pixman_image_for_pattern (pattern, extents, &src_x, &src_y);
- if (unlikely (src == NULL))
- return _cairo_error (CAIRO_STATUS_NO_MEMORY);
-
src_x -= dst_x;
src_y -= dst_y;
} else {
src = _pixman_white_image ();
- src_x = src_y = 0;
}
+ if (unlikely (src == NULL))
+ return _cairo_error (CAIRO_STATUS_NO_MEMORY);
memset (glyph_cache, 0, sizeof (glyph_cache));
status = CAIRO_STATUS_SUCCESS;
commit 4a181ebac416ec35e412ddbe9ed1392fb8b74ab7
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue May 4 10:26:30 2010 +0100
pdf: Cleanup local reference to source on error paths.
diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index a76d289..da51295 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -1150,6 +1150,7 @@ _cairo_pdf_surface_add_source_surface (cairo_pdf_surface_t *surface,
src_surface.surface = cairo_surface_reference (source);
surface_entry->surface_res = _cairo_pdf_surface_new_object (surface);
if (surface_entry->surface_res.id == 0) {
+ cairo_surface_destroy (source);
free (surface_entry);
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
}
@@ -1159,6 +1160,7 @@ _cairo_pdf_surface_add_source_surface (cairo_pdf_surface_t *surface,
status = _cairo_array_append (&surface->page_surfaces, &src_surface);
if (unlikely (status)) {
+ cairo_surface_destroy (source);
free (surface_entry);
return status;
}
commit ba48edcd86ee1bca06b25587e56abcd2c1b19d79
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue May 4 10:26:13 2010 +0100
ps: Always cleanup used font subsets.
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 422e232..13ccb0b 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -706,28 +706,23 @@ _cairo_ps_surface_emit_font_subsets (cairo_ps_surface_t *surface)
_cairo_ps_surface_analyze_user_font_subset,
surface);
if (unlikely (status))
- goto BAIL;
+ return status;
status = _cairo_scaled_font_subsets_foreach_unscaled (surface->font_subsets,
_cairo_ps_surface_emit_unscaled_font_subset,
surface);
if (unlikely (status))
- goto BAIL;
+ return status;
status = _cairo_scaled_font_subsets_foreach_scaled (surface->font_subsets,
_cairo_ps_surface_emit_scaled_font_subset,
surface);
if (unlikely (status))
- goto BAIL;
-
- status = _cairo_scaled_font_subsets_foreach_user (surface->font_subsets,
- _cairo_ps_surface_emit_scaled_font_subset,
- surface);
-BAIL:
- _cairo_scaled_font_subsets_destroy (surface->font_subsets);
- surface->font_subsets = NULL;
+ return status;
- return status;
+ return _cairo_scaled_font_subsets_foreach_user (surface->font_subsets,
+ _cairo_ps_surface_emit_scaled_font_subset,
+ surface);
}
static cairo_status_t
@@ -1497,6 +1492,8 @@ _cairo_ps_surface_finish (void *abstract_surface)
_cairo_ps_surface_emit_footer (surface);
CLEANUP:
+ _cairo_scaled_font_subsets_destroy (surface->font_subsets);
+
status2 = _cairo_output_stream_destroy (surface->stream);
if (status == CAIRO_STATUS_SUCCESS)
status = status2;
commit 9a0958be012e097c239260fac0dec0b1e5679028
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue May 4 10:25:48 2010 +0100
test: Cleanup after failed pthread_join().
diff --git a/test/pthread-same-source.c b/test/pthread-same-source.c
index 49123b4..10ea283 100644
--- a/test/pthread-same-source.c
+++ b/test/pthread-same-source.c
@@ -144,22 +144,23 @@ draw (cairo_t *cr, int width, int height)
cairo_set_source_rgb (cr, 0.5, 0.5, 0.5);
cairo_paint (cr);
+ pthread_yield ();
+
for (i = 0; i < N_THREADS; i++) {
void *surface;
if (pthread_equal (threads[i], pthread_self ()))
break;
- if (pthread_join (threads[i], &surface) != 0) {
+ if (pthread_join (threads[i], &surface) == 0) {
+ cairo_set_source_surface (cr, surface, 0, 0);
+ cairo_surface_destroy (surface);
+ cairo_paint (cr);
+
+ cairo_translate (cr, 0, 4 * HEIGHT);
+ } else {
test_status = CAIRO_TEST_FAILURE;
- break;
}
-
- cairo_set_source_surface (cr, surface, 0, 0);
- cairo_surface_destroy (surface);
- cairo_paint (cr);
-
- cairo_translate (cr, 0, 4 * HEIGHT);
}
return test_status;
diff --git a/test/pthread-show-text.c b/test/pthread-show-text.c
index 2d22076..b6be8dc 100644
--- a/test/pthread-show-text.c
+++ b/test/pthread-show-text.c
@@ -114,22 +114,23 @@ draw (cairo_t *cr, int width, int height)
cairo_set_source_rgb (cr, 0.5, 0.5, 0.5);
cairo_paint (cr);
+ pthread_yield ();
+
for (i = 0; i < N_THREADS; i++) {
void *surface;
if (pthread_equal (threads[i], pthread_self ()))
break;
- if (pthread_join (threads[i], &surface) != 0) {
+ if (pthread_join (threads[i], &surface) == 0) {
+ cairo_set_source_surface (cr, surface, 0, 0);
+ cairo_surface_destroy (surface);
+ cairo_paint (cr);
+
+ cairo_translate (cr, 0, HEIGHT);
+ } else {
test_status = CAIRO_TEST_FAILURE;
- break;
}
-
- cairo_set_source_surface (cr, surface, 0, 0);
- cairo_surface_destroy (surface);
- cairo_paint (cr);
-
- cairo_translate (cr, 0, HEIGHT);
}
return test_status;
diff --git a/test/pthread-similar.c b/test/pthread-similar.c
index 15196ad..9d33b15 100644
--- a/test/pthread-similar.c
+++ b/test/pthread-similar.c
@@ -77,22 +77,23 @@ draw (cairo_t *cr, int width, int height)
}
}
+ pthread_yield ();
+
for (i = 0; i < N_THREADS; i++) {
void *surface;
if (pthread_equal (threads[i], pthread_self ()))
break;
- if (pthread_join (threads[i], &surface) != 0) {
+ if (pthread_join (threads[i], &surface) == 0) {
+ cairo_set_source_surface (cr, surface, 0, 0);
+ cairo_surface_destroy (surface);
+ cairo_paint (cr);
+
+ cairo_translate (cr, 0, HEIGHT);
+ } else {
test_status = CAIRO_TEST_FAILURE;
- break;
}
-
- cairo_set_source_surface (cr, surface, 0, 0);
- cairo_surface_destroy (surface);
- cairo_paint (cr);
-
- cairo_translate (cr, 0, HEIGHT);
}
return test_status;
commit 08b9984da9f2119cd4ed03bbd656a349b49d1f12
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue May 4 08:19:41 2010 +0100
image: Replace assert with error return
It is possible to encounter an allocation failure here since we may have
tweaked the clip since the last evaluation of the clip region.
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 21cfe4d..f5b5aab 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -2191,8 +2191,9 @@ _clip_and_composite (cairo_image_surface_t *dst,
status = _cairo_clip_get_region (clip, &clip_region);
if (unlikely (status == CAIRO_INT_STATUS_NOTHING_TO_DO))
return CAIRO_STATUS_SUCCESS;
+ if (unlikely (_cairo_status_is_error (status)))
+ return status;
- assert (! _cairo_status_is_error (status));
need_clip_surface = status == CAIRO_INT_STATUS_UNSUPPORTED;
if (clip_region != NULL) {
commit 2c68fcace4ad47ad09e9699e45afb514be1381f9
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Mon May 3 20:39:34 2010 +0100
test: Embed the list pointer into cairo_test_t
Reduce the amount of output printed by leak-detectors when a test
crashes.
diff --git a/test/cairo-test-runner.c b/test/cairo-test-runner.c
index 2b83b88..1e789ec 100644
--- a/test/cairo-test-runner.c
+++ b/test/cairo-test-runner.c
@@ -101,7 +101,7 @@ typedef enum {
GT
} cairo_test_compare_op_t;
-static cairo_test_list_t *tests;
+static cairo_test_t *tests;
static void CAIRO_BOILERPLATE_PRINTF_FORMAT(2,3)
_log (cairo_test_context_t *ctx,
@@ -638,7 +638,7 @@ int
main (int argc, char **argv)
{
cairo_test_runner_t runner;
- cairo_test_list_t *list;
+ cairo_test_t *test;
cairo_test_status_t *target_status;
unsigned int n, m;
char targets[4096];
@@ -687,18 +687,18 @@ main (int argc, char **argv)
runner.base.num_targets);
}
- for (list = tests; list != NULL; list = list->next) {
+ for (test = tests; test != NULL; test = test->next) {
cairo_test_context_t ctx;
cairo_test_status_t status;
cairo_bool_t failed = FALSE, xfailed = FALSE, crashed = FALSE, skipped = TRUE;
cairo_bool_t in_preamble = FALSE;
- char *name = cairo_test_get_name (list->test);
+ char *name = cairo_test_get_name (test);
int i;
/* check for restricted runs */
if (argc) {
cairo_bool_t found = FALSE;
- const char *keywords = list->test->keywords;
+ const char *keywords = test->keywords;
for (i = 0; i < argc; i++) {
const char *match = argv[i];
@@ -733,8 +733,8 @@ main (int argc, char **argv)
}
/* check to see if external requirements match */
- if (list->test->requirements != NULL) {
- const char *requirements = list->test->requirements;
+ if (test->requirements != NULL) {
+ const char *requirements = test->requirements;
const char *str;
str = strstr (requirements, "cairo");
@@ -775,7 +775,7 @@ main (int argc, char **argv)
goto TEST_NEXT;
}
- _cairo_test_context_init_for_test (&ctx, &runner.base, list->test);
+ _cairo_test_context_init_for_test (&ctx, &runner.base, test);
memset (target_status, 0,
sizeof (cairo_test_status_t) * ctx.num_targets);
@@ -795,7 +795,7 @@ main (int argc, char **argv)
case CAIRO_TEST_NEW:
case CAIRO_TEST_FAILURE:
runner.fails_preamble = _list_prepend (runner.fails_preamble,
- list->test);
+ test);
in_preamble = TRUE;
failed = TRUE;
goto TEST_DONE;
@@ -803,7 +803,7 @@ main (int argc, char **argv)
case CAIRO_TEST_NO_MEMORY:
case CAIRO_TEST_CRASHED:
runner.crashes_preamble = _list_prepend (runner.crashes_preamble,
- list->test);
+ test);
in_preamble = TRUE;
failed = TRUE;
goto TEST_DONE;
@@ -861,13 +861,13 @@ main (int argc, char **argv)
target_status[n] = CAIRO_TEST_CRASHED;
runner.num_crashed_per_target[n]++;
runner.crashes_per_target[n] = _list_prepend (runner.crashes_per_target[n],
- list->test);
+ test);
crashed = TRUE;
} else if (target_failed) {
target_status[n] = CAIRO_TEST_FAILURE;
runner.num_failed_per_target[n]++;
runner.fails_per_target[n] = _list_prepend (runner.fails_per_target[n],
- list->test);
+ test);
failed = TRUE;
} else if (target_xfailed) {
@@ -947,8 +947,6 @@ main (int argc, char **argv)
}
- _list_free (tests);
-
if (runner.list_only) {
printf ("\n");
return CAIRO_TEST_SUCCESS;
@@ -966,7 +964,8 @@ main (int argc, char **argv)
}
void
-cairo_test_register (const cairo_test_t *test)
+cairo_test_register (cairo_test_t *test)
{
- tests = _list_prepend (tests, test);
+ test->next = tests;
+ tests = test;
}
diff --git a/test/cairo-test.h b/test/cairo-test.h
index bf10eb7..53db80b 100644
--- a/test/cairo-test.h
+++ b/test/cairo-test.h
@@ -138,6 +138,7 @@ typedef cairo_test_status_t
(cairo_test_draw_function_t) (cairo_t *cr, int width, int height);
struct _cairo_test {
+ struct _cairo_test *next;
const char *name;
const char *description;
const char *keywords;
@@ -177,8 +178,8 @@ struct _cairo_test {
#define CAIRO_TEST(name, description, keywords, requirements, width, height, preamble, draw) \
void _register_##name (void); \
void _register_##name (void) { \
- static const cairo_test_t test = { \
- #name, description, \
+ static cairo_test_t test = { \
+ NULL, #name, description, \
keywords, requirements, \
width, height, \
preamble, draw \
@@ -187,7 +188,7 @@ void _register_##name (void) { \
}
void
-cairo_test_register (const cairo_test_t *test);
+cairo_test_register (cairo_test_t *test);
/* The full context for the test.
* For ordinary tests (using the CAIRO_TEST()->draw interface) the context
More information about the cairo-commit
mailing list