Commit af9fbd17 authored by Chris Wilson's avatar Chris Wilson 🤔
Browse files

Introduce a new compositor architecture



Having spent the last dev cycle looking at how we could specialize the
compositors for various backends, we once again look for the
commonalities in order to reduce the duplication. In part this is
motivated by the idea that spans is a good interface for both the
existent GL backend and pixman, and so they deserve a dedicated
compositor. xcb/xlib target an identical rendering system and so they
should be using the same compositor, and it should be possible to run
that same compositor locally against pixman to generate reference tests.
Signed-off-by: Chris Wilson's avatarChris Wilson <chris@chris-wilson.co.uk>

P.S. This brings massive upheaval (read breakage) I've tried delaying in
order to fix as many things as possible but now this one patch does far,
far, far too much. Apologies in advance for breaking your favourite
backend, but trust me in that the end result will be much better. :)
parent 0540bf38
......@@ -30,66 +30,133 @@
#include <cairo-types-private.h>
#include <test-fallback-surface.h>
#include <test-fallback16-surface.h>
#include <test-compositor-surface.h>
#include <test-null-compositor-surface.h>
#if CAIRO_HAS_TEST_PAGINATED_SURFACE
#include <test-paginated-surface.h>
#endif
#if CAIRO_HAS_TEST_NULL_SURFACE
#include <test-null-surface.h>
#endif
#if CAIRO_HAS_TEST_WRAPPING_SURFACE
#include <test-wrapping-surface.h>
#endif
static cairo_surface_t *
_cairo_boilerplate_test_fallback_create_surface (const char *name,
cairo_content_t content,
double width,
double height,
double max_width,
double max_height,
cairo_boilerplate_mode_t mode,
int id,
void **closure)
_cairo_boilerplate_test_base_compositor_create_surface (const char *name,
cairo_content_t content,
double width,
double height,
double max_width,
double max_height,
cairo_boilerplate_mode_t mode,
int id,
void **closure)
{
*closure = NULL;
return _cairo_test_fallback_surface_create (content,
ceil (width), ceil (height));
return _cairo_test_base_compositor_surface_create (content, ceil (width), ceil (height));
}
static cairo_surface_t *
_cairo_boilerplate_test_fallback16_create_surface (const char *name,
cairo_content_t content,
double width,
double height,
double max_width,
double max_height,
cairo_boilerplate_mode_t mode,
int id,
void **closure)
_cairo_boilerplate_test_fallback_compositor_create_surface (const char *name,
cairo_content_t content,
double width,
double height,
double max_width,
double max_height,
cairo_boilerplate_mode_t mode,
int id,
void **closure)
{
*closure = NULL;
return _cairo_test_fallback16_surface_create (content,
ceil (width), ceil (height));
return _cairo_test_fallback_compositor_surface_create (content, ceil (width), ceil (height));
}
#if CAIRO_HAS_TEST_NULL_SURFACE
static cairo_surface_t *
_cairo_boilerplate_test_null_create_surface (const char *name,
cairo_content_t content,
double width,
double height,
double max_width,
double max_height,
cairo_boilerplate_mode_t mode,
int id,
void **closure)
_cairo_boilerplate_test_mask_compositor_create_surface (const char *name,
cairo_content_t content,
double width,
double height,
double max_width,
double max_height,
cairo_boilerplate_mode_t mode,
int id,
void **closure)
{
*closure = NULL;
return _cairo_test_null_surface_create (content);
return _cairo_test_mask_compositor_surface_create (content, ceil (width), ceil (height));
}
static cairo_surface_t *
_cairo_boilerplate_test_traps_compositor_create_surface (const char *name,
cairo_content_t content,
double width,
double height,
double max_width,
double max_height,
cairo_boilerplate_mode_t mode,
int id,
void **closure)
{
*closure = NULL;
return _cairo_test_traps_compositor_surface_create (content, ceil (width), ceil (height));
}
static cairo_surface_t *
_cairo_boilerplate_test_spans_compositor_create_surface (const char *name,
cairo_content_t content,
double width,
double height,
double max_width,
double max_height,
cairo_boilerplate_mode_t mode,
int id,
void **closure)
{
*closure = NULL;
return _cairo_test_spans_compositor_surface_create (content, ceil (width), ceil (height));
}
static cairo_surface_t *
_cairo_boilerplate_test_no_fallback_compositor_create_surface (const char *name,
cairo_content_t content,
double width,
double height,
double max_width,
double max_height,
cairo_boilerplate_mode_t mode,
int id,
void **closure)
{
*closure = NULL;
return _cairo_test_no_fallback_compositor_surface_create (content, ceil (width), ceil (height));
}
static cairo_surface_t *
_cairo_boilerplate_test_no_traps_compositor_create_surface (const char *name,
cairo_content_t content,
double width,
double height,
double max_width,
double max_height,
cairo_boilerplate_mode_t mode,
int id,
void **closure)
{
*closure = NULL;
return _cairo_test_no_traps_compositor_surface_create (content, ceil (width), ceil (height));
}
static cairo_surface_t *
_cairo_boilerplate_test_no_spans_compositor_create_surface (const char *name,
cairo_content_t content,
double width,
double height,
double max_width,
double max_height,
cairo_boilerplate_mode_t mode,
int id,
void **closure)
{
*closure = NULL;
return _cairo_test_no_spans_compositor_surface_create (content, ceil (width), ceil (height));
}
#endif
#if CAIRO_HAS_TEST_PAGINATED_SURFACE
static const cairo_user_data_key_t test_paginated_closure_key;
......@@ -201,40 +268,38 @@ _cairo_boilerplate_test_paginated_cleanup (void *closure)
}
#endif
#if CAIRO_HAS_TEST_WRAPPING_SURFACE
static cairo_surface_t *
_cairo_boilerplate_test_wrapping_create_surface (const char *name,
cairo_content_t content,
double width,
double height,
double max_width,
double max_height,
cairo_boilerplate_mode_t mode,
int id,
void **closure)
{
cairo_surface_t *target;
cairo_surface_t *surface;
cairo_format_t format;
*closure = NULL;
format = cairo_boilerplate_format_from_content (content);
target = cairo_image_surface_create (format, ceil (width), ceil (height));
surface = _cairo_test_wrapping_surface_create (target);
cairo_surface_destroy (target);
return surface;
}
#endif
static const cairo_boilerplate_target_t targets[] = {
{
"test-base", "image", NULL, NULL,
CAIRO_SURFACE_TYPE_IMAGE,
CAIRO_CONTENT_COLOR_ALPHA, 0,
"_cairo_test_base_compositor_surface_create",
_cairo_boilerplate_test_base_compositor_create_surface,
cairo_surface_create_similar,
NULL, NULL,
_cairo_boilerplate_get_image_surface,
cairo_surface_write_to_png,
NULL, NULL, NULL, TRUE, FALSE, FALSE
},
{
"test-base", "image", NULL, NULL,
CAIRO_SURFACE_TYPE_IMAGE,
CAIRO_CONTENT_COLOR, 0,
"_cairo_test_base_compositor_surface_create",
_cairo_boilerplate_test_base_compositor_create_surface,
cairo_surface_create_similar,
NULL, NULL,
_cairo_boilerplate_get_image_surface,
cairo_surface_write_to_png,
NULL, NULL, NULL, FALSE, FALSE, FALSE
},
{
"test-fallback", "image", NULL, NULL,
CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
CAIRO_SURFACE_TYPE_IMAGE,
CAIRO_CONTENT_COLOR_ALPHA, 0,
"_cairo_test_fallback_surface_create",
_cairo_boilerplate_test_fallback_create_surface,
"_cairo_test_fallback_compositor_surface_create",
_cairo_boilerplate_test_fallback_compositor_create_surface,
cairo_surface_create_similar,
NULL, NULL,
_cairo_boilerplate_get_image_surface,
......@@ -243,40 +308,128 @@ static const cairo_boilerplate_target_t targets[] = {
},
{
"test-fallback", "image", NULL, NULL,
CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
CAIRO_SURFACE_TYPE_IMAGE,
CAIRO_CONTENT_COLOR, 0,
"_cairo_test_fallback_surface_create",
_cairo_boilerplate_test_fallback_create_surface,
"_cairo_test_fallback_compositor_surface_create",
_cairo_boilerplate_test_fallback_compositor_create_surface,
cairo_surface_create_similar,
NULL, NULL,
_cairo_boilerplate_get_image_surface,
cairo_surface_write_to_png,
NULL, NULL, NULL, FALSE, FALSE, FALSE
},
{
"test-fallback16", "image", NULL, NULL,
CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
"test-mask", "mask", NULL, NULL,
CAIRO_SURFACE_TYPE_IMAGE,
CAIRO_CONTENT_COLOR_ALPHA, 0,
"_cairo_test_fallback16_surface_create",
_cairo_boilerplate_test_fallback16_create_surface,
"_cairo_test_traps_compositor_surface_create",
_cairo_boilerplate_test_mask_compositor_create_surface,
cairo_surface_create_similar,
NULL, NULL,
NULL, /* _cairo_boilerplate_get_image_surface, */
_cairo_boilerplate_get_image_surface,
cairo_surface_write_to_png,
NULL, NULL, NULL, TRUE, FALSE, FALSE
},
{
"test-mask", "mask", NULL, NULL,
CAIRO_SURFACE_TYPE_IMAGE,
CAIRO_CONTENT_COLOR, 0,
"_cairo_test_mask_compositor_surface_create",
_cairo_boilerplate_test_mask_compositor_create_surface,
cairo_surface_create_similar,
NULL, NULL,
_cairo_boilerplate_get_image_surface,
cairo_surface_write_to_png,
NULL, NULL, NULL, FALSE, FALSE, FALSE
},
{
"test-fallback16", "image", NULL, NULL,
CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
"test-traps", "traps", NULL, NULL,
CAIRO_SURFACE_TYPE_IMAGE,
CAIRO_CONTENT_COLOR_ALPHA, 0,
"_cairo_test_traps_compositor_surface_create",
_cairo_boilerplate_test_traps_compositor_create_surface,
cairo_surface_create_similar,
NULL, NULL,
_cairo_boilerplate_get_image_surface,
cairo_surface_write_to_png,
NULL, NULL, NULL, TRUE, FALSE, FALSE
},
{
"test-traps", "traps", NULL, NULL,
CAIRO_SURFACE_TYPE_IMAGE,
CAIRO_CONTENT_COLOR, 0,
"_cairo_test_fallback16_surface_create",
_cairo_boilerplate_test_fallback16_create_surface,
"_cairo_test_traps_compositor_surface_create",
_cairo_boilerplate_test_traps_compositor_create_surface,
cairo_surface_create_similar,
NULL, NULL,
_cairo_boilerplate_get_image_surface,
cairo_surface_write_to_png,
NULL, NULL, NULL, FALSE, FALSE, FALSE
},
{
"test-spans", "spans", NULL, NULL,
CAIRO_SURFACE_TYPE_IMAGE,
CAIRO_CONTENT_COLOR_ALPHA, 0,
"_cairo_test_spans_compositor_surface_create",
_cairo_boilerplate_test_spans_compositor_create_surface,
cairo_surface_create_similar,
NULL, NULL,
_cairo_boilerplate_get_image_surface,
cairo_surface_write_to_png,
NULL, NULL, NULL, TRUE, FALSE, FALSE
},
{
"test-spans", "spans", NULL, NULL,
CAIRO_SURFACE_TYPE_IMAGE,
CAIRO_CONTENT_COLOR, 0,
"_cairo_test_spans_compositor_surface_create",
_cairo_boilerplate_test_spans_compositor_create_surface,
cairo_surface_create_similar,
NULL, NULL,
_cairo_boilerplate_get_image_surface,
cairo_surface_write_to_png,
NULL, NULL, NULL, FALSE, FALSE, FALSE
},
{
"no-fallback", "image", NULL, NULL,
CAIRO_SURFACE_TYPE_IMAGE,
CAIRO_CONTENT_COLOR_ALPHA, 0,
"_cairo_test_no_fallback_compositor_surface_create",
_cairo_boilerplate_test_no_fallback_compositor_create_surface,
cairo_surface_create_similar,
NULL, NULL,
NULL, /* _cairo_boilerplate_get_image_surface, */
_cairo_boilerplate_get_image_surface,
cairo_surface_write_to_png,
NULL, NULL, NULL, FALSE, FALSE, FALSE
},
{
"no-traps", "traps", NULL, NULL,
CAIRO_SURFACE_TYPE_IMAGE,
CAIRO_CONTENT_COLOR_ALPHA, 0,
"_cairo_test_no_traps_compositor_surface_create",
_cairo_boilerplate_test_no_traps_compositor_create_surface,
cairo_surface_create_similar,
NULL, NULL,
_cairo_boilerplate_get_image_surface,
cairo_surface_write_to_png,
NULL, NULL, NULL, TRUE, FALSE, FALSE
},
{
"no-spans", "spans", NULL, NULL,
CAIRO_SURFACE_TYPE_IMAGE,
CAIRO_CONTENT_COLOR_ALPHA, 0,
"_cairo_test_no_spans_compositor_surface_create",
_cairo_boilerplate_test_no_spans_compositor_create_surface,
cairo_surface_create_similar,
NULL, NULL,
_cairo_boilerplate_get_image_surface,
cairo_surface_write_to_png,
NULL, NULL, NULL, TRUE, FALSE, FALSE
},
#if CAIRO_HAS_TEST_PAGINATED_SURFACE
{
"test-paginated", "image", NULL, NULL,
......@@ -305,33 +458,5 @@ static const cairo_boilerplate_target_t targets[] = {
NULL, NULL, FALSE, TRUE, FALSE
},
#endif
#if CAIRO_HAS_TEST_WRAPPING_SURFACE
{
"test-wrapping", "image", NULL, NULL,
CAIRO_INTERNAL_SURFACE_TYPE_TEST_WRAPPING,
CAIRO_CONTENT_COLOR_ALPHA, 0,
"_cairo_test_wrapping_surface_create",
_cairo_boilerplate_test_wrapping_create_surface,
cairo_surface_create_similar,
NULL, NULL,
_cairo_boilerplate_get_image_surface,
cairo_surface_write_to_png,
NULL, NULL, NULL, FALSE, FALSE, FALSE
},
#endif
#if CAIRO_HAS_TEST_NULL_SURFACE
{
"null", "image", NULL, NULL,
CAIRO_INTERNAL_SURFACE_TYPE_NULL,
CAIRO_CONTENT_COLOR_ALPHA, 0,
"_cairo_test_null_surface_create",
_cairo_boilerplate_test_null_create_surface,
cairo_surface_create_similar,
NULL, NULL,
NULL, NULL, NULL,
NULL, NULL,
TRUE, TRUE, FALSE
},
#endif
};
CAIRO_BOILERPLATE (test, targets)
......@@ -31,7 +31,6 @@
#if CAIRO_HAS_XLIB_XRENDER_SURFACE
#include <cairo-xlib-xrender.h>
#endif
#include <cairo-xlib-surface-private.h>
#include <X11/Xutil.h> /* for XDestroyImage */
......@@ -412,6 +411,7 @@ _cairo_boilerplate_xlib_window_create_surface (const char *name,
cairo_status_t
cairo_boilerplate_xlib_surface_disable_render (cairo_surface_t *abstract_surface)
{
#if 0
/* The following stunt doesn't work with xlib-xcb because it doesn't use
* cairo_xlib_surface_t for its surfaces. Sadly, there is no sane
* alternative, so we can't disable render with xlib-xcb.
......@@ -439,6 +439,7 @@ cairo_boilerplate_xlib_surface_disable_render (cairo_surface_t *abstract_surface
#if CAIRO_XLIB_SURFACE_HAS_BUGGY_REPEAT
surface->buggy_repeat = TRUE;
#endif
#endif
#endif
return CAIRO_STATUS_SUCCESS;
......
......@@ -683,16 +683,12 @@ cairo_boilerplate_get_image_target (cairo_content_t content)
if (cairo_boilerplate_targets == NULL)
_cairo_boilerplate_register_all ();
for (list = cairo_boilerplate_targets; list != NULL; list = list->next) {
const cairo_boilerplate_target_t *target = list->target;
if (target->expected_type == CAIRO_SURFACE_TYPE_IMAGE &&
target->content == content)
{
return target;
}
switch (content) {
default:
case CAIRO_CONTENT_ALPHA: return NULL;
case CAIRO_CONTENT_COLOR: return &builtin_targets[1];
case CAIRO_CONTENT_COLOR_ALPHA: return &builtin_targets[0];
}
return NULL;
}
const cairo_boilerplate_target_t *
......
......@@ -202,11 +202,11 @@ CAIRO_ENABLE_SURFACE_BACKEND(skia, Skia, no, [
[skia_DIR="`pwd`/../skia"])
AC_ARG_WITH([skia-bulid],
[AS_HELP_STRING([--with-skia-build=(Release|Debug)]
[build of skia to link with, default is Relese])],
[build of skia to link with, default is Release])],
[skia_BUILD="$withval"],
[skia_BUILD="Release"])
skia_NONPKGCONFIG_CFLAGS="-I$skia_DIR/include/config -I$skia_DIR/include/core -I$skia_DIR/include/effects"
if test "x$(skia_BUILD)" = x"Relese"; then
if test "x$skia_BUILD" = x"Release"; then
skia_NONPKGCONFIG_CFLAGS="-DSK_RELEASE -DSK_CAN_USE_FLOAT $skia_NONPKGCONFIG_CFLAGS"
fi
skia_NONPKGCONFIG_LIBS="--start-group $skia_DIR/out/$skia_BUILD/obj.target/gyp/libeffects.a $skia_DIR/out/$skia_BUILD/obj.target/gyp/libimages.a $skia_DIR/out/$skia_BUILD/obj.target/gyp/libutils.a $skia_DIR/out/$skia_BUILD/obj.target/gyp/libopts.a $skia_DIR/out/$skia_BUILD/obj.target/gyp/libcore.a -end-group"
......
libcairoperf_sources = \
cairo-perf.c \
cairo-perf.c \
cairo-perf-report.c \
cairo-stats.c \
$(NULL)
......
......@@ -73,7 +73,7 @@ print_change_bar (double change,
double max_change,
int use_utf)
{
int units_per_cell = (int) ceil (max_change / CHANGE_BAR_WIDTH);
int units_per_cell = ceil (max_change / CHANGE_BAR_WIDTH);
static char const *ascii_boxes[8] = {
"****","***" ,"***", "**",
"**", "*", "*", ""
......@@ -369,7 +369,7 @@ main (int argc,
if (args.num_filenames) {
reports = xcalloc (args.num_filenames, sizeof (cairo_perf_report_t));
for (i = 0; i < args.num_filenames; i++) {
cairo_perf_report_load (&reports[i], args.filenames[i],
cairo_perf_report_load (&reports[i], args.filenames[i], i,
test_report_cmp_name);
printf ("loaded: %s, %d tests\n",
args.filenames[i], reports[i].tests_count);
......@@ -377,7 +377,7 @@ main (int argc,
} else {
args.num_filenames = 1;
reports = xcalloc (args.num_filenames, sizeof (cairo_perf_report_t));
cairo_perf_report_load (&reports[0], NULL, test_report_cmp_name);
cairo_perf_report_load (&reports[0], NULL, 0, test_report_cmp_name);
}
cairo_perf_reports_compare (reports, args.num_filenames, &args.options);
......
......@@ -161,16 +161,14 @@ test_diff_print_binary (test_diff_t *diff,
else
printf ("%5s %26s", diff->tests[0]->backend, diff->tests[0]->name);
if (diff->tests[0]->size) {
printf (" %6.2f (%.2f %4.2f%%) -> %6.2f (%.2f %4.2f%%): %5.2fx ",
diff->tests[0]->stats.min_ticks / diff->tests[0]->stats.ticks_per_ms,
diff->tests[0]->stats.median_ticks / diff->tests[0]->stats.ticks_per_ms,
diff->tests[0]->stats.std_dev * 100,
diff->tests[1]->stats.min_ticks / diff->tests[1]->stats.ticks_per_ms,
diff->tests[1]->stats.median_ticks / diff->tests[1]->stats.ticks_per_ms,
diff->tests[1]->stats.std_dev * 100,
fabs (diff->change));
}
printf (" %6.2f (%.2f %4.2f%%) -> %6.2f (%.2f %4.2f%%): %5.2fx ",
diff->tests[0]->stats.min_ticks / diff->tests[0]->stats.ticks_per_ms,
diff->tests[0]->stats.median_ticks / diff->tests[0]->stats.ticks_per_ms,
diff->tests[0]->stats.std_dev * 100,
diff->tests[1]->stats.min_ticks / diff->tests[1]->stats.ticks_per_ms,
diff->tests[1]->stats.median_ticks / diff->tests[1]->stats.ticks_per_ms,
diff->tests[1]->stats.std_dev * 100,
fabs (diff->change));
if (diff->change > 1.0)
printf ("speedup\n");
......@@ -191,24 +189,32 @@ test_diff_print_multi (test_diff_t *diff,
double test_time;
double change;
printf ("%s (backend: %s-%s, size: %d)\n",
diff->tests[0]->name,
diff->tests[0]->backend,
diff->tests[0]->content,
diff->tests[0]->size);
if (diff->tests[0]->size) {
printf ("%s (backend: %s-%s, size: %d)\n",
diff->tests[0]->name,
diff->tests[0]->backend,
diff->tests[0]->content,
diff->tests[0]->size);
} else {
printf ("%s (backend: %s)\n",
diff->tests[0]->name,
diff->tests[0]->backend);
}
for (i = 0; i < diff->num_tests; i++) {
test_time = diff->tests[i]->stats.min_ticks;
if (! options->use_ticks)
test_time /= diff->tests[i]->stats.ticks_per_ms;
change = diff->max / test_time;
printf ("%8s %6.2f: %5.2fx ",
diff->tests[i]->configuration,
printf ("[%d] %6.2f: %5.2fx ",
diff->tests[i]->fileno,
diff->tests[i]->stats.min_ticks / diff->tests[i]->stats.ticks_per_ms,
change);
if (options->print_change_bars)
print_change_bar (change, max_change, options->use_utf);
else
printf("\n");
}
printf("\n");
......@@ -476,8 +482,11 @@ main (int argc,
reports = xmalloc (args.num_filenames * sizeof (cairo_perf_report_t));
for (i = 0; i < args.num_filenames; i++ )
cairo_perf_report_load (&reports[i], args.filenames[i], NULL);
for (i = 0; i < args.num_filenames; i++ ) {
cairo_perf_report_load (&reports[i], args.filenames[i], i, NULL);
printf ("[%d] %s\n", i, args.filenames[i]);
}
printf ("\n");
cairo_perf_reports_compare (reports, args.num_filenames, &args.options);
......
......@@ -50,12 +50,13 @@
#define CAIRO_PERF_ITERATIONS_DEFAULT 100
#define CAIRO_PERF_LOW_STD_DEV 0.03
#define CAIRO_PERF_STABLE_STD_DEV_COUNT 5
#define CAIRO_PERF_ITERATION_MS_DEFAULT 2000
#define CAIRO_PERF_STABLE_STD_DEV_COUNT 5
#define CAIRO_PERF_ITERATION_MS_DEFAULT 2000