From caf2ac58396e20e6ba2977dbdd2eec7c79bfa4cc Mon Sep 17 00:00:00 2001 From: Charlie Brej Date: Sat, 20 Sep 2008 18:25:57 -0400 Subject: [PATCH] Add new functions for filling fb within clip rect --- src/libply/ply-frame-buffer.c | 37 +++++++++++++++++++++++++++++++++-- src/libply/ply-frame-buffer.h | 14 +++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/src/libply/ply-frame-buffer.c b/src/libply/ply-frame-buffer.c index 4f0cfb47..03bbd2bd 100644 --- a/src/libply/ply-frame-buffer.c +++ b/src/libply/ply-frame-buffer.c @@ -922,8 +922,9 @@ ply_frame_buffer_fill_with_hex_color (ply_frame_buffer_t *buffer, } bool -ply_frame_buffer_fill_with_argb32_data_at_opacity (ply_frame_buffer_t *buffer, +ply_frame_buffer_fill_with_argb32_data_at_opacity_with_clip (ply_frame_buffer_t *buffer, ply_frame_buffer_area_t *area, + ply_frame_buffer_area_t *clip, unsigned long x, unsigned long y, uint32_t *data, @@ -941,6 +942,14 @@ ply_frame_buffer_fill_with_argb32_data_at_opacity (ply_frame_buffer_t *buff ply_frame_buffer_area_intersect (area, &buffer->area, &cropped_area); + if (clip) + ply_frame_buffer_area_intersect (&cropped_area, clip, &cropped_area); + + if (cropped_area.width == 0 || cropped_area.height == 0) + return true; + + x += cropped_area.x - area->x; + y += cropped_area.y - area->y; opacity_as_byte = (uint8_t) (opacity * 255.0); for (row = y; row < y + cropped_area.height; row++) @@ -967,6 +976,18 @@ ply_frame_buffer_fill_with_argb32_data_at_opacity (ply_frame_buffer_t *buff return ply_frame_buffer_flush (buffer); } +bool +ply_frame_buffer_fill_with_argb32_data_at_opacity (ply_frame_buffer_t *buffer, + ply_frame_buffer_area_t *area, + unsigned long x, + unsigned long y, + uint32_t *data, + double opacity) +{ + return ply_frame_buffer_fill_with_argb32_data_at_opacity_with_clip (buffer, area, NULL, + x, y, data, opacity); +} + bool ply_frame_buffer_fill_with_argb32_data (ply_frame_buffer_t *buffer, ply_frame_buffer_area_t *area, @@ -974,7 +995,19 @@ ply_frame_buffer_fill_with_argb32_data (ply_frame_buffer_t *buffer, unsigned long y, uint32_t *data) { - return ply_frame_buffer_fill_with_argb32_data_at_opacity (buffer, area, + return ply_frame_buffer_fill_with_argb32_data_at_opacity_with_clip (buffer, area, NULL, + x, y, data, 1.0); +} + +bool +ply_frame_buffer_fill_with_argb32_data_with_clip (ply_frame_buffer_t *buffer, + ply_frame_buffer_area_t *area, + ply_frame_buffer_area_t *clip, + unsigned long x, + unsigned long y, + uint32_t *data) +{ + return ply_frame_buffer_fill_with_argb32_data_at_opacity_with_clip (buffer, area, clip, x, y, data, 1.0); } diff --git a/src/libply/ply-frame-buffer.h b/src/libply/ply-frame-buffer.h index dcaf873a..d30e4ef4 100644 --- a/src/libply/ply-frame-buffer.h +++ b/src/libply/ply-frame-buffer.h @@ -89,6 +89,20 @@ bool ply_frame_buffer_fill_with_argb32_data_at_opacity (ply_frame_buffer_t uint32_t *data, double opacity); +bool ply_frame_buffer_fill_with_argb32_data_with_clip (ply_frame_buffer_t *buffer, + ply_frame_buffer_area_t *area, + ply_frame_buffer_area_t *clip, + unsigned long x, + unsigned long y, + uint32_t *data); +bool ply_frame_buffer_fill_with_argb32_data_at_opacity_with_clip (ply_frame_buffer_t *buffer, + ply_frame_buffer_area_t *area, + ply_frame_buffer_area_t *clip, + unsigned long x, + unsigned long y, + uint32_t *data, + double opacity); + const char *ply_frame_buffer_get_bytes (ply_frame_buffer_t *buffer); -- 2.47.3