diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-11-27 17:30:51 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-01-22 23:01:49 +0000 |
commit | bc2d0ad114f8fc0b0579851154fe9d39c0aa0fc9 (patch) | |
tree | ec28f448713ef1d3bae80a72b4287fec95ca0dac /util | |
parent | 411c09eed7ebff7335948a7f96d2b29d82ed817a (diff) |
script: Permit surface operations on the context
By implicitly reference the target of the context instead, i.e.
this reduces the use of:
/target get (example.png) write-to-png pop
as a common idiom where the context is kept on the stack and the surface
forgotten.
Diffstat (limited to 'util')
-rw-r--r-- | util/cairo-script/cairo-script-operators.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/util/cairo-script/cairo-script-operators.c b/util/cairo-script/cairo-script-operators.c index 31ab58e0..79460423 100644 --- a/util/cairo-script/cairo-script-operators.c +++ b/util/cairo-script/cairo-script-operators.c @@ -351,12 +351,20 @@ static csi_status_t _csi_ostack_get_surface (csi_t *ctx, unsigned int i, cairo_surface_t **out) { csi_object_t *obj; + int type; obj = _csi_peek_ostack (ctx, i); - if (_csi_unlikely (csi_object_get_type (obj) != CSI_OBJECT_TYPE_SURFACE)) + type = csi_object_get_type (obj); + switch (type) { + case CSI_OBJECT_TYPE_CONTEXT: + *out = cairo_get_target (obj->datum.cr); + break; + case CSI_OBJECT_TYPE_SURFACE: + *out = obj->datum.surface; + break; + default: return _csi_error (CSI_STATUS_INVALID_SCRIPT); - - *out = obj->datum.surface; + } return CSI_STATUS_SUCCESS; } |