[cairo-commit] 6 commits - src/cairo-color.c src/cairoint.h
src/cairo-pattern.c test/cairo-test.c test/pattern-getters.c
Behdad Esfahbod
behdad at kemper.freedesktop.org
Tue Mar 13 13:51:31 PDT 2007
src/cairo-color.c | 11 ++++++-----
src/cairo-pattern.c | 17 +++++++++--------
src/cairoint.h | 3 +++
test/cairo-test.c | 44 +++++++++++++++++++++++++++++---------------
test/pattern-getters.c | 14 +++++++++++---
5 files changed, 58 insertions(+), 31 deletions(-)
New commits:
diff-tree f3c8d82d6d6a759364c4228d9b0badf846debcea (from 30b5f1baa8cbd01ac0a3ff376e294775b600b4e4)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Mar 13 16:51:34 2007 -0400
[test] If backends are limited and all untested, pass the test
This is necessary to ensure that limiting backends using
CAIRO_TEST_TARGET does not increase the number of tests failing,
which is a desirable invariant.
diff --git a/test/cairo-test.c b/test/cairo-test.c
index 0228a17..f3cf9e9 100755
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -453,10 +453,11 @@ cairo_test_expecting (cairo_test_t *test
/* The intended logic here is that we return overall SUCCESS
* iff. there is at least one tested backend and that all tested
- * backends return SUCCESS, OR, there's no backend to test at all.
+ * backends return SUCCESS, OR, there's backends were manually
+ * limited, and none were tested.
* In other words:
*
- * if no backend to test
+ * if backends limited and no backend tested
* -> SUCCESS
* else if any backend not SUCCESS
* -> FAILURE
@@ -547,19 +548,32 @@ cairo_test_expecting (cairo_test_t *test
if (ret != CAIRO_TEST_SUCCESS)
printf ("Check %s%s out for more information.\n", test->name, CAIRO_TEST_LOG_SUFFIX);
- /* if no target was requested for test, succeed, otherwise if all
- * were untested, fail. */
- if (ret == CAIRO_TEST_UNTESTED)
- ret = num_targets ? CAIRO_TEST_FAILURE : CAIRO_TEST_SUCCESS;
-
- /* if targets are limited using CAIRO_TEST_TARGET, and expecting failure,
- * make it fail, such that we can pass test suite by limiting backends
- * to test without triggering XPASS failures. */
- if (limited_targets && expectation == CAIRO_TEST_FAILURE && ret == CAIRO_TEST_SUCCESS) {
- printf ("All tested backends passed, but tested targets are manually limited\n"
- "and the test suite expects this test to fail for at least one target.\n"
- "Intentionally failing the test, to not fail the suite.\n");
- ret = CAIRO_TEST_FAILURE;
+ /* if the set of targets to test was limited using CAIRO_TEST_TARGET, we
+ * behave slightly differently, to ensure that limiting the targets does
+ * not increase the number of tests failing. */
+ if (limited_targets) {
+
+ /* if all untested, success */
+ if (ret == CAIRO_TEST_UNTESTED) {
+ printf ("None of the tested backends passed, but tested targets are manually limited.\n"
+ "Passing the test, to not fail the suite.\n");
+ ret = CAIRO_TEST_SUCCESS;
+ }
+
+ /* if all passed, but expecting failure, return failure to not
+ * trigger an XPASS failure */
+ if (expectation == CAIRO_TEST_FAILURE && ret == CAIRO_TEST_SUCCESS) {
+ printf ("All tested backends passed, but tested targets are manually limited\n"
+ "and the test suite expects this test to fail for at least one target.\n"
+ "Intentionally failing the test, to not fail the suite.\n");
+ ret = CAIRO_TEST_FAILURE;
+ }
+
+ } else {
+
+ if (ret == CAIRO_TEST_UNTESTED)
+ ret = CAIRO_TEST_FAILURE;
+
}
cairo_test_fini ();
diff-tree 30b5f1baa8cbd01ac0a3ff376e294775b600b4e4 (from 9267cb042418250614db83bd3b2dcb0e7615af79)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Mar 13 16:50:10 2007 -0400
[test] In pattern-getters test, log what went wrong
diff --git a/test/pattern-getters.c b/test/pattern-getters.c
index d4014ea..695245d 100644
--- a/test/pattern-getters.c
+++ b/test/pattern-getters.c
@@ -45,8 +45,11 @@ double_buf_equal (double *a, double *b,
{
int i;
for (i = 0; i < nc; i++) {
- if (!DOUBLE_EQUALS(a[i],b[i]))
+ if (!DOUBLE_EQUALS(a[i],b[i])) {
+ cairo_test_log ("Error: doubles not equal: %g, %g\n",
+ a[i], b[i]);
return 0;
+ }
}
return 1;
}
@@ -68,8 +71,11 @@ draw (cairo_t *cr, int width, int height
if (!DOUBLE_EQUALS(r,0.2) ||
!DOUBLE_EQUALS(g,0.3) ||
!DOUBLE_EQUALS(b,0.4) ||
- !DOUBLE_EQUALS(a,0.5))
+ !DOUBLE_EQUALS(a,0.5)) {
+ cairo_test_log ("Error: cairo_pattern_get_rgba returned unexepcted results: %g, %g, %g, %g\n",
+ r, g, b, a);
return CAIRO_TEST_FAILURE;
+ }
cairo_pattern_destroy (pat);
}
@@ -83,8 +89,10 @@ draw (cairo_t *cr, int width, int height
status = cairo_pattern_get_surface (pat, &surf);
CHECK_SUCCESS;
- if (surf != cairo_get_target (cr))
+ if (surf != cairo_get_target (cr)) {
+ cairo_test_log ("Error: cairo_pattern_get_resurface returned wrong surface\n");
return CAIRO_TEST_FAILURE;
+ }
cairo_pattern_destroy (pat);
}
diff-tree 9267cb042418250614db83bd3b2dcb0e7615af79 (from 60502ba3481ea751df6f379e1c38850172826695)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Mar 13 16:49:42 2007 -0400
[cairo-pattern] Use _cairo_color_double_to_short() to fix color conversion
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index c8e74de..7cd033c 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -684,10 +684,10 @@ _cairo_pattern_add_color_stop (cairo_gra
new_stops[i].x = x;
- new_stops[i].color.red = red * 65535.0;
- new_stops[i].color.green = green * 65535.0;
- new_stops[i].color.blue = blue * 65535.0;
- new_stops[i].color.alpha = alpha * 65535.0;
+ new_stops[i].color.red = _cairo_color_double_to_short (red);
+ new_stops[i].color.green = _cairo_color_double_to_short (green);
+ new_stops[i].color.blue = _cairo_color_double_to_short (blue);
+ new_stops[i].color.alpha = _cairo_color_double_to_short (alpha);
pattern->n_stops++;
}
diff-tree 60502ba3481ea751df6f379e1c38850172826695 (from 956fdfbb62ac82da1e6fbd467c50e449ec621937)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Mar 13 16:13:35 2007 -0400
[cairo-color] Add cairo-private _cairo_color_double_to_short()
diff --git a/src/cairo-color.c b/src/cairo-color.c
index a348839..ad6316e 100644
--- a/src/cairo-color.c
+++ b/src/cairo-color.c
@@ -95,7 +95,8 @@ _cairo_color_init_rgb (cairo_color_t *co
* then special-casing the result of an input value of 1.0 so that it
* maps to 65535 instead of 65536.
*/
-static inline uint16_t _color_to_short (double d)
+uint16_t
+_cairo_color_double_to_short (double d)
{
uint32_t i;
i = (uint32_t) (d * 65536);
@@ -106,10 +107,10 @@ static inline uint16_t _color_to_short (
static void
_cairo_color_compute_shorts (cairo_color_t *color)
{
- color->red_short = _color_to_short (color->red * color->alpha);
- color->green_short = _color_to_short (color->green * color->alpha);
- color->blue_short = _color_to_short (color->blue * color->alpha);
- color->alpha_short = _color_to_short (color->alpha);
+ color->red_short = _cairo_color_double_to_short (color->red * color->alpha);
+ color->green_short = _cairo_color_double_to_short (color->green * color->alpha);
+ color->blue_short = _cairo_color_double_to_short (color->blue * color->alpha);
+ color->alpha_short = _cairo_color_double_to_short (color->alpha);
}
void
diff --git a/src/cairoint.h b/src/cairoint.h
index 3251950..c31f1dc 100755
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -1589,6 +1589,9 @@ _cairo_stock_color (cairo_stock_t stock)
#define CAIRO_COLOR_BLACK _cairo_stock_color (CAIRO_STOCK_BLACK)
#define CAIRO_COLOR_TRANSPARENT _cairo_stock_color (CAIRO_STOCK_TRANSPARENT)
+cairo_private uint16_t
+_cairo_color_double_to_short (double d);
+
cairo_private void
_cairo_color_init (cairo_color_t *color);
diff-tree 956fdfbb62ac82da1e6fbd467c50e449ec621937 (from 20304908626f0af40aeda145b2967a40151728c5)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Mar 13 06:30:11 2007 -0400
[cairo-pattern] Fix color conversion from short to double
We should divide by 65535.0, not 65536.0.
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 5c1823e..c8e74de 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -1442,10 +1442,10 @@ _cairo_pattern_acquire_surface (cairo_pa
cairo_color_t color;
_cairo_color_init_rgba (&color,
- src->stops->color.red / 65536.0,
- src->stops->color.green / 65536.0,
- src->stops->color.blue / 65536.0,
- src->stops->color.alpha / 65536.0);
+ src->stops->color.red / 65535.0,
+ src->stops->color.green / 65535.0,
+ src->stops->color.blue / 65535.0,
+ src->stops->color.alpha / 65535.0);
_cairo_pattern_init_solid (&solid, &color);
}
diff-tree 20304908626f0af40aeda145b2967a40151728c5 (from deed0f473400bc2e91dde8bad2537d499a5941ea)
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Mar 13 06:20:21 2007 -0400
[cairo-pattern] Add XXX note
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index efa0c5a..5c1823e 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -1637,6 +1637,7 @@ _cairo_pattern_get_extents (cairo_patter
imatrix = pattern->matrix;
cairo_matrix_invert (&imatrix);
+ /* XXX Use _cairo_matrix_transform_bounding_box here */
for (sy = 0; sy <= 1; sy++) {
for (sx = 0; sx <= 1; sx++) {
x = surface_extents.x + sx * surface_extents.width;
More information about the cairo-commit
mailing list