mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-09 04:58:04 +02:00
[script] Emit surface content
Include the desired content with the creation info.
This commit is contained in:
parent
052211b072
commit
7306305cc8
4 changed files with 27 additions and 15 deletions
|
|
@ -61,7 +61,7 @@ _cairo_boilerplate_script_create_surface (const char *name,
|
|||
xunlink (ptc->filename);
|
||||
|
||||
ctx = cairo_script_context_create (ptc->filename);
|
||||
surface = cairo_script_surface_create (ctx, width, height);
|
||||
surface = cairo_script_surface_create (ctx, content, width, height);
|
||||
cairo_script_context_destroy (ctx);
|
||||
|
||||
status = cairo_surface_set_user_data (surface,
|
||||
|
|
|
|||
|
|
@ -151,6 +151,7 @@ static const cairo_surface_backend_t _cairo_script_surface_backend;
|
|||
|
||||
static cairo_script_surface_t *
|
||||
_cairo_script_surface_create_internal (cairo_script_context_t *ctx,
|
||||
cairo_content_t content,
|
||||
double width,
|
||||
double height,
|
||||
cairo_surface_t *passthrough);
|
||||
|
|
@ -428,11 +429,23 @@ _get_target (cairo_script_surface_t *surface)
|
|||
}
|
||||
}
|
||||
|
||||
static const char *
|
||||
_content_to_string (cairo_content_t content)
|
||||
{
|
||||
switch (content) {
|
||||
case CAIRO_CONTENT_ALPHA: return "ALPHA";
|
||||
case CAIRO_CONTENT_COLOR: return "COLOR";
|
||||
default:
|
||||
case CAIRO_CONTENT_COLOR_ALPHA: return "COLOR_ALPHA";
|
||||
}
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
_emit_surface (cairo_script_surface_t *surface)
|
||||
{
|
||||
_cairo_output_stream_printf (surface->ctx->stream,
|
||||
"<< /width %f /height %f",
|
||||
"<< /content %s /width %f /height %f",
|
||||
_content_to_string (surface->base.content),
|
||||
surface->width,
|
||||
surface->height);
|
||||
|
||||
|
|
@ -909,17 +922,6 @@ _emit_radial_pattern (cairo_script_surface_t *surface,
|
|||
return _emit_gradient_color_stops (&radial->base, surface->ctx->stream);
|
||||
}
|
||||
|
||||
static const char *
|
||||
_content_to_string (cairo_content_t content)
|
||||
{
|
||||
switch (content) {
|
||||
case CAIRO_CONTENT_ALPHA: return "ALPHA";
|
||||
case CAIRO_CONTENT_COLOR: return "COLOR";
|
||||
default:
|
||||
case CAIRO_CONTENT_COLOR_ALPHA: return "COLOR_ALPHA";
|
||||
}
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
_emit_meta_surface_pattern (cairo_script_surface_t *surface,
|
||||
const cairo_pattern_t *pattern)
|
||||
|
|
@ -944,6 +946,7 @@ _emit_meta_surface_pattern (cairo_script_surface_t *surface,
|
|||
_cairo_box_round_to_rectangle (&bbox, &rect);
|
||||
|
||||
similar = _cairo_script_surface_create_internal (surface->ctx,
|
||||
source->content,
|
||||
rect.width,
|
||||
rect.height,
|
||||
NULL);
|
||||
|
|
@ -1677,6 +1680,7 @@ _cairo_script_surface_create_similar (void *abstract_surface,
|
|||
}
|
||||
|
||||
surface = _cairo_script_surface_create_internal (ctx,
|
||||
content,
|
||||
width, height,
|
||||
passthrough);
|
||||
cairo_surface_destroy (passthrough);
|
||||
|
|
@ -3209,6 +3213,7 @@ _cairo_script_implicit_context_reset (cairo_script_implicit_context_t *cr)
|
|||
|
||||
static cairo_script_surface_t *
|
||||
_cairo_script_surface_create_internal (cairo_script_context_t *ctx,
|
||||
cairo_content_t content,
|
||||
double width,
|
||||
double height,
|
||||
cairo_surface_t *passthrough)
|
||||
|
|
@ -3224,7 +3229,7 @@ _cairo_script_surface_create_internal (cairo_script_context_t *ctx,
|
|||
|
||||
_cairo_surface_init (&surface->base,
|
||||
&_cairo_script_surface_backend,
|
||||
CAIRO_CONTENT_COLOR_ALPHA);
|
||||
content);
|
||||
|
||||
_cairo_surface_wrapper_init (&surface->wrapper, passthrough);
|
||||
|
||||
|
|
@ -3335,10 +3340,12 @@ cairo_script_context_get_mode (cairo_script_context_t *context)
|
|||
|
||||
cairo_surface_t *
|
||||
cairo_script_surface_create (cairo_script_context_t *context,
|
||||
cairo_content_t content,
|
||||
double width,
|
||||
double height)
|
||||
{
|
||||
return &_cairo_script_surface_create_internal (context,
|
||||
content,
|
||||
width, height,
|
||||
NULL)->base;
|
||||
}
|
||||
|
|
@ -3356,6 +3363,7 @@ cairo_script_surface_create_for_target (cairo_script_context_t *context,
|
|||
extents.width = extents.height = -1;
|
||||
|
||||
return &_cairo_script_surface_create_internal (context,
|
||||
target->content,
|
||||
extents.width,
|
||||
extents.height,
|
||||
target)->base;
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ cairo_script_context_destroy (cairo_script_context_t *context);
|
|||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_script_surface_create (cairo_script_context_t *context,
|
||||
cairo_content_t content,
|
||||
double width,
|
||||
double height);
|
||||
|
||||
|
|
|
|||
|
|
@ -4146,22 +4146,25 @@ cairo_xlib_surface_create_with_xrender_format (Display *dpy,
|
|||
#include <cairo-script.h>
|
||||
cairo_surface_t *
|
||||
cairo_script_surface_create (cairo_script_context_t *ctx,
|
||||
cairo_content_t content,
|
||||
double width,
|
||||
double height)
|
||||
{
|
||||
cairo_surface_t *ret;
|
||||
long surface_id;
|
||||
|
||||
ret = DLCALL (cairo_script_surface_create, ctx, width, height);
|
||||
ret = DLCALL (cairo_script_surface_create, ctx, content, width, height);
|
||||
surface_id = _create_surface_id (ret);
|
||||
|
||||
_emit_line_info ();
|
||||
if (_write_lock ()) {
|
||||
_trace_printf ("dict\n"
|
||||
" /type /script set\n"
|
||||
" /content %s set\n"
|
||||
" /width %g set\n"
|
||||
" /height %g set\n"
|
||||
" surface dup /s%ld exch def\n",
|
||||
_content_to_string (content),
|
||||
width, height,
|
||||
surface_id);
|
||||
_surface_object_set_size (ret, width, height);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue