summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--boilerplate/cairo-boilerplate-script.c6
-rw-r--r--boilerplate/cairo-boilerplate.c6
-rw-r--r--src/cairo-script-surface.c491
-rw-r--r--src/cairo-script.h35
-rw-r--r--test/cairo-test-trace.c7
-rw-r--r--util/cairo-fdr/fdr.c10
-rw-r--r--util/cairo-script/csi-trace.c11
-rw-r--r--util/cairo-sphinx/fdr.c4
-rw-r--r--util/cairo-sphinx/sphinx.c17
-rw-r--r--util/cairo-trace/trace.c8
10 files changed, 312 insertions, 283 deletions
diff --git a/boilerplate/cairo-boilerplate-script.c b/boilerplate/cairo-boilerplate-script.c
index e37fdf13..7c052a34 100644
--- a/boilerplate/cairo-boilerplate-script.c
+++ b/boilerplate/cairo-boilerplate-script.c
@@ -48,7 +48,7 @@ _cairo_boilerplate_script_create_surface (const char *name,
void **closure)
{
script_target_closure_t *ptc;
- cairo_script_context_t *ctx;
+ cairo_device_t *ctx;
cairo_surface_t *surface;
cairo_status_t status;
@@ -60,9 +60,9 @@ _cairo_boilerplate_script_create_surface (const char *name,
xasprintf (&ptc->filename, "%s.out.cs", name);
xunlink (ptc->filename);
- ctx = cairo_script_context_create (ptc->filename);
+ ctx = cairo_script_create (ptc->filename);
surface = cairo_script_surface_create (ctx, content, width, height);
- cairo_script_context_destroy (ctx);
+ cairo_device_destroy (ctx);
status = cairo_surface_set_user_data (surface,
&script_closure_key, ptc, NULL);
diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index 401e613d..d3f312f3 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -203,13 +203,13 @@ _cairo_boilerplate_get_image_surface (cairo_surface_t *src,
test_name = cairo_surface_get_user_data (src,
&cairo_boilerplate_output_basename_key);
if (test_name != NULL) {
- cairo_script_context_t *ctx;
+ cairo_device_t *ctx;
char *filename;
xasprintf (&filename, "%s.out.trace", test_name);
- ctx = cairo_script_context_create (filename);
+ ctx = cairo_script_create (filename);
surface = cairo_script_surface_create_for_target (ctx, image);
- cairo_script_context_destroy (ctx);
+ cairo_device_destroy (ctx);
free (filename);
}
}
diff --git a/src/cairo-script-surface.c b/src/cairo-script-surface.c
index 897fcab6..53cfb7a9 100644
--- a/src/cairo-script-surface.c
+++ b/src/cairo-script-surface.c
@@ -47,6 +47,7 @@
#include "cairo-script.h"
#include "cairo-analysis-surface-private.h"
+#include "cairo-device-private.h"
#include "cairo-error-private.h"
#include "cairo-ft-private.h"
#include "cairo-list-private.h"
@@ -63,6 +64,7 @@
#define static cairo_warn static
+typedef struct _cairo_script_context cairo_script_context_t;
typedef struct _cairo_script_surface cairo_script_surface_t;
typedef struct _cairo_script_implicit_context cairo_script_implicit_context_t;
typedef struct _cairo_script_surface_font_private cairo_script_surface_font_private_t;
@@ -82,9 +84,8 @@ struct deferred_finish {
};
struct _cairo_script_context {
- cairo_status_t status;
+ cairo_device_t base;
- int ref;
int active;
cairo_output_stream_t *stream;
@@ -134,7 +135,6 @@ struct _cairo_script_surface {
cairo_surface_wrapper_t wrapper;
- cairo_script_context_t *ctx;
cairo_surface_clipper_t clipper;
operand_t operand;
@@ -158,9 +158,6 @@ _cairo_script_surface_create_internal (cairo_script_context_t *ctx,
double height,
cairo_surface_t *passthrough);
-static cairo_status_t
-_context_destroy (cairo_script_context_t *ctx);
-
static void
_cairo_script_surface_scaled_font_fini (cairo_scaled_font_t *scaled_font);
@@ -371,17 +368,23 @@ _line_join_to_string (cairo_line_join_t line_join)
return names[line_join];
}
+static inline cairo_script_context_t *
+to_context (cairo_script_surface_t *surface)
+{
+ return (cairo_script_context_t *) surface->base.device;
+}
+
static cairo_bool_t
target_is_active (cairo_script_surface_t *surface)
{
return cairo_list_is_first (&surface->operand.link,
- &surface->ctx->operands);
+ &to_context (surface)->operands);
}
static void
target_push (cairo_script_surface_t *surface)
{
- cairo_list_move (&surface->operand.link, &surface->ctx->operands);
+ cairo_list_move (&surface->operand.link, &to_context (surface)->operands);
}
static int
@@ -390,7 +393,7 @@ target_depth (cairo_script_surface_t *surface)
cairo_list_t *link;
int depth = 0;
- cairo_list_foreach (link, &surface->ctx->operands) {
+ cairo_list_foreach (link, &to_context (surface)->operands) {
if (link == &surface->operand.link)
break;
depth++;
@@ -402,7 +405,7 @@ target_depth (cairo_script_surface_t *surface)
static void
_get_target (cairo_script_surface_t *surface)
{
- cairo_script_context_t *ctx = surface->ctx;
+ cairo_script_context_t *ctx = to_context (surface);
if (surface->defined) {
_cairo_output_stream_printf (ctx->stream, "s%u ",
@@ -416,10 +419,10 @@ _get_target (cairo_script_surface_t *surface)
_cairo_output_stream_puts (ctx->stream, "/target get exch pop ");
} else {
if (depth == 1) {
- _cairo_output_stream_puts (surface->ctx->stream,
+ _cairo_output_stream_puts (ctx->stream,
"exch\n");
} else {
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"%d -1 roll\n",
depth);
}
@@ -446,11 +449,13 @@ _content_to_string (cairo_content_t content)
static cairo_status_t
_emit_surface (cairo_script_surface_t *surface)
{
- _cairo_output_stream_printf (surface->ctx->stream,
+ cairo_script_context_t *ctx = to_context (surface);
+
+ _cairo_output_stream_printf (ctx->stream,
"<< /content //%s",
_content_to_string (surface->base.content));
if (surface->width != -1 && surface->height != -1) {
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
" /width %f /height %f",
surface->width,
surface->height);
@@ -461,7 +466,7 @@ _emit_surface (cairo_script_surface_t *surface)
surface->base.y_fallback_resolution !=
CAIRO_SURFACE_FALLBACK_RESOLUTION_DEFAULT)
{
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
" /fallback-resolution [%f %f]",
surface->base.x_fallback_resolution,
surface->base.y_fallback_resolution);
@@ -472,14 +477,14 @@ _emit_surface (cairo_script_surface_t *surface)
{
/* XXX device offset is encoded into the pattern matrices etc. */
if (0) {
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
" /device-offset [%f %f]",
surface->base.device_transform.x0,
surface->base.device_transform.y0);
}
}
- _cairo_output_stream_puts (surface->ctx->stream, " >> surface context\n");
+ _cairo_output_stream_puts (ctx->stream, " >> surface context\n");
surface->emitted = TRUE;
return CAIRO_STATUS_SUCCESS;
}
@@ -487,7 +492,7 @@ _emit_surface (cairo_script_surface_t *surface)
static cairo_status_t
_emit_context (cairo_script_surface_t *surface)
{
- cairo_script_context_t *ctx = surface->ctx;
+ cairo_script_context_t *ctx = to_context (surface);
if (target_is_active (surface))
return CAIRO_STATUS_SUCCESS;
@@ -563,7 +568,7 @@ _emit_operator (cairo_script_surface_t *surface,
surface->cr.current_operator = op;
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (to_context (surface)->stream,
"//%s set-operator\n",
_operator_to_string (op));
return CAIRO_STATUS_SUCCESS;
@@ -580,7 +585,7 @@ _emit_fill_rule (cairo_script_surface_t *surface,
surface->cr.current_fill_rule = fill_rule;
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (to_context (surface)->stream,
"//%s set-fill-rule\n",
_fill_rule_to_string (fill_rule));
return CAIRO_STATUS_SUCCESS;
@@ -602,7 +607,7 @@ _emit_tolerance (cairo_script_surface_t *surface,
surface->cr.current_tolerance = tolerance;
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (to_context (surface)->stream,
"%f set-tolerance\n",
tolerance);
return CAIRO_STATUS_SUCCESS;
@@ -619,7 +624,7 @@ _emit_antialias (cairo_script_surface_t *surface,
surface->cr.current_antialias = antialias;
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (to_context (surface)->stream,
"//%s set-antialias\n",
_antialias_to_string (antialias));
@@ -642,7 +647,7 @@ _emit_line_width (cairo_script_surface_t *surface,
surface->cr.current_style.line_width = line_width;
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (to_context (surface)->stream,
"%f set-line-width\n",
line_width);
return CAIRO_STATUS_SUCCESS;
@@ -659,7 +664,7 @@ _emit_line_cap (cairo_script_surface_t *surface,
surface->cr.current_style.line_cap = line_cap;
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (to_context (surface)->stream,
"//%s set-line-cap\n",
_line_cap_to_string (line_cap));
return CAIRO_STATUS_SUCCESS;
@@ -676,7 +681,7 @@ _emit_line_join (cairo_script_surface_t *surface,
surface->cr.current_style.line_join = line_join;
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (to_context (surface)->stream,
"//%s set-line-join\n",
_line_join_to_string (line_join));
return CAIRO_STATUS_SUCCESS;
@@ -698,7 +703,7 @@ _emit_miter_limit (cairo_script_surface_t *surface,
surface->cr.current_style.miter_limit = miter_limit;
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (to_context (surface)->stream,
"%f set-miter-limit\n",
miter_limit);
return CAIRO_STATUS_SUCCESS;
@@ -762,13 +767,13 @@ _emit_dash (cairo_script_surface_t *surface,
surface->cr.current_style.num_dashes = num_dashes;
surface->cr.current_style.dash_offset = offset;
- _cairo_output_stream_puts (surface->ctx->stream, "[");
+ _cairo_output_stream_puts (to_context (surface)->stream, "[");
for (n = 0; n < num_dashes; n++) {
- _cairo_output_stream_printf (surface->ctx->stream, "%f", dash[n]);
+ _cairo_output_stream_printf (to_context (surface)->stream, "%f", dash[n]);
if (n < num_dashes-1)
- _cairo_output_stream_puts (surface->ctx->stream, " ");
+ _cairo_output_stream_puts (to_context (surface)->stream, " ");
}
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (to_context (surface)->stream,
"] %f set-dash\n",
offset);
@@ -827,6 +832,7 @@ _emit_solid_pattern (cairo_script_surface_t *surface,
const cairo_pattern_t *pattern)
{
cairo_solid_pattern_t *solid = (cairo_solid_pattern_t *) pattern;
+ cairo_script_context_t *ctx = to_context (surface);
if (solid->content & CAIRO_CONTENT_ALPHA &&
! CAIRO_COLOR_IS_OPAQUE (&solid->color))
@@ -837,13 +843,13 @@ _emit_solid_pattern (cairo_script_surface_t *surface,
(solid->color.green_short == 0 || solid->color.green_short == 0xffff) &&
(solid->color.blue_short == 0 || solid->color.blue_short == 0xffff) ))
{
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"%f a",
solid->color.alpha);
}
else
{
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"%f %f %f %f rgba",
solid->color.red,
solid->color.green,
@@ -856,13 +862,13 @@ _emit_solid_pattern (cairo_script_surface_t *surface,
if (solid->color.red_short == solid->color.green_short &&
solid->color.red_short == solid->color.blue_short)
{
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"%f g",
solid->color.red);
}
else
{
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"%f %f %f rgb",
solid->color.red,
solid->color.green,
@@ -897,28 +903,30 @@ static cairo_status_t
_emit_linear_pattern (cairo_script_surface_t *surface,
const cairo_pattern_t *pattern)
{
+ cairo_script_context_t *ctx = to_context (surface);
cairo_linear_pattern_t *linear;
linear = (cairo_linear_pattern_t *) pattern;
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"%f %f %f %f linear",
_cairo_fixed_to_double (linear->p1.x),
_cairo_fixed_to_double (linear->p1.y),
_cairo_fixed_to_double (linear->p2.x),
_cairo_fixed_to_double (linear->p2.y));
- return _emit_gradient_color_stops (&linear->base, surface->ctx->stream);
+ return _emit_gradient_color_stops (&linear->base, ctx->stream);
}
static cairo_status_t
_emit_radial_pattern (cairo_script_surface_t *surface,
const cairo_pattern_t *pattern)
{
+ cairo_script_context_t *ctx = to_context (surface);
cairo_radial_pattern_t *radial;
radial = (cairo_radial_pattern_t *) pattern;
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"%f %f %f %f %f %f radial",
_cairo_fixed_to_double (radial->c1.x),
_cairo_fixed_to_double (radial->c1.y),
@@ -926,7 +934,7 @@ _emit_radial_pattern (cairo_script_surface_t *surface,
_cairo_fixed_to_double (radial->c2.x),
_cairo_fixed_to_double (radial->c2.y),
_cairo_fixed_to_double (radial->r2));
- return _emit_gradient_color_stops (&radial->base, surface->ctx->stream);
+ return _emit_gradient_color_stops (&radial->base, ctx->stream);
}
static cairo_status_t
@@ -952,7 +960,7 @@ _emit_recording_surface_pattern (cairo_script_surface_t *surface,
/* convert to extents so that it matches the public api */
_cairo_box_round_to_rectangle (&bbox, &rect);
- similar = _cairo_script_surface_create_internal (surface->ctx,
+ similar = _cairo_script_surface_create_internal (to_context (surface),
source->content,
rect.width,
rect.height,
@@ -964,7 +972,7 @@ _emit_recording_surface_pattern (cairo_script_surface_t *surface,
surface->is_clear = TRUE;
_get_target (surface);
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (to_context (surface)->stream,
"%d %d //%s similar dup context\n",
rect.width, rect.height,
_content_to_string (source->content));
@@ -984,7 +992,7 @@ _emit_recording_surface_pattern (cairo_script_surface_t *surface,
cairo_list_del (&similar->operand.link);
assert (target_is_active (surface));
- _cairo_output_stream_puts (surface->ctx->stream, "pop pattern");
+ _cairo_output_stream_puts (to_context (surface)->stream, "pop pattern");
cairo_surface_destroy (&similar->base);
return CAIRO_STATUS_SUCCESS;
@@ -1001,7 +1009,7 @@ _emit_script_surface_pattern (cairo_script_surface_t *surface,
source = (cairo_script_surface_t *) surface_pattern->surface;
_get_target (source);
- _cairo_output_stream_puts (surface->ctx->stream, "pattern");
+ _cairo_output_stream_puts (to_context (surface)->stream, "pattern");
return CAIRO_STATUS_SUCCESS;
}
@@ -1115,8 +1123,9 @@ _write_image_surface (cairo_output_stream_t *output,
static cairo_int_status_t
_emit_png_surface (cairo_script_surface_t *surface,
- cairo_image_surface_t *image)
+ cairo_image_surface_t *image)
{
+ cairo_script_context_t *ctx = to_context (surface);
cairo_output_stream_t *base85_stream;
cairo_status_t status;
const uint8_t *mime_data;
@@ -1127,7 +1136,7 @@ _emit_png_surface (cairo_script_surface_t *surface,
if (mime_data == NULL)
return CAIRO_INT_STATUS_UNSUPPORTED;
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"<< "
"/width %d "
"/height %d "
@@ -1137,13 +1146,13 @@ _emit_png_surface (cairo_script_surface_t *surface,
image->width, image->height,
_format_to_string (image->format));
- base85_stream = _cairo_base85_stream_create (surface->ctx->stream);
+ base85_stream = _cairo_base85_stream_create (ctx->stream);
_cairo_output_stream_write (base85_stream, mime_data, mime_data_length);
status = _cairo_output_stream_destroy (base85_stream);
if (unlikely (status))
return status;
- _cairo_output_stream_puts (surface->ctx->stream, "~> >> image ");
+ _cairo_output_stream_puts (ctx->stream, "~> >> image ");
return CAIRO_STATUS_SUCCESS;
}
@@ -1168,6 +1177,7 @@ static cairo_status_t
_emit_image_surface (cairo_script_surface_t *surface,
cairo_image_surface_t *image)
{
+ cairo_script_context_t *ctx = to_context (surface);
cairo_output_stream_t *base85_stream;
cairo_output_stream_t *zlib_stream;
cairo_status_t status, status2;
@@ -1176,9 +1186,9 @@ _emit_image_surface (cairo_script_surface_t *surface,
struct def *tag;
if (_cairo_user_data_array_get_data (&image->base.user_data,
- (cairo_user_data_key_t *) surface->ctx))
+ (cairo_user_data_key_t *) ctx))
{
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"s%u pattern ",
image->base.unique_id);
return CAIRO_STATUS_SUCCESS;
@@ -1200,7 +1210,7 @@ _emit_image_surface (cairo_script_surface_t *surface,
cairo_surface_reference (&image->base);
}
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"<< "
"/width %d "
"/height %d "
@@ -1226,9 +1236,9 @@ _emit_image_surface (cairo_script_surface_t *surface,
len *= clone->height;
if (len > 24) {
- _cairo_output_stream_puts (surface->ctx->stream, "<|");
+ _cairo_output_stream_puts (ctx->stream, "<|");
- base85_stream = _cairo_base85_stream_create (surface->ctx->stream);
+ base85_stream = _cairo_base85_stream_create (ctx->stream);
_cairo_output_stream_write (base85_stream, &len, sizeof (len));
@@ -1244,9 +1254,9 @@ _emit_image_surface (cairo_script_surface_t *surface,
if (unlikely (status))
return status;
} else {
- _cairo_output_stream_puts (surface->ctx->stream, "<~");
+ _cairo_output_stream_puts (ctx->stream, "<~");
- base85_stream = _cairo_base85_stream_create (surface->ctx->stream);
+ base85_stream = _cairo_base85_stream_create (ctx->stream);
status = _write_image_surface (base85_stream, clone);
status2 = _cairo_output_stream_destroy (base85_stream);
if (status == CAIRO_STATUS_SUCCESS)
@@ -1254,7 +1264,7 @@ _emit_image_surface (cairo_script_surface_t *surface,
if (unlikely (status))
return status;
}
- _cairo_output_stream_puts (surface->ctx->stream, "~> >> image ");
+ _cairo_output_stream_puts (ctx->stream, "~> >> image ");
cairo_surface_destroy (&clone->base);
}
@@ -1263,55 +1273,55 @@ _emit_image_surface (cairo_script_surface_t *surface,
if (unlikely (tag == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- tag->ctx = surface->ctx;
+ tag->ctx = ctx;
tag->tag = image->base.unique_id;
tag->user_data = &image->base.user_data;
- cairo_list_add (&tag->link, &surface->ctx->defines);
+ cairo_list_add (&tag->link, &ctx->defines);
status = _cairo_user_data_array_set_data (&image->base.user_data,
- (cairo_user_data_key_t *) surface->ctx,
+ (cairo_user_data_key_t *) ctx,
tag, _undef);
if (unlikely (status)) {
free (tag);
return status;
}
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"dup /s%u exch def ",
image->base.unique_id);
cairo_surface_get_mime_data (&image->base, CAIRO_MIME_TYPE_JPEG,
&mime_data, &mime_data_length);
if (mime_data != NULL) {
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"\n (%s) <~",
CAIRO_MIME_TYPE_JPEG);
- base85_stream = _cairo_base85_stream_create (surface->ctx->stream);
+ base85_stream = _cairo_base85_stream_create (ctx->stream);
_cairo_output_stream_write (base85_stream, mime_data, mime_data_length);
status = _cairo_output_stream_destroy (base85_stream);
if (unlikely (status))
return status;
- _cairo_output_stream_puts (surface->ctx->stream, "~> set-mime-data\n");
+ _cairo_output_stream_puts (ctx->stream, "~> set-mime-data\n");
}
cairo_surface_get_mime_data (&image->base, CAIRO_MIME_TYPE_JP2,
&mime_data, &mime_data_length);
if (mime_data != NULL) {
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"\n (%s) <~",
CAIRO_MIME_TYPE_JP2);
- base85_stream = _cairo_base85_stream_create (surface->ctx->stream);
+ base85_stream = _cairo_base85_stream_create (ctx->stream);
_cairo_output_stream_write (base85_stream, mime_data, mime_data_length);
status = _cairo_output_stream_destroy (base85_stream);
if (unlikely (status))
return status;
- _cairo_output_stream_puts (surface->ctx->stream, "~> set-mime-data\n");
+ _cairo_output_stream_puts (ctx->stream, "~> set-mime-data\n");
}
- _cairo_output_stream_puts (surface->ctx->stream, "pattern");
+ _cairo_output_stream_puts (ctx->stream, "pattern");
return CAIRO_STATUS_SUCCESS;
}
@@ -1321,17 +1331,22 @@ _emit_image_surface_pattern (cairo_script_surface_t *surface,
const cairo_pattern_t *pattern)
{
cairo_surface_pattern_t *surface_pattern;
+ cairo_surface_t *snapshot;
cairo_image_surface_t *image;
cairo_status_t status;
+ void *extra;
/* XXX keeping a copy is nasty, but we want to hook into the surface's
* lifetime. Using a snapshot is a convenient method.
*/
surface_pattern = (cairo_surface_pattern_t *) pattern;
- image = (cairo_image_surface_t *)
- _cairo_surface_snapshot (surface_pattern->surface);
- status = _emit_image_surface (surface, image);
- cairo_surface_destroy (&image->base);
+ snapshot = _cairo_surface_snapshot (surface_pattern->surface);
+ status = _cairo_surface_acquire_source_image (snapshot, &image, &extra);
+ if (likely (status == CAIRO_STATUS_SUCCESS)) {
+ status = _emit_image_surface (surface, image);
+ _cairo_surface_release_source_image (snapshot, image, extra);
+ }
+ cairo_surface_destroy (snapshot);
return status;
}
@@ -1360,6 +1375,7 @@ static cairo_status_t
_emit_pattern (cairo_script_surface_t *surface,
const cairo_pattern_t *pattern)
{
+ cairo_script_context_t *ctx = to_context (surface);
cairo_status_t status;
cairo_bool_t is_default_extend;
cairo_bool_t need_newline = TRUE;
@@ -1391,11 +1407,11 @@ _emit_pattern (cairo_script_surface_t *surface,
if (! _cairo_matrix_is_identity (&pattern->matrix)) {
if (need_newline) {
- _cairo_output_stream_puts (surface->ctx->stream, "\n ");
+ _cairo_output_stream_puts (ctx->stream, "\n ");
need_newline = FALSE;
}
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
" [%f %f %f %f %f %f] set-matrix\n ",
pattern->matrix.xx, pattern->matrix.yx,
pattern->matrix.xy, pattern->matrix.yy,
@@ -1405,27 +1421,27 @@ _emit_pattern (cairo_script_surface_t *surface,
/* XXX need to discriminate the user explicitly setting the default */
if (pattern->filter != CAIRO_FILTER_DEFAULT) {
if (need_newline) {
- _cairo_output_stream_puts (surface->ctx->stream, "\n ");
+ _cairo_output_stream_puts (ctx->stream, "\n ");
need_newline = FALSE;
}
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
" //%s set-filter\n ",
_filter_to_string (pattern->filter));
}
if (! is_default_extend ){
if (need_newline) {
- _cairo_output_stream_puts (surface->ctx->stream, "\n ");
+ _cairo_output_stream_puts (ctx->stream, "\n ");
need_newline = FALSE;
}
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
" //%s set-extend\n ",
_extend_to_string (pattern->extend));
}
if (need_newline)
- _cairo_output_stream_puts (surface->ctx->stream, "\n ");
+ _cairo_output_stream_puts (ctx->stream, "\n ");
return CAIRO_STATUS_SUCCESS;
}
@@ -1439,7 +1455,7 @@ _emit_identity (cairo_script_surface_t *surface,
if (_cairo_matrix_is_identity (&surface->cr.current_ctm))
return CAIRO_STATUS_SUCCESS;
- _cairo_output_stream_puts (surface->ctx->stream,
+ _cairo_output_stream_puts (to_context (surface)->stream,
"identity set-matrix\n");
*matrix_updated = TRUE;
@@ -1480,7 +1496,7 @@ _emit_source (cairo_script_surface_t *surface,
if (unlikely (status))
return status;
- _cairo_output_stream_puts (surface->ctx->stream,
+ _cairo_output_stream_puts (to_context (surface)->stream,
" set-source\n");
return CAIRO_STATUS_SUCCESS;
}
@@ -1540,6 +1556,7 @@ static cairo_status_t
_emit_path (cairo_script_surface_t *surface,
cairo_path_fixed_t *path)
{
+ cairo_script_context_t *ctx = to_context (surface);
cairo_box_t box;
cairo_status_t status;
@@ -1551,7 +1568,7 @@ _emit_path (cairo_script_surface_t *surface,
_cairo_path_fixed_fini (&surface->cr.current_path);
- _cairo_output_stream_puts (surface->ctx->stream, "n");
+ _cairo_output_stream_puts (ctx->stream, "n");
if (path == NULL) {
_cairo_path_fixed_init (&surface->cr.current_path);
@@ -1565,7 +1582,7 @@ _emit_path (cairo_script_surface_t *surface,
if (unlikely (status))
return status;
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
" %f %f %f %f rectangle",
x1, y1, x2 - x1, y2 - y1);
} else {
@@ -1581,12 +1598,12 @@ _emit_path (cairo_script_surface_t *surface,
_path_line_to,
_path_curve_to,
_path_close,
- surface->ctx->stream);
+ ctx->stream);
if (unlikely (status))
return status;
}
- _cairo_output_stream_puts (surface->ctx->stream, "\n");
+ _cairo_output_stream_puts (ctx->stream, "\n");
return CAIRO_STATUS_SUCCESS;
}
@@ -1605,6 +1622,7 @@ _emit_scaling_matrix (cairo_script_surface_t *surface,
const cairo_matrix_t *ctm,
cairo_bool_t *matrix_updated)
{
+ cairo_script_context_t *ctx = to_context (surface);
cairo_bool_t was_identity;
assert (target_is_active (surface));
@@ -1619,17 +1637,17 @@ _emit_scaling_matrix (cairo_script_surface_t *surface,
surface->cr.current_ctm.y0 = 0.;
if (_cairo_matrix_is_identity (&surface->cr.current_ctm)) {
- _cairo_output_stream_puts (surface->ctx->stream,
+ _cairo_output_stream_puts (ctx->stream,
"identity set-matrix\n");
} else if (was_identity && fabs (ctm->yx) < 1e-5 && fabs (ctm->xy) < 1e-5) {
- _cairo_output_stream_printf (surface->ctx->stream,
- "%f %f scale\n",
- ctm->xx, ctm->yy);
+ _cairo_output_stream_printf (ctx->stream,
+ "%f %f scale\n",
+ ctm->xx, ctm->yy);
} else {
- _cairo_output_stream_printf (surface->ctx->stream,
- "[%f %f %f %f 0 0] set-matrix\n",
- ctm->xx, ctm->yx,
- ctm->xy, ctm->yy);
+ _cairo_output_stream_printf (ctx->stream,
+ "[%f %f %f %f 0 0] set-matrix\n",
+ ctm->xx, ctm->yx,
+ ctm->xy, ctm->yy);
}
return CAIRO_STATUS_SUCCESS;
@@ -1639,6 +1657,7 @@ static cairo_status_t
_emit_font_matrix (cairo_script_surface_t *surface,
const cairo_matrix_t *font_matrix)
{
+ cairo_script_context_t *ctx = to_context (surface);
assert (target_is_active (surface));
if (memcmp (&surface->cr.current_font_matrix,
@@ -1651,14 +1670,14 @@ _emit_font_matrix (cairo_script_surface_t *surface,
surface->cr.current_font_matrix = *font_matrix;
if (_cairo_matrix_is_identity (font_matrix)) {
- _cairo_output_stream_puts (surface->ctx->stream,
+ _cairo_output_stream_puts (ctx->stream,
"identity set-font-matrix\n");
} else {
- _cairo_output_stream_printf (surface->ctx->stream,
- "[%f %f %f %f %f %f] set-font-matrix\n",
- font_matrix->xx, font_matrix->yx,
- font_matrix->xy, font_matrix->yy,
- font_matrix->x0, font_matrix->y0);
+ _cairo_output_stream_printf (ctx->stream,
+ "[%f %f %f %f %f %f] set-font-matrix\n",
+ font_matrix->xx, font_matrix->yx,
+ font_matrix->xy, font_matrix->yy,
+ font_matrix->x0, font_matrix->y0);
}
return CAIRO_STATUS_SUCCESS;
@@ -1675,7 +1694,7 @@ _cairo_script_surface_create_similar (void *abstract_surface,
cairo_script_context_t *ctx;
cairo_status_t status;
- ctx = other->ctx;
+ ctx = to_context (other);
if (! other->emitted) {
status = _emit_surface (other);
@@ -1716,15 +1735,12 @@ _cairo_script_surface_create_similar (void *abstract_surface,
return &surface->base;
}
-static cairo_status_t
-_context_destroy (cairo_script_context_t *ctx)
+static void
+_device_destroy (void *abstract_device)
{
+ cairo_script_context_t *ctx = abstract_device;
cairo_status_t status;
- assert (ctx->ref > 0);
- if (--ctx->ref)
- return _cairo_output_stream_flush (ctx->stream);
-
while (! cairo_list_is_empty (&ctx->fonts)) {
cairo_script_surface_font_private_t *font;
@@ -1748,8 +1764,6 @@ _context_destroy (cairo_script_context_t *ctx)
status = _cairo_output_stream_destroy (ctx->stream);
free (ctx);
-
- return status;
}
static cairo_status_t
@@ -1785,6 +1799,7 @@ static cairo_status_t
_cairo_script_surface_finish (void *abstract_surface)
{
cairo_script_surface_t *surface = abstract_surface;
+ cairo_script_context_t *ctx = to_context (surface);
cairo_status_t status = CAIRO_STATUS_SUCCESS, status2;
_cairo_surface_wrapper_fini (&surface->wrapper);
@@ -1801,17 +1816,17 @@ _cairo_script_surface_finish (void *abstract_surface)
assert (! surface->active);
if (! cairo_list_is_empty (&surface->operand.link)) {
- if (! surface->ctx->active) {
+ if (! ctx->active) {
if (target_is_active (surface)) {
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"pop\n");
} else {
int depth = target_depth (surface);
if (depth == 1) {
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"exch pop\n");
} else {
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"%d -1 roll pop\n",
depth);
}
@@ -1828,22 +1843,18 @@ _cairo_script_surface_finish (void *abstract_surface)
link->operand.type = DEFERRED;
cairo_list_swap (&link->operand.link,
&surface->operand.link);
- cairo_list_add (&link->link, &surface->ctx->deferred);
+ cairo_list_add (&link->link, &ctx->deferred);
}
}
}
if (surface->defined) {
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"/s%u undef\n",
surface->base.unique_id);
}
}
- status2 = _context_destroy (surface->ctx);
- if (status == CAIRO_STATUS_SUCCESS)
- status = status2;
-
return status;
}
@@ -1857,7 +1868,7 @@ _cairo_script_surface_copy_page (void *abstract_surface)
if (unlikely (status))
return status;
- _cairo_output_stream_puts (surface->ctx->stream, "copy-page\n");
+ _cairo_output_stream_puts (to_context (surface)->stream, "copy-page\n");
return CAIRO_STATUS_SUCCESS;
}
@@ -1872,7 +1883,7 @@ _cairo_script_surface_show_page (void *abstract_surface)
if (unlikely (status))
return status;
- _cairo_output_stream_puts (surface->ctx->stream, "show-page\n");
+ _cairo_output_stream_puts (to_context (surface)->stream, "show-page\n");
return CAIRO_STATUS_SUCCESS;
}
@@ -1887,6 +1898,7 @@ _cairo_script_surface_clipper_intersect_clip_path (cairo_surface_clipper_t *clip
cairo_script_surface_t *surface = cairo_container_of (clipper,
cairo_script_surface_t,
clipper);
+ cairo_script_context_t *ctx = to_context (surface);
cairo_bool_t matrix_updated = FALSE;
cairo_status_t status;
cairo_box_t box;
@@ -1897,7 +1909,7 @@ _cairo_script_surface_clipper_intersect_clip_path (cairo_surface_clipper_t *clip
if (path == NULL) {
if (surface->cr.has_clip) {
- _cairo_output_stream_puts (surface->ctx->stream, "reset-clip\n");
+ _cairo_output_stream_puts (ctx->stream, "reset-clip\n");
surface->cr.has_clip = FALSE;
}
return CAIRO_STATUS_SUCCESS;
@@ -1939,7 +1951,7 @@ _cairo_script_surface_clipper_intersect_clip_path (cairo_surface_clipper_t *clip
if (unlikely (status))
return status;
- _cairo_output_stream_puts (surface->ctx->stream, "clip+\n");
+ _cairo_output_stream_puts (ctx->stream, "clip+\n");
surface->cr.has_clip = TRUE;
return CAIRO_STATUS_SUCCESS;
@@ -1949,13 +1961,13 @@ static void
active (cairo_script_surface_t *surface)
{
if (surface->active++ == 0)
- surface->ctx->active++;
+ to_context (surface)->active++;
}
static void
inactive (cairo_script_surface_t *surface)
{
- cairo_script_context_t *ctx = surface->ctx;
+ cairo_script_context_t *ctx = to_context (surface);
cairo_list_t sorted;
if (--surface->active)
@@ -2065,7 +2077,7 @@ _cairo_script_surface_paint (void *abstract_surface,
if (unlikely (status))
return status;
- _cairo_output_stream_puts (surface->ctx->stream,
+ _cairo_output_stream_puts (to_context (surface)->stream,
"paint\n");
surface->is_clear = op == CAIRO_OPERATOR_CLEAR && clip == NULL;
@@ -2115,7 +2127,7 @@ _cairo_script_surface_mask (void *abstract_surface,
return status;
if (_cairo_pattern_equal (source, mask)) {
- _cairo_output_stream_puts (surface->ctx->stream, "/source get");
+ _cairo_output_stream_puts (to_context (surface)->stream, "/source get");
} else {
status = _emit_pattern (surface, mask);
if (unlikely (status))
@@ -2124,7 +2136,7 @@ _cairo_script_surface_mask (void *abstract_surface,
assert (surface->cr.current_operator == op);
- _cairo_output_stream_puts (surface->ctx->stream,
+ _cairo_output_stream_puts (to_context (surface)->stream,
" mask\n");
surface->is_clear = FALSE;
@@ -2145,9 +2157,9 @@ _cairo_script_surface_stroke (void *abstract_surface,
cairo_operator_t op,
const cairo_pattern_t *source,
cairo_path_fixed_t *path,
- const cairo_stroke_style_t *style,
- const cairo_matrix_t *ctm,
- const cairo_matrix_t *ctm_inverse,
+ const cairo_stroke_style_t *style,
+ const cairo_matrix_t *ctm,
+ const cairo_matrix_t *ctm_inverse,
double tolerance,
cairo_antialias_t antialias,
cairo_clip_t *clip)
@@ -2216,7 +2228,7 @@ _cairo_script_surface_stroke (void *abstract_surface,
if (unlikely (status))
return status;
- _cairo_output_stream_puts (surface->ctx->stream, "stroke+\n");
+ _cairo_output_stream_puts (to_context (surface)->stream, "stroke+\n");
surface->is_clear = FALSE;
@@ -2299,7 +2311,7 @@ _cairo_script_surface_fill (void *abstract_surface,
if (unlikely (status))
return status;
- _cairo_output_stream_puts (surface->ctx->stream, "fill+\n");
+ _cairo_output_stream_puts (to_context (surface)->stream, "fill+\n");
surface->is_clear = FALSE;
@@ -2374,16 +2386,18 @@ static cairo_status_t
_emit_font_options (cairo_script_surface_t *surface,
cairo_font_options_t *font_options)
{
+ cairo_script_context_t *ctx = to_context (surface);
+
if (cairo_font_options_equal (&surface->cr.current_font_options,
font_options))
{
return CAIRO_STATUS_SUCCESS;
}
- _cairo_output_stream_printf (surface->ctx->stream, "<<");
+ _cairo_output_stream_printf (ctx->stream, "<<");
if (font_options->antialias != surface->cr.current_font_options.antialias) {
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
" /antialias //%s",
_antialias_to_string (font_options->antialias));
}
@@ -2391,7 +2405,7 @@ _emit_font_options (cairo_script_surface_t *surface,
if (font_options->subpixel_order !=
surface->cr.current_font_options.subpixel_order)
{
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
" /subpixel-order //%s",
_subpixel_order_to_string (font_options->subpixel_order));
}
@@ -2399,7 +2413,7 @@ _emit_font_options (cairo_script_surface_t *surface,
if (font_options->hint_style !=
surface->cr.current_font_options.hint_style)
{
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
" /hint-style //%s",
_hint_style_to_string (font_options->hint_style));
}
@@ -2407,12 +2421,12 @@ _emit_font_options (cairo_script_surface_t *surface,
if (font_options->hint_metrics !=
surface->cr.current_font_options.hint_metrics)
{
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
" /hint-metrics //%s",
_hint_metrics_to_string (font_options->hint_metrics));
}
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
" >> set-font-options\n");
surface->cr.current_font_options = *font_options;
@@ -2443,6 +2457,7 @@ static cairo_status_t
_emit_type42_font (cairo_script_surface_t *surface,
cairo_scaled_font_t *scaled_font)
{
+ cairo_script_context_t *ctx = to_context (surface);
const cairo_scaled_font_backend_t *backend;
cairo_script_surface_font_private_t *font_private;
cairo_output_stream_t *base85_stream;
@@ -2473,7 +2488,7 @@ _emit_type42_font (cairo_script_surface_t *surface,
}
load_flags = _cairo_ft_scaled_font_get_load_flags (scaled_font);
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"<< "
"/type 42 "
"/index 0 "
@@ -2481,7 +2496,7 @@ _emit_type42_font (cairo_script_surface_t *surface,
"/source <|",
load_flags);
- base85_stream = _cairo_base85_stream_create (surface->ctx->stream);
+ base85_stream = _cairo_base85_stream_create (ctx->stream);
len = size;
_cairo_output_stream_write (base85_stream, &len, sizeof (len));
@@ -2499,7 +2514,7 @@ _emit_type42_font (cairo_script_surface_t *surface,
status = status2;
font_private = scaled_font->surface_private;
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"~> >> font dup /f%lu exch def set-font-face",
font_private->id);
@@ -2510,6 +2525,7 @@ static cairo_status_t
_emit_scaled_font_init (cairo_script_surface_t *surface,
cairo_scaled_font_t *scaled_font)
{
+ cairo_script_context_t *ctx = to_context (surface);
cairo_script_surface_font_private_t *font_private;
cairo_status_t status;
@@ -2517,14 +2533,14 @@ _emit_scaled_font_init (cairo_script_surface_t *surface,
if (unlikely (font_private == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
- font_private->ctx = surface->ctx;
+ font_private->ctx = ctx;
font_private->parent = scaled_font;
font_private->subset_glyph_index = 0;
font_private->has_sfnt = TRUE;
- cairo_list_add (&font_private->link, &surface->ctx->fonts);
+ cairo_list_add (&font_private->link, &ctx->fonts);
- status = _bitmap_next_id (&surface->ctx->font_id,
+ status = _bitmap_next_id (&ctx->font_id,
&font_private->id);
if (unlikely (status)) {
free (font_private);
@@ -2543,7 +2559,7 @@ _emit_scaled_font_init (cairo_script_surface_t *surface,
return status;
font_private->has_sfnt = FALSE;
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"dict\n"
" /type 3 set\n"
" /metrics [%f %f %f %f %f] set\n"
@@ -2563,6 +2579,7 @@ static cairo_status_t
_emit_scaled_font (cairo_script_surface_t *surface,
cairo_scaled_font_t *scaled_font)
{
+ cairo_script_context_t *ctx = to_context (surface);
cairo_matrix_t matrix;
cairo_font_options_t options;
cairo_bool_t matrix_updated = FALSE;
@@ -2605,11 +2622,11 @@ _emit_scaled_font (cairo_script_surface_t *surface,
assert (font_private != NULL);
assert (target_is_active (surface));
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
" /scaled-font get /sf%lu exch def\n",
font_private->id);
} else {
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"sf%lu set-scaled-font\n",
font_private->id);
}
@@ -2622,6 +2639,7 @@ _emit_scaled_glyph_vector (cairo_script_surface_t *surface,
cairo_scaled_font_t *scaled_font,
cairo_scaled_glyph_t *scaled_glyph)
{
+ cairo_script_context_t *ctx = to_context (surface);
cairo_script_surface_font_private_t *font_private;
cairo_script_implicit_context_t old_cr;
cairo_status_t status;
@@ -2631,7 +2649,7 @@ _emit_scaled_glyph_vector (cairo_script_surface_t *surface,
index = ++font_private->subset_glyph_index;
scaled_glyph->surface_private = (void *) index;
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"%lu <<\n"
" /metrics [%f %f %f %f %f %f]\n"
" /render {\n",
@@ -2644,7 +2662,7 @@ _emit_scaled_glyph_vector (cairo_script_surface_t *surface,
scaled_glyph->fs_metrics.y_advance);
if (! _cairo_matrix_is_identity (&scaled_font->scale_inverse)) {
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"[%f %f %f %f %f %f] transform\n",
scaled_font->scale_inverse.xx,
scaled_font->scale_inverse.yx,
@@ -2660,7 +2678,7 @@ _emit_scaled_glyph_vector (cairo_script_surface_t *surface,
&surface->base);
surface->cr = old_cr;
- _cairo_output_stream_puts (surface->ctx->stream, "} >> set\n");
+ _cairo_output_stream_puts (ctx->stream, "} >> set\n");
return status;
}
@@ -2670,6 +2688,7 @@ _emit_scaled_glyph_bitmap (cairo_script_surface_t *surface,
cairo_scaled_font_t *scaled_font,
cairo_scaled_glyph_t *scaled_glyph)
{
+ cairo_script_context_t *ctx = to_context (surface);
cairo_script_surface_font_private_t *font_private;
cairo_status_t status;
unsigned long index;
@@ -2678,7 +2697,7 @@ _emit_scaled_glyph_bitmap (cairo_script_surface_t *surface,
index = ++font_private->subset_glyph_index;
scaled_glyph->surface_private = (void *) index;
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"%lu <<\n"
" /metrics [%f %f %f %f %f %f]\n"
" /render {\n"
@@ -2698,7 +2717,7 @@ _emit_scaled_glyph_bitmap (cairo_script_surface_t *surface,
return status;
if (! _cairo_matrix_is_identity (&scaled_font->font_matrix)) {
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"\n [%f %f %f %f %f %f] set-matrix\n",
scaled_font->font_matrix.xx,
scaled_font->font_matrix.yx,
@@ -2707,7 +2726,7 @@ _emit_scaled_glyph_bitmap (cairo_script_surface_t *surface,
scaled_font->font_matrix.x0,
scaled_font->font_matrix.y0);
}
- _cairo_output_stream_puts (surface->ctx->stream,
+ _cairo_output_stream_puts (ctx->stream,
"mask\n} >> set\n");
return CAIRO_STATUS_SUCCESS;
@@ -2723,7 +2742,7 @@ _emit_scaled_glyph_prologue (cairo_script_surface_t *surface,
font_private = scaled_font->surface_private;
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (to_context (surface)->stream,
"f%lu /glyphs get\n",
font_private->id);
@@ -2815,7 +2834,7 @@ _emit_scaled_glyphs (cairo_script_surface_t *surface,
_cairo_scaled_font_thaw_cache (scaled_font);
if (have_glyph_prologue) {
- _cairo_output_stream_puts (surface->ctx->stream, "pop pop\n");
+ _cairo_output_stream_puts (to_context (surface)->stream, "pop pop\n");
}
return status;
@@ -2825,10 +2844,11 @@ static void
_emit_string_literal (cairo_script_surface_t *surface,
const char *utf8, int len)
{
+ cairo_script_context_t *ctx = to_context (surface);
char c;
const char *end;
- _cairo_output_stream_puts (surface->ctx->stream, "(");
+ _cairo_output_stream_puts (ctx->stream, "(");
if (utf8 == NULL) {
end = utf8;
@@ -2859,11 +2879,11 @@ _emit_string_literal (cairo_script_surface_t *surface,
case '(':
case ')':
ESCAPED_CHAR:
- _cairo_output_stream_printf (surface->ctx->stream, "\\%c", c);
+ _cairo_output_stream_printf (ctx->stream, "\\%c", c);
break;
default:
if (isprint (c) || isspace (c)) {
- _cairo_output_stream_printf (surface->ctx->stream, "%c", c);
+ _cairo_output_stream_printf (ctx->stream, "%c", c);
} else {
int octal = 0;
while (c) {
@@ -2871,13 +2891,13 @@ ESCAPED_CHAR:
octal += c&7;
c /= 8;
}
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"\\%03d", octal);
}
break;
}
}
- _cairo_output_stream_puts (surface->ctx->stream, ")");
+ _cairo_output_stream_puts (ctx->stream, ")");
}
static cairo_int_status_t
@@ -2895,6 +2915,7 @@ _cairo_script_surface_show_text_glyphs (void *abstract_surface,
cairo_clip_t *clip)
{
cairo_script_surface_t *surface = abstract_surface;
+ cairo_script_context_t *ctx = to_context (surface);
cairo_script_surface_font_private_t *font_private;
cairo_scaled_glyph_t *scaled_glyph;
cairo_matrix_t matrix;
@@ -2939,7 +2960,7 @@ _cairo_script_surface_show_text_glyphs (void *abstract_surface,
if (utf8 != NULL && clusters != NULL) {
_emit_string_literal (surface, utf8, utf8_len);
- _cairo_output_stream_puts (surface->ctx->stream, " ");
+ _cairo_output_stream_puts (ctx->stream, " ");
}
matrix = surface->cr.current_ctm;
@@ -2955,7 +2976,7 @@ _cairo_script_surface_show_text_glyphs (void *abstract_surface,
_cairo_scaled_font_freeze_cache (scaled_font);
font_private = scaled_font->surface_private;
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"[%f %f ",
ix, iy);
@@ -2979,10 +3000,10 @@ _cairo_script_surface_show_text_glyphs (void *abstract_surface,
}
if (n == num_glyphs) {
- _cairo_output_stream_puts (surface->ctx->stream, "<~");
- base85_stream = _cairo_base85_stream_create (surface->ctx->stream);
+ _cairo_output_stream_puts (ctx->stream, "<~");
+ base85_stream = _cairo_base85_stream_create (ctx->stream);
} else
- _cairo_output_stream_puts (surface->ctx->stream, "[");
+ _cairo_output_stream_puts (ctx->stream, "[");
for (n = 0; n < num_glyphs; n++) {
double dx, dy;
@@ -3003,11 +3024,11 @@ _cairo_script_surface_show_text_glyphs (void *abstract_surface,
break;
}
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"~> %f <~", glyphs[n].x - x);
- base85_stream = _cairo_base85_stream_create (surface->ctx->stream);
+ base85_stream = _cairo_base85_stream_create (ctx->stream);
} else {
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
" ] %f [ ", glyphs[n].x - x);
}
@@ -3025,12 +3046,12 @@ _cairo_script_surface_show_text_glyphs (void *abstract_surface,
break;
}
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"~> %f %f <~",
ix, iy);
- base85_stream = _cairo_base85_stream_create (surface->ctx->stream);
+ base85_stream = _cairo_base85_stream_create (ctx->stream);
} else {
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
" ] %f %f [ ",
ix, iy);
}
@@ -3047,10 +3068,10 @@ _cairo_script_surface_show_text_glyphs (void *abstract_surface,
_cairo_output_stream_write (base85_stream, &c, 1);
} else {
if (font_private->has_sfnt)
- _cairo_output_stream_printf (surface->ctx->stream, " %lu",
+ _cairo_output_stream_printf (ctx->stream, " %lu",
glyphs[n].index);
else
- _cairo_output_stream_printf (surface->ctx->stream, " %lu",
+ _cairo_output_stream_printf (ctx->stream, " %lu",
(long unsigned) scaled_glyph->surface_private);
}
@@ -3069,9 +3090,9 @@ _cairo_script_surface_show_text_glyphs (void *abstract_surface,
if (status == CAIRO_STATUS_SUCCESS)
status = status2;
- _cairo_output_stream_printf (surface->ctx->stream, "~>");
+ _cairo_output_stream_printf (ctx->stream, "~>");
} else {
- _cairo_output_stream_puts (surface->ctx->stream, " ]");
+ _cairo_output_stream_puts (ctx->stream, " ]");
}
if (unlikely (status))
return status;
@@ -3086,19 +3107,19 @@ _cairo_script_surface_show_text_glyphs (void *abstract_surface,
}
if (n < num_clusters) {
- _cairo_output_stream_puts (surface->ctx->stream, "] [ ");
+ _cairo_output_stream_puts (ctx->stream, "] [ ");
for (n = 0; n < num_clusters; n++) {
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
"%d %d ",
clusters[n].num_bytes,
clusters[n].num_glyphs);
}
- _cairo_output_stream_puts (surface->ctx->stream, "]");
+ _cairo_output_stream_puts (ctx->stream, "]");
}
else
{
- _cairo_output_stream_puts (surface->ctx->stream, "] <~");
- base85_stream = _cairo_base85_stream_create (surface->ctx->stream);
+ _cairo_output_stream_puts (ctx->stream, "] <~");
+ base85_stream = _cairo_base85_stream_create (ctx->stream);
for (n = 0; n < num_clusters; n++) {
uint8_t c[2];
c[0] = clusters[n].num_bytes;
@@ -3109,14 +3130,14 @@ _cairo_script_surface_show_text_glyphs (void *abstract_surface,
if (unlikely (status))
return status;
- _cairo_output_stream_puts (surface->ctx->stream, "~>");
+ _cairo_output_stream_puts (ctx->stream, "~>");
}
- _cairo_output_stream_printf (surface->ctx->stream,
+ _cairo_output_stream_printf (ctx->stream,
" //%s show-text-glyphs\n",
_direction_to_string (backward));
} else {
- _cairo_output_stream_puts (surface->ctx->stream,
+ _cairo_output_stream_puts (ctx->stream,
"] show-glyphs\n");
}
@@ -3257,7 +3278,7 @@ _cairo_script_surface_create_internal (cairo_script_context_t *ctx,
_cairo_surface_init (&surface->base,
&_cairo_script_surface_backend,
- NULL, /* device */
+ &ctx->base,
content);
_cairo_surface_wrapper_init (&surface->wrapper, passthrough);
@@ -3265,9 +3286,6 @@ _cairo_script_surface_create_internal (cairo_script_context_t *ctx,
_cairo_surface_clipper_init (&surface->clipper,
_cairo_script_surface_clipper_intersect_clip_path);
- surface->ctx = ctx;
- ctx->ref++;
-
surface->width = width;
surface->height = height;
@@ -3283,25 +3301,28 @@ _cairo_script_surface_create_internal (cairo_script_context_t *ctx,
return surface;
}
-static const cairo_script_context_t _nil_context = {
- CAIRO_STATUS_NO_MEMORY,
- -1
+static const cairo_device_backend_t _cairo_script_device_backend = {
+ CAIRO_DEVICE_TYPE_SCRIPT,
+
+ NULL, NULL, /* lock, unlock */
+
+ NULL, /* flush */
+ NULL, /* finish */
+ _device_destroy
};
-static cairo_script_context_t *
+static cairo_device_t *
_cairo_script_context_create_internal (cairo_output_stream_t *stream)
{
cairo_script_context_t *ctx;
ctx = malloc (sizeof (cairo_script_context_t));
- if (unlikely (ctx == NULL)) {
- _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
- return (cairo_script_context_t *) &_nil_context;
- }
+ if (unlikely (ctx == NULL))
+ return _cairo_device_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
memset (ctx, 0, sizeof (cairo_script_context_t));
- ctx->status = CAIRO_STATUS_SUCCESS;
- ctx->ref = 1;
+
+ _cairo_device_init (&ctx->base, &_cairo_script_device_backend);
cairo_list_init (&ctx->operands);
cairo_list_init (&ctx->deferred);
@@ -3313,39 +3334,43 @@ _cairo_script_context_create_internal (cairo_output_stream_t *stream)
_cairo_output_stream_puts (ctx->stream, "%!CairoScript\n");
- return ctx;
+ return &ctx->base;
}
-cairo_script_context_t *
-cairo_script_context_create (const char *filename)
+cairo_device_t *
+cairo_script_create (const char *filename)
{
cairo_output_stream_t *stream;
+ cairo_status_t status;
stream = _cairo_output_stream_create_for_filename (filename);
- if (_cairo_output_stream_get_status (stream))
- return (cairo_script_context_t *) &_nil_context;
+ if ((status = _cairo_output_stream_get_status (stream)))
+ return _cairo_device_create_in_error (status);
return _cairo_script_context_create_internal (stream);
}
-cairo_script_context_t *
-cairo_script_context_create_for_stream (cairo_write_func_t write_func,
- void *closure)
+cairo_device_t *
+cairo_script_create_for_stream (cairo_write_func_t write_func,
+ void *closure)
{
cairo_output_stream_t *stream;
+ cairo_status_t status;
stream = _cairo_output_stream_create (write_func, NULL, closure);
- if (_cairo_output_stream_get_status (stream))
- return (cairo_script_context_t *) &_nil_context;
+ if ((status = _cairo_output_stream_get_status (stream)))
+ return _cairo_device_create_in_error (status);
return _cairo_script_context_create_internal (stream);
}
void
-cairo_script_context_write_comment (cairo_script_context_t *context,
- const char *comment,
- int len)
+cairo_script_write_comment (cairo_device_t *device,
+ const char *comment,
+ int len)
{
+ cairo_script_context_t *context = (cairo_script_context_t *) device;
+
if (len < 0)
len = strlen (comment);
@@ -3355,43 +3380,59 @@ cairo_script_context_write_comment (cairo_script_context_t *context,
}
void
-cairo_script_context_set_mode (cairo_script_context_t *context,
- cairo_script_mode_t mode)
+cairo_script_set_mode (cairo_device_t *device,
+ cairo_script_mode_t mode)
{
+ cairo_script_context_t *context = (cairo_script_context_t *) device;
+
context->mode = mode;
}
cairo_script_mode_t
-cairo_script_context_get_mode (cairo_script_context_t *context)
+cairo_script_get_mode (cairo_device_t *device)
{
+ cairo_script_context_t *context = (cairo_script_context_t *) device;
+
return context->mode;
}
cairo_surface_t *
-cairo_script_surface_create (cairo_script_context_t *context,
+cairo_script_surface_create (cairo_device_t *device,
cairo_content_t content,
double width,
double height)
{
- return &_cairo_script_surface_create_internal (context,
+ if (unlikely (device->backend->type != CAIRO_DEVICE_TYPE_SCRIPT))
+ return _cairo_surface_create_in_error (CAIRO_STATUS_DEVICE_TYPE_MISMATCH);
+
+ if (unlikely (device->status))
+ return _cairo_surface_create_in_error (device->status);
+
+ return &_cairo_script_surface_create_internal ((cairo_script_context_t *) device,
content,
width, height,
NULL)->base;
}
cairo_surface_t *
-cairo_script_surface_create_for_target (cairo_script_context_t *context,
+cairo_script_surface_create_for_target (cairo_device_t *device,
cairo_surface_t *target)
{
cairo_rectangle_int_t extents;
+ if (unlikely (device->backend->type != CAIRO_DEVICE_TYPE_SCRIPT))
+ return _cairo_surface_create_in_error (CAIRO_STATUS_DEVICE_TYPE_MISMATCH);
+
+ if (unlikely (device->status))
+ return _cairo_surface_create_in_error (device->status);
+
if (unlikely (target->status))
return _cairo_surface_create_in_error (target->status);
if (! _cairo_surface_get_extents (target, &extents))
extents.width = extents.height = -1;
- return &_cairo_script_surface_create_internal (context,
+ return &_cairo_script_surface_create_internal ((cairo_script_context_t *) device,
target->content,
extents.width,
extents.height,
@@ -3399,7 +3440,7 @@ cairo_script_surface_create_for_target (cairo_script_context_t *context,
}
cairo_status_t
-cairo_script_from_recording_surface (cairo_script_context_t *context,
+cairo_script_from_recording_surface (cairo_device_t *device,
cairo_surface_t *recording_surface)
{
cairo_box_t bbox;
@@ -3407,8 +3448,11 @@ cairo_script_from_recording_surface (cairo_script_context_t *context,
cairo_surface_t *surface;
cairo_status_t status;
- if (unlikely (context->status))
- return context->status;
+ if (unlikely (device->backend->type != CAIRO_DEVICE_TYPE_SCRIPT))
+ return _cairo_error (CAIRO_STATUS_DEVICE_TYPE_MISMATCH);
+
+ if (unlikely (device->status))
+ return _cairo_error (device->status);
if (unlikely (recording_surface->status))
return recording_surface->status;
@@ -3423,7 +3467,7 @@ cairo_script_from_recording_surface (cairo_script_context_t *context,
_cairo_box_round_to_rectangle (&bbox, &extents);
- surface = &_cairo_script_surface_create_internal (context,
+ surface = &_cairo_script_surface_create_internal ((cairo_script_context_t *) device,
recording_surface->content,
extents.width,
extents.height,
@@ -3437,14 +3481,3 @@ cairo_script_from_recording_surface (cairo_script_context_t *context,
return status;
}
-
-void
-cairo_script_context_destroy (cairo_script_context_t *context)
-{
- cairo_status_t status_ignored;
-
- if (context == NULL || context->ref < 0)
- return;
-
- status_ignored = _context_destroy (context);
-}
diff --git a/src/cairo-script.h b/src/cairo-script.h
index 5af625c1..376232da 100644
--- a/src/cairo-script.h
+++ b/src/cairo-script.h
@@ -42,48 +42,43 @@
CAIRO_BEGIN_DECLS
-typedef struct _cairo_script_context cairo_script_context_t;
-
typedef enum {
CAIRO_SCRIPT_MODE_BINARY,
CAIRO_SCRIPT_MODE_ASCII
} cairo_script_mode_t;
-cairo_public cairo_script_context_t *
-cairo_script_context_create (const char *filename);
+cairo_public cairo_device_t *
+cairo_script_create (const char *filename);
-cairo_public cairo_script_context_t *
-cairo_script_context_create_for_stream (cairo_write_func_t write_func,
- void *closure);
+cairo_public cairo_device_t *
+cairo_script_create_for_stream (cairo_write_func_t write_func,
+ void *closure);
cairo_public void
-cairo_script_context_write_comment (cairo_script_context_t *context,
- const char *comment,
- int len);
+cairo_script_write_comment (cairo_device_t *script,
+ const char *comment,
+ int len);
cairo_public void
-cairo_script_context_set_mode (cairo_script_context_t *context,
- cairo_script_mode_t mode);
+cairo_script_set_mode (cairo_device_t *script,
+ cairo_script_mode_t mode);
cairo_public cairo_script_mode_t
-cairo_script_context_get_mode (cairo_script_context_t *context);
-
-cairo_public void
-cairo_script_context_destroy (cairo_script_context_t *context);
+cairo_script_get_mode (cairo_device_t *script);
cairo_public cairo_surface_t *
-cairo_script_surface_create (cairo_script_context_t *context,
+cairo_script_surface_create (cairo_device_t *script,
cairo_content_t content,
double width,
double height);
cairo_public cairo_surface_t *
-cairo_script_surface_create_for_target (cairo_script_context_t *context,
+cairo_script_surface_create_for_target (cairo_device_t *script,
cairo_surface_t *target);
cairo_public cairo_status_t
-cairo_script_from_recording_surface (cairo_script_context_t *context,
- cairo_surface_t *recording_surface);
+cairo_script_from_recording_surface (cairo_device_t *script,
+ cairo_surface_t *recording_surface);
CAIRO_END_DECLS
diff --git a/test/cairo-test-trace.c b/test/cairo-test-trace.c
index b7cae200..ed81eb29 100644
--- a/test/cairo-test-trace.c
+++ b/test/cairo-test-trace.c
@@ -864,17 +864,18 @@ static void
write_trace (const char *trace, struct slave *slave)
{
#if CAIRO_HAS_SCRIPT_SURFACE
- cairo_script_context_t *ctx;
+ cairo_device_t *ctx,
cairo_surface_t *script;
char *filename;
cairo_t *cr;
xasprintf (&filename, "%s-fail.trace", trace);
- ctx = cairo_script_context_create (filename);
+ ctx = cairo_script_create (filename);
script = cairo_script_surface_create (ctx,
+ cairo_surface_get_content (slave->image),
slave->width,
slave->height);
- cairo_script_context_destroy (ctx);
+ cairo_device_destroy (ctx);
free (filename);
cr = cairo_create (slave->image);
diff --git a/util/cairo-fdr/fdr.c b/util/cairo-fdr/fdr.c
index 05c77e59..30f2dda9 100644
--- a/util/cairo-fdr/fdr.c
+++ b/util/cairo-fdr/fdr.c
@@ -52,10 +52,10 @@ static int fdr_dump;
static const cairo_user_data_key_t fdr_key;
static void
-fdr_replay_to_script (cairo_surface_t *recording, cairo_script_context_t *ctx)
+fdr_replay_to_script (cairo_surface_t *recording, cairo_device_t *ctx)
{
if (recording != NULL) {
- DLCALL (cairo_script_context_write_comment, ctx, "--- fdr ---", -1);
+ DLCALL (cairo_script_write_comment, ctx, "--- fdr ---", -1);
DLCALL (cairo_script_from_recording_surface, ctx, recording);
}
}
@@ -63,10 +63,10 @@ fdr_replay_to_script (cairo_surface_t *recording, cairo_script_context_t *ctx)
static void
fdr_dump_ringbuffer (void)
{
- cairo_script_context_t *ctx;
+ cairo_device_t *ctx;
int n;
- ctx = DLCALL (cairo_script_context_create, "/tmp/fdr.trace");
+ ctx = DLCALL (cairo_script_create, "/tmp/fdr.trace");
for (n = fdr_position; n < RINGBUFFER_SIZE; n++)
fdr_replay_to_script (fdr_ringbuffer[n], ctx);
@@ -74,7 +74,7 @@ fdr_dump_ringbuffer (void)
for (n = 0; n < fdr_position; n++)
fdr_replay_to_script (fdr_ringbuffer[n], ctx);
- DLCALL (cairo_script_context_destroy, ctx);
+ DLCALL (cairo_device_destroy, ctx);
}
static void
diff --git a/util/cairo-script/csi-trace.c b/util/cairo-script/csi-trace.c
index d118067f..c57a56b1 100644
--- a/util/cairo-script/csi-trace.c
+++ b/util/cairo-script/csi-trace.c
@@ -8,9 +8,10 @@
static cairo_surface_t *
_script_surface_create (void *closure,
cairo_content_t content,
- double width, double height)
+ double width, double height,
+ long uid)
{
- return cairo_script_surface_create (closure, width, height);
+ return cairo_script_surface_create (closure, content, width, height);
}
int
@@ -28,12 +29,12 @@ main (int argc, char **argv)
char buf[4096];
snprintf (buf, sizeof (buf), "%s.trace", basename (argv[i]));
- cairo_script_context_destroy (hooks.closure);
- hooks.closure = cairo_script_context_create (buf);
+ cairo_device_destroy (hooks.closure);
+ hooks.closure = cairo_script_create (buf);
cairo_script_interpreter_install_hooks (csi, &hooks);
cairo_script_interpreter_run (csi, argv[i]);
}
- cairo_script_context_destroy (hooks.closure);
+ cairo_device_destroy (hooks.closure);
return cairo_script_interpreter_destroy (csi);
}
diff --git a/util/cairo-sphinx/fdr.c b/util/cairo-sphinx/fdr.c
index 9c66608a..31945f6f 100644
--- a/util/cairo-sphinx/fdr.c
+++ b/util/cairo-sphinx/fdr.c
@@ -46,7 +46,7 @@ static void *_dlhandle = RTLD_NEXT;
(*name##_real) (args); \
})
-static cairo_script_context_t *fdr_context;
+static cairo_device_t *fdr_context;
static const cairo_user_data_key_t fdr_key;
static void
@@ -126,7 +126,7 @@ cairo_create (cairo_surface_t *surface)
if (fdr_context == NULL) {
const char *env = getenv ("CAIRO_SPHINX_FD");
int fd = env ? atoi (env) : 1;
- fdr_context = DLCALL (cairo_script_context_create_for_stream,
+ fdr_context = DLCALL (cairo_script_create_for_stream,
fdr_write, (void *) (intptr_t) fd);
}
diff --git a/util/cairo-sphinx/sphinx.c b/util/cairo-sphinx/sphinx.c
index d5f0e93d..6d2cda70 100644
--- a/util/cairo-sphinx/sphinx.c
+++ b/util/cairo-sphinx/sphinx.c
@@ -135,7 +135,7 @@ daemonize (void)
/* Let the parent go. */
switch (fork ()) {
case -1: return -1;
- case 0: break;
+ case 0: break;
default: _exit (0);
}
@@ -145,13 +145,11 @@ daemonize (void)
/* Refork to yield session leadership. */
oldhup = signal (SIGHUP, SIG_IGN);
-
- switch (fork ()) { /* refork to yield session leadership. */
+ switch (fork ()) {
case -1: return -1;
- case 0: break;
+ case 0: break;
default: _exit (0);
}
-
signal (SIGHUP, oldhup);
/* Establish stdio. */
@@ -427,6 +425,7 @@ u8_cmp (const void *A, const void *B)
static uint8_t
median (uint8_t *values, int count)
{
+ /* XXX could use a fast median here if we cared */
qsort (values, count, 1, u8_cmp);
return values[count/2];
}
@@ -667,16 +666,16 @@ checksum (const char *filename)
static void
write_trace (struct clients *clients)
{
- cairo_script_context_t *ctx;
+ cairo_device_t *ctx;
gchar *csum;
char buf[4096];
int i;
mkdir ("output", 0777);
- ctx = cairo_script_context_create ("output/cairo-sphinx.trace");
+ ctx = cairo_script_create ("output/cairo-sphinx.trace");
cairo_script_from_recording_surface (ctx, clients->recording);
- cairo_script_context_destroy (ctx);
+ cairo_device_destroy (ctx);
csum = checksum ("output/cairo-sphinx.trace");
@@ -1262,7 +1261,7 @@ do_server (const char *path)
}
} else if (strncmp (line, ".complete", 9) == 0) {
clients_complete (&clients, pfd[n].fd);
- } else if (strncmp (line, ".recording", 5) == 0) {
+ } else if (strncmp (line, ".recording", 10) == 0) {
clients_recording (&clients, pfd[n].fd, line + 6);
} else {
printf ("do_command (%s)\n", line);
diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c
index f624c0f4..46ec7f29 100644
--- a/util/cairo-trace/trace.c
+++ b/util/cairo-trace/trace.c
@@ -4567,7 +4567,7 @@ cairo_xlib_surface_create_with_xrender_format (Display *dpy,
#if CAIRO_HAS_SCRIPT_SURFACE
#include <cairo-script.h>
cairo_surface_t *
-cairo_script_surface_create (cairo_script_context_t *ctx,
+cairo_script_surface_create (cairo_device_t *device,
cairo_content_t content,
double width,
double height)
@@ -4577,7 +4577,7 @@ cairo_script_surface_create (cairo_script_context_t *ctx,
_enter_trace ();
- ret = DLCALL (cairo_script_surface_create, ctx, content, width, height);
+ ret = DLCALL (cairo_script_surface_create, device, content, width, height);
surface_id = _create_surface_id (ret);
_emit_line_info ();
@@ -4602,7 +4602,7 @@ cairo_script_surface_create (cairo_script_context_t *ctx,
}
cairo_surface_t *
-cairo_script_surface_create_for_target (cairo_script_context_t *ctx,
+cairo_script_surface_create_for_target (cairo_device_t *device,
cairo_surface_t *target)
{
cairo_surface_t *ret;
@@ -4610,7 +4610,7 @@ cairo_script_surface_create_for_target (cairo_script_context_t *ctx,
_enter_trace ();
- ret = DLCALL (cairo_script_surface_create_for_target, ctx, target);
+ ret = DLCALL (cairo_script_surface_create_for_target, device, target);
surface_id = _create_surface_id (ret);
_emit_line_info ();