diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-01-08 12:53:24 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2013-01-08 15:01:37 +0000 |
commit | e1307da8616027004dd6c901017a667b1503781d (patch) | |
tree | d6bf431a187cffd1f6dda234877068389f53ec35 /util | |
parent | 146da77d85b304651949a819bc8b0a74819f0416 (diff) | |
download | cairo-e1307da8616027004dd6c901017a667b1503781d.tar.gz |
script: Simply exchange source/dest images for _set_source_image
But note we can only do the exchange if they do indeed match and
there are no other references (the objects are only on the stack).
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'util')
-rw-r--r-- | util/cairo-script/cairo-script-operators.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/util/cairo-script/cairo-script-operators.c b/util/cairo-script/cairo-script-operators.c index efc1970cf..71d2b79b7 100644 --- a/util/cairo-script/cairo-script-operators.c +++ b/util/cairo-script/cairo-script-operators.c @@ -5356,11 +5356,20 @@ _set_source_image (csi_t *ctx) * principally to remove the pixman ops from the profiles. */ if (_csi_likely (_matching_images (surface, source))) { - cairo_surface_flush (surface); - memcpy (cairo_image_surface_get_data (surface), - cairo_image_surface_get_data (source), - cairo_image_surface_get_height (source) * cairo_image_surface_get_stride (source)); - cairo_surface_mark_dirty (surface); + if (cairo_surface_get_reference_count (surface) == 1 && + cairo_surface_get_reference_count (source) == 1) + { + _csi_peek_ostack (ctx, 0)->datum.surface = surface; + _csi_peek_ostack (ctx, 1)->datum.surface = source; + } + else + { + cairo_surface_flush (surface); + memcpy (cairo_image_surface_get_data (surface), + cairo_image_surface_get_data (source), + cairo_image_surface_get_height (source) * cairo_image_surface_get_stride (source)); + cairo_surface_mark_dirty (surface); + } } else { cairo_t *cr; |