diff options
author | M Joonas Pihlaja <jpihlaja@cc.helsinki.fi> | 2008-07-11 00:59:47 +0300 |
---|---|---|
committer | M Joonas Pihlaja <jpihlaja@cc.helsinki.fi> | 2008-12-06 14:04:36 +0200 |
commit | 4a9b274eebe674bbc5c66dc3e33256723cdf9829 (patch) | |
tree | ef6445766c969c24848f0cc3317a0c68c20df24d | |
parent | 948c3526dcdbc440395fff4ce9bf4b7553930d92 (diff) |
[cairo-spans] Add a check/create_span_renderer backend methods.
A surface will have the chance to use span rendering at cairo_fill()
time by creating a renderer for a specific combination of
pattern/dst/op before the path is scan converted. The protocol is to
first call check_span_renderer() to see if the surface wants to render
with spans and then later call create_span_renderer() to create the
renderer for real once the extents of the path are known.
No backends have an implementation yet.
-rw-r--r-- | src/cairo-analysis-surface.c | 4 | ||||
-rw-r--r-- | src/cairo-beos-surface.cpp | 2 | ||||
-rw-r--r-- | src/cairo-directfb-surface.c | 2 | ||||
-rw-r--r-- | src/cairo-glitz-surface.c | 2 | ||||
-rw-r--r-- | src/cairo-image-surface.c | 2 | ||||
-rw-r--r-- | src/cairo-meta-surface.c | 2 | ||||
-rw-r--r-- | src/cairo-os2-surface.c | 2 | ||||
-rw-r--r-- | src/cairo-paginated-surface.c | 2 | ||||
-rw-r--r-- | src/cairo-pdf-surface.c | 2 | ||||
-rw-r--r-- | src/cairo-ps-surface.c | 2 | ||||
-rw-r--r-- | src/cairo-quartz-image-surface.c | 2 | ||||
-rw-r--r-- | src/cairo-quartz-surface.c | 2 | ||||
-rw-r--r-- | src/cairo-script-surface.c | 2 | ||||
-rw-r--r-- | src/cairo-sdl-surface.c | 2 | ||||
-rw-r--r-- | src/cairo-surface.c | 53 | ||||
-rw-r--r-- | src/cairo-svg-surface.c | 2 | ||||
-rw-r--r-- | src/cairo-type3-glyph-surface.c | 2 | ||||
-rw-r--r-- | src/cairo-win32-printing-surface.c | 2 | ||||
-rw-r--r-- | src/cairo-win32-surface.c | 2 | ||||
-rw-r--r-- | src/cairo-xcb-surface.c | 2 | ||||
-rw-r--r-- | src/cairo-xlib-surface.c | 2 | ||||
-rw-r--r-- | src/cairoint.h | 30 | ||||
-rw-r--r-- | src/test-fallback-surface.c | 2 | ||||
-rw-r--r-- | src/test-meta-surface.c | 2 | ||||
-rw-r--r-- | src/test-paginated-surface.c | 2 |
25 files changed, 131 insertions, 0 deletions
diff --git a/src/cairo-analysis-surface.c b/src/cairo-analysis-surface.c index a19ff10c..50005c21 100644 --- a/src/cairo-analysis-surface.c +++ b/src/cairo-analysis-surface.c @@ -746,6 +746,8 @@ static const cairo_surface_backend_t cairo_analysis_surface_backend = { NULL, /* composite */ NULL, /* fill_rectangles */ NULL, /* composite_trapezoids */ + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ NULL, /* copy_page */ NULL, /* show_page */ NULL, /* set_clip_region */ @@ -961,6 +963,8 @@ static const cairo_surface_backend_t cairo_null_surface_backend = { NULL, /* composite */ NULL, /* fill_rectangles */ NULL, /* composite_trapezoids */ + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ NULL, /* copy_page */ NULL, /* show_page */ (_set_clip_region_func) _return_success, /* set_clip_region */ diff --git a/src/cairo-beos-surface.cpp b/src/cairo-beos-surface.cpp index ec4aff03..e527272e 100644 --- a/src/cairo-beos-surface.cpp +++ b/src/cairo-beos-surface.cpp @@ -895,6 +895,8 @@ static const struct _cairo_surface_backend cairo_beos_surface_backend = { _cairo_beos_surface_composite, /* composite */ _cairo_beos_surface_fill_rectangles, NULL, /* composite_trapezoids */ + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ NULL, /* copy_page */ NULL, /* show_page */ _cairo_beos_surface_set_clip_region, diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c index cab7104c..71c46755 100644 --- a/src/cairo-directfb-surface.c +++ b/src/cairo-directfb-surface.c @@ -1815,6 +1815,8 @@ _cairo_directfb_surface_backend = { #else NULL,/*composite_trapezoids*/ #endif + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ NULL, /* copy_page */ NULL, /* show_page */ _cairo_directfb_surface_set_clip_region,/* set_clip_region */ diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c index 589e14ff..f049f401 100644 --- a/src/cairo-glitz-surface.c +++ b/src/cairo-glitz-surface.c @@ -2293,6 +2293,8 @@ static const cairo_surface_backend_t cairo_glitz_surface_backend = { _cairo_glitz_surface_composite, _cairo_glitz_surface_fill_rectangles, _cairo_glitz_surface_composite_trapezoids, + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ NULL, /* copy_page */ NULL, /* show_page */ _cairo_glitz_surface_set_clip_region, diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c index 2bf45430..ef5e238d 100644 --- a/src/cairo-image-surface.c +++ b/src/cairo-image-surface.c @@ -1303,6 +1303,8 @@ const cairo_surface_backend_t _cairo_image_surface_backend = { _cairo_image_surface_composite, _cairo_image_surface_fill_rectangles, _cairo_image_surface_composite_trapezoids, + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ NULL, /* copy_page */ NULL, /* show_page */ _cairo_image_surface_set_clip_region, diff --git a/src/cairo-meta-surface.c b/src/cairo-meta-surface.c index e69df21c..0f6e6324 100644 --- a/src/cairo-meta-surface.c +++ b/src/cairo-meta-surface.c @@ -647,6 +647,8 @@ static const cairo_surface_backend_t cairo_meta_surface_backend = { NULL, /* composite */ NULL, /* fill_rectangles */ NULL, /* composite_trapezoids */ + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ NULL, /* copy_page */ NULL, /* show_page */ NULL, /* set_clip_region */ diff --git a/src/cairo-os2-surface.c b/src/cairo-os2-surface.c index e4cef052..02840e33 100644 --- a/src/cairo-os2-surface.c +++ b/src/cairo-os2-surface.c @@ -1326,6 +1326,8 @@ static const cairo_surface_backend_t cairo_os2_surface_backend = { NULL, /* composite */ NULL, /* fill_rectangles */ NULL, /* composite_trapezoids */ + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ NULL, /* copy_page */ NULL, /* show_page */ NULL, /* set_clip_region */ diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c index 2b58e499..ce4e4def 100644 --- a/src/cairo-paginated-surface.c +++ b/src/cairo-paginated-surface.c @@ -678,6 +678,8 @@ static const cairo_surface_backend_t cairo_paginated_surface_backend = { NULL, /* composite */ NULL, /* fill_rectangles */ NULL, /* composite_trapezoids */ + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ _cairo_paginated_surface_copy_page, _cairo_paginated_surface_show_page, NULL, /* set_clip_region */ diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c index b85a6c82..5862c4b5 100644 --- a/src/cairo-pdf-surface.c +++ b/src/cairo-pdf-surface.c @@ -5308,6 +5308,8 @@ static const cairo_surface_backend_t cairo_pdf_surface_backend = { NULL, /* composite */ NULL, /* fill_rectangles */ NULL, /* composite_trapezoids */ + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ NULL, /* _cairo_pdf_surface_copy_page */ _cairo_pdf_surface_show_page, NULL, /* set_clip_region */ diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c index 9d2a7c5c..a13be1d8 100644 --- a/src/cairo-ps-surface.c +++ b/src/cairo-ps-surface.c @@ -3503,6 +3503,8 @@ static const cairo_surface_backend_t cairo_ps_surface_backend = { NULL, /* composite */ NULL, /* fill_rectangles */ NULL, /* composite_trapezoids */ + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ NULL, /* cairo_ps_surface_copy_page */ _cairo_ps_surface_show_page, NULL, /* set_clip_region */ diff --git a/src/cairo-quartz-image-surface.c b/src/cairo-quartz-image-surface.c index 3eee2c11..3bfd9e21 100644 --- a/src/cairo-quartz-image-surface.c +++ b/src/cairo-quartz-image-surface.c @@ -163,6 +163,8 @@ static const cairo_surface_backend_t cairo_quartz_image_surface_backend = { NULL, /* composite */ NULL, /* fill_rectangles */ NULL, /* composite_trapezoids */ + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ NULL, /* copy_page */ NULL, /* show_page */ NULL, /* set_clip_region */ diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c index 19160b4b..9f6b2451 100644 --- a/src/cairo-quartz-surface.c +++ b/src/cairo-quartz-surface.c @@ -2404,6 +2404,8 @@ static const struct _cairo_surface_backend cairo_quartz_surface_backend = { NULL, /* composite */ NULL, /* fill_rectangles */ NULL, /* composite_trapezoids */ + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ NULL, /* copy_page */ NULL, /* show_page */ NULL, /* set_clip_region */ diff --git a/src/cairo-script-surface.c b/src/cairo-script-surface.c index 77a9e5f5..cf2809f5 100644 --- a/src/cairo-script-surface.c +++ b/src/cairo-script-surface.c @@ -2423,6 +2423,8 @@ _cairo_script_surface_backend = { NULL, /* composite */ NULL, /* fill_rectangles */ NULL, /* composite_trapezoids */ + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ _cairo_script_surface_copy_page, _cairo_script_surface_show_page, NULL, /* set_clip_region */ diff --git a/src/cairo-sdl-surface.c b/src/cairo-sdl-surface.c index d98566d5..1f97fb47 100644 --- a/src/cairo-sdl-surface.c +++ b/src/cairo-sdl-surface.c @@ -357,6 +357,8 @@ static const cairo_surface_backend_t _cairo_sdl_surface_backend = { _cairo_sdl_surface_composite, NULL, /* fill rectangles */ NULL, /* composite traps */ + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ NULL, /* copy_page */ NULL, /* show_page */ _cairo_sdl_surface_set_clip_region, diff --git a/src/cairo-surface.c b/src/cairo-surface.c index dff8d9f0..077af5b4 100644 --- a/src/cairo-surface.c +++ b/src/cairo-surface.c @@ -1953,6 +1953,59 @@ _cairo_surface_composite_trapezoids (cairo_operator_t op, traps, num_traps)); } +cairo_span_renderer_t * +_cairo_surface_create_span_renderer (cairo_operator_t op, + const cairo_pattern_t *pattern, + cairo_surface_t *dst, + cairo_antialias_t antialias, + const cairo_composite_rectangles_t *rects) +{ + assert (! dst->is_snapshot); + + if (dst->status) + return _cairo_span_renderer_create_in_error (dst->status); + + if (dst->finished) + return _cairo_span_renderer_create_in_error (CAIRO_STATUS_SURFACE_FINISHED); + + if (dst->backend->create_span_renderer) { + return dst->backend->create_span_renderer (op, + pattern, dst, + antialias, + rects); + } + ASSERT_NOT_REACHED; + return _cairo_span_renderer_create_in_error (CAIRO_INT_STATUS_UNSUPPORTED); +} + +cairo_bool_t +_cairo_surface_check_span_renderer (cairo_operator_t op, + const cairo_pattern_t *pattern, + cairo_surface_t *dst, + cairo_antialias_t antialias, + const cairo_composite_rectangles_t *rects) +{ + cairo_int_status_t status; + + assert (! dst->is_snapshot); + + if (dst->status) + return FALSE; + + if (dst->finished) { + status = _cairo_surface_set_error (dst, CAIRO_STATUS_SURFACE_FINISHED); + return FALSE; + } + + if (dst->backend->check_span_renderer) { + return dst->backend->check_span_renderer (op, + pattern, dst, + antialias, + rects); + } + return FALSE; +} + /** * cairo_surface_copy_page: * @surface: a #cairo_surface_t diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c index 8b66662d..cfd9a2d5 100644 --- a/src/cairo-svg-surface.c +++ b/src/cairo-svg-surface.c @@ -2422,6 +2422,8 @@ static const cairo_surface_backend_t cairo_svg_surface_backend = { NULL, /* _cairo_svg_surface_composite, */ NULL, /* _cairo_svg_surface_fill_rectangles, */ NULL, /* _cairo_svg_surface_composite_trapezoids,*/ + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ _cairo_svg_surface_copy_page, _cairo_svg_surface_show_page, NULL, /* set_clip_region */ diff --git a/src/cairo-type3-glyph-surface.c b/src/cairo-type3-glyph-surface.c index ebc78dd2..b3a48313 100644 --- a/src/cairo-type3-glyph-surface.c +++ b/src/cairo-type3-glyph-surface.c @@ -315,6 +315,8 @@ static const cairo_surface_backend_t cairo_type3_glyph_surface_backend = { NULL, /* composite */ NULL, /* fill_rectangles */ NULL, /* composite_trapezoids */ + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ NULL, /* cairo_type3_glyph_surface_copy_page */ NULL, /* _cairo_type3_glyph_surface_show_page */ NULL, /* set_clip_region */ diff --git a/src/cairo-win32-printing-surface.c b/src/cairo-win32-printing-surface.c index 41330198..94927aeb 100644 --- a/src/cairo-win32-printing-surface.c +++ b/src/cairo-win32-printing-surface.c @@ -1752,6 +1752,8 @@ static const cairo_surface_backend_t cairo_win32_printing_surface_backend = { NULL, /* composite */ NULL, /* fill_rectangles */ NULL, /* composite_trapezoids */ + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ NULL, /* copy_page */ _cairo_win32_printing_surface_show_page, NULL, /* set_clip_region */ diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c index bc665807..03a8f61a 100644 --- a/src/cairo-win32-surface.c +++ b/src/cairo-win32-surface.c @@ -1982,6 +1982,8 @@ static const cairo_surface_backend_t cairo_win32_surface_backend = { _cairo_win32_surface_composite, _cairo_win32_surface_fill_rectangles, NULL, /* composite_trapezoids */ + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ NULL, /* copy_page */ NULL, /* show_page */ _cairo_win32_surface_set_clip_region, diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c index 999f7d54..6f246f80 100644 --- a/src/cairo-xcb-surface.c +++ b/src/cairo-xcb-surface.c @@ -1684,6 +1684,8 @@ static const cairo_surface_backend_t cairo_xcb_surface_backend = { _cairo_xcb_surface_composite, _cairo_xcb_surface_fill_rectangles, _cairo_xcb_surface_composite_trapezoids, + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ NULL, /* copy_page */ NULL, /* show_page */ _cairo_xcb_surface_set_clip_region, diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c index 0e915132..68d81922 100644 --- a/src/cairo-xlib-surface.c +++ b/src/cairo-xlib-surface.c @@ -2446,6 +2446,8 @@ static const cairo_surface_backend_t cairo_xlib_surface_backend = { _cairo_xlib_surface_composite, _cairo_xlib_surface_fill_rectangles, _cairo_xlib_surface_composite_trapezoids, + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ NULL, /* copy_page */ NULL, /* show_page */ _cairo_xlib_surface_set_clip_region, diff --git a/src/cairoint.h b/src/cairoint.h index 6b26e293..cfc850e8 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -634,6 +634,20 @@ struct _cairo_surface_backend { cairo_trapezoid_t *traps, int num_traps); + cairo_warn cairo_span_renderer_t * + (*create_span_renderer) (cairo_operator_t op, + const cairo_pattern_t *pattern, + void *dst, + cairo_antialias_t antialias, + const cairo_composite_rectangles_t *rects); + + cairo_warn cairo_bool_t + (*check_span_renderer) (cairo_operator_t op, + const cairo_pattern_t *pattern, + void *dst, + cairo_antialias_t antialias, + const cairo_composite_rectangles_t *rects); + cairo_warn cairo_int_status_t (*copy_page) (void *surface); @@ -1863,6 +1877,22 @@ _cairo_surface_composite_trapezoids (cairo_operator_t op, cairo_trapezoid_t *traps, int ntraps); +cairo_private cairo_span_renderer_t * +_cairo_surface_create_span_renderer ( + cairo_operator_t op, + const cairo_pattern_t *pattern, + cairo_surface_t *dst, + cairo_antialias_t antialias, + const cairo_composite_rectangles_t *rects); + +cairo_private cairo_bool_t +_cairo_surface_check_span_renderer ( + cairo_operator_t op, + const cairo_pattern_t *pattern, + cairo_surface_t *dst, + cairo_antialias_t antialias, + const cairo_composite_rectangles_t *rects); + cairo_private cairo_status_t _cairo_surface_acquire_source_image (cairo_surface_t *surface, cairo_image_surface_t **image_out, diff --git a/src/test-fallback-surface.c b/src/test-fallback-surface.c index d20e7c94..8acd91ee 100644 --- a/src/test-fallback-surface.c +++ b/src/test-fallback-surface.c @@ -214,6 +214,8 @@ static const cairo_surface_backend_t test_fallback_surface_backend = { NULL, /* composite */ NULL, /* fill_rectangles */ NULL, /* composite_trapezoids */ + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ NULL, /* copy_page */ NULL, /* show_page */ NULL, /* set_clip_region */ diff --git a/src/test-meta-surface.c b/src/test-meta-surface.c index 6ac1803e..42bf6b0c 100644 --- a/src/test-meta-surface.c +++ b/src/test-meta-surface.c @@ -313,6 +313,8 @@ static const cairo_surface_backend_t test_meta_surface_backend = { NULL, /* composite */ NULL, /* fill_rectangles */ NULL, /* composite_trapezoids */ + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ NULL, /* copy_page */ _test_meta_surface_show_page, NULL, /* set_clip_region */ diff --git a/src/test-paginated-surface.c b/src/test-paginated-surface.c index 58d5b0a7..4c566470 100644 --- a/src/test-paginated-surface.c +++ b/src/test-paginated-surface.c @@ -298,6 +298,8 @@ static const cairo_surface_backend_t test_paginated_surface_backend = { NULL, /* composite */ NULL, /* fill_rectangles */ NULL, /* composite_trapezoids */ + NULL, /* create_span_renderer */ + NULL, /* check_span_renderer */ NULL, /* copy_page */ NULL, /* show_page */ _test_paginated_surface_set_clip_region, |