mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-07 21:28:02 +02:00
Merge branch 'get-type' into cairo
This commit is contained in:
commit
6fe93cbf5b
29 changed files with 546 additions and 96 deletions
|
|
@ -104,6 +104,7 @@ _cairo_atsui_font_face_scaled_font_create (void *abstract_face,
|
|||
}
|
||||
|
||||
static const cairo_font_face_backend_t _cairo_atsui_font_face_backend = {
|
||||
CAIRO_FONT_TYPE_ATSUI,
|
||||
_cairo_atsui_font_face_destroy,
|
||||
_cairo_atsui_font_face_scaled_font_create
|
||||
};
|
||||
|
|
@ -674,6 +675,7 @@ _cairo_atsui_font_old_show_glyphs (void *abstract_font,
|
|||
}
|
||||
|
||||
const cairo_scaled_font_backend_t cairo_atsui_scaled_font_backend = {
|
||||
CAIRO_FONT_TYPE_ATSUI,
|
||||
_cairo_atsui_font_create_toy,
|
||||
_cairo_atsui_font_fini,
|
||||
_cairo_atsui_font_scaled_glyph_init,
|
||||
|
|
|
|||
|
|
@ -662,6 +662,7 @@ _cairo_directfb_surface_scaled_glyph_fini (cairo_scaled_glyph_t *scaled_glyph,
|
|||
|
||||
|
||||
static const cairo_surface_backend_t cairo_directfb_surface_backend = {
|
||||
CAIRO_SURFACE_TYPE_DIRECTFB,
|
||||
_cairo_directfb_surface_create_similar,
|
||||
_cairo_directfb_surface_finish,
|
||||
_cairo_directfb_surface_acquire_source_image,
|
||||
|
|
|
|||
|
|
@ -130,6 +130,18 @@ cairo_font_face_destroy (cairo_font_face_t *font_face)
|
|||
free (font_face);
|
||||
}
|
||||
|
||||
/**
|
||||
* cairo_font_face_get_type:
|
||||
* @font_face: a #cairo_font_face_t
|
||||
*
|
||||
* Return value: The type of @font_face. See #cairo_font_type_t.
|
||||
**/
|
||||
cairo_font_type_t
|
||||
cairo_font_face_get_type (cairo_font_face_t *font_face)
|
||||
{
|
||||
return font_face->backend->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* cairo_font_face_status:
|
||||
* @font_face: a #cairo_font_face_t
|
||||
|
|
@ -409,6 +421,7 @@ _cairo_toy_font_face_scaled_font_create (void *abstract_font_face
|
|||
}
|
||||
|
||||
static const cairo_font_face_backend_t _cairo_toy_font_face_backend = {
|
||||
CAIRO_FONT_TYPE_TOY,
|
||||
_cairo_toy_font_face_destroy,
|
||||
_cairo_toy_font_face_scaled_font_create
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1901,6 +1901,7 @@ _cairo_ft_show_glyphs (void *abstract_font,
|
|||
}
|
||||
|
||||
const cairo_scaled_font_backend_t cairo_ft_scaled_font_backend = {
|
||||
CAIRO_FONT_TYPE_FT,
|
||||
_cairo_ft_scaled_font_create_toy,
|
||||
_cairo_ft_scaled_font_fini,
|
||||
_cairo_ft_scaled_glyph_init,
|
||||
|
|
@ -2004,6 +2005,7 @@ _cairo_ft_font_face_scaled_font_create (void *abstract_face,
|
|||
}
|
||||
|
||||
static const cairo_font_face_backend_t _cairo_ft_font_face_backend = {
|
||||
CAIRO_FONT_TYPE_FT,
|
||||
_cairo_ft_font_face_destroy,
|
||||
_cairo_ft_font_face_scaled_font_create
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2121,6 +2121,7 @@ _cairo_glitz_surface_flush (void *abstract_surface)
|
|||
}
|
||||
|
||||
static const cairo_surface_backend_t cairo_glitz_surface_backend = {
|
||||
CAIRO_SURFACE_TYPE_GLITZ,
|
||||
_cairo_glitz_surface_create_similar,
|
||||
_cairo_glitz_surface_finish,
|
||||
_cairo_glitz_surface_acquire_source_image,
|
||||
|
|
|
|||
|
|
@ -903,6 +903,7 @@ _cairo_surface_is_image (const cairo_surface_t *surface)
|
|||
}
|
||||
|
||||
const cairo_surface_backend_t cairo_image_surface_backend = {
|
||||
CAIRO_SURFACE_TYPE_IMAGE,
|
||||
_cairo_image_surface_create_similar,
|
||||
_cairo_image_surface_finish,
|
||||
_cairo_image_surface_acquire_source_image,
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ _init_pattern_with_snapshot (cairo_pattern_t *pattern,
|
|||
{
|
||||
_cairo_pattern_init_copy (pattern, other);
|
||||
|
||||
if (pattern->type == CAIRO_PATTERN_SURFACE) {
|
||||
if (pattern->type == CAIRO_PATTERN_TYPE_SURFACE) {
|
||||
cairo_surface_pattern_t *surface_pattern =
|
||||
(cairo_surface_pattern_t *) pattern;
|
||||
cairo_surface_t *surface = surface_pattern->surface;
|
||||
|
|
@ -557,6 +557,7 @@ _cairo_surface_is_meta (const cairo_surface_t *surface)
|
|||
}
|
||||
|
||||
static const cairo_surface_backend_t cairo_meta_surface_backend = {
|
||||
CAIRO_INTERNAL_SURFACE_TYPE_META,
|
||||
_cairo_meta_surface_create_similar,
|
||||
_cairo_meta_surface_finish,
|
||||
_cairo_meta_surface_acquire_source_image,
|
||||
|
|
|
|||
|
|
@ -97,6 +97,24 @@ const cairo_private cairo_surface_backend_t cairo_paginated_surface_backend;
|
|||
static cairo_int_status_t
|
||||
_cairo_paginated_surface_show_page (void *abstract_surface);
|
||||
|
||||
/* XXX: This would seem the natural thing to do here. But currently,
|
||||
* PDF and PS surfaces do not yet work as source surfaces. So instead,
|
||||
* we don't implement create_similar for the paginate_surface which
|
||||
* means that any create_similar() call on a paginated_surfacae will
|
||||
* result in a new image surface. */
|
||||
#if 0
|
||||
static cairo_surface_t *
|
||||
_cairo_paginated_surface_create_similar (void *abstract_surface,
|
||||
cairo_content_t content,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
cairo_paginated_surface_t *surface = abstract_surface;
|
||||
return cairo_surface_create_similar (surface->target, content,
|
||||
width, height);
|
||||
}
|
||||
#endif
|
||||
|
||||
cairo_surface_t *
|
||||
_cairo_paginated_surface_create (cairo_surface_t *target,
|
||||
cairo_content_t content,
|
||||
|
|
@ -111,6 +129,10 @@ _cairo_paginated_surface_create (cairo_surface_t *target,
|
|||
|
||||
_cairo_surface_init (&surface->base, &cairo_paginated_surface_backend);
|
||||
|
||||
/* Override surface->base.type with target's type so we don't leak
|
||||
* evidence of the paginated wrapper out to the user. */
|
||||
surface->base.type = cairo_surface_get_type (target);
|
||||
|
||||
surface->content = content;
|
||||
surface->width = width;
|
||||
surface->height = height;
|
||||
|
|
@ -381,7 +403,8 @@ _cairo_paginated_surface_snapshot (void *abstract_other)
|
|||
}
|
||||
|
||||
const cairo_surface_backend_t cairo_paginated_surface_backend = {
|
||||
NULL, /* create_similar */
|
||||
CAIRO_INTERNAL_SURFACE_TYPE_PAGINATED,
|
||||
NULL, /* create_similar --- see note for _cairo_paginated_surface_create_similar */
|
||||
_cairo_paginated_surface_finish,
|
||||
_cairo_paginated_surface_acquire_source_image,
|
||||
_cairo_paginated_surface_release_source_image,
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
#include "cairoint.h"
|
||||
|
||||
const cairo_solid_pattern_t cairo_pattern_nil = {
|
||||
{ CAIRO_PATTERN_SOLID, /* type */
|
||||
{ CAIRO_PATTERN_TYPE_SOLID, /* type */
|
||||
(unsigned int)-1, /* ref_count */
|
||||
CAIRO_STATUS_NO_MEMORY, /* status */
|
||||
{ 1., 0., 0., 1., 0., 0., }, /* matrix */
|
||||
|
|
@ -39,7 +39,7 @@ const cairo_solid_pattern_t cairo_pattern_nil = {
|
|||
};
|
||||
|
||||
static const cairo_solid_pattern_t cairo_pattern_nil_null_pointer = {
|
||||
{ CAIRO_PATTERN_SOLID, /* type */
|
||||
{ CAIRO_PATTERN_TYPE_SOLID, /* type */
|
||||
(unsigned int)-1, /* ref_count */
|
||||
CAIRO_STATUS_NULL_POINTER,/* status */
|
||||
{ 1., 0., 0., 1., 0., 0., }, /* matrix */
|
||||
|
|
@ -48,7 +48,7 @@ static const cairo_solid_pattern_t cairo_pattern_nil_null_pointer = {
|
|||
};
|
||||
|
||||
static const cairo_solid_pattern_t cairo_pattern_nil_file_not_found = {
|
||||
{ CAIRO_PATTERN_SOLID, /* type */
|
||||
{ CAIRO_PATTERN_TYPE_SOLID, /* type */
|
||||
(unsigned int)-1, /* ref_count */
|
||||
CAIRO_STATUS_FILE_NOT_FOUND, /* status */
|
||||
{ 1., 0., 0., 1., 0., 0., }, /* matrix */
|
||||
|
|
@ -57,7 +57,7 @@ static const cairo_solid_pattern_t cairo_pattern_nil_file_not_found = {
|
|||
};
|
||||
|
||||
static const cairo_solid_pattern_t cairo_pattern_nil_read_error = {
|
||||
{ CAIRO_PATTERN_SOLID, /* type */
|
||||
{ CAIRO_PATTERN_TYPE_SOLID, /* type */
|
||||
(unsigned int)-1, /* ref_count */
|
||||
CAIRO_STATUS_READ_ERROR, /* status */
|
||||
{ 1., 0., 0., 1., 0., 0., }, /* matrix */
|
||||
|
|
@ -117,7 +117,7 @@ _cairo_pattern_init (cairo_pattern_t *pattern, cairo_pattern_type_t type)
|
|||
pattern->ref_count = 1;
|
||||
pattern->status = CAIRO_STATUS_SUCCESS;
|
||||
|
||||
if (type == CAIRO_PATTERN_SURFACE)
|
||||
if (type == CAIRO_PATTERN_TYPE_SURFACE)
|
||||
pattern->extend = CAIRO_EXTEND_SURFACE_DEFAULT;
|
||||
else
|
||||
pattern->extend = CAIRO_EXTEND_GRADIENT_DEFAULT;
|
||||
|
|
@ -131,7 +131,7 @@ static void
|
|||
_cairo_gradient_pattern_init_copy (cairo_gradient_pattern_t *pattern,
|
||||
const cairo_gradient_pattern_t *other)
|
||||
{
|
||||
if (other->base.type == CAIRO_PATTERN_LINEAR)
|
||||
if (other->base.type == CAIRO_PATTERN_TYPE_LINEAR)
|
||||
{
|
||||
cairo_linear_pattern_t *dst = (cairo_linear_pattern_t *) pattern;
|
||||
cairo_linear_pattern_t *src = (cairo_linear_pattern_t *) other;
|
||||
|
|
@ -170,21 +170,21 @@ _cairo_pattern_init_copy (cairo_pattern_t *pattern,
|
|||
}
|
||||
|
||||
switch (other->type) {
|
||||
case CAIRO_PATTERN_SOLID: {
|
||||
case CAIRO_PATTERN_TYPE_SOLID: {
|
||||
cairo_solid_pattern_t *dst = (cairo_solid_pattern_t *) pattern;
|
||||
cairo_solid_pattern_t *src = (cairo_solid_pattern_t *) other;
|
||||
|
||||
*dst = *src;
|
||||
} break;
|
||||
case CAIRO_PATTERN_SURFACE: {
|
||||
case CAIRO_PATTERN_TYPE_SURFACE: {
|
||||
cairo_surface_pattern_t *dst = (cairo_surface_pattern_t *) pattern;
|
||||
cairo_surface_pattern_t *src = (cairo_surface_pattern_t *) other;
|
||||
|
||||
*dst = *src;
|
||||
cairo_surface_reference (dst->surface);
|
||||
} break;
|
||||
case CAIRO_PATTERN_LINEAR:
|
||||
case CAIRO_PATTERN_RADIAL: {
|
||||
case CAIRO_PATTERN_TYPE_LINEAR:
|
||||
case CAIRO_PATTERN_TYPE_RADIAL: {
|
||||
cairo_gradient_pattern_t *dst = (cairo_gradient_pattern_t *) pattern;
|
||||
cairo_gradient_pattern_t *src = (cairo_gradient_pattern_t *) other;
|
||||
|
||||
|
|
@ -199,16 +199,16 @@ void
|
|||
_cairo_pattern_fini (cairo_pattern_t *pattern)
|
||||
{
|
||||
switch (pattern->type) {
|
||||
case CAIRO_PATTERN_SOLID:
|
||||
case CAIRO_PATTERN_TYPE_SOLID:
|
||||
break;
|
||||
case CAIRO_PATTERN_SURFACE: {
|
||||
case CAIRO_PATTERN_TYPE_SURFACE: {
|
||||
cairo_surface_pattern_t *surface_pattern =
|
||||
(cairo_surface_pattern_t *) pattern;
|
||||
|
||||
cairo_surface_destroy (surface_pattern->surface);
|
||||
} break;
|
||||
case CAIRO_PATTERN_LINEAR:
|
||||
case CAIRO_PATTERN_RADIAL: {
|
||||
case CAIRO_PATTERN_TYPE_LINEAR:
|
||||
case CAIRO_PATTERN_TYPE_RADIAL: {
|
||||
cairo_gradient_pattern_t *gradient =
|
||||
(cairo_gradient_pattern_t *) pattern;
|
||||
|
||||
|
|
@ -222,7 +222,7 @@ void
|
|||
_cairo_pattern_init_solid (cairo_solid_pattern_t *pattern,
|
||||
const cairo_color_t *color)
|
||||
{
|
||||
_cairo_pattern_init (&pattern->base, CAIRO_PATTERN_SOLID);
|
||||
_cairo_pattern_init (&pattern->base, CAIRO_PATTERN_TYPE_SOLID);
|
||||
pattern->color = *color;
|
||||
}
|
||||
|
||||
|
|
@ -232,12 +232,12 @@ _cairo_pattern_init_for_surface (cairo_surface_pattern_t *pattern,
|
|||
{
|
||||
if (surface->status) {
|
||||
/* Force to solid to simplify the pattern_fini process. */
|
||||
pattern->base.type = CAIRO_PATTERN_SOLID;
|
||||
pattern->base.type = CAIRO_PATTERN_TYPE_SOLID;
|
||||
_cairo_pattern_set_error (&pattern->base, surface->status);
|
||||
return;
|
||||
}
|
||||
|
||||
_cairo_pattern_init (&pattern->base, CAIRO_PATTERN_SURFACE);
|
||||
_cairo_pattern_init (&pattern->base, CAIRO_PATTERN_TYPE_SURFACE);
|
||||
|
||||
pattern->surface = cairo_surface_reference (surface);
|
||||
}
|
||||
|
|
@ -256,7 +256,7 @@ void
|
|||
_cairo_pattern_init_linear (cairo_linear_pattern_t *pattern,
|
||||
double x0, double y0, double x1, double y1)
|
||||
{
|
||||
_cairo_pattern_init_gradient (&pattern->base, CAIRO_PATTERN_LINEAR);
|
||||
_cairo_pattern_init_gradient (&pattern->base, CAIRO_PATTERN_TYPE_LINEAR);
|
||||
|
||||
pattern->gradient.p1.x = _cairo_fixed_from_double (x0);
|
||||
pattern->gradient.p1.y = _cairo_fixed_from_double (y0);
|
||||
|
|
@ -269,7 +269,7 @@ _cairo_pattern_init_radial (cairo_radial_pattern_t *pattern,
|
|||
double cx0, double cy0, double radius0,
|
||||
double cx1, double cy1, double radius1)
|
||||
{
|
||||
_cairo_pattern_init_gradient (&pattern->base, CAIRO_PATTERN_RADIAL);
|
||||
_cairo_pattern_init_gradient (&pattern->base, CAIRO_PATTERN_TYPE_RADIAL);
|
||||
|
||||
pattern->gradient.inner.x = _cairo_fixed_from_double (cx0);
|
||||
pattern->gradient.inner.y = _cairo_fixed_from_double (cy0);
|
||||
|
|
@ -524,6 +524,18 @@ cairo_pattern_reference (cairo_pattern_t *pattern)
|
|||
return pattern;
|
||||
}
|
||||
|
||||
/**
|
||||
* cairo_pattern_get_type:
|
||||
* @pattern: a #cairo_pattern_t
|
||||
*
|
||||
* Return value: The type of @pattern. See #cairo_pattern_type_t.
|
||||
**/
|
||||
cairo_pattern_type_t
|
||||
cairo_pattern_get_type (cairo_pattern_t *pattern)
|
||||
{
|
||||
return pattern->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* cairo_pattern_status:
|
||||
* @pattern: a #cairo_pattern_t
|
||||
|
|
@ -641,8 +653,8 @@ cairo_pattern_add_color_stop_rgb (cairo_pattern_t *pattern,
|
|||
if (pattern->status)
|
||||
return;
|
||||
|
||||
if (pattern->type != CAIRO_PATTERN_LINEAR &&
|
||||
pattern->type != CAIRO_PATTERN_RADIAL)
|
||||
if (pattern->type != CAIRO_PATTERN_TYPE_LINEAR &&
|
||||
pattern->type != CAIRO_PATTERN_TYPE_RADIAL)
|
||||
{
|
||||
_cairo_pattern_set_error (pattern, CAIRO_STATUS_PATTERN_TYPE_MISMATCH);
|
||||
return;
|
||||
|
|
@ -689,8 +701,8 @@ cairo_pattern_add_color_stop_rgba (cairo_pattern_t *pattern,
|
|||
if (pattern->status)
|
||||
return;
|
||||
|
||||
if (pattern->type != CAIRO_PATTERN_LINEAR &&
|
||||
pattern->type != CAIRO_PATTERN_RADIAL)
|
||||
if (pattern->type != CAIRO_PATTERN_TYPE_LINEAR &&
|
||||
pattern->type != CAIRO_PATTERN_TYPE_RADIAL)
|
||||
{
|
||||
_cairo_pattern_set_error (pattern, CAIRO_STATUS_PATTERN_TYPE_MISMATCH);
|
||||
return;
|
||||
|
|
@ -894,7 +906,7 @@ _cairo_pattern_acquire_surface_for_gradient (cairo_gradient_pattern_t *pattern,
|
|||
cairo_status_t status;
|
||||
cairo_bool_t repeat = FALSE;
|
||||
|
||||
if (pattern->base.type == CAIRO_PATTERN_LINEAR)
|
||||
if (pattern->base.type == CAIRO_PATTERN_TYPE_LINEAR)
|
||||
{
|
||||
cairo_linear_pattern_t *linear = (cairo_linear_pattern_t *) pattern;
|
||||
|
||||
|
|
@ -936,7 +948,7 @@ _cairo_pattern_acquire_surface_for_gradient (cairo_gradient_pattern_t *pattern,
|
|||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (pattern->base.type == CAIRO_PATTERN_LINEAR) {
|
||||
if (pattern->base.type == CAIRO_PATTERN_TYPE_LINEAR) {
|
||||
cairo_bool_t is_horizontal;
|
||||
cairo_bool_t is_vertical;
|
||||
|
||||
|
|
@ -1055,7 +1067,7 @@ _cairo_pattern_is_opaque_solid (cairo_pattern_t *pattern)
|
|||
{
|
||||
cairo_solid_pattern_t *solid;
|
||||
|
||||
if (pattern->type != CAIRO_PATTERN_SOLID)
|
||||
if (pattern->type != CAIRO_PATTERN_TYPE_SOLID)
|
||||
return FALSE;
|
||||
|
||||
solid = (cairo_solid_pattern_t *) pattern;
|
||||
|
|
@ -1151,7 +1163,7 @@ _cairo_pattern_acquire_surface (cairo_pattern_t *pattern,
|
|||
}
|
||||
|
||||
switch (pattern->type) {
|
||||
case CAIRO_PATTERN_SOLID: {
|
||||
case CAIRO_PATTERN_TYPE_SOLID: {
|
||||
cairo_solid_pattern_t *src = (cairo_solid_pattern_t *) pattern;
|
||||
|
||||
status = _cairo_pattern_acquire_surface_for_solid (src, dst,
|
||||
|
|
@ -1159,8 +1171,8 @@ _cairo_pattern_acquire_surface (cairo_pattern_t *pattern,
|
|||
surface_out,
|
||||
attributes);
|
||||
} break;
|
||||
case CAIRO_PATTERN_LINEAR:
|
||||
case CAIRO_PATTERN_RADIAL: {
|
||||
case CAIRO_PATTERN_TYPE_LINEAR:
|
||||
case CAIRO_PATTERN_TYPE_RADIAL: {
|
||||
cairo_gradient_pattern_t *src = (cairo_gradient_pattern_t *) pattern;
|
||||
|
||||
/* fast path for gradients with less than 2 color stops */
|
||||
|
|
@ -1203,7 +1215,7 @@ _cairo_pattern_acquire_surface (cairo_pattern_t *pattern,
|
|||
attributes);
|
||||
}
|
||||
} break;
|
||||
case CAIRO_PATTERN_SURFACE: {
|
||||
case CAIRO_PATTERN_TYPE_SURFACE: {
|
||||
cairo_surface_pattern_t *src = (cairo_surface_pattern_t *) pattern;
|
||||
|
||||
status = _cairo_pattern_acquire_surface_for_surface (src, dst,
|
||||
|
|
@ -1235,7 +1247,7 @@ _cairo_pattern_release_surface (cairo_pattern_t *pattern,
|
|||
{
|
||||
cairo_surface_pattern_t *surface_pattern;
|
||||
|
||||
assert (pattern->type == CAIRO_PATTERN_SURFACE);
|
||||
assert (pattern->type == CAIRO_PATTERN_TYPE_SURFACE);
|
||||
surface_pattern = (cairo_surface_pattern_t *) pattern;
|
||||
|
||||
_cairo_surface_release_source_image (surface_pattern->surface,
|
||||
|
|
@ -1277,8 +1289,8 @@ _cairo_pattern_acquire_surfaces (cairo_pattern_t *src,
|
|||
/* XXX: This optimization assumes that there is no color
|
||||
* information in mask, so this will need to change when we
|
||||
* support RENDER-style 4-channel masks. */
|
||||
if (src->type == CAIRO_PATTERN_SOLID &&
|
||||
mask && mask->type == CAIRO_PATTERN_SOLID)
|
||||
if (src->type == CAIRO_PATTERN_TYPE_SOLID &&
|
||||
mask && mask->type == CAIRO_PATTERN_TYPE_SOLID)
|
||||
{
|
||||
cairo_color_t combined;
|
||||
cairo_solid_pattern_t *src_solid = (cairo_solid_pattern_t *) src;
|
||||
|
|
@ -1346,7 +1358,7 @@ _cairo_pattern_get_extents (cairo_pattern_t *pattern,
|
|||
cairo_rectangle_t *extents)
|
||||
{
|
||||
if (pattern->extend == CAIRO_EXTEND_NONE &&
|
||||
pattern->type == CAIRO_PATTERN_SURFACE)
|
||||
pattern->type == CAIRO_PATTERN_TYPE_SURFACE)
|
||||
{
|
||||
cairo_status_t status;
|
||||
cairo_rectangle_t surface_extents;
|
||||
|
|
|
|||
|
|
@ -841,7 +841,7 @@ _cairo_pdf_surface_composite (cairo_operator_t op,
|
|||
if (mask_pattern)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
if (src_pattern->type != CAIRO_PATTERN_SURFACE)
|
||||
if (src_pattern->type != CAIRO_PATTERN_TYPE_SURFACE)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
if (src->surface->backend == &cairo_pdf_surface_backend)
|
||||
|
|
@ -1237,16 +1237,16 @@ static cairo_status_t
|
|||
emit_pattern (cairo_pdf_surface_t *surface, cairo_pattern_t *pattern)
|
||||
{
|
||||
switch (pattern->type) {
|
||||
case CAIRO_PATTERN_SOLID:
|
||||
case CAIRO_PATTERN_TYPE_SOLID:
|
||||
return emit_solid_pattern (surface, (cairo_solid_pattern_t *) pattern);
|
||||
|
||||
case CAIRO_PATTERN_SURFACE:
|
||||
case CAIRO_PATTERN_TYPE_SURFACE:
|
||||
return emit_surface_pattern (surface, (cairo_surface_pattern_t *) pattern);
|
||||
|
||||
case CAIRO_PATTERN_LINEAR:
|
||||
case CAIRO_PATTERN_TYPE_LINEAR:
|
||||
return emit_linear_pattern (surface, (cairo_linear_pattern_t *) pattern);
|
||||
|
||||
case CAIRO_PATTERN_RADIAL:
|
||||
case CAIRO_PATTERN_TYPE_RADIAL:
|
||||
return emit_radial_pattern (surface, (cairo_radial_pattern_t *) pattern);
|
||||
}
|
||||
|
||||
|
|
@ -1657,6 +1657,7 @@ _cairo_pdf_surface_get_font_options (void *abstract_surface,
|
|||
}
|
||||
|
||||
static const cairo_surface_backend_t cairo_pdf_surface_backend = {
|
||||
CAIRO_SURFACE_TYPE_PDF,
|
||||
_cairo_pdf_surface_create_similar,
|
||||
_cairo_pdf_surface_finish,
|
||||
NULL, /* acquire_source_image */
|
||||
|
|
|
|||
|
|
@ -546,12 +546,12 @@ pattern_is_translucent (const cairo_pattern_t *abstract_pattern)
|
|||
|
||||
pattern = (cairo_pattern_union_t *) abstract_pattern;
|
||||
switch (pattern->base.type) {
|
||||
case CAIRO_PATTERN_SOLID:
|
||||
case CAIRO_PATTERN_TYPE_SOLID:
|
||||
return color_is_translucent (&pattern->solid.color);
|
||||
case CAIRO_PATTERN_SURFACE:
|
||||
case CAIRO_PATTERN_TYPE_SURFACE:
|
||||
return surface_is_translucent (pattern->surface.surface);
|
||||
case CAIRO_PATTERN_LINEAR:
|
||||
case CAIRO_PATTERN_RADIAL:
|
||||
case CAIRO_PATTERN_TYPE_LINEAR:
|
||||
case CAIRO_PATTERN_TYPE_RADIAL:
|
||||
return gradient_is_translucent (&pattern->gradient.base);
|
||||
}
|
||||
|
||||
|
|
@ -637,7 +637,7 @@ color_operation_needs_fallback (cairo_operator_t op,
|
|||
static cairo_bool_t
|
||||
pattern_type_supported (const cairo_pattern_t *pattern)
|
||||
{
|
||||
if (pattern->type == CAIRO_PATTERN_SOLID)
|
||||
if (pattern->type == CAIRO_PATTERN_TYPE_SOLID)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
|
@ -837,19 +837,19 @@ emit_pattern (cairo_ps_surface_t *surface, cairo_pattern_t *pattern)
|
|||
* different pattern. */
|
||||
|
||||
switch (pattern->type) {
|
||||
case CAIRO_PATTERN_SOLID:
|
||||
case CAIRO_PATTERN_TYPE_SOLID:
|
||||
emit_solid_pattern (surface, (cairo_solid_pattern_t *) pattern);
|
||||
break;
|
||||
|
||||
case CAIRO_PATTERN_SURFACE:
|
||||
case CAIRO_PATTERN_TYPE_SURFACE:
|
||||
emit_surface_pattern (surface, (cairo_surface_pattern_t *) pattern);
|
||||
break;
|
||||
|
||||
case CAIRO_PATTERN_LINEAR:
|
||||
case CAIRO_PATTERN_TYPE_LINEAR:
|
||||
emit_linear_pattern (surface, (cairo_linear_pattern_t *) pattern);
|
||||
break;
|
||||
|
||||
case CAIRO_PATTERN_RADIAL:
|
||||
case CAIRO_PATTERN_TYPE_RADIAL:
|
||||
emit_radial_pattern (surface, (cairo_radial_pattern_t *) pattern);
|
||||
break;
|
||||
}
|
||||
|
|
@ -890,12 +890,12 @@ _cairo_ps_surface_composite (cairo_operator_t op,
|
|||
|
||||
status = CAIRO_STATUS_SUCCESS;
|
||||
switch (src_pattern->type) {
|
||||
case CAIRO_PATTERN_SOLID:
|
||||
case CAIRO_PATTERN_TYPE_SOLID:
|
||||
_cairo_output_stream_printf (stream,
|
||||
"%% _cairo_ps_surface_composite: solid\n");
|
||||
goto bail;
|
||||
|
||||
case CAIRO_PATTERN_SURFACE:
|
||||
case CAIRO_PATTERN_TYPE_SURFACE:
|
||||
surface_pattern = (cairo_surface_pattern_t *) src_pattern;
|
||||
|
||||
if (src_pattern->extend != CAIRO_EXTEND_NONE) {
|
||||
|
|
@ -920,8 +920,8 @@ _cairo_ps_surface_composite (cairo_operator_t op,
|
|||
image, image_extra);
|
||||
break;
|
||||
|
||||
case CAIRO_PATTERN_LINEAR:
|
||||
case CAIRO_PATTERN_RADIAL:
|
||||
case CAIRO_PATTERN_TYPE_LINEAR:
|
||||
case CAIRO_PATTERN_TYPE_RADIAL:
|
||||
_cairo_output_stream_printf (stream,
|
||||
"%% _cairo_ps_surface_composite: gradient\n");
|
||||
goto bail;
|
||||
|
|
@ -1322,6 +1322,7 @@ _cairo_ps_surface_fill (void *abstract_surface,
|
|||
}
|
||||
|
||||
static const cairo_surface_backend_t cairo_ps_surface_backend = {
|
||||
CAIRO_SURFACE_TYPE_PS,
|
||||
NULL, /* create_similar */
|
||||
_cairo_ps_surface_finish,
|
||||
NULL, /* acquire_source_image */
|
||||
|
|
|
|||
|
|
@ -118,6 +118,18 @@ _cairo_scaled_font_set_error (cairo_scaled_font_t *scaled_font,
|
|||
_cairo_error (status);
|
||||
}
|
||||
|
||||
/**
|
||||
* cairo_scaled_font_get_type:
|
||||
* @scaled_font: a #cairo_scaled_font_t
|
||||
*
|
||||
* Return value: The type of @scaled_font. See #cairo_font_type_t.
|
||||
**/
|
||||
cairo_font_type_t
|
||||
cairo_scaled_font_get_type (cairo_scaled_font_t *scaled_font)
|
||||
{
|
||||
return scaled_font->backend->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* cairo_scaled_font_status:
|
||||
* @scaled_font: a #cairo_scaled_font_t
|
||||
|
|
|
|||
|
|
@ -576,7 +576,7 @@ _clip_and_composite_trapezoids (cairo_pattern_t *src,
|
|||
{
|
||||
cairo_surface_t *clip_surface = clip ? clip->surface : NULL;
|
||||
|
||||
if ((src->type == CAIRO_PATTERN_SOLID || op == CAIRO_OPERATOR_CLEAR) &&
|
||||
if ((src->type == CAIRO_PATTERN_TYPE_SOLID || op == CAIRO_OPERATOR_CLEAR) &&
|
||||
!clip_surface)
|
||||
{
|
||||
const cairo_color_t *color;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
const cairo_surface_t _cairo_surface_nil = {
|
||||
&cairo_image_surface_backend, /* backend */
|
||||
CAIRO_SURFACE_TYPE_IMAGE,
|
||||
-1, /* ref_count */
|
||||
CAIRO_STATUS_NO_MEMORY, /* status */
|
||||
FALSE, /* finished */
|
||||
|
|
@ -59,6 +60,7 @@ const cairo_surface_t _cairo_surface_nil = {
|
|||
|
||||
const cairo_surface_t _cairo_surface_nil_file_not_found = {
|
||||
&cairo_image_surface_backend, /* backend */
|
||||
CAIRO_SURFACE_TYPE_IMAGE,
|
||||
-1, /* ref_count */
|
||||
CAIRO_STATUS_FILE_NOT_FOUND, /* status */
|
||||
FALSE, /* finished */
|
||||
|
|
@ -75,6 +77,7 @@ const cairo_surface_t _cairo_surface_nil_file_not_found = {
|
|||
|
||||
const cairo_surface_t _cairo_surface_nil_read_error = {
|
||||
&cairo_image_surface_backend, /* backend */
|
||||
CAIRO_SURFACE_TYPE_IMAGE,
|
||||
-1, /* ref_count */
|
||||
CAIRO_STATUS_READ_ERROR, /* status */
|
||||
FALSE, /* finished */
|
||||
|
|
@ -118,6 +121,22 @@ _cairo_surface_set_error (cairo_surface_t *surface,
|
|||
_cairo_error (status);
|
||||
}
|
||||
|
||||
/**
|
||||
* cairo_surface_get_type:
|
||||
* @surface: a #cairo_surface_t
|
||||
*
|
||||
* Return value: The type of @surface. See #cairo_surface_type_t.
|
||||
**/
|
||||
cairo_surface_type_t
|
||||
cairo_surface_get_type (cairo_surface_t *surface)
|
||||
{
|
||||
/* We don't use surface->backend->type here so that some of the
|
||||
* special "wrapper" surfaces such as cairo_paginated_surface_t
|
||||
* can override surface->type with the type of the "child"
|
||||
* surface. */
|
||||
return surface->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* cairo_surface_status:
|
||||
* @surface: a #cairo_surface_t
|
||||
|
|
@ -141,6 +160,8 @@ _cairo_surface_init (cairo_surface_t *surface,
|
|||
const cairo_surface_backend_t *backend)
|
||||
{
|
||||
surface->backend = backend;
|
||||
|
||||
surface->type = backend->type;
|
||||
|
||||
surface->ref_count = 1;
|
||||
surface->status = CAIRO_STATUS_SUCCESS;
|
||||
|
|
@ -186,7 +207,8 @@ _cairo_surface_create_similar_scratch (cairo_surface_t *other,
|
|||
*
|
||||
* Create a new surface that is as compatible as possible with an
|
||||
* existing surface. The new surface will use the same backend as
|
||||
* @other unless that is not possible for some reason.
|
||||
* @other unless that is not possible for some reason. The type of the
|
||||
* returned surface may be examined with cairo_surface_get_type().
|
||||
*
|
||||
* Return value: a pointer to the newly allocated surface. The caller
|
||||
* owns the surface and should call cairo_surface_destroy when done
|
||||
|
|
|
|||
|
|
@ -1221,6 +1221,7 @@ _cairo_svg_surface_get_font_options (void *abstract_surface,
|
|||
|
||||
|
||||
static const cairo_surface_backend_t cairo_svg_surface_backend = {
|
||||
CAIRO_SURFACE_TYPE_SVG,
|
||||
_cairo_svg_surface_create_similar,
|
||||
_cairo_svg_surface_finish,
|
||||
NULL, /* acquire_source_image */
|
||||
|
|
|
|||
|
|
@ -1355,6 +1355,7 @@ CLEANUP_FONT:
|
|||
}
|
||||
|
||||
const cairo_scaled_font_backend_t cairo_win32_scaled_font_backend = {
|
||||
CAIRO_FONT_TYPE_WIN32,
|
||||
_cairo_win32_scaled_font_create_toy,
|
||||
_cairo_win32_scaled_font_fini,
|
||||
_cairo_win32_scaled_font_glyph_init,
|
||||
|
|
@ -1398,6 +1399,7 @@ _cairo_win32_font_face_scaled_font_create (void *abstract_face,
|
|||
}
|
||||
|
||||
static const cairo_font_face_backend_t _cairo_win32_font_face_backend = {
|
||||
CAIRO_FONT_TYPE_WIN32,
|
||||
_cairo_win32_font_face_destroy,
|
||||
_cairo_win32_font_face_scaled_font_create
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1108,6 +1108,7 @@ cairo_win32_surface_get_dc (cairo_surface_t *surface)
|
|||
}
|
||||
|
||||
static const cairo_surface_backend_t cairo_win32_surface_backend = {
|
||||
CAIRO_SURFACE_TYPE_WIN32,
|
||||
_cairo_win32_surface_create_similar,
|
||||
_cairo_win32_surface_finish,
|
||||
_cairo_win32_surface_acquire_source_image,
|
||||
|
|
|
|||
|
|
@ -1025,6 +1025,7 @@ _cairo_xcb_surface_get_extents (void *abstract_surface,
|
|||
}
|
||||
|
||||
static const cairo_surface_backend_t cairo_xcb_surface_backend = {
|
||||
CAIRO_SURFACE_TYPE_XCB,
|
||||
_cairo_xcb_surface_create_similar,
|
||||
_cairo_xcb_surface_finish,
|
||||
_cairo_xcb_surface_acquire_source_image,
|
||||
|
|
|
|||
|
|
@ -1047,7 +1047,7 @@ _categorize_composite_operation (cairo_xlib_surface_t *dst,
|
|||
if (!dst->buggy_repeat)
|
||||
return DO_RENDER;
|
||||
|
||||
if (src_pattern->type == CAIRO_PATTERN_SURFACE)
|
||||
if (src_pattern->type == CAIRO_PATTERN_TYPE_SURFACE)
|
||||
{
|
||||
cairo_surface_pattern_t *surface_pattern = (cairo_surface_pattern_t *)src_pattern;
|
||||
|
||||
|
|
@ -1675,6 +1675,7 @@ _cairo_xlib_surface_scaled_glyph_fini (cairo_scaled_glyph_t *scaled_glyph,
|
|||
cairo_scaled_font_t *scaled_font);
|
||||
|
||||
static const cairo_surface_backend_t cairo_xlib_surface_backend = {
|
||||
CAIRO_SURFACE_TYPE_XLIB,
|
||||
_cairo_xlib_surface_create_similar,
|
||||
_cairo_xlib_surface_finish,
|
||||
_cairo_xlib_surface_acquire_source_image,
|
||||
|
|
|
|||
135
src/cairo.h
135
src/cairo.h
|
|
@ -896,6 +896,47 @@ cairo_font_face_destroy (cairo_font_face_t *font_face);
|
|||
cairo_public cairo_status_t
|
||||
cairo_font_face_status (cairo_font_face_t *font_face);
|
||||
|
||||
/**
|
||||
* cairo_font_type_t
|
||||
* @CAIRO_SCALED_FONT_TYPE_FT: The font is of type ft
|
||||
* @CAIRO_SCALED_FONT_TYPE_WIN32: The font is of type win32
|
||||
* @CAIRO_SCALED_FONT_TYPE_ATSUI: The font is of type atsui
|
||||
*
|
||||
* @cairo_font_type_t is used to describe the type of a given font
|
||||
* face or scaled font. The font types are also known as "font
|
||||
* backends" within cairo.
|
||||
*
|
||||
* The type of a font face is determined by the function used to
|
||||
* create it, which will generally be of the form
|
||||
* cairo_<type>_font_face_create. The font face type can be queried
|
||||
* with cairo_font_face_get_type()
|
||||
*
|
||||
* The various cairo_font_face functions can be used with a font face
|
||||
* of any type.
|
||||
*
|
||||
* The type of a scaled font is determined by the type of the font
|
||||
* face passed to cairo_scaled_font_create. The scaled font type can
|
||||
* be queried with cairo_scaled_font_get_type()
|
||||
*
|
||||
* The various cairo_scaled_font functions can be used with scaled
|
||||
* fonts of any type, but some font backends also provide
|
||||
* type-specific functions that must only be called with a scaled font
|
||||
* of the appropriate type. These functions have names that begin with
|
||||
* cairo_<type>_scaled_font such as cairo_ft_scaled_font_lock_face.
|
||||
*
|
||||
* The behavior of calling a type-specific function with a scaled font
|
||||
* of the wrong type is undefined.
|
||||
*/
|
||||
typedef enum _cairo_font_type {
|
||||
CAIRO_FONT_TYPE_TOY,
|
||||
CAIRO_FONT_TYPE_FT,
|
||||
CAIRO_FONT_TYPE_WIN32,
|
||||
CAIRO_FONT_TYPE_ATSUI
|
||||
} cairo_font_type_t;
|
||||
|
||||
cairo_public cairo_font_type_t
|
||||
cairo_font_face_get_type (cairo_font_face_t *font_face);
|
||||
|
||||
cairo_public void *
|
||||
cairo_font_face_get_user_data (cairo_font_face_t *font_face,
|
||||
const cairo_user_data_key_t *key);
|
||||
|
|
@ -923,6 +964,9 @@ cairo_scaled_font_destroy (cairo_scaled_font_t *scaled_font);
|
|||
cairo_public cairo_status_t
|
||||
cairo_scaled_font_status (cairo_scaled_font_t *scaled_font);
|
||||
|
||||
cairo_public cairo_font_type_t
|
||||
cairo_scaled_font_get_type (cairo_scaled_font_t *scaled_font);
|
||||
|
||||
cairo_public void
|
||||
cairo_scaled_font_extents (cairo_scaled_font_t *scaled_font,
|
||||
cairo_font_extents_t *extents);
|
||||
|
|
@ -1147,14 +1191,64 @@ cairo_surface_create_similar (cairo_surface_t *other,
|
|||
cairo_public cairo_surface_t *
|
||||
cairo_surface_reference (cairo_surface_t *surface);
|
||||
|
||||
cairo_public void
|
||||
cairo_surface_finish (cairo_surface_t *surface);
|
||||
|
||||
cairo_public void
|
||||
cairo_surface_destroy (cairo_surface_t *surface);
|
||||
|
||||
cairo_public cairo_status_t
|
||||
cairo_surface_status (cairo_surface_t *surface);
|
||||
|
||||
cairo_public void
|
||||
cairo_surface_finish (cairo_surface_t *surface);
|
||||
/**
|
||||
* cairo_surface_type_t
|
||||
* @CAIRO_SURFACE_TYPE_IMAGE: The surface is of type image
|
||||
* @CAIRO_SURFACE_TYPE_PDF: The surface is of type pdf
|
||||
* @CAIRO_SURFACE_TYPE_PS: The surface is of type ps
|
||||
* @CAIRO_SURFACE_TYPE_XLIB: The surface is of type xlib
|
||||
* @CAIRO_SURFACE_TYPE_XCB: The surface is of type xcb
|
||||
* @CAIRO_SURFACE_TYPE_GLITZ: The surface is of type glitz
|
||||
* @CAIRO_SURFACE_TYPE_QUARTZ: The surface is of type quartz
|
||||
* @CAIRO_SURFACE_TYPE_WIN32: The surface is of type win32
|
||||
* @CAIRO_SURFACE_TYPE_BEOS: The surface is of type beos
|
||||
* @CAIRO_SURFACE_TYPE_DIRECTFB: The surface is of type directfb
|
||||
* @CAIRO_SURFACE_TYPE_SVG: The surface is of type svg
|
||||
*
|
||||
* @cairo_surface_type_t is used to describe the type of a given
|
||||
* surface. The surface types are also known as "backends" or "surface
|
||||
* backends" within cairo.
|
||||
*
|
||||
* The type of a surface is determined by the function used to create
|
||||
* it, which will generally be of the form cairo_<type>_surface_create,
|
||||
* (though see cairo_surface_create_similar as well).
|
||||
*
|
||||
* The surface type can be queried with cairo_surface_get_type()
|
||||
*
|
||||
* The various cairo_surface functions can be used with surfaces of
|
||||
* any type, but some backends also provide type-specific functions
|
||||
* that must only be called with a surface of the appropriate
|
||||
* type. These functions have names that begin with
|
||||
* cairo_<type>_surface such as cairo_image_surface_get_width().
|
||||
*
|
||||
* The behavior of calling a type-specific function with a surface of
|
||||
* the wrong type is undefined.
|
||||
*/
|
||||
typedef enum _cairo_surface_type {
|
||||
CAIRO_SURFACE_TYPE_IMAGE,
|
||||
CAIRO_SURFACE_TYPE_PDF,
|
||||
CAIRO_SURFACE_TYPE_PS,
|
||||
CAIRO_SURFACE_TYPE_XLIB,
|
||||
CAIRO_SURFACE_TYPE_XCB,
|
||||
CAIRO_SURFACE_TYPE_GLITZ,
|
||||
CAIRO_SURFACE_TYPE_QUARTZ,
|
||||
CAIRO_SURFACE_TYPE_WIN32,
|
||||
CAIRO_SURFACE_TYPE_BEOS,
|
||||
CAIRO_SURFACE_TYPE_DIRECTFB,
|
||||
CAIRO_SURFACE_TYPE_SVG
|
||||
} cairo_surface_type_t;
|
||||
|
||||
cairo_public cairo_surface_type_t
|
||||
cairo_surface_get_type (cairo_surface_t *surface);
|
||||
|
||||
#if CAIRO_HAS_PNG_FUNCTIONS
|
||||
|
||||
|
|
@ -1290,6 +1384,43 @@ cairo_pattern_destroy (cairo_pattern_t *pattern);
|
|||
cairo_public cairo_status_t
|
||||
cairo_pattern_status (cairo_pattern_t *pattern);
|
||||
|
||||
/**
|
||||
* cairo_pattern_type_t
|
||||
|
||||
* @CAIRO_PATTERN_TYPE_SOLID: The pattern is a solid (uniform)
|
||||
* color. It may be opaque or translucent.
|
||||
* @CAIRO_PATTERN_TYPE_SURFACE: The pattern is a based on a surface (an image).
|
||||
* @CAIRO_PATTERN_TYPE_LINEAR: The pattern is a linear gradient.
|
||||
* @CAIRO_PATTERN_TYPE_RADIAL: The pattern is a radial gradient.
|
||||
*
|
||||
* @cairo_pattern_type_t us used to describe the type of a given pattern.
|
||||
*
|
||||
* The type of a pattern is determined by the function used to create
|
||||
* it. The cairo_pattern_create_rgb() and cairo_pattern_create_rgba()
|
||||
* functions create SOLID patterns. The remaining
|
||||
* cairo_pattern_create functions map to pattern types in obvious
|
||||
* ways.
|
||||
*
|
||||
* The pattern type can be queried with cairo_pattern_get_type()
|
||||
*
|
||||
* Most cairo_pattern functions can be called with a pattern of any
|
||||
* type, (though trying to change the extend or filter for a solid
|
||||
* pattern will have no effect). A notable exception is
|
||||
* cairo_pattern_add_color_stop_rgb() and
|
||||
* cairo_pattern_add_color_stop_rgba() which must only be called with
|
||||
* gradient patterns (either LINEAR or RADIAL). Otherwise the pattern
|
||||
* will be shutdown and put into an error state.
|
||||
*/
|
||||
typedef enum _cairo_pattern_type {
|
||||
CAIRO_PATTERN_TYPE_SOLID,
|
||||
CAIRO_PATTERN_TYPE_SURFACE,
|
||||
CAIRO_PATTERN_TYPE_LINEAR,
|
||||
CAIRO_PATTERN_TYPE_RADIAL
|
||||
} cairo_pattern_type_t;
|
||||
|
||||
cairo_public cairo_pattern_type_t
|
||||
cairo_pattern_get_type (cairo_pattern_t *pattern);
|
||||
|
||||
cairo_public void
|
||||
cairo_pattern_add_color_stop_rgb (cairo_pattern_t *pattern,
|
||||
double offset,
|
||||
|
|
|
|||
|
|
@ -260,6 +260,14 @@ typedef enum cairo_int_status {
|
|||
CAIRO_INT_STATUS_CACHE_EMPTY
|
||||
} cairo_int_status_t;
|
||||
|
||||
typedef enum cairo_internal_surface_type {
|
||||
CAIRO_INTERNAL_SURFACE_TYPE_META = 0x1000,
|
||||
CAIRO_INTERNAL_SURFACE_TYPE_PAGINATED,
|
||||
CAIRO_INTERNAL_SURFACE_TYPE_TEST_META,
|
||||
CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
|
||||
CAIRO_INTERNAL_SURFACE_TYPE_TEST_PAGINATED
|
||||
} cairo_internal_surface_type_t;
|
||||
|
||||
typedef enum cairo_direction {
|
||||
CAIRO_DIRECTION_FORWARD,
|
||||
CAIRO_DIRECTION_REVERSE
|
||||
|
|
@ -468,6 +476,7 @@ struct _cairo_scaled_font {
|
|||
};
|
||||
|
||||
struct _cairo_font_face {
|
||||
/* hash_entry must be first */
|
||||
cairo_hash_entry_t hash_entry;
|
||||
cairo_status_t status;
|
||||
int ref_count;
|
||||
|
|
@ -512,6 +521,8 @@ typedef enum _cairo_scaled_glyph_info {
|
|||
} cairo_scaled_glyph_info_t;
|
||||
|
||||
struct _cairo_scaled_font_backend {
|
||||
cairo_font_type_t type;
|
||||
|
||||
cairo_status_t
|
||||
(*create_toy) (cairo_toy_font_face_t *toy_face,
|
||||
const cairo_matrix_t *font_matrix,
|
||||
|
|
@ -559,6 +570,8 @@ struct _cairo_scaled_font_backend {
|
|||
};
|
||||
|
||||
struct _cairo_font_face_backend {
|
||||
cairo_font_type_t type;
|
||||
|
||||
/* The destroy() function is allowed to resurrect the font face
|
||||
* by re-referencing. This is needed for the FreeType backend.
|
||||
*/
|
||||
|
|
@ -603,6 +616,8 @@ typedef struct _cairo_stroke_style {
|
|||
} cairo_stroke_style_t;
|
||||
|
||||
struct _cairo_surface_backend {
|
||||
cairo_surface_type_t type;
|
||||
|
||||
cairo_surface_t *
|
||||
(*create_similar) (void *surface,
|
||||
cairo_content_t content,
|
||||
|
|
@ -833,6 +848,11 @@ typedef struct _cairo_format_masks {
|
|||
struct _cairo_surface {
|
||||
const cairo_surface_backend_t *backend;
|
||||
|
||||
/* We allow surfaces to override the backend->type by shoving something
|
||||
* else into surface->type. This is for "wrapper" surfaces that want to
|
||||
* hide their internal type from the user-level API. */
|
||||
cairo_surface_type_t type;
|
||||
|
||||
unsigned int ref_count;
|
||||
cairo_status_t status;
|
||||
cairo_bool_t finished;
|
||||
|
|
@ -913,13 +933,6 @@ typedef enum {
|
|||
#define CAIRO_EXTEND_GRADIENT_DEFAULT CAIRO_EXTEND_PAD
|
||||
#define CAIRO_FILTER_DEFAULT CAIRO_FILTER_BEST
|
||||
|
||||
typedef enum {
|
||||
CAIRO_PATTERN_SOLID,
|
||||
CAIRO_PATTERN_SURFACE,
|
||||
CAIRO_PATTERN_LINEAR,
|
||||
CAIRO_PATTERN_RADIAL
|
||||
} cairo_pattern_type_t;
|
||||
|
||||
struct _cairo_pattern {
|
||||
cairo_pattern_type_t type;
|
||||
unsigned int ref_count;
|
||||
|
|
@ -2151,7 +2164,6 @@ cairo_private int
|
|||
_cairo_dtostr (char *buffer, size_t size, double d);
|
||||
|
||||
/* Avoid unnecessary PLT entries. */
|
||||
|
||||
slim_hidden_proto(cairo_get_current_point)
|
||||
slim_hidden_proto(cairo_fill_preserve)
|
||||
slim_hidden_proto(cairo_clip_preserve)
|
||||
|
|
|
|||
|
|
@ -175,6 +175,7 @@ _test_fallback_surface_get_extents (void *abstract_surface,
|
|||
}
|
||||
|
||||
const cairo_surface_backend_t test_fallback_surface_backend = {
|
||||
CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
|
||||
_test_fallback_surface_create_similar,
|
||||
_test_fallback_surface_finish,
|
||||
_test_fallback_surface_acquire_source_image,
|
||||
|
|
|
|||
|
|
@ -296,6 +296,7 @@ _test_meta_surface_snapshot (void *abstract_other)
|
|||
}
|
||||
|
||||
const cairo_surface_backend_t test_meta_surface_backend = {
|
||||
CAIRO_INTERNAL_SURFACE_TYPE_TEST_META,
|
||||
NULL, /* create_similar */
|
||||
_test_meta_surface_finish,
|
||||
_test_meta_surface_acquire_source_image,
|
||||
|
|
|
|||
2
test/.gitignore
vendored
2
test/.gitignore
vendored
|
|
@ -24,6 +24,7 @@ fill-and-stroke
|
|||
fill-rule
|
||||
filter-nearest-offset
|
||||
ft-font-create-for-ft-face
|
||||
font-face-get-type
|
||||
get-and-set
|
||||
gradient-alpha
|
||||
imagediff
|
||||
|
|
@ -43,6 +44,7 @@ operator-source
|
|||
paint
|
||||
paint-with-alpha
|
||||
path-data
|
||||
pattern-get-type
|
||||
pdf2png
|
||||
png-flatten
|
||||
svg2png
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ extend-reflect \
|
|||
fill-and-stroke \
|
||||
fill-rule \
|
||||
filter-nearest-offset \
|
||||
font-face-get-type \
|
||||
get-and-set \
|
||||
gradient-alpha \
|
||||
leaky-polygon \
|
||||
|
|
@ -35,6 +36,7 @@ operator-source \
|
|||
paint \
|
||||
paint-with-alpha \
|
||||
path-data \
|
||||
pattern-get-type \
|
||||
pixman-rotate \
|
||||
rectangle-rounding-error \
|
||||
scale-source-surface-paint \
|
||||
|
|
@ -299,6 +301,7 @@ dash_offset_negative_LDADD = $(LDADDS)
|
|||
extend_reflect_LDADD = $(LDADDS)
|
||||
fill_and_stroke_LDADD = $(LDADDS)
|
||||
fill_rule_LDADD = $(LDADDS)
|
||||
font_face_get_type_LDADD = $(LDADDS)
|
||||
filter_nearest_offset_LDADD = $(LDADDS)
|
||||
ft_font_create_for_ft_face_LDADD = $(LDADDS)
|
||||
get_and_set_LDADD = $(LDADDS)
|
||||
|
|
@ -317,6 +320,7 @@ operator_source_LDADD = $(LDADDS)
|
|||
paint_LDADD = $(LDADDS)
|
||||
paint_with_alpha_LDADD = $(LDADDS)
|
||||
path_data_LDADD = $(LDADDS)
|
||||
pattern_get_type_LDADD = $(LDADDS)
|
||||
svg_surface_LDADD = $(LDADDS)
|
||||
svg_clip_LDADD = $(LDADDS)
|
||||
pixman_rotate_LDADD = $(LDADDS)
|
||||
|
|
|
|||
|
|
@ -47,6 +47,20 @@
|
|||
#include "write-png.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* This is copied from cairoint.h. That makes it painful to keep in
|
||||
* sync, but the slim stuff makes cairoint.h "hard" to include when
|
||||
* not actually building the cairo library itself. Fortunately, since
|
||||
* we're checking all these values, we do have a safeguard for keeping
|
||||
* them in sync.
|
||||
*/
|
||||
typedef enum cairo_internal_surface_type {
|
||||
CAIRO_INTERNAL_SURFACE_TYPE_META = 0x1000,
|
||||
CAIRO_INTERNAL_SURFACE_TYPE_PAGINATED,
|
||||
CAIRO_INTERNAL_SURFACE_TYPE_TEST_META,
|
||||
CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
|
||||
CAIRO_INTERNAL_SURFACE_TYPE_TEST_PAGINATED
|
||||
} cairo_internal_surface_type_t;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define vsnprintf _vsnprintf
|
||||
#define access _access
|
||||
|
|
@ -163,6 +177,7 @@ typedef void
|
|||
typedef struct _cairo_test_target
|
||||
{
|
||||
const char *name;
|
||||
cairo_surface_type_t expected_type;
|
||||
cairo_content_t content;
|
||||
cairo_test_create_target_surface_t create_target_surface;
|
||||
cairo_test_write_to_png_t write_to_png;
|
||||
|
|
@ -1387,6 +1402,13 @@ cairo_test_for_target (cairo_test_t *test,
|
|||
goto UNWIND_STRINGS;
|
||||
}
|
||||
|
||||
if (cairo_surface_get_type (surface) != target->expected_type) {
|
||||
cairo_test_log ("Error: Created surface is of type %d (expected %d)\n",
|
||||
cairo_surface_get_type (surface), target->expected_type);
|
||||
ret = CAIRO_TEST_FAILURE;
|
||||
goto UNWIND_SURFACE;
|
||||
}
|
||||
|
||||
cr = cairo_create (surface);
|
||||
|
||||
/* Clear to transparent (or black) depending on whether the target
|
||||
|
|
@ -1436,6 +1458,7 @@ cairo_test_for_target (cairo_test_t *test,
|
|||
|
||||
UNWIND_CAIRO:
|
||||
cairo_destroy (cr);
|
||||
UNWIND_SURFACE:
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
cairo_debug_reset_static_data ();
|
||||
|
|
@ -1461,102 +1484,128 @@ cairo_test_expecting (cairo_test_t *test, cairo_test_draw_function_t draw,
|
|||
cairo_test_target_t **targets_to_test;
|
||||
cairo_test_target_t targets[] =
|
||||
{
|
||||
{ "image", CAIRO_CONTENT_COLOR_ALPHA,
|
||||
{ "image", CAIRO_SURFACE_TYPE_IMAGE, CAIRO_CONTENT_COLOR_ALPHA,
|
||||
create_image_surface, cairo_surface_write_to_png, NULL},
|
||||
{ "image", CAIRO_CONTENT_COLOR,
|
||||
{ "image", CAIRO_SURFACE_TYPE_IMAGE, CAIRO_CONTENT_COLOR,
|
||||
create_image_surface, cairo_surface_write_to_png, NULL},
|
||||
#ifdef CAIRO_HAS_TEST_SURFACES
|
||||
{ "test-fallback", CAIRO_CONTENT_COLOR_ALPHA,
|
||||
{ "test-fallback", CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
|
||||
CAIRO_CONTENT_COLOR_ALPHA,
|
||||
create_test_fallback_surface, cairo_surface_write_to_png, NULL },
|
||||
{ "test-fallback", CAIRO_CONTENT_COLOR,
|
||||
{ "test-fallback", CAIRO_INTERNAL_SURFACE_TYPE_TEST_FALLBACK,
|
||||
CAIRO_CONTENT_COLOR,
|
||||
create_test_fallback_surface, cairo_surface_write_to_png, NULL },
|
||||
{ "test-meta", CAIRO_CONTENT_COLOR_ALPHA,
|
||||
{ "test-meta", CAIRO_INTERNAL_SURFACE_TYPE_TEST_META,
|
||||
CAIRO_CONTENT_COLOR_ALPHA,
|
||||
create_test_meta_surface, cairo_surface_write_to_png, NULL },
|
||||
{ "test-meta", CAIRO_CONTENT_COLOR,
|
||||
{ "test-meta", CAIRO_INTERNAL_SURFACE_TYPE_TEST_META,
|
||||
CAIRO_CONTENT_COLOR,
|
||||
create_test_meta_surface, cairo_surface_write_to_png, NULL },
|
||||
{ "test-paginated", CAIRO_CONTENT_COLOR_ALPHA,
|
||||
{ "test-paginated", CAIRO_SURFACE_TYPE_IMAGE,
|
||||
CAIRO_CONTENT_COLOR_ALPHA,
|
||||
create_test_paginated_surface,
|
||||
test_paginated_write_to_png,
|
||||
cleanup_test_paginated },
|
||||
{ "test-paginated", CAIRO_CONTENT_COLOR,
|
||||
{ "test-paginated", CAIRO_SURFACE_TYPE_IMAGE,
|
||||
CAIRO_CONTENT_COLOR,
|
||||
create_test_paginated_surface,
|
||||
test_paginated_write_to_png,
|
||||
cleanup_test_paginated },
|
||||
#endif
|
||||
#ifdef CAIRO_HAS_GLITZ_SURFACE
|
||||
#if CAIRO_CAN_TEST_GLITZ_GLX_SURFACE
|
||||
{ "glitz-glx", CAIRO_CONTENT_COLOR_ALPHA,
|
||||
{ "glitz-glx", CAIRO_SURFACE_TYPE_GLITZ,CAIRO_CONTENT_COLOR_ALPHA,
|
||||
create_cairo_glitz_glx_surface, cairo_surface_write_to_png,
|
||||
cleanup_cairo_glitz_glx },
|
||||
{ "glitz-glx", CAIRO_CONTENT_COLOR,
|
||||
{ "glitz-glx", CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR,
|
||||
create_cairo_glitz_glx_surface, cairo_surface_write_to_png,
|
||||
cleanup_cairo_glitz_glx },
|
||||
#endif
|
||||
#if CAIRO_CAN_TEST_GLITZ_AGL_SURFACE
|
||||
{ "glitz-agl", CAIRO_CONTENT_COLOR_ALPHA,
|
||||
{ "glitz-agl", CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR_ALPHA,
|
||||
create_cairo_glitz_agl_surface, cairo_surface_write_to_png,
|
||||
cleanup_cairo_glitz_agl },
|
||||
{ "glitz-agl", CAIRO_CONTENT_COLOR,
|
||||
{ "glitz-agl", CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR,
|
||||
create_cairo_glitz_agl_surface, cairo_surface_write_to_png,
|
||||
cleanup_cairo_glitz_agl },
|
||||
#endif
|
||||
#if CAIRO_CAN_TEST_GLITZ_WGL_SURFACE
|
||||
{ "glitz-wgl", CAIRO_CONTENT_COLOR_ALPHA,
|
||||
{ "glitz-wgl", CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR_ALPHA,
|
||||
create_cairo_glitz_wgl_surface, cairo_surface_write_to_png,
|
||||
cleanup_cairo_glitz_wgl },
|
||||
{ "glitz-wgl", CAIRO_CONTENT_COLOR,
|
||||
{ "glitz-wgl", CAIRO_SURFACE_TYPE_GLITZ, CAIRO_CONTENT_COLOR,
|
||||
create_cairo_glitz_wgl_surface, cairo_surface_write_to_png,
|
||||
cleanup_cairo_glitz_wgl },
|
||||
#endif
|
||||
#endif /* CAIRO_HAS_GLITZ_SURFACE */
|
||||
#if 0 && CAIRO_HAS_QUARTZ_SURFACE
|
||||
{ "quartz", CAIRO_CONTENT_COLOR,
|
||||
{ "quartz", CAIRO_SURFACE_TYPE_QUARTZ, CAIRO_CONTENT_COLOR,
|
||||
create_quartz_surface, cairo_surface_write_to_png,
|
||||
cleanup_quartz },
|
||||
#endif
|
||||
#if CAIRO_HAS_WIN32_SURFACE
|
||||
{ "win32", CAIRO_CONTENT_COLOR,
|
||||
{ "win32", CAIRO_SURFACE_TYPE_WIN32, CAIRO_CONTENT_COLOR,
|
||||
create_win32_surface, cairo_surface_write_to_png, cleanup_win32 },
|
||||
#endif
|
||||
#if CAIRO_HAS_XCB_SURFACE
|
||||
{ "xcb", CAIRO_CONTENT_COLOR_ALPHA,
|
||||
{ "xcb", CAIRO_SURFACE_TYPE_XCB, CAIRO_CONTENT_COLOR_ALPHA,
|
||||
create_xcb_surface, cairo_surface_write_to_png, cleanup_xcb},
|
||||
#endif
|
||||
#if CAIRO_HAS_XLIB_SURFACE
|
||||
{ "xlib", CAIRO_CONTENT_COLOR_ALPHA,
|
||||
{ "xlib", CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR_ALPHA,
|
||||
create_xlib_surface, cairo_surface_write_to_png, cleanup_xlib},
|
||||
{ "xlib", CAIRO_CONTENT_COLOR,
|
||||
{ "xlib", CAIRO_SURFACE_TYPE_XLIB, CAIRO_CONTENT_COLOR,
|
||||
create_xlib_surface, cairo_surface_write_to_png, cleanup_xlib},
|
||||
#endif
|
||||
#if CAIRO_HAS_PS_SURFACE
|
||||
{ "ps", CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED,
|
||||
{ "ps", CAIRO_SURFACE_TYPE_PS,
|
||||
CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED,
|
||||
create_ps_surface, ps_surface_write_to_png, cleanup_ps },
|
||||
{ "ps", CAIRO_CONTENT_COLOR,
|
||||
|
||||
/* XXX: We expect type image here only due to a limitation in
|
||||
* the current PS/meta-surface code. A PS surface is
|
||||
* "naturally" COLOR_ALPHA, so the COLOR-only variant goes
|
||||
* through create_similar in create_ps_surface which results
|
||||
* in the similar surface being used as a source. We do not yet
|
||||
* have source support for PS/meta-surfaces, so the
|
||||
* create_similar path for all paginated surfaces currently
|
||||
* returns an image surface.*/
|
||||
{ "ps", CAIRO_SURFACE_TYPE_IMAGE, CAIRO_CONTENT_COLOR,
|
||||
create_ps_surface, ps_surface_write_to_png, cleanup_ps },
|
||||
#endif
|
||||
#if CAIRO_HAS_PDF_SURFACE && CAIRO_CAN_TEST_PDF_SURFACE
|
||||
{ "pdf", CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED,
|
||||
{ "pdf", CAIRO_SURFACE_TYPE_PDF,
|
||||
CAIRO_TEST_CONTENT_COLOR_ALPHA_FLATTENED,
|
||||
create_pdf_surface, pdf_surface_write_to_png, cleanup_pdf },
|
||||
{ "pdf", CAIRO_CONTENT_COLOR,
|
||||
|
||||
/* XXX: We expect type image here only due to a limitation in
|
||||
* the current PDF/meta-surface code. A PDF surface is
|
||||
* "naturally" COLOR_ALPHA, so the COLOR-only variant goes
|
||||
* through create_similar in create_pdf_surface which results
|
||||
* in the similar surface being used as a source. We do not yet
|
||||
* have source support for PDF/meta-surfaces, so the
|
||||
* create_similar path for all paginated surfaces currently
|
||||
* returns an image surface.*/
|
||||
{ "pdf", CAIRO_SURFACE_TYPE_IMAGE, CAIRO_CONTENT_COLOR,
|
||||
create_pdf_surface, pdf_surface_write_to_png, cleanup_pdf },
|
||||
#endif
|
||||
#if CAIRO_HAS_SVG_SURFACE && CAIRO_CAN_TEST_SVG_SURFACE
|
||||
{ "svg", CAIRO_CONTENT_COLOR_ALPHA,
|
||||
{ "svg", CAIRO_SURFACE_TYPE_SVG, CAIRO_CONTENT_COLOR_ALPHA,
|
||||
create_svg_surface, svg_surface_write_to_png, cleanup_svg },
|
||||
#endif
|
||||
#if CAIRO_HAS_BEOS_SURFACE
|
||||
{ "beos", CAIRO_CONTENT_COLOR,
|
||||
{ "beos", CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR,
|
||||
create_beos_surface, cairo_surface_write_to_png, cleanup_beos},
|
||||
{ "beos_bitmap", CAIRO_CONTENT_COLOR,
|
||||
{ "beos_bitmap", CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR,
|
||||
create_beos_bitmap_surface, cairo_surface_write_to_png, cleanup_beos_bitmap},
|
||||
{ "beos_bitmap", CAIRO_CONTENT_COLOR_ALPHA,
|
||||
{ "beos_bitmap", CAIRO_SURFACE_TYPE_BEOS, CAIRO_CONTENT_COLOR_ALPHA,
|
||||
create_beos_bitmap_surface, cairo_surface_write_to_png, cleanup_beos_bitmap},
|
||||
#endif
|
||||
|
||||
#if CAIRO_HAS_DIRECTFB_SURFACE
|
||||
{ "directfb", CAIRO_CONTENT_COLOR,
|
||||
{ "directfb", CAIRO_SURFACE_TYPE_DIRECTFB, CAIRO_CONTENT_COLOR,
|
||||
create_directfb_surface, cairo_surface_write_to_png, cleanup_directfb},
|
||||
{ "directfb_bitmap", CAIRO_CONTENT_COLOR_ALPHA,
|
||||
{ "directfb_bitmap", CAIRO_SURFACE_TYPE_DIRECTFB, CAIRO_CONTENT_COLOR_ALPHA,
|
||||
create_directfb_bitmap_surface, cairo_surface_write_to_png,cleanup_directfb},
|
||||
#endif
|
||||
};
|
||||
|
|
|
|||
64
test/font-face-get-type.c
Normal file
64
test/font-face-get-type.c
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright © 2006 Red Hat, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the name of
|
||||
* Red Hat, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior
|
||||
* permission. Red Hat, Inc. makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
||||
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: Carl D. Worth <cworth@cworth.org>
|
||||
*/
|
||||
|
||||
#include "cairo-test.h"
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
cairo_font_face_t *font_face;
|
||||
|
||||
cairo_test_init ("font-face-get-type");
|
||||
|
||||
cairo_test_log ("Creating cairo context and obtaining a font face\n");
|
||||
|
||||
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
|
||||
cr = cairo_create (surface);
|
||||
|
||||
cairo_select_font_face (cr, "Bitstream Vera Sans",
|
||||
CAIRO_FONT_SLANT_NORMAL,
|
||||
CAIRO_FONT_WEIGHT_NORMAL);
|
||||
|
||||
font_face = cairo_get_font_face (cr);
|
||||
|
||||
cairo_test_log ("Testing return value of cairo_font_face_get_type\n");
|
||||
|
||||
if (cairo_font_face_get_type (font_face) != CAIRO_FONT_TYPE_TOY) {
|
||||
cairo_test_log ("Unexpected value %d from cairo_font_face_get_type (expected %d)\n",
|
||||
cairo_font_face_get_type (font_face), CAIRO_FONT_TYPE_TOY);
|
||||
return CAIRO_TEST_FAILURE;
|
||||
}
|
||||
|
||||
cairo_destroy (cr);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
return CAIRO_TEST_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -64,6 +64,13 @@ draw (cairo_t *cr, int width, int height)
|
|||
|
||||
font_face = cairo_ft_font_face_create_for_pattern (resolved);
|
||||
|
||||
if (cairo_font_face_get_type (font_face) != CAIRO_FONT_TYPE_FT) {
|
||||
cairo_test_log ("Unexpected value from cairo_font_face_get_type: %d (expected %d)\n",
|
||||
cairo_font_face_get_type (font_face), CAIRO_FONT_TYPE_FT);
|
||||
cairo_font_face_destroy (font_face);
|
||||
return CAIRO_TEST_FAILURE;
|
||||
}
|
||||
|
||||
cairo_matrix_init_identity (&font_matrix);
|
||||
|
||||
cairo_get_matrix (cr, &ctm);
|
||||
|
|
@ -82,6 +89,13 @@ draw (cairo_t *cr, int width, int height)
|
|||
FcPatternDestroy (pattern);
|
||||
FcPatternDestroy (resolved);
|
||||
|
||||
if (cairo_scaled_font_get_type (scaled_font) != CAIRO_FONT_TYPE_FT) {
|
||||
cairo_test_log ("Unexpected value from cairo_scaled_font_get_type: %d (expected %d)\n",
|
||||
cairo_scaled_font_get_type (scaled_font), CAIRO_FONT_TYPE_FT);
|
||||
cairo_scaled_font_destroy (scaled_font);
|
||||
return CAIRO_TEST_FAILURE;
|
||||
}
|
||||
|
||||
if (!ft_face) {
|
||||
cairo_test_log ("Failed to get an ft_face with cairo_ft_scaled_font_lock_face\n");
|
||||
cairo_scaled_font_destroy (scaled_font);
|
||||
|
|
|
|||
74
test/pattern-get-type.c
Normal file
74
test/pattern-get-type.c
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Copyright © 2006 Red Hat, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software
|
||||
* and its documentation for any purpose is hereby granted without
|
||||
* fee, provided that the above copyright notice appear in all copies
|
||||
* and that both that copyright notice and this permission notice
|
||||
* appear in supporting documentation, and that the name of
|
||||
* Red Hat, Inc. not be used in advertising or publicity pertaining to
|
||||
* distribution of the software without specific, written prior
|
||||
* permission. Red Hat, Inc. makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as
|
||||
* is" without express or implied warranty.
|
||||
*
|
||||
* RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
||||
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
|
||||
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Author: Carl D. Worth <cworth@cworth.org>
|
||||
*/
|
||||
|
||||
#include "cairo-test.h"
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
cairo_pattern_t *solid_rgb, *solid_rgba, *surface_pattern, *linear, *radial;
|
||||
|
||||
cairo_test_init ("pattern-get-type");
|
||||
|
||||
cairo_test_log ("Creating patterns of all types\n");
|
||||
|
||||
solid_rgb = cairo_pattern_create_rgb (0.0, 0.1, 0.2);
|
||||
solid_rgba = cairo_pattern_create_rgba (0.3, 0.4, 0.5, 0.6);
|
||||
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
|
||||
1, 1);
|
||||
surface_pattern = cairo_pattern_create_for_surface (surface);
|
||||
linear = cairo_pattern_create_linear (0.0, 0.0, 10.0, 10.0);
|
||||
radial = cairo_pattern_create_radial (10.0, 10.0, 0.1,
|
||||
10.0, 10.0, 1.0);
|
||||
|
||||
cairo_test_log ("Verifying return values of cairo_pattern_get_type\n");
|
||||
|
||||
if (cairo_pattern_get_type (solid_rgb) != CAIRO_PATTERN_TYPE_SOLID)
|
||||
return CAIRO_TEST_FAILURE;
|
||||
|
||||
if (cairo_pattern_get_type (solid_rgba) != CAIRO_PATTERN_TYPE_SOLID)
|
||||
return CAIRO_TEST_FAILURE;
|
||||
|
||||
if (cairo_pattern_get_type (surface_pattern) != CAIRO_PATTERN_TYPE_SURFACE)
|
||||
return CAIRO_TEST_FAILURE;
|
||||
|
||||
if (cairo_pattern_get_type (linear) != CAIRO_PATTERN_TYPE_LINEAR)
|
||||
return CAIRO_TEST_FAILURE;
|
||||
|
||||
if (cairo_pattern_get_type (radial) != CAIRO_PATTERN_TYPE_RADIAL)
|
||||
return CAIRO_TEST_FAILURE;
|
||||
|
||||
cairo_test_log ("Cleaning up\n");
|
||||
|
||||
cairo_pattern_destroy (solid_rgb);
|
||||
cairo_pattern_destroy (solid_rgba);
|
||||
cairo_pattern_destroy (surface_pattern);
|
||||
cairo_surface_destroy (surface);
|
||||
cairo_pattern_destroy (linear);
|
||||
cairo_pattern_destroy (radial);
|
||||
|
||||
return CAIRO_TEST_SUCCESS;
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue