diff options
-rw-r--r-- | fimage.c | 32 | ||||
-rw-r--r-- | fimage.h | 13 | ||||
-rw-r--r-- | fragment.c | 29 |
3 files changed, 60 insertions, 14 deletions
@@ -19,14 +19,15 @@ struct fimage_t static const fimage_t broken_fimage = { TRUE, /* broken */ - 0, - NULL + 0, /* n_allocated_fragments */ + 0, /* n_fragments */ + { NULL } /* fragments */ }; static fimage_t * fimage_ensure_space (fimage_t *fimage, int n_more) { - size_t required_fragments = fimage->n_fragments + n_more; + int required_fragments = fimage->n_fragments + n_more; if (required_fragments > fimage->n_allocated_fragments) { @@ -72,7 +73,7 @@ fimage_append_fragment (fimage_t *fimage, fragment_t *fragment) return fimage; } - fimage = ensure_space (fimage, 1); + fimage = fimage_ensure_space (fimage, 1); if (fimage->broken) return fimage; @@ -138,22 +139,22 @@ fimage_new_image (int width, int height, pixman_image_t *image) return make_image (fragment_new_image (width, height, image)); } - /* Makes a copy of the region; does not take ownership */ fimage_t * fimage_new_region (int width, int height, pixman_region32_t *region) { fragment_t *fragment1, *fragment2; + fimage_t *image; fragment1 = fragment_new_region (region); fragment2 = fragment_new_blank (width, height); - fragment2 = fragment_subtract (fragment1, fragment_2); + fragment2 = fragment_subtract (fragment1, fragment2); image = fimage_new (); - image = fimage_append (image, fragment1); - image = fimage_appned (image, fragment2); + image = fimage_append_fragment (image, fragment1); + image = fimage_append_fragment (image, fragment2); return image; } @@ -195,7 +196,7 @@ fimage_composite (fimage_t *dest, pixman_op_t op, fimage_t *source) } void -fimage_paint (fimage_t *image, pixman_image_t *image) +fimage_paint (fimage_t *image, pixman_image_t *pimage) { int i; @@ -203,6 +204,17 @@ fimage_paint (fimage_t *image, pixman_image_t *image) { fragment_t *fragment = image->fragments[i]; - fragment_apply (fragment, image); + fragment_apply (fragment, pimage); } } + +void +fimage_free (fimage_t *image) +{ + int i; + + for (i = 0; i < image->n_fragments; ++i) + fragment_free (image->fragments[i]); + + free (image); +} @@ -40,7 +40,9 @@ fragment_t * fragment_subtract (fragment_t *dest, pixman_bool_t fragment_apply (fragment_t *fragment, pixman_image_t *image); -void fragment_free (fragment_t *fragment); +void fragment_free (fragment_t *fragment); +pixman_bool_t fragment_is_empty (fragment_t *fragment); +pixman_bool_t fragment_is_broken (fragment_t *fragment); @@ -53,11 +55,14 @@ fimage_t *fimage_new_white (int width, int height); fimage_t *fimage_new_glyphs (int width, int height, pixman_glyph_cache_t *glyph_cache, int n_glyphs, - pixman_glyphs_t *glyphs); + pixman_glyph_t *glyphs); /* Takes ownership of the trapezoids */ -fimage_t *fimage_new_traps (int width, int height, int n_traps, pixman_trapezoids_t *traps); +fimage_t *fimage_new_traps (int width, int height, int n_traps, pixman_trapezoid_t *traps); /* Takes ownership of the image */ -fimage_t *fimage_new_image (pixman_image_t *image); +fimage_t *fimage_new_image (int width, int height, pixman_image_t *image); /* Makes a copy of the region; does not take ownership */ fimage_t *fimage_new_region (int width, int height, pixman_region32_t *region); +fimage_t * +fimage_composite (fimage_t *dest, pixman_op_t op, fimage_t *source); +void fimage_free (fimage_t *image); @@ -245,6 +245,20 @@ fragment_new_glyphs (int width, int height, } fragment_t * +fragment_new_image (int width, int height, + pixman_image_t *image) +{ + fragment_t *fragment; + fragment = fragment_alloc (width, height, STATE_IMAGE); + if (fragment->broken) + return fragment; + + fragment->state->image.image = image; + + return fragment; +} + +fragment_t * fragment_subtract (fragment_t *dest, fragment_t *other) { if (dest->broken || other->broken || @@ -259,6 +273,21 @@ fragment_subtract (fragment_t *dest, fragment_t *other) return dest; } +pixman_bool_t +fragment_is_empty (fragment_t *fragment) +{ + if (fragment->broken) + return FALSE; + + return !pixman_region32_not_empty (&fragment->region); +} + +pixman_bool_t +fragment_is_broken (fragment_t *fragment) +{ + return fragment->broken; +} + static fragment_t * fragment_intersect (fragment_t *dest, fragment_t *source) { |