mirror of
https://gitlab.freedesktop.org/plymouth/plymouth.git
synced 2026-05-08 12:28:12 +02:00
pixel-buffer: add ability track opaqueness
Pixel buffers contain ARGB32 data. Add functionality to mark a buffer as containing only fully opaque pixels. This functionality can be used by rendering functions to be able to optimize drawing of such buffers. https://bugs.freedesktop.org/show_bug.cgi?id=87105
This commit is contained in:
parent
4ecd0c2436
commit
00ee03695c
2 changed files with 31 additions and 0 deletions
|
|
@ -37,6 +37,8 @@
|
|||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define ALPHA_MASK 0xff000000
|
||||
|
||||
struct _ply_pixel_buffer
|
||||
{
|
||||
uint32_t *bytes;
|
||||
|
|
@ -45,6 +47,7 @@ struct _ply_pixel_buffer
|
|||
ply_list_t *clip_areas;
|
||||
|
||||
ply_region_t *updated_areas;
|
||||
uint32_t is_opaque : 1;
|
||||
};
|
||||
|
||||
static inline void ply_pixel_buffer_blend_value_at_pixel (ply_pixel_buffer_t *buffer,
|
||||
|
|
@ -198,6 +201,14 @@ ply_pixel_buffer_fill_area_with_pixel_value (ply_pixel_buffer_t *buffer,
|
|||
|
||||
ply_pixel_buffer_crop_area_to_clip_area (buffer, fill_area, &cropped_area);
|
||||
|
||||
/* If we're filling the entire buffer with a fully opaque color,
|
||||
* then make note of it
|
||||
*/
|
||||
if (fill_area == &buffer->area &&
|
||||
(pixel_value >> 24) == 0xff) {
|
||||
buffer->is_opaque = true;
|
||||
}
|
||||
|
||||
for (row = cropped_area.y; row < cropped_area.y + cropped_area.height; row++) {
|
||||
for (column = cropped_area.x; column < cropped_area.x + cropped_area.width; column++) {
|
||||
ply_pixel_buffer_blend_value_at_pixel (buffer,
|
||||
|
|
@ -244,6 +255,7 @@ ply_pixel_buffer_new (unsigned long width,
|
|||
|
||||
buffer->clip_areas = ply_list_new ();
|
||||
ply_pixel_buffer_push_clip_area (buffer, &buffer->area);
|
||||
buffer->is_opaque = false;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
|
@ -295,6 +307,21 @@ ply_pixel_buffer_get_height (ply_pixel_buffer_t *buffer)
|
|||
return buffer->area.height;
|
||||
}
|
||||
|
||||
bool
|
||||
ply_pixel_buffer_is_opaque (ply_pixel_buffer_t *buffer)
|
||||
{
|
||||
assert (buffer != NULL);
|
||||
return buffer->is_opaque;
|
||||
}
|
||||
|
||||
void
|
||||
ply_pixel_buffer_set_opaque (ply_pixel_buffer_t *buffer,
|
||||
bool is_opaque)
|
||||
{
|
||||
assert (buffer != NULL);
|
||||
buffer->is_opaque = is_opaque;
|
||||
}
|
||||
|
||||
ply_region_t *
|
||||
ply_pixel_buffer_get_updated_areas (ply_pixel_buffer_t *buffer)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -47,6 +47,10 @@ void ply_pixel_buffer_get_size (ply_pixel_buffer_t *buffer,
|
|||
unsigned long ply_pixel_buffer_get_width (ply_pixel_buffer_t *buffer);
|
||||
unsigned long ply_pixel_buffer_get_height (ply_pixel_buffer_t *buffer);
|
||||
|
||||
bool ply_pixel_buffer_is_opaque (ply_pixel_buffer_t *buffer);
|
||||
void ply_pixel_buffer_set_opaque (ply_pixel_buffer_t *buffer,
|
||||
bool is_opaque);
|
||||
|
||||
ply_region_t *ply_pixel_buffer_get_updated_areas (ply_pixel_buffer_t *buffer);
|
||||
|
||||
void ply_pixel_buffer_fill_with_color (ply_pixel_buffer_t *buffer,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue