diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cairo-paginated-surface.c | 14 | ||||
-rw-r--r-- | src/cairo-pdf-surface.c | 14 | ||||
-rw-r--r-- | src/cairo-ps-surface.c | 13 | ||||
-rw-r--r-- | src/cairo-surface-backend-private.h | 3 | ||||
-rw-r--r-- | src/cairo-surface.c | 30 | ||||
-rw-r--r-- | src/cairo-svg-surface.c | 18 | ||||
-rw-r--r-- | src/cairo-win32-printing-surface.c | 16 | ||||
-rw-r--r-- | src/cairo.h | 4 | ||||
-rw-r--r-- | src/cairoint.h | 1 |
9 files changed, 112 insertions, 1 deletions
diff --git a/src/cairo-paginated-surface.c b/src/cairo-paginated-surface.c index 0418e67b..e872e395 100644 --- a/src/cairo-paginated-surface.c +++ b/src/cairo-paginated-surface.c @@ -640,6 +640,17 @@ _cairo_paginated_surface_show_text_glyphs (void *abstract_surface, clip); } +static const char ** +_cairo_paginated_surface_get_supported_mime_types (void *abstract_surface) +{ + cairo_paginated_surface_t *surface = abstract_surface; + + if (surface->target->backend->get_supported_mime_types) + return surface->target->backend->get_supported_mime_types (surface->target); + + return NULL; +} + static cairo_surface_t * _cairo_paginated_surface_snapshot (void *abstract_other) { @@ -691,5 +702,6 @@ static const cairo_surface_backend_t cairo_paginated_surface_backend = { NULL, /* fill_stroke */ NULL, /* show_glyphs */ _cairo_paginated_surface_has_show_text_glyphs, - _cairo_paginated_surface_show_text_glyphs + _cairo_paginated_surface_show_text_glyphs, + _cairo_paginated_surface_get_supported_mime_types, }; diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c index 148e6ff7..cf8aab44 100644 --- a/src/cairo-pdf-surface.c +++ b/src/cairo-pdf-surface.c @@ -157,6 +157,14 @@ static const char * _cairo_pdf_version_strings[CAIRO_PDF_VERSION_LAST] = "PDF 1.5" }; +static const char *_cairo_pdf_supported_mime_types[] = +{ + CAIRO_MIME_TYPE_JPEG, + CAIRO_MIME_TYPE_JP2, + CAIRO_MIME_TYPE_UNIQUE_ID, + NULL +}; + typedef struct _cairo_pdf_object { long offset; } cairo_pdf_object_t; @@ -7240,6 +7248,11 @@ cleanup: return status; } +static const char ** +_cairo_pdf_surface_get_supported_mime_types (void *abstract_surface) +{ + return _cairo_pdf_supported_mime_types; +} static void _cairo_pdf_surface_set_paginated_mode (void *abstract_surface, @@ -7283,6 +7296,7 @@ static const cairo_surface_backend_t cairo_pdf_surface_backend = { NULL, /* show_glyphs */ _cairo_pdf_surface_has_show_text_glyphs, _cairo_pdf_surface_show_text_glyphs, + _cairo_pdf_surface_get_supported_mime_types, }; static const cairo_paginated_surface_backend_t diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c index 8fdc46f7..f71b079f 100644 --- a/src/cairo-ps-surface.c +++ b/src/cairo-ps-surface.c @@ -144,6 +144,12 @@ static const char * _cairo_ps_level_strings[CAIRO_PS_LEVEL_LAST] = "PS Level 3" }; +static const char *_cairo_ps_supported_mime_types[] = +{ + CAIRO_MIME_TYPE_JPEG, + NULL +}; + typedef struct _cairo_page_standard_media { const char *name; int width; @@ -4155,6 +4161,12 @@ cleanup_composite: return status; } +static const char ** +_cairo_ps_surface_get_supported_mime_types (void *abstract_surface) +{ + return _cairo_ps_supported_mime_types; +} + static void _cairo_ps_surface_set_paginated_mode (void *abstract_surface, cairo_paginated_mode_t paginated_mode) @@ -4304,6 +4316,7 @@ static const cairo_surface_backend_t cairo_ps_surface_backend = { NULL, /* show_glyphs */ _cairo_ps_surface_has_show_text_glyphs, _cairo_ps_surface_show_text_glyphs, + _cairo_ps_surface_get_supported_mime_types, }; static const cairo_paginated_surface_backend_t cairo_ps_surface_paginated_backend = { diff --git a/src/cairo-surface-backend-private.h b/src/cairo-surface-backend-private.h index 03468cc7..1f076e22 100644 --- a/src/cairo-surface-backend-private.h +++ b/src/cairo-surface-backend-private.h @@ -192,6 +192,9 @@ struct _cairo_surface_backend { cairo_text_cluster_flags_t cluster_flags, cairo_scaled_font_t *scaled_font, const cairo_clip_t *clip); + + const char ** + (*get_supported_mime_types) (void *surface); }; CAIRO_END_DECLS diff --git a/src/cairo-surface.c b/src/cairo-surface.c index 2607f299..99a0777e 100644 --- a/src/cairo-surface.c +++ b/src/cairo-surface.c @@ -1193,6 +1193,36 @@ cairo_surface_set_mime_data (cairo_surface_t *surface, } slim_hidden_def (cairo_surface_set_mime_data); +/** + * cairo_surface_supports_mime_type: + * @surface: a #cairo_surface_t + * @mime_type: the mime type + * + * Return whether @surface supports @mime_type. + * + * Since: 1.12 + **/ +cairo_bool_t +cairo_surface_supports_mime_type (cairo_surface_t *surface, + const char *mime_type) +{ + const char **types; + + if (surface->backend->get_supported_mime_types) { + types = surface->backend->get_supported_mime_types (surface); + if (types) { + while (*types) { + if (strcmp (*types, mime_type) == 0) + return TRUE; + types++; + } + } + } + + return FALSE; +} +slim_hidden_def (cairo_surface_supports_mime_type); + static void _cairo_mime_data_reference (const void *key, void *elt, void *closure) { diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c index eab50c88..c5a02c23 100644 --- a/src/cairo-svg-surface.c +++ b/src/cairo-svg-surface.c @@ -87,6 +87,14 @@ static const cairo_svg_version_t _cairo_svg_versions[] = #define CAIRO_SVG_VERSION_LAST ARRAY_LENGTH (_cairo_svg_versions) +static const char *_cairo_svg_supported_mime_types[] = +{ + CAIRO_MIME_TYPE_JPEG, + CAIRO_MIME_TYPE_PNG, + CAIRO_MIME_TYPE_URI, + NULL +}; + static void _cairo_svg_surface_emit_path (cairo_output_stream_t *output, const cairo_path_fixed_t *path, @@ -2577,6 +2585,13 @@ _cairo_svg_surface_get_font_options (void *abstract_surface, _cairo_font_options_set_round_glyph_positions (options, CAIRO_ROUND_GLYPH_POS_OFF); } + +static const char ** +_cairo_svg_surface_get_supported_mime_types (void *abstract_surface) +{ + return _cairo_svg_supported_mime_types; +} + static const cairo_surface_backend_t cairo_svg_surface_backend = { CAIRO_SURFACE_TYPE_SVG, _cairo_svg_surface_finish, @@ -2607,6 +2622,9 @@ static const cairo_surface_backend_t cairo_svg_surface_backend = { _cairo_svg_surface_fill, _cairo_svg_surface_fill_stroke, _cairo_svg_surface_show_glyphs, + NULL, /* has_show_text_glyphs */ + NULL, /* show_text_glyphs */ + _cairo_svg_surface_get_supported_mime_types, }; static cairo_status_t diff --git a/src/cairo-win32-printing-surface.c b/src/cairo-win32-printing-surface.c index 296e6265..931ae0f5 100644 --- a/src/cairo-win32-printing-surface.c +++ b/src/cairo-win32-printing-surface.c @@ -91,6 +91,13 @@ #define PELS_72DPI ((LONG)(72. / 0.0254)) +static const char *_cairo_win32_printing_supported_mime_types[] = +{ + CAIRO_MIME_TYPE_JPEG, + CAIRO_MIME_TYPE_PNG, + NULL +}; + static const cairo_surface_backend_t cairo_win32_printing_surface_backend; static const cairo_paginated_surface_backend_t cairo_win32_surface_paginated_backend; @@ -1655,6 +1662,12 @@ _cairo_win32_printing_surface_show_glyphs (void *abstract_surfac return status; } +static const char ** +_cairo_win32_printing_surface_get_supported_mime_types (void *abstract_surface) +{ + return _cairo_win32_printing_supported_mime_types; +} + static cairo_surface_t * _cairo_win32_printing_surface_create_similar (void *abstract_surface, cairo_content_t content, @@ -1887,6 +1900,9 @@ static const cairo_surface_backend_t cairo_win32_printing_surface_backend = { _cairo_win32_printing_surface_fill, NULL, /* fill/stroke */ _cairo_win32_printing_surface_show_glyphs, + NULL, /* has_show_text_glyphs */ + NULL, /* show_text_glyphs */ + _cairo_win32_printing_surface_get_supported_mime_types, }; static const cairo_paginated_surface_backend_t cairo_win32_surface_paginated_backend = { diff --git a/src/cairo.h b/src/cairo.h index d5f58618..a64a8a00 100644 --- a/src/cairo.h +++ b/src/cairo.h @@ -2370,6 +2370,10 @@ cairo_surface_set_mime_data (cairo_surface_t *surface, cairo_destroy_func_t destroy, void *closure); +cairo_public cairo_bool_t +cairo_surface_supports_mime_type (cairo_surface_t *surface, + const char *mime_type); + cairo_public void cairo_surface_get_font_options (cairo_surface_t *surface, cairo_font_options_t *options); diff --git a/src/cairoint.h b/src/cairoint.h index f08462c1..d3ad9037 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -1898,6 +1898,7 @@ slim_hidden_proto (cairo_surface_set_fallback_resolution); slim_hidden_proto (cairo_surface_set_mime_data); slim_hidden_proto (cairo_surface_show_page); slim_hidden_proto (cairo_surface_status); +slim_hidden_proto (cairo_surface_supports_mime_type); slim_hidden_proto (cairo_surface_unmap_image); slim_hidden_proto (cairo_text_cluster_allocate); slim_hidden_proto (cairo_text_cluster_free); |