mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-10 01:10:26 +01:00
recording: optionally disable optimise away clears
The observer wants to get an accurate recording of all operations, including clears. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
236cb8aa22
commit
cb243acee5
4 changed files with 28 additions and 12 deletions
|
|
@ -224,9 +224,7 @@ _cairo_composite_rectangles_init_for_glyphs (cairo_composite_rectangles_t *exten
|
|||
|
||||
if (! _cairo_composite_rectangles_init (extents, unbounded,
|
||||
op, source, clip))
|
||||
{
|
||||
return CAIRO_INT_STATUS_NOTHING_TO_DO;
|
||||
}
|
||||
|
||||
/* Computing the exact bbox and the overlap is expensive.
|
||||
* First perform a cheap test to see if the glyphs are all clipped out.
|
||||
|
|
|
|||
|
|
@ -134,6 +134,7 @@ typedef struct _cairo_recording_surface {
|
|||
cairo_array_t commands;
|
||||
int *indices;
|
||||
int num_indices;
|
||||
cairo_bool_t optimize_clears;
|
||||
|
||||
struct bbtree {
|
||||
cairo_box_t extents;
|
||||
|
|
|
|||
|
|
@ -413,6 +413,7 @@ cairo_recording_surface_create (cairo_content_t content,
|
|||
|
||||
surface->indices = NULL;
|
||||
surface->num_indices = 0;
|
||||
surface->optimize_clears = TRUE;
|
||||
|
||||
return &surface->base;
|
||||
}
|
||||
|
|
@ -714,13 +715,12 @@ _cairo_recording_surface_paint (void *abstract_surface,
|
|||
cairo_composite_rectangles_t composite;
|
||||
const cairo_rectangle_int_t *extents;
|
||||
|
||||
/* An optimisation that takes care to not replay what was done
|
||||
* before surface is cleared. We don't erase recorded commands
|
||||
* since we may have earlier snapshots of this surface. */
|
||||
if (op == CAIRO_OPERATOR_CLEAR && clip == NULL) {
|
||||
_cairo_recording_surface_destroy_bbtree (surface);
|
||||
surface->commands.num_elements = 0;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
if (surface->optimize_clears) {
|
||||
_cairo_recording_surface_destroy_bbtree (surface);
|
||||
surface->commands.num_elements = 0;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
extents = _cairo_recording_surface_extents (surface);
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ static void init_glyphs (struct glyphs *g)
|
|||
init_clip (&g->clip);
|
||||
}
|
||||
|
||||
static void
|
||||
static cairo_status_t
|
||||
log_init (cairo_observation_t *log)
|
||||
{
|
||||
memset (log, 0, sizeof(*log));
|
||||
|
|
@ -125,8 +125,15 @@ log_init (cairo_observation_t *log)
|
|||
init_glyphs (&log->glyphs);
|
||||
|
||||
_cairo_array_init (&log->timings, sizeof (cairo_observation_record_t));
|
||||
|
||||
log->record = (cairo_recording_surface_t *)
|
||||
cairo_recording_surface_create (CAIRO_CONTENT_COLOR_ALPHA, NULL);
|
||||
if (unlikely (log->record->base.status))
|
||||
return log->record->base.status;
|
||||
|
||||
log->record->optimize_clears = FALSE;
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -323,15 +330,20 @@ static cairo_device_t *
|
|||
_cairo_device_create_observer_internal (cairo_device_t *target)
|
||||
{
|
||||
cairo_device_observer_t *device;
|
||||
cairo_status_t status;
|
||||
|
||||
device = malloc (sizeof (cairo_device_observer_t));
|
||||
if (unlikely (device == NULL))
|
||||
return _cairo_device_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
|
||||
_cairo_device_init (&device->base, &_cairo_device_observer_backend);
|
||||
device->target = cairo_device_reference (target);
|
||||
status = log_init (&device->log);
|
||||
if (unlikely (status)) {
|
||||
free (device);
|
||||
return _cairo_device_create_in_error (status);
|
||||
}
|
||||
|
||||
log_init (&device->log);
|
||||
device->target = cairo_device_reference (target);
|
||||
|
||||
return &device->base;
|
||||
}
|
||||
|
|
@ -349,6 +361,7 @@ _cairo_surface_create_observer_internal (cairo_device_t *device,
|
|||
cairo_surface_t *target)
|
||||
{
|
||||
cairo_surface_observer_t *surface;
|
||||
cairo_status_t status;
|
||||
|
||||
surface = malloc (sizeof (cairo_surface_observer_t));
|
||||
if (unlikely (surface == NULL))
|
||||
|
|
@ -358,7 +371,11 @@ _cairo_surface_create_observer_internal (cairo_device_t *device,
|
|||
&_cairo_surface_observer_backend, device,
|
||||
target->content);
|
||||
|
||||
log_init (&surface->log);
|
||||
status = log_init (&surface->log);
|
||||
if (unlikely (status)) {
|
||||
free (surface);
|
||||
return _cairo_surface_create_in_error (status);
|
||||
}
|
||||
|
||||
surface->target = cairo_surface_reference (target);
|
||||
surface->base.type = surface->target->type;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue