Optimisation of CLEAR operator in meta-surface.

This optimisation 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.
(cherry picked from 926e2494ca2211e9117ab70fc427208d125e1bd5 commit)
This commit is contained in:
Emmanuel Pacaud 2006-04-23 22:55:37 +02:00 committed by Carl Worth
parent a732058920
commit 9bca27a1ad
2 changed files with 16 additions and 1 deletions

View file

@ -137,6 +137,9 @@ typedef struct _cairo_meta_surface {
cairo_array_t commands;
cairo_surface_t *commands_owner;
cairo_bool_t is_clipped;
int replay_start_idx;
} cairo_meta_surface_t;
cairo_private cairo_surface_t *

View file

@ -81,6 +81,9 @@ _cairo_meta_surface_create (cairo_content_t content,
_cairo_array_init (&meta->commands, sizeof (cairo_command_t *));
meta->commands_owner = NULL;
meta->is_clipped = FALSE;
meta->replay_start_idx = 0;
return &meta->base;
}
@ -226,6 +229,12 @@ _cairo_meta_surface_paint (void *abstract_surface,
cairo_meta_surface_t *meta = abstract_surface;
cairo_command_paint_t *command;
/* 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 && !meta->is_clipped)
meta->replay_start_idx = meta->commands.num_elements;
command = malloc (sizeof (cairo_command_paint_t));
if (command == NULL)
return CAIRO_STATUS_NO_MEMORY;
@ -473,6 +482,7 @@ _cairo_meta_surface_snapshot (void *abstract_other)
meta->width_pixels = other->width_pixels;
meta->height_pixels = other->height_pixels;
meta->replay_start_idx = other->replay_start_idx;
_cairo_array_init_snapshot (&meta->commands, &other->commands);
meta->commands_owner = cairo_surface_reference (&other->base);
@ -504,8 +514,10 @@ _cairo_meta_surface_intersect_clip_path (void *dst,
return status;
}
command->path_pointer = &command->path;
meta->is_clipped = TRUE;
} else {
command->path_pointer = NULL;
meta->is_clipped = FALSE;
}
command->fill_rule = fill_rule;
command->tolerance = tolerance;
@ -610,7 +622,7 @@ _cairo_meta_surface_replay (cairo_surface_t *surface,
num_elements = meta->commands.num_elements;
elements = _cairo_array_index (&meta->commands, 0);
for (i = 0; i < num_elements; i++) {
for (i = meta->replay_start_idx; i < num_elements; i++) {
command = elements[i];
switch (command->type) {
case CAIRO_COMMAND_PAINT: