mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-08 21:10:30 +01:00
api: add cairo_surface_supports_mime_type
to allow querying if a surface supports a particular mime type.
This commit is contained in:
parent
a7c9c75ffa
commit
0f40cdea1b
9 changed files with 112 additions and 1 deletions
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue