summaryrefslogtreecommitdiff
path: root/src/cairo.c
diff options
context:
space:
mode:
authorAndrea Canciani <ranma42@gmail.com>2011-01-20 01:44:29 +0100
committerAndrea Canciani <ranma42@gmail.com>2011-01-22 11:59:38 +0100
commit5d95ae924ed15200a17d240d8f0744c74df7c61b (patch)
tree3278d6bf194a6f08af74bc1cb7f891eea62d2087 /src/cairo.c
parente0b741de9006a02acd9b05c8fae52f6b7f775163 (diff)
gstate: Set an error status when restoring a push_group
cairo_push_group (cr) followed by cairo_restore (cr) should put cr in an error status of CAIRO_STATUS_INVALID_RESTORE. Fixes group-state.
Diffstat (limited to 'src/cairo.c')
-rw-r--r--src/cairo.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/cairo.c b/src/cairo.c
index b87274a2..73dbaeef 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -585,6 +585,11 @@ cairo_restore (cairo_t *cr)
if (unlikely (cr->status))
return;
+ if (unlikely (_cairo_gstate_is_group (cr->gstate))) {
+ _cairo_set_error (cr, _cairo_error (CAIRO_STATUS_INVALID_RESTORE));
+ return;
+ }
+
status = _cairo_gstate_restore (&cr->gstate, &cr->gstate_freelist);
if (unlikely (status))
_cairo_set_error (cr, status);
@@ -754,7 +759,7 @@ slim_hidden_def(cairo_push_group_with_content);
cairo_pattern_t *
cairo_pop_group (cairo_t *cr)
{
- cairo_surface_t *group_surface, *parent_target;
+ cairo_surface_t *group_surface;
cairo_pattern_t *group_pattern;
cairo_matrix_t group_matrix, device_transform_matrix;
cairo_status_t status;
@@ -762,27 +767,18 @@ cairo_pop_group (cairo_t *cr)
if (unlikely (cr->status))
return _cairo_pattern_create_in_error (cr->status);
- /* Grab the active surfaces */
- group_surface = _cairo_gstate_get_target (cr->gstate);
- parent_target = _cairo_gstate_get_parent_target (cr->gstate);
-
/* Verify that we are at the right nesting level */
- if (parent_target == NULL) {
+ if (unlikely (! _cairo_gstate_is_group (cr->gstate))) {
_cairo_set_error (cr, CAIRO_STATUS_INVALID_POP_GROUP);
return _cairo_pattern_create_in_error (CAIRO_STATUS_INVALID_POP_GROUP);
}
- /* We need to save group_surface before we restore; we don't need
- * to reference parent_target and original_target, since the
- * gstate will still hold refs to them once we restore. */
+ /* Get a reference to the active surface before restoring */
+ group_surface = _cairo_gstate_get_target (cr->gstate);
group_surface = cairo_surface_reference (group_surface);
- cairo_restore (cr);
-
- if (unlikely (cr->status)) {
- group_pattern = _cairo_pattern_create_in_error (cr->status);
- goto done;
- }
+ status = _cairo_gstate_restore (&cr->gstate, &cr->gstate_freelist);
+ assert (status == CAIRO_STATUS_SUCCESS);
group_pattern = cairo_pattern_create_for_surface (group_surface);
status = group_pattern->status;