diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-09-30 17:35:37 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-09-30 17:35:37 -0400 |
commit | 5a8c34cd098f890d5cb5e6e49f38e2659d3e5edd (patch) | |
tree | 292fc80de8844e1a382ad7900b6a78d30b55268c | |
parent | 026d85e283582b49ed4f288d9290546dd6f73f40 (diff) |
proto constructors
-rw-r--r-- | src/cairo-pixman-surface.c | 187 |
1 files changed, 139 insertions, 48 deletions
diff --git a/src/cairo-pixman-surface.c b/src/cairo-pixman-surface.c index f1924a3d..f6ee2600 100644 --- a/src/cairo-pixman-surface.c +++ b/src/cairo-pixman-surface.c @@ -339,6 +339,141 @@ cairo_pixman_surface_get_font_options (void *abstract_surface, _cairo_font_options_set_round_glyph_positions (options, CAIRO_ROUND_GLYPH_POS_ON); } +typedef union proto_image_t proto_image_t; + +typedef enum +{ + REGION, + TRAPS, + GLYPHS, + PIXMAN, + COMPOSITE +} proto_image_type_t; + +typedef struct +{ + proto_image_type_t type; + pixman_region32_t *region; +} proto_region_t; + +typedef struct +{ + proto_image_type_t type; + int n_traps; + pixman_trapezoid_t *traps; +} proto_traps_t; + +typedef struct +{ + proto_image_type_t type; + pixman_glyph_cache_t *glyph_cache; + int n_glyphs; + pixman_glyph_t * glyphs; +} proto_glyphs_t; + +typedef struct +{ + proto_image_type_t type; + pixman_image_t * image; +} proto_pixman_t; + +typedef struct +{ + proto_image_type_t type; + pixman_op_t op; + proto_image_t * left; + proto_image_t * right; +} proto_composite_t; + +union proto_image_t +{ + proto_image_type_t type; + proto_region_t region; + proto_traps_t traps; + proto_glyphs_t glyphs; + proto_pixman_t pixman; + proto_composite_t composite; +}; + +static proto_image_t * +proto_image_new (proto_image_type_t type) +{ + proto_image_t *image; + + if ((image = malloc (sizeof *image))) + image->type = type; + + return image; +} + +static proto_image_t * +proto_image_new_traps (int n_traps, pixman_trapezoid_t *traps) +{ + proto_image_t *image; + + if ((image = proto_image_new (TRAPS))) + { + image->traps.n_traps = n_traps; + image->traps.traps = traps; + } + + return image; +} + +static proto_image_t * +proto_image_new_region (pixman_region32_t *region) +{ + proto_image_t *image; + + if ((image = proto_image_new (REGION))) + image->region.region = region; + + return image; +} + +static proto_image_t * +proto_image_new_glyphs (pixman_glyph_cache_t *glyph_cache, + int n_glyphs, + pixman_glyph_t * glyphs) +{ + proto_image_t *image; + + if ((image = proto_image_new (GLYPHS))) + { + image->glyphs.glyph_cache = glyph_cache; + image->glyphs.n_glyphs = n_glyphs; + image->glyphs.glyphs = glyphs; + } + + return image; +} + +static proto_image_t * +proto_image_new_pixman (pixman_image_t *pimage) +{ + proto_image_t *image; + + if ((image = proto_image_new (PIXMAN))) + image->pixman.image = pimage; + + return image; +} + +static proto_image_t * +proto_image_new_composite (pixman_op_t op, proto_image_t *left, proto_image_t *right) +{ + proto_image_t *image; + + if ((image = proto_image_new (COMPOSITE))) + { + image->composite.op = op; + image->composite.left = left; + image->composite.right = right; + } + + return image; +} + static void set_properties (pixman_image_t *image, cairo_pattern_t *pattern, cairo_matrix_t *matrix) { @@ -858,7 +993,7 @@ traps_to_pixman_trapezoids (const cairo_traps_t *traps) static cairo_int_status_t create_clip_image (const cairo_clip_t *clip, int width, int height, - pixman_image_t **clip_image) + proto_image_t **clip_image) { cairo_int_status_t status; pixman_trapezoid_t *ptraps = NULL; @@ -1040,50 +1175,6 @@ _pixman_operator (cairo_operator_t op) } } -typedef enum -{ - REGION, - TRAPS, - GLYPHS, - PIXMAN -} proto_image_type_t; - -typedef struct -{ - proto_image_type_t type; - pixman_region32_t *region; -} proto_region_t; - -typedef struct -{ - proto_image_type_t type; - int n_traps; - pixman_trapezoid_t *traps; -} proto_traps_t; - -typedef struct -{ - proto_image_type_t type; - pixman_glyph_cache_t *glyph_cache; - int n_glyphs; - pixman_glyph_t * glyphs; -} proto_glyphs_t; - -typedef struct -{ - proto_image_type_t type; - pixman_image_t * image; -} proto_pixman_t; - -typedef union -{ - proto_image_type_t type; - proto_region_t region; - proto_traps_t traps; - proto_glyphs_t glyphs; - proto_pixman_t pixman; -} proto_image_t; - static cairo_int_status_t proto_image_resolve (proto_image_t *proto_image, int width, int height, pixman_image_t **result) @@ -1227,14 +1318,14 @@ static cairo_int_status_t clip_and_composite (cairo_pixman_surface_t *psurface, cairo_operator_t operator, const cairo_pattern_t *source, - pixman_image_t *mask_image, + proto_image_t *mask_image, const cairo_clip_t *clip) { pixman_image_t *dest_image = psurface->pimage; int width = pixman_image_get_width (dest_image); int height = pixman_image_get_height (dest_image); - pixman_image_t *src_image = NULL; - pixman_image_t *clip_image = NULL; + proto_image_t *src_image = NULL; + proto_image_t *clip_image = NULL; pixman_image_t *combined = NULL; cairo_int_status_t status; pixman_op_t pop; |