From fb7cfdd94d4e436e066d884f6dc294efd896b344 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Wed, 1 Oct 2008 20:52:08 +0930 Subject: [PATCH] Make meta-surface store and replay extents of each operation To be able to provide the extents of each operation to the backend during the render phase the meta-surface needs to store the extents computed by the analysis surface during the analysis phase. The extents argument is either a pointer to the extents of the operation stored in the meta-surface or NULL. During analysis the analysis surface writes the extents to the meta-surface. During the render phase the extents is made available to paginated surface backends. --- src/cairo-analysis-surface.c | 12 ++++++++++++ src/cairo-meta-surface-private.h | 1 + src/cairo-meta-surface.c | 33 ++++++++++++++++++++++++++------ 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/cairo-analysis-surface.c b/src/cairo-analysis-surface.c index be3f734b1..d5b63e8ed 100644 --- a/src/cairo-analysis-surface.c +++ b/src/cairo-analysis-surface.c @@ -354,6 +354,8 @@ _cairo_analysis_surface_paint (void *abstract_surface, } is_empty = _cairo_rectangle_intersect (&extents, &surface->current_clip); + if (paint_extents) + *paint_extents = extents; status = _add_operation (surface, &extents, backend_status); @@ -432,6 +434,8 @@ _cairo_analysis_surface_mask (void *abstract_surface, } is_empty = _cairo_rectangle_intersect (&extents, &surface->current_clip); + if (mask_extents) + *mask_extents = extents; status = _add_operation (surface, &extents, backend_status); @@ -505,6 +509,8 @@ _cairo_analysis_surface_stroke (void *abstract_surface, _cairo_box_round_to_rectangle (&box, &extents); } + if (stroke_extents) + *stroke_extents = extents; status = _add_operation (surface, &extents, backend_status); @@ -574,6 +580,8 @@ _cairo_analysis_surface_fill (void *abstract_surface, _cairo_box_round_to_rectangle (&box, &extents); } + if (fill_extents) + *fill_extents = extents; status = _add_operation (surface, &extents, backend_status); @@ -642,6 +650,8 @@ _cairo_analysis_surface_show_glyphs (void *abstract_surface, is_empty = _cairo_rectangle_intersect (&extents, &glyph_extents); } + if (show_glyphs_extents) + *show_glyphs_extents = extents; status = _add_operation (surface, &extents, backend_status); @@ -726,6 +736,8 @@ _cairo_analysis_surface_show_text_glyphs (void *abstract_surface, is_empty = _cairo_rectangle_intersect (&extents, &glyph_extents); } + if (show_text_glyphs_extents) + *show_text_glyphs_extents = extents; status = _add_operation (surface, &extents, backend_status); diff --git a/src/cairo-meta-surface-private.h b/src/cairo-meta-surface-private.h index 9a1b169cf..8d5e096e4 100644 --- a/src/cairo-meta-surface-private.h +++ b/src/cairo-meta-surface-private.h @@ -67,6 +67,7 @@ typedef enum { typedef struct _cairo_command_header { cairo_command_type_t type; cairo_meta_region_type_t region; + cairo_rectangle_int_t extents; } cairo_command_header_t; typedef struct _cairo_command_paint { diff --git a/src/cairo-meta-surface.c b/src/cairo-meta-surface.c index 5f9fed25d..cfaaf304b 100644 --- a/src/cairo-meta-surface.c +++ b/src/cairo-meta-surface.c @@ -232,6 +232,10 @@ _cairo_meta_surface_paint (void *abstract_surface, command->header.type = CAIRO_COMMAND_PAINT; command->header.region = CAIRO_META_REGION_ALL; + command->header.extents.x = 0; + command->header.extents.y = 0; + command->header.extents.width = meta->width_pixels; + command->header.extents.height = meta->height_pixels; command->op = op; status = _cairo_pattern_init_snapshot (&command->source.base, source); @@ -274,6 +278,10 @@ _cairo_meta_surface_mask (void *abstract_surface, command->header.type = CAIRO_COMMAND_MASK; command->header.region = CAIRO_META_REGION_ALL; + command->header.extents.x = 0; + command->header.extents.y = 0; + command->header.extents.width = meta->width_pixels; + command->header.extents.height = meta->height_pixels; command->op = op; status = _cairo_pattern_init_snapshot (&command->source.base, source); @@ -321,6 +329,10 @@ _cairo_meta_surface_stroke (void *abstract_surface, command->header.type = CAIRO_COMMAND_STROKE; command->header.region = CAIRO_META_REGION_ALL; + command->header.extents.x = 0; + command->header.extents.y = 0; + command->header.extents.width = meta->width_pixels; + command->header.extents.height = meta->height_pixels; command->op = op; status = _cairo_pattern_init_snapshot (&command->source.base, source); @@ -377,6 +389,10 @@ _cairo_meta_surface_fill (void *abstract_surface, command->header.type = CAIRO_COMMAND_FILL; command->header.region = CAIRO_META_REGION_ALL; + command->header.extents.x = 0; + command->header.extents.y = 0; + command->header.extents.width = meta->width_pixels; + command->header.extents.height = meta->height_pixels; command->op = op; status = _cairo_pattern_init_snapshot (&command->source.base, source); @@ -436,6 +452,10 @@ _cairo_meta_surface_show_text_glyphs (void *abstract_surface, command->header.type = CAIRO_COMMAND_SHOW_TEXT_GLYPHS; command->header.region = CAIRO_META_REGION_ALL; + command->header.extents.x = 0; + command->header.extents.y = 0; + command->header.extents.width = meta->width_pixels; + command->header.extents.height = meta->height_pixels; command->op = op; status = _cairo_pattern_init_snapshot (&command->source.base, source); @@ -811,13 +831,13 @@ _cairo_meta_surface_replay_internal (cairo_surface_t *surface, case CAIRO_COMMAND_PAINT: status = _cairo_surface_paint (target, command->paint.op, - &command->paint.source.base, NULL); + &command->paint.source.base, &command->header.extents); break; case CAIRO_COMMAND_MASK: status = _cairo_surface_mask (target, command->mask.op, &command->mask.source.base, - &command->mask.mask.base, NULL); + &command->mask.mask.base, &command->header.extents); break; case CAIRO_COMMAND_STROKE: { @@ -839,7 +859,7 @@ _cairo_meta_surface_replay_internal (cairo_surface_t *surface, &dev_ctm, &dev_ctm_inverse, command->stroke.tolerance, - command->stroke.antialias, NULL); + command->stroke.antialias, &command->header.extents); break; } case CAIRO_COMMAND_FILL: @@ -886,7 +906,8 @@ _cairo_meta_surface_replay_internal (cairo_surface_t *surface, &dev_ctm, &dev_ctm_inverse, stroke_command->stroke.tolerance, - stroke_command->stroke.antialias, NULL); + stroke_command->stroke.antialias, + &stroke_command->header.extents); i++; } else status = _cairo_surface_fill (target, @@ -895,7 +916,7 @@ _cairo_meta_surface_replay_internal (cairo_surface_t *surface, dev_path, command->fill.fill_rule, command->fill.tolerance, - command->fill.antialias, NULL); + command->fill.antialias, &command->header.extents); break; } case CAIRO_COMMAND_SHOW_TEXT_GLYPHS: @@ -932,7 +953,7 @@ _cairo_meta_surface_replay_internal (cairo_surface_t *surface, dev_glyphs, num_glyphs, command->show_text_glyphs.clusters, command->show_text_glyphs.num_clusters, command->show_text_glyphs.cluster_flags, - command->show_text_glyphs.scaled_font, NULL); + command->show_text_glyphs.scaled_font, &command->header.extents); free (dev_glyphs); break;