[test] Handle TEST_CONTENT_COLOR_ALPHA_FLATTENED similar surfaces.

Convert the boilerplate specific flattened content value to the ordinary
CAIRO_CONTENT_COLOR_ALPHA for use with cairo_push_group_with_content() -
otherwise cairo rightfully flags an error and the test harness decides
that the similar surface is not available.
This commit is contained in:
Chris Wilson 2008-04-11 11:36:24 +01:00
parent e4fc5279cc
commit f57100acd4
4 changed files with 20 additions and 11 deletions

View file

@ -68,16 +68,22 @@
#include <ctype.h>
#include <assert.h>
cairo_content_t
cairo_boilerplate_content (cairo_content_t content)
{
if (content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED)
content = CAIRO_CONTENT_COLOR_ALPHA;
return content;
}
const char *
cairo_boilerplate_content_name (cairo_content_t content)
{
/* For the purpose of the content name, we don't distinguish the
* flattened content value.
*/
if (content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED)
content = CAIRO_CONTENT_COLOR_ALPHA;
switch (content) {
switch (cairo_boilerplate_content (content)) {
case CAIRO_CONTENT_COLOR:
return "rgb24";
case CAIRO_CONTENT_COLOR_ALPHA:

View file

@ -95,6 +95,9 @@
* PDF surfaces. */
#define CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED ((unsigned int) -1)
cairo_content_t
cairo_boilerplate_content (cairo_content_t content);
const char *
cairo_boilerplate_content_name (cairo_content_t content);

View file

@ -176,7 +176,8 @@ cairo_perf_run (cairo_perf_t *perf,
/* We run one iteration in advance to warm caches, etc. */
cairo_perf_yield ();
if (similar)
cairo_push_group_with_content (perf->cr, perf->target->content);
cairo_push_group_with_content (perf->cr,
cairo_boilerplate_content (perf->target->content));
(perf_func) (perf->cr, perf->size, perf->size);
if (similar)
cairo_pattern_destroy (cairo_pop_group (perf->cr));
@ -185,7 +186,8 @@ cairo_perf_run (cairo_perf_t *perf,
for (i =0; i < perf->iterations; i++) {
cairo_perf_yield ();
if (similar)
cairo_push_group_with_content (perf->cr, perf->target->content);
cairo_push_group_with_content (perf->cr,
cairo_boilerplate_content (perf->target->content));
times[i] = (perf_func) (perf->cr, perf->size, perf->size);
if (similar)
cairo_pattern_destroy (cairo_pop_group (perf->cr));

View file

@ -242,7 +242,7 @@ cairo_test_target_has_similar (const cairo_test_t *test, cairo_boilerplate_targe
if (surface != NULL) {
cairo_t * cr = cairo_create (surface);
cairo_surface_t *similar;
cairo_push_group_with_content (cr, target->content);
cairo_push_group_with_content (cr, cairo_boilerplate_content (target->content));
similar = cairo_get_group_target (cr);
has_similar = cairo_surface_get_type (similar) == cairo_surface_get_type (surface);
@ -342,9 +342,7 @@ cairo_test_for_target (cairo_test_t *test,
* (ignore the articifical
* CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED value).
*/
expected_content = target->content;
if (expected_content == CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED)
expected_content = CAIRO_CONTENT_COLOR_ALPHA;
expected_content = cairo_boilerplate_content (target->content);
if (cairo_surface_get_content (surface) != expected_content) {
cairo_test_log ("Error: Created surface has content %d (expected %d)\n",
@ -357,7 +355,7 @@ cairo_test_for_target (cairo_test_t *test,
cr = cairo_create (surface);
if (similar)
cairo_push_group_with_content (cr, target->content);
cairo_push_group_with_content (cr, expected_content);
/* Clear to transparent (or black) depending on whether the target
* surface supports alpha. */