summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-07-23 22:48:15 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2011-07-23 22:50:25 +0100
commit7f77e2f36a0803e3ec08bc70f4923bb2d043658e (patch)
tree6b11463364c762f748d5499e9248ac2060b1b63e /util
parent1578530557481346f98f449d0f2885a7c985a222 (diff)
trace: Create a new opcode for recording surface
During replay we want to handle recording surfaces specially, and not redirect the creation of those to the target surface. This is similar to the need to keep image surfaces as images during replay. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'util')
-rw-r--r--util/cairo-script/cairo-script-operators.c64
-rw-r--r--util/cairo-trace/trace.c11
2 files changed, 66 insertions, 9 deletions
diff --git a/util/cairo-script/cairo-script-operators.c b/util/cairo-script/cairo-script-operators.c
index f5a9bf19..ef96e447 100644
--- a/util/cairo-script/cairo-script-operators.c
+++ b/util/cairo-script/cairo-script-operators.c
@@ -278,6 +278,24 @@ _csi_ostack_get_number (csi_t *ctx, unsigned int i, double *out)
return CSI_STATUS_SUCCESS;
}
+static double
+_csi_object_as_real (csi_object_t *obj)
+{
+ int type;
+
+ type = csi_object_get_type (obj);
+ switch (type) {
+ case CSI_OBJECT_TYPE_BOOLEAN:
+ return obj->datum.boolean;
+ case CSI_OBJECT_TYPE_INTEGER:
+ return obj->datum.integer;
+ case CSI_OBJECT_TYPE_REAL:
+ return obj->datum.real;
+ default:
+ return 0;
+ }
+}
+
static csi_status_t
_csi_ostack_get_name (csi_t *ctx, unsigned int i, csi_name_t *out)
{
@@ -5947,6 +5965,51 @@ _surface (csi_t *ctx)
}
static csi_status_t
+_record (csi_t *ctx)
+{
+ csi_object_t obj;
+ long content;
+ csi_array_t *array;
+ csi_status_t status;
+ cairo_rectangle_t extents;
+ cairo_rectangle_t *r;
+
+ check (2);
+
+ status = _csi_ostack_get_array (ctx, 0, &array);
+ if (_csi_unlikely (status))
+ return status;
+
+ status = _csi_ostack_get_integer (ctx, 1, &content);
+ if (_csi_unlikely (status))
+ return status;
+
+ switch (array->stack.len) {
+ case 0:
+ r = NULL;
+ case 2:
+ extents.x = extents.y = 0;
+ extents.width = _csi_object_as_real (&array->stack.objects[0]);
+ extents.height = _csi_object_as_real (&array->stack.objects[1]);
+ break;
+ case 4:
+ extents.x = _csi_object_as_real (&array->stack.objects[0]);
+ extents.y = _csi_object_as_real (&array->stack.objects[1]);
+ extents.width = _csi_object_as_real (&array->stack.objects[2]);
+ extents.height = _csi_object_as_real (&array->stack.objects[3]);
+ r = &extents;
+ break;
+ default:
+ return _csi_error (CSI_STATUS_INVALID_SCRIPT);
+ }
+
+ obj.type = CSI_OBJECT_TYPE_SURFACE;
+ obj.datum.surface = cairo_recording_surface_create (content, r);
+ pop (2);
+ return push (&obj);
+}
+
+static csi_status_t
_text_path (csi_t *ctx)
{
csi_status_t status;
@@ -6270,6 +6333,7 @@ _defs[] = {
{ "push-group", _push_group },
{ "radial", _radial },
{ "rand", NULL },
+ { "record", _record },
{ "rectangle", _rectangle },
{ "repeat", _repeat },
{ "restore", _restore },
diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c
index 3470c88b..9c59b1d6 100644
--- a/util/cairo-trace/trace.c
+++ b/util/cairo-trace/trace.c
@@ -4836,11 +4836,7 @@ cairo_recording_surface_create (cairo_content_t content,
Object *obj = _create_surface (ret);
if (extents) {
- _trace_printf ("dict\n"
- " /type /recording set\n"
- " /content //%s set\n"
- " /extents [%f %f %f %f] set\n"
- " surface dup /s%ld exch def\n",
+ _trace_printf ("//%s [ %f %f %f %f ] record dup /s%ld exch def\n",
_content_to_string (content),
extents->x, extents->y,
extents->width, extents->height,
@@ -4848,10 +4844,7 @@ cairo_recording_surface_create (cairo_content_t content,
obj->width = extents->width;
obj->height = extents->height;
} else {
- _trace_printf ("dict\n"
- " /type /recording set\n"
- " /content //%s set\n"
- " surface dup /s%ld exch def\n",
+ _trace_printf ("//%s [ ] record dup /s%ld exch def\n",
_content_to_string (content),
obj->token);
}