[cairo-commit] 5 commits - boilerplate/Makefile.am src/cairo-output-stream.c src/cairo-output-stream-private.h src/cairo-ps-surface.c src/cairo-scaled-font-subsets-private.h test/cairo-test.c test/pdiff
Chris Wilson
ickle at kemper.freedesktop.org
Tue Aug 26 16:56:15 PDT 2008
boilerplate/Makefile.am | 2 -
src/cairo-output-stream-private.h | 2 -
src/cairo-output-stream.c | 2 -
src/cairo-ps-surface.c | 12 +++----
src/cairo-scaled-font-subsets-private.h | 2 -
test/cairo-test.c | 54 ++++++++++++++++----------------
test/pdiff/pdiff.c | 38 +++++++++-------------
7 files changed, 53 insertions(+), 59 deletions(-)
New commits:
commit bd21b2f6307549d9ade94bbe3f32f92efae97f72
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Aug 26 21:06:26 2008 +0100
[test] Ensure that the output is always saved.
Do the saving of the output first before checking for various failures
with respect to the reference images.
diff --git a/test/cairo-test.c b/test/cairo-test.c
index 2108eb7..c0e59bf 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -669,13 +669,6 @@ cairo_test_for_target (cairo_test_context_t *ctx,
buffer_diff_result_t result;
cairo_status_t diff_status;
- if (ref_name == NULL) {
- cairo_test_log (ctx, "Error: Cannot find reference image for %s\n",
- base_name);
- ret = CAIRO_TEST_FAILURE;
- goto UNWIND_CAIRO;
- }
-
if (target->finish_surface != NULL) {
diff_status = target->finish_surface (surface);
if (diff_status) {
@@ -686,6 +679,30 @@ cairo_test_for_target (cairo_test_context_t *ctx,
}
}
+ _xunlink (ctx, png_name);
+ _xunlink (ctx, diff_name);
+
+ /* first *always* save the test output */
+ test_image = target->get_image_surface (surface,
+ ctx->test->width,
+ ctx->test->height);
+ if (cairo_surface_status (test_image)) {
+ cairo_test_log (ctx, "Error: Failed to extract image: %s\n",
+ cairo_status_to_string (cairo_surface_status (test_image)));
+ ret = CAIRO_TEST_FAILURE;
+ goto UNWIND_CAIRO;
+ }
+
+ diff_status = cairo_surface_write_to_png (test_image, png_name);
+ if (diff_status) {
+ cairo_test_log (ctx, "Error: Failed to write output image: %s\n",
+ cairo_status_to_string (diff_status));
+ cairo_surface_destroy (test_image);
+ ret = CAIRO_TEST_FAILURE;
+ goto UNWIND_CAIRO;
+ }
+ have_output = TRUE;
+
if (target->file_extension != NULL) { /* compare vector surfaces */
xasprintf (&test_filename, "%s-out%s",
base_name, target->file_extension);
@@ -708,27 +725,12 @@ cairo_test_for_target (cairo_test_context_t *ctx,
}
}
- _xunlink (ctx, png_name);
-
- test_image = target->get_image_surface (surface,
- ctx->test->width,
- ctx->test->height);
- if (cairo_surface_status (test_image)) {
- cairo_test_log (ctx, "Error: Failed to extract image: %s\n",
- cairo_status_to_string (cairo_surface_status (test_image)));
- ret = CAIRO_TEST_FAILURE;
- goto UNWIND_CAIRO;
- }
-
- diff_status = cairo_surface_write_to_png (test_image, png_name);
- if (diff_status) {
- cairo_test_log (ctx, "Error: Failed to write output image: %s\n",
- cairo_status_to_string (diff_status));
- cairo_surface_destroy (test_image);
+ if (ref_name == NULL) {
+ cairo_test_log (ctx, "Error: Cannot find reference image for %s\n",
+ base_name);
ret = CAIRO_TEST_FAILURE;
goto UNWIND_CAIRO;
}
- have_output = TRUE;
/* binary compare png files (no decompression) */
if (target->file_extension == NULL) {
@@ -779,8 +781,6 @@ cairo_test_for_target (cairo_test_context_t *ctx,
goto UNWIND_CAIRO;
}
- _xunlink (ctx, diff_name);
-
diff_image = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
ctx->test->width,
ctx->test->height);
commit de6742c5f190664556658e35f5ea5ede979671af
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Aug 26 18:41:22 2008 +0100
[ps] Mark the hex data as unsigned char.
Use unsigned char to avoid sign extensions issues when bit shifting.
diff --git a/src/cairo-output-stream-private.h b/src/cairo-output-stream-private.h
index 9bfc534..15cd2c0 100644
--- a/src/cairo-output-stream-private.h
+++ b/src/cairo-output-stream-private.h
@@ -107,7 +107,7 @@ _cairo_output_stream_write (cairo_output_stream_t *stream,
cairo_private void
_cairo_output_stream_write_hex_string (cairo_output_stream_t *stream,
- const char *data,
+ const unsigned char *data,
size_t length);
cairo_private void
diff --git a/src/cairo-output-stream.c b/src/cairo-output-stream.c
index 5041f75..206ed30 100644
--- a/src/cairo-output-stream.c
+++ b/src/cairo-output-stream.c
@@ -237,7 +237,7 @@ _cairo_output_stream_write (cairo_output_stream_t *stream,
void
_cairo_output_stream_write_hex_string (cairo_output_stream_t *stream,
- const char *data,
+ const unsigned char *data,
size_t length)
{
const char hex_chars[] = "0123456789abcdef";
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 25a8ad1..981f69d 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -367,7 +367,7 @@ _cairo_ps_surface_emit_truetype_font_subset (cairo_ps_surface_t *surface,
subset.data + begin, end - begin);
_cairo_output_stream_printf (surface->final_stream,"00>\n");
begin = end;
- }
+ }
if (subset.data_length > end) {
_cairo_output_stream_printf (surface->final_stream,"<");
_cairo_output_stream_write_hex_string (surface->final_stream,
diff --git a/src/cairo-scaled-font-subsets-private.h b/src/cairo-scaled-font-subsets-private.h
index 4eb2c79..e877318 100644
--- a/src/cairo-scaled-font-subsets-private.h
+++ b/src/cairo-scaled-font-subsets-private.h
@@ -371,7 +371,7 @@ typedef struct _cairo_truetype_subset {
double *widths;
double x_min, y_min, x_max, y_max;
double ascent, descent;
- char *data;
+ unsigned char *data;
unsigned long data_length;
unsigned long *string_offsets;
unsigned long num_string_offsets;
commit 92fcb9d2f7fa143d1f6707ead7d4a85e9f739bcb
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Tue Aug 26 14:36:46 2008 +0100
[configure.in] Autoconf strikes back
Need to disable references to *.cpp to convince autoconf
not to use the g++ linker (and fail miserably).
diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index b025acd..79cb444 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -13,7 +13,7 @@ libcairoboilerplate_la_SOURCES = \
libcairoboilerplate_la_LIBADD = $(top_builddir)/src/libcairo.la $(CAIRO_LDADD)
if CAIRO_HAS_BEOS_SURFACE
-libcairoboilerplate_la_SOURCES += cairo-boilerplate-beos.cpp
+#libcairoboilerplate_la_SOURCES += cairo-boilerplate-beos.cpp
libcairoboilerplate_la_SOURCES += cairo-boilerplate-beos-private.h
# BeOS system headers trigger this warning
libcairoboilerplate_la_CXXFLAGS = -Wno-multichar
commit 08ea9d1f2a2210a1f333f3425eb141c2f5f1399c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri Aug 22 23:09:13 2008 +0100
[pdiff] Get the surface data pointer once.
Don't call cairo_image_surface_get_data() for every single component of
the two surfaces to compare.
diff --git a/test/pdiff/pdiff.c b/test/pdiff/pdiff.c
index 3f472f3..c4f7d53 100644
--- a/test/pdiff/pdiff.c
+++ b/test/pdiff/pdiff.c
@@ -175,24 +175,19 @@ XYZToLAB (float x, float y, float z, float *L, float *A, float *B)
}
static uint32_t
-_get_pixel (cairo_surface_t *surface, int i)
+_get_pixel (const uint32_t *data, int i)
{
- uint32_t *data;
-
- data = (uint32_t *) cairo_image_surface_get_data (surface);
return data[i];
}
static unsigned char
-_get_red (cairo_surface_t *surface, int i)
+_get_red (const uint32_t *data, int i)
{
uint32_t pixel;
uint8_t alpha;
- pixel = _get_pixel (surface, i);
-
+ pixel = _get_pixel (data, i);
alpha = (pixel & 0xff000000) >> 24;
-
if (alpha == 0)
return 0;
else
@@ -200,15 +195,13 @@ _get_red (cairo_surface_t *surface, int i)
}
static unsigned char
-_get_green (cairo_surface_t *surface, int i)
+_get_green (const uint32_t *data, int i)
{
uint32_t pixel;
uint8_t alpha;
- pixel = _get_pixel (surface, i);
-
+ pixel = _get_pixel (data, i);
alpha = (pixel & 0xff000000) >> 24;
-
if (alpha == 0)
return 0;
else
@@ -216,15 +209,13 @@ _get_green (cairo_surface_t *surface, int i)
}
static unsigned char
-_get_blue (cairo_surface_t *surface, int i)
+_get_blue (const uint32_t *data, int i)
{
uint32_t pixel;
uint8_t alpha;
- pixel = _get_pixel (surface, i);
-
+ pixel = _get_pixel (data, i);
alpha = (pixel & 0xff000000) >> 24;
-
if (alpha == 0)
return 0;
else
@@ -281,6 +272,7 @@ pdiff_compare (cairo_surface_t *surface_a,
float cpd[MAX_PYR_LEVELS];
float F_freq[MAX_PYR_LEVELS - 2];
float csf_max;
+ const uint32_t *data_a, *data_b;
unsigned int pixels_failed;
@@ -303,19 +295,21 @@ pdiff_compare (cairo_surface_t *surface_a,
aB = xmalloc (dim * sizeof (float));
bB = xmalloc (dim * sizeof (float));
+ data_a = (uint32_t *) cairo_image_surface_get_data (surface_a);
+ data_b = (uint32_t *) cairo_image_surface_get_data (surface_b);
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
float r, g, b, l;
i = x + y * w;
- r = powf(_get_red (surface_a, i) / 255.0f, gamma);
- g = powf(_get_green (surface_a, i) / 255.0f, gamma);
- b = powf(_get_blue (surface_a, i) / 255.0f, gamma);
+ r = powf(_get_red (data_a, i) / 255.0f, gamma);
+ g = powf(_get_green (data_a, i) / 255.0f, gamma);
+ b = powf(_get_blue (data_a, i) / 255.0f, gamma);
AdobeRGBToXYZ(r,g,b,&aX[i],&aY[i],&aZ[i]);
XYZToLAB(aX[i], aY[i], aZ[i], &l, &aA[i], &aB[i]);
- r = powf(_get_red (surface_b, i) / 255.0f, gamma);
- g = powf(_get_green (surface_b, i) / 255.0f, gamma);
- b = powf(_get_blue (surface_b, i) / 255.0f, gamma);
+ r = powf(_get_red (data_b, i) / 255.0f, gamma);
+ g = powf(_get_green (data_b, i) / 255.0f, gamma);
+ b = powf(_get_blue (data_b, i) / 255.0f, gamma);
AdobeRGBToXYZ(r,g,b,&bX[i],&bY[i],&bZ[i]);
XYZToLAB(bX[i], bY[i], bZ[i], &l, &bA[i], &bB[i]);
commit 590ccb900605f9bdf30f02f76b7dd622acb9a27d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date: Fri Aug 22 14:54:19 2008 +0100
[ps] Convert a few residual CRLF to LF.
Just a few CRLF eol-terminators remained, cluttering the output.
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index f1ce1d1..25a8ad1 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -2709,17 +2709,17 @@ _cairo_ps_surface_emit_linear_pattern (cairo_ps_surface_t *surface,
" << /ShadingType 2\n"
" /ColorSpace /DeviceRGB\n"
" /Coords [ %f %f %f %f ]\n"
- " /Domain [ %f %f ]\r\n"
+ " /Domain [ %f %f ]\n"
" /Function CairoFunction\n",
x1, y1, x2, y2,
first_stop, last_stop);
if (extend == CAIRO_EXTEND_PAD) {
_cairo_output_stream_printf (surface->stream,
- " /Extend [ true true ]\r\n");
+ " /Extend [ true true ]\n");
} else {
_cairo_output_stream_printf (surface->stream,
- " /Extend [ false false ]\r\n");
+ " /Extend [ false false ]\n");
}
_cairo_output_stream_printf (surface->stream,
@@ -2791,10 +2791,10 @@ _cairo_ps_surface_emit_radial_pattern (cairo_ps_surface_t *surface,
if (extend == CAIRO_EXTEND_PAD) {
_cairo_output_stream_printf (surface->stream,
- " /Extend [ true true ]\r\n");
+ " /Extend [ true true ]\n");
} else {
_cairo_output_stream_printf (surface->stream,
- " /Extend [ false false ]\r\n");
+ " /Extend [ false false ]\n");
}
_cairo_output_stream_printf (surface->stream,
More information about the cairo-commit
mailing list