diff options
author | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-10-04 21:08:35 -0400 |
---|---|---|
committer | Søren Sandmann Pedersen <ssp@redhat.com> | 2012-10-04 21:08:35 -0400 |
commit | f526ff2d6b51c6586bce65a444ca727aa6f76282 (patch) | |
tree | d15123300b6df4634721209d1bfa1363c7183a37 | |
parent | f6455ef738f0c98d2450cbb7c6c384197297a164 (diff) |
fragment_new_region(); fragment_subtract()
-rw-r--r-- | fimage.h | 51 | ||||
-rw-r--r-- | fragment.c | 33 |
2 files changed, 65 insertions, 19 deletions
@@ -3,26 +3,39 @@ typedef struct fragment_t fragment_t; #define TRUE 1 #define FALSE 0 -fragment_t *fragment_new_blank (int width, int height); -fragment_t *fragment_new_white (int width, int height); -fragment_t *fragment_new_traps (int width, int height, - int n_traps, - pixman_trapezoid_t *traps); -fragment_t *fragment_new_glyphs (int width, int height, +fragment_t *fragment_new_blank (int width, + int height); +fragment_t *fragment_new_white (int width, + int height); +fragment_t *fragment_new_traps (int width, + int height, + int n_traps, + pixman_trapezoid_t *traps); +fragment_t *fragment_new_glyphs (int width, + int height, pixman_glyph_cache_t *cache, - int n_glyphs, - pixman_glyph_t *glyphs); -fragment_t *fragment_new_image (int width, int height, - pixman_image_t *image); + int n_glyphs, + pixman_glyph_t *glyphs); +fragment_t *fragment_new_image (int width, + int height, + pixman_image_t *image); +fragment_t *fragment_new_region (pixman_region32_t *region); -/* Compute intersection of dest and source with state corresponding - * to compositing source with dest. Then subtract the region of - * intersection from dest and return the intersection fragment. - * Both intersection and dest may end up empty or broken. +/* Creates a new fragment corresponding to the intersection of + * source with destination. The content of this fragment is + * (dest OP source). + * + * The intersection is subtracted from dest. The source is not changed */ -fragment_t *fragment_composite (fragment_t *dest, - pixman_op_t op, - fragment_t *source); +fragment_t * fragment_composite (fragment_t *dest, + pixman_op_t op, + fragment_t *source); +/* A new fragment is create that is the same as dest with the + * region of other subtracted. @dest is freed (or, more likely, recycled) + */ +fragment_t * fragment_subtract (fragment_t *dest, + fragment_t *other); +pixman_bool_t fragment_apply (fragment_t *fragment, + pixman_image_t *image); -pixman_bool_t fragment_apply (fragment_t *fragment, - pixman_image_t *image); +void fragment_free (fragment_t *fragment); @@ -208,6 +208,24 @@ fragment_new_traps (int width, int height, } fragment_t * +fragment_new_region (pixman_region32_t *region) +{ + fragment_t *fragment; + + fragment = fragment_alloc (1, 1, STATE_WHITE); + if (fragment->broken) + return fragment; + + if (!pixman_region32_copy (&fragment->region, region)) + { + fragment_free (fragment); + return (fragment_t *)&broken_fragment; + } + + return fragment; +} + +fragment_t * fragment_new_glyphs (int width, int height, pixman_glyph_cache_t *cache, int n_glyphs, @@ -226,6 +244,21 @@ fragment_new_glyphs (int width, int height, return fragment; } +fragment_t * +fragment_subtract (fragment_t *dest, fragment_t *other) +{ + if (dest->broken || other->broken || + !pixman_region32_subtract ( + &dest->region, &dest->region, &(other->region))) + { + fragment_free (dest); + + return (fragment_t *)&broken_fragment; + } + + return dest; +} + static fragment_t * fragment_intersect (fragment_t *dest, fragment_t *source) { |