test-null-surface.c [plain text]
#include "cairoint.h"
#include "test-null-surface.h"
#include "cairo-error-private.h"
slim_hidden_proto (_cairo_test_null_surface_create);
static cairo_int_status_t
_return_success (void)
{
return CAIRO_STATUS_SUCCESS;
}
typedef cairo_int_status_t
(*_paint_func) (void *surface,
cairo_operator_t op,
const cairo_pattern_t *source,
cairo_clip_t *clip);
typedef cairo_int_status_t
(*_mask_func) (void *surface,
cairo_operator_t op,
const cairo_pattern_t *source,
const cairo_pattern_t *mask,
cairo_clip_t *clip);
typedef cairo_int_status_t
(*_stroke_func) (void *surface,
cairo_operator_t op,
const cairo_pattern_t *source,
cairo_path_fixed_t *path,
const cairo_stroke_style_t *style,
const cairo_matrix_t *ctm,
const cairo_matrix_t *ctm_inverse,
double tolerance,
cairo_antialias_t antialias,
cairo_clip_t *clip);
typedef cairo_int_status_t
(*_fill_func) (void *surface,
cairo_operator_t op,
const cairo_pattern_t *source,
cairo_path_fixed_t *path,
cairo_fill_rule_t fill_rule,
double tolerance,
cairo_antialias_t antialias,
cairo_clip_t *clip);
typedef cairo_int_status_t
(*_show_glyphs_func) (void *surface,
cairo_operator_t op,
const cairo_pattern_t *source,
cairo_glyph_t *glyphs,
int num_glyphs,
cairo_scaled_font_t *scaled_font,
cairo_clip_t *clip,
int *remaining_glyphs);
typedef cairo_int_status_t
(*_show_text_glyphs_func) (void *surface,
cairo_operator_t op,
const cairo_pattern_t *source,
const char *utf8,
int utf8_len,
cairo_glyph_t *glyphs,
int num_glyphs,
const cairo_text_cluster_t *clusters,
int num_clusters,
cairo_text_cluster_flags_t cluster_flags,
cairo_scaled_font_t *scaled_font,
cairo_clip_t *clip);
static cairo_surface_t *
_cairo_null_surface_create_similar (void *other,
cairo_content_t content,
int width, int height)
{
return _cairo_test_null_surface_create (content);
}
static cairo_bool_t
_cairo_null_surface_get_extents (void *surface,
cairo_rectangle_int_t *extents)
{
return FALSE;
}
static cairo_bool_t
_cairo_null_surface_has_show_text_glyphs (void *surface)
{
return TRUE;
}
static const cairo_surface_backend_t null_surface_backend = {
CAIRO_INTERNAL_SURFACE_TYPE_NULL,
_cairo_null_surface_create_similar,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
_cairo_null_surface_get_extents,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
(_paint_func) _return_success,
(_mask_func) _return_success,
(_stroke_func) _return_success,
(_fill_func) _return_success,
(_show_glyphs_func) _return_success,
NULL,
NULL,
NULL,
NULL,
NULL,
_cairo_null_surface_has_show_text_glyphs,
(_show_text_glyphs_func) _return_success,
};
cairo_surface_t *
_cairo_test_null_surface_create (cairo_content_t content)
{
cairo_surface_t *surface;
surface = malloc (sizeof (cairo_surface_t));
if (unlikely (surface == NULL)) {
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
}
_cairo_surface_init (surface,
&null_surface_backend,
NULL,
content);
return surface;
}
slim_hidden_def (_cairo_test_null_surface_create);