mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 00:38:06 +02:00
Add a new cairo_paginated_surface_backend_t rather than just a single function pointer.
This commit is contained in:
parent
5461f25df9
commit
8f3c60096d
5 changed files with 63 additions and 52 deletions
|
|
@ -43,15 +43,18 @@ typedef enum {
|
|||
CAIRO_PAGINATED_MODE_RENDER /* render page contents */
|
||||
} cairo_paginated_mode_t;
|
||||
|
||||
typedef void (*cairo_set_paginated_mode_func_t) (cairo_surface_t *target,
|
||||
cairo_paginated_mode_t mode);
|
||||
typedef struct _cairo_paginated_surface_backend {
|
||||
void
|
||||
(*set_paginated_mode) (void *surface,
|
||||
cairo_paginated_mode_t mode);
|
||||
} cairo_paginated_surface_backend_t;
|
||||
|
||||
cairo_private cairo_surface_t *
|
||||
_cairo_paginated_surface_create (cairo_surface_t *target,
|
||||
cairo_content_t content,
|
||||
int width,
|
||||
int height,
|
||||
cairo_set_paginated_mode_func_t set_paginated_mode);
|
||||
_cairo_paginated_surface_create (cairo_surface_t *target,
|
||||
cairo_content_t content,
|
||||
int width,
|
||||
int height,
|
||||
const cairo_paginated_surface_backend_t *backend);
|
||||
|
||||
cairo_private cairo_surface_t *
|
||||
_cairo_paginated_surface_get_target (cairo_surface_t *surface);
|
||||
|
|
|
|||
|
|
@ -74,6 +74,9 @@
|
|||
typedef struct _cairo_paginated_surface {
|
||||
cairo_surface_t base;
|
||||
|
||||
/* The target surface to hold the final result. */
|
||||
cairo_surface_t *target;
|
||||
|
||||
cairo_content_t content;
|
||||
|
||||
/* XXX: These shouldn't actually exist. We inherit this ugliness
|
||||
|
|
@ -84,11 +87,8 @@ typedef struct _cairo_paginated_surface {
|
|||
int width;
|
||||
int height;
|
||||
|
||||
/* The target surface to hold the final result. */
|
||||
cairo_surface_t *target;
|
||||
|
||||
/* Paginated-surface specific function for the target */
|
||||
cairo_set_paginated_mode_func_t set_paginated_mode;
|
||||
/* Paginated-surface specific functions for the target */
|
||||
const cairo_paginated_surface_backend_t *backend;
|
||||
|
||||
/* A cairo_meta_surface to record all operations. To be replayed
|
||||
* against target, and also against image surface as necessary for
|
||||
|
|
@ -121,11 +121,11 @@ _cairo_paginated_surface_create_similar (void *abstract_surface,
|
|||
#endif
|
||||
|
||||
cairo_surface_t *
|
||||
_cairo_paginated_surface_create (cairo_surface_t *target,
|
||||
cairo_content_t content,
|
||||
int width,
|
||||
int height,
|
||||
cairo_set_paginated_mode_func_t set_paginated_mode)
|
||||
_cairo_paginated_surface_create (cairo_surface_t *target,
|
||||
cairo_content_t content,
|
||||
int width,
|
||||
int height,
|
||||
const cairo_paginated_surface_backend_t *backend)
|
||||
{
|
||||
cairo_paginated_surface_t *surface;
|
||||
|
||||
|
|
@ -139,12 +139,13 @@ _cairo_paginated_surface_create (cairo_surface_t *target,
|
|||
* evidence of the paginated wrapper out to the user. */
|
||||
surface->base.type = cairo_surface_get_type (target);
|
||||
|
||||
surface->target = target;
|
||||
|
||||
surface->content = content;
|
||||
surface->width = width;
|
||||
surface->height = height;
|
||||
|
||||
surface->target = target;
|
||||
surface->set_paginated_mode = set_paginated_mode;
|
||||
surface->backend = backend;
|
||||
|
||||
surface->meta = _cairo_meta_surface_create (content, width, height);
|
||||
if (cairo_surface_status (surface->meta))
|
||||
|
|
@ -231,9 +232,9 @@ _paint_page (cairo_paginated_surface_t *surface)
|
|||
analysis = _cairo_analysis_surface_create (surface->target,
|
||||
surface->width, surface->height);
|
||||
|
||||
surface->set_paginated_mode (surface->target, CAIRO_PAGINATED_MODE_ANALYZE);
|
||||
surface->backend->set_paginated_mode (surface->target, CAIRO_PAGINATED_MODE_ANALYZE);
|
||||
_cairo_meta_surface_replay (surface->meta, analysis);
|
||||
surface->set_paginated_mode (surface->target, CAIRO_PAGINATED_MODE_RENDER);
|
||||
surface->backend->set_paginated_mode (surface->target, CAIRO_PAGINATED_MODE_RENDER);
|
||||
|
||||
if (analysis->status) {
|
||||
status = analysis->status;
|
||||
|
|
|
|||
|
|
@ -187,11 +187,8 @@ _cairo_pdf_surface_add_stream (cairo_pdf_surface_t *surface,
|
|||
static void
|
||||
_cairo_pdf_surface_ensure_stream (cairo_pdf_surface_t *surface);
|
||||
|
||||
static void
|
||||
_cairo_pdf_set_paginated_mode (cairo_surface_t *target,
|
||||
cairo_paginated_mode_t mode);
|
||||
|
||||
static const cairo_surface_backend_t cairo_pdf_surface_backend;
|
||||
static const cairo_paginated_surface_backend_t cairo_pdf_surface_paginated_backend;
|
||||
|
||||
static unsigned int
|
||||
_cairo_pdf_document_new_object (cairo_pdf_document_t *document)
|
||||
|
|
@ -313,7 +310,7 @@ _cairo_pdf_surface_create_for_stream_internal (cairo_output_stream_t *stream,
|
|||
return _cairo_paginated_surface_create (target,
|
||||
CAIRO_CONTENT_COLOR_ALPHA,
|
||||
width, height,
|
||||
_cairo_pdf_set_paginated_mode);
|
||||
&cairo_pdf_surface_paginated_backend);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2095,10 +2092,10 @@ _cairo_pdf_document_add_page (cairo_pdf_document_t *document,
|
|||
}
|
||||
|
||||
static void
|
||||
_cairo_pdf_set_paginated_mode (cairo_surface_t *target,
|
||||
cairo_paginated_mode_t paginated_mode)
|
||||
_cairo_pdf_surface_set_paginated_mode (void *abstract_surface,
|
||||
cairo_paginated_mode_t paginated_mode)
|
||||
{
|
||||
cairo_pdf_surface_t *surface = (cairo_pdf_surface_t *) target;
|
||||
cairo_pdf_surface_t *surface = abstract_surface;
|
||||
|
||||
surface->paginated_mode = paginated_mode;
|
||||
}
|
||||
|
|
@ -2135,3 +2132,7 @@ static const cairo_surface_backend_t cairo_pdf_surface_backend = {
|
|||
_cairo_pdf_surface_fill,
|
||||
NULL /* show_glyphs */
|
||||
};
|
||||
|
||||
static const cairo_paginated_surface_backend_t cairo_pdf_surface_paginated_backend = {
|
||||
_cairo_pdf_surface_set_paginated_mode
|
||||
};
|
||||
|
|
|
|||
|
|
@ -55,10 +55,7 @@
|
|||
*/
|
||||
|
||||
static const cairo_surface_backend_t cairo_ps_surface_backend;
|
||||
|
||||
static void
|
||||
_cairo_ps_set_paginated_mode (cairo_surface_t *target,
|
||||
cairo_paginated_mode_t mode);
|
||||
static const cairo_paginated_surface_backend_t cairo_ps_surface_paginated_backend;
|
||||
|
||||
/*
|
||||
* Type1 and Type3 PS fonts can hold only 256 glyphs.
|
||||
|
|
@ -583,7 +580,7 @@ _cairo_ps_surface_create_for_stream_internal (cairo_output_stream_t *stream,
|
|||
return _cairo_paginated_surface_create (&surface->base,
|
||||
CAIRO_CONTENT_COLOR_ALPHA,
|
||||
width, height,
|
||||
_cairo_ps_set_paginated_mode);
|
||||
&cairo_ps_surface_paginated_backend);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1824,6 +1821,15 @@ fallback:
|
|||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
_cairo_ps_surface_set_paginated_mode (void *abstract_surface,
|
||||
cairo_paginated_mode_t paginated_mode)
|
||||
{
|
||||
cairo_ps_surface_t *surface = abstract_surface;
|
||||
|
||||
surface->paginated_mode = paginated_mode;
|
||||
}
|
||||
|
||||
static const cairo_surface_backend_t cairo_ps_surface_backend = {
|
||||
CAIRO_SURFACE_TYPE_PS,
|
||||
NULL, /* create_similar */
|
||||
|
|
@ -1858,11 +1864,6 @@ static const cairo_surface_backend_t cairo_ps_surface_backend = {
|
|||
NULL, /* snapshot */
|
||||
};
|
||||
|
||||
static void
|
||||
_cairo_ps_set_paginated_mode (cairo_surface_t *target,
|
||||
cairo_paginated_mode_t paginated_mode)
|
||||
{
|
||||
cairo_ps_surface_t *surface = (cairo_ps_surface_t *) target;
|
||||
|
||||
surface->paginated_mode = paginated_mode;
|
||||
}
|
||||
static const cairo_paginated_surface_backend_t cairo_ps_surface_paginated_backend = {
|
||||
_cairo_ps_surface_set_paginated_mode
|
||||
};
|
||||
|
|
|
|||
|
|
@ -58,15 +58,7 @@ typedef struct _test_paginated_surface {
|
|||
} test_paginated_surface_t;
|
||||
|
||||
static const cairo_surface_backend_t test_paginated_surface_backend;
|
||||
|
||||
static void
|
||||
_test_paginated_surface_set_paginated_mode (cairo_surface_t *abstract_surface,
|
||||
cairo_paginated_mode_t mode)
|
||||
{
|
||||
test_paginated_surface_t *surface = (test_paginated_surface_t *) abstract_surface;
|
||||
|
||||
surface->paginated_mode = mode;
|
||||
}
|
||||
static const cairo_paginated_surface_backend_t test_paginated_surface_paginated_backend;
|
||||
|
||||
cairo_surface_t *
|
||||
_test_paginated_surface_create_for_data (unsigned char *data,
|
||||
|
|
@ -99,7 +91,7 @@ _test_paginated_surface_create_for_data (unsigned char *data,
|
|||
surface->target = target;
|
||||
|
||||
return _cairo_paginated_surface_create (&surface->base, content, width, height,
|
||||
_test_paginated_surface_set_paginated_mode);
|
||||
&test_paginated_surface_paginated_backend);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
|
|
@ -238,6 +230,15 @@ _test_paginated_surface_show_glyphs (void *abstract_surface,
|
|||
glyphs, num_glyphs, scaled_font);
|
||||
}
|
||||
|
||||
static void
|
||||
_test_paginated_surface_set_paginated_mode (void *abstract_surface,
|
||||
cairo_paginated_mode_t mode)
|
||||
{
|
||||
test_paginated_surface_t *surface = abstract_surface;
|
||||
|
||||
surface->paginated_mode = mode;
|
||||
}
|
||||
|
||||
static const cairo_surface_backend_t test_paginated_surface_backend = {
|
||||
CAIRO_INTERNAL_SURFACE_TYPE_TEST_PAGINATED,
|
||||
|
||||
|
|
@ -276,3 +277,7 @@ static const cairo_surface_backend_t test_paginated_surface_backend = {
|
|||
_test_paginated_surface_show_glyphs,
|
||||
NULL /* snapshot */
|
||||
};
|
||||
|
||||
static const cairo_paginated_surface_backend_t test_paginated_surface_paginated_backend = {
|
||||
_test_paginated_surface_set_paginated_mode
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue