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.
This commit is contained in:
Chris Wilson 2009-11-27 17:30:51 +00:00
parent 411c09eed7
commit bc2d0ad114

View file

@ -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;
}