mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-04 23:28:07 +02:00
Support meta surface patterns
This commit is contained in:
parent
ad247974eb
commit
9ca67992a5
2 changed files with 36 additions and 14 deletions
|
|
@ -155,6 +155,15 @@ _cairo_paginated_surface_get_target (cairo_surface_t *surface)
|
|||
return paginated_surface->target;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
_cairo_paginated_surface_create_similar (void *other,
|
||||
cairo_content_t content,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
return _cairo_meta_surface_create (content, width, height);
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
_cairo_paginated_surface_finish (void *abstract_surface)
|
||||
{
|
||||
|
|
@ -412,7 +421,7 @@ _cairo_paginated_surface_snapshot (void *abstract_other)
|
|||
}
|
||||
|
||||
const cairo_surface_backend_t cairo_paginated_surface_backend = {
|
||||
NULL, /* create_similar */
|
||||
_cairo_paginated_surface_create_similar,
|
||||
_cairo_paginated_surface_finish,
|
||||
_cairo_paginated_surface_acquire_source_image,
|
||||
_cairo_paginated_surface_release_source_image,
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
#include "cairo-ps.h"
|
||||
#include "cairo-font-subset-private.h"
|
||||
#include "cairo-paginated-surface-private.h"
|
||||
#include "cairo-meta-surface-private.h"
|
||||
#include "cairo-ft-private.h"
|
||||
|
||||
#include <time.h>
|
||||
|
|
@ -620,9 +621,11 @@ operator_always_translucent (cairo_operator_t op)
|
|||
static cairo_bool_t
|
||||
pattern_surface_supported (const cairo_surface_pattern_t *pattern)
|
||||
{
|
||||
if (pattern->surface->backend->acquire_source_image == NULL)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
if (_cairo_surface_is_meta (pattern->surface))
|
||||
return TRUE;
|
||||
if (pattern->surface->backend->acquire_source_image != NULL)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static cairo_bool_t
|
||||
|
|
@ -823,20 +826,30 @@ static void
|
|||
emit_surface_pattern (cairo_ps_surface_t *surface,
|
||||
cairo_surface_pattern_t *pattern)
|
||||
{
|
||||
cairo_image_surface_t *image;
|
||||
cairo_status_t status;
|
||||
void *image_extra;
|
||||
cairo_rectangle_t extents;
|
||||
|
||||
status = _cairo_surface_acquire_source_image (pattern->surface,
|
||||
&image,
|
||||
&image_extra);
|
||||
assert (status == CAIRO_STATUS_SUCCESS);
|
||||
emit_image (surface, image, &pattern->base.matrix, "MyPattern");
|
||||
_cairo_surface_release_source_image (pattern->surface, image, image_extra);
|
||||
if (_cairo_surface_is_meta (pattern->surface)) {
|
||||
_cairo_output_stream_printf (surface->stream, "/MyPattern {\n");
|
||||
_cairo_meta_surface_replay (pattern->surface, &surface->base);
|
||||
extents.width = surface->width;
|
||||
extents.height = surface->height;
|
||||
_cairo_output_stream_printf (surface->stream, "} bind def\n");
|
||||
} else {
|
||||
cairo_image_surface_t *image;
|
||||
void *image_extra;
|
||||
cairo_status_t status;
|
||||
|
||||
status = _cairo_surface_acquire_source_image (pattern->surface,
|
||||
&image,
|
||||
&image_extra);
|
||||
_cairo_surface_get_extents (&image->base, &extents);
|
||||
assert (status == CAIRO_STATUS_SUCCESS);
|
||||
emit_image (surface, image, &pattern->base.matrix, "MyPattern");
|
||||
_cairo_surface_release_source_image (pattern->surface, image,
|
||||
image_extra);
|
||||
}
|
||||
_cairo_output_stream_printf (surface->stream,
|
||||
"<< /PatternType 1 /PaintType 1 /TilingType 1\n");
|
||||
_cairo_surface_get_extents (&image->base, &extents);
|
||||
_cairo_output_stream_printf (surface->stream,
|
||||
"/BBox [0 0 %d %d]\n",
|
||||
extents.width, extents.height);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue