]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
[pixel-buffer] Add fill buffer with buffer functions
authorCharlie Brej <cbrej@cs.man.ac.uk>
Sun, 18 Apr 2010 16:14:21 +0000 (17:14 +0100)
committerCharlie Brej <cbrej@cs.man.ac.uk>
Sun, 18 Apr 2010 16:14:21 +0000 (17:14 +0100)
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.

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

index 79ff91612cd805c0c0c6db417d1a146f798f74c2..038601e65621fd13133ec0d6a08e3920b47a8e29 100644 (file)
@@ -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)
 {
index 18ac0946620e8a98c4175c8cfae37f657fe171e9..47cdd5248f56a0e6753f4617d76c6c63ef62f385 100644 (file)
@@ -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);