From: Charlie Brej Date: Sun, 18 Apr 2010 16:14:21 +0000 (+0100) Subject: [pixel-buffer] Add fill buffer with buffer functions X-Git-Tag: 0.8.3~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d93ae6cdc72fe3a019003fdc539d6ad40f305a61;p=thirdparty%2Fplymouth.git [pixel-buffer] Add fill buffer with buffer functions These draw the content of one buffer into another. This is cleaner than using the raw data and passing the width and height of the data separately. --- diff --git a/src/libply-splash-core/ply-pixel-buffer.c b/src/libply-splash-core/ply-pixel-buffer.c index 79ff9161..038601e6 100644 --- a/src/libply-splash-core/ply-pixel-buffer.c +++ b/src/libply-splash-core/ply-pixel-buffer.c @@ -603,6 +603,108 @@ ply_pixel_buffer_fill_with_argb32_data_with_clip (ply_pixel_buffer_t *buffer, data, 1.0); } +void +ply_pixel_buffer_fill_with_buffer_at_opacity_with_clip (ply_pixel_buffer_t *canvas, + ply_pixel_buffer_t *source, + int x_offset, + int y_offset, + ply_rectangle_t *clip_area, + float opacity) +{ + unsigned long row, column; + uint8_t opacity_as_byte; + ply_rectangle_t cropped_area; + unsigned long x; + unsigned long y; + + assert (canvas != NULL); + assert (source != NULL); + + cropped_area.x = x_offset; + cropped_area.y = y_offset; + cropped_area.width = source->area.width; + cropped_area.height = source->area.height; + + ply_pixel_buffer_crop_area_to_clip_area (canvas, &cropped_area, &cropped_area); + + if (clip_area) + ply_rectangle_intersect (&cropped_area, clip_area, &cropped_area); + + if (cropped_area.width == 0 || cropped_area.height == 0) + return; + + x = cropped_area.x - x_offset; + y = cropped_area.y - y_offset; + opacity_as_byte = (uint8_t) (opacity * 255.0); + + for (row = y; row < y + cropped_area.height; row++) + { + for (column = x; column < x + cropped_area.width; column++) + { + uint32_t pixel_value; + + pixel_value = source->bytes[row * source->area.width + column]; + + pixel_value = make_pixel_value_translucent (pixel_value, opacity_as_byte); + + if ((pixel_value >> 24) == 0x00) + continue; + + ply_pixel_buffer_blend_value_at_pixel (canvas, + cropped_area.x + (column - x), + cropped_area.y + (row - y), + pixel_value); + + } + } + + ply_region_add_rectangle (canvas->updated_areas, &cropped_area); +} + +void +ply_pixel_buffer_fill_with_buffer_at_opacity (ply_pixel_buffer_t *canvas, + ply_pixel_buffer_t *source, + int x_offset, + int y_offset, + float opacity) +{ + ply_pixel_buffer_fill_with_buffer_at_opacity_with_clip (canvas, + source, + x_offset, + y_offset, + NULL, + opacity); +} + +void +ply_pixel_buffer_fill_with_buffer_with_clip (ply_pixel_buffer_t *canvas, + ply_pixel_buffer_t *source, + int x_offset, + int y_offset, + ply_rectangle_t *clip_area) +{ + ply_pixel_buffer_fill_with_buffer_at_opacity_with_clip (canvas, + source, + x_offset, + y_offset, + clip_area, + 1.0); +} + +void +ply_pixel_buffer_fill_with_buffer (ply_pixel_buffer_t *canvas, + ply_pixel_buffer_t *source, + int x_offset, + int y_offset) +{ + ply_pixel_buffer_fill_with_buffer_at_opacity_with_clip (canvas, + source, + x_offset, + y_offset, + NULL, + 1.0); +} + uint32_t * ply_pixel_buffer_get_argb32_data (ply_pixel_buffer_t *buffer) { diff --git a/src/libply-splash-core/ply-pixel-buffer.h b/src/libply-splash-core/ply-pixel-buffer.h index 18ac0946..47cdd524 100644 --- a/src/libply-splash-core/ply-pixel-buffer.h +++ b/src/libply-splash-core/ply-pixel-buffer.h @@ -87,6 +87,28 @@ void ply_pixel_buffer_fill_with_argb32_data_at_opacity_with_clip (ply_pixel_buff uint32_t *data, double opacity); +void ply_pixel_buffer_fill_with_buffer_at_opacity_with_clip (ply_pixel_buffer_t *canvas, + ply_pixel_buffer_t *source, + int x_offset, + int y_offset, + ply_rectangle_t *clip_area, + float opacity); +void ply_pixel_buffer_fill_with_buffer_at_opacity (ply_pixel_buffer_t *canvas, + ply_pixel_buffer_t *source, + int x_offset, + int y_offset, + float opacity); +void ply_pixel_buffer_fill_with_buffer_with_clip (ply_pixel_buffer_t *canvas, + ply_pixel_buffer_t *source, + int x_offset, + int y_offset, + ply_rectangle_t *clip_area); +void ply_pixel_buffer_fill_with_buffer (ply_pixel_buffer_t *canvas, + ply_pixel_buffer_t *source, + int x_offset, + int y_offset); + + void ply_pixel_buffer_push_clip_area (ply_pixel_buffer_t *buffer, ply_rectangle_t *clip_area); void ply_pixel_buffer_pop_clip_area (ply_pixel_buffer_t *buffer);