]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
pixel-buffer: add ability track opaqueness
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>
Mon, 8 Dec 2014 10:39:39 +0000 (11:39 +0100)
committerRay Strode <rstrode@redhat.com>
Thu, 26 Mar 2015 00:59:25 +0000 (20:59 -0400)
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

src/libply-splash-core/ply-pixel-buffer.c
src/libply-splash-core/ply-pixel-buffer.h

index c1825cc21995e69bf4d97e7c7888ce4e2038f859..2ecfb256f2d1dbc7259941e0da963241c1adae8b 100644 (file)
@@ -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)
 {
index 7848a986c013e81148d54d27139fa48433d73633..a374c6c5e40b5252445aca7ae794e2ccb3330b70 100644 (file)
@@ -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,