]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
ply-pixel-buffer: Add ply_pixel_buffer_get/set_device_rotation helpers
authorHans de Goede <hdegoede@redhat.com>
Tue, 6 Nov 2018 17:55:27 +0000 (18:55 +0100)
committerHans de Goede <hdegoede@redhat.com>
Tue, 27 Nov 2018 07:48:56 +0000 (08:48 +0100)
For some themes we want to use the firmware-logo / splash as background,
when the LCD panel of a laptop is mounted non-upright then the image which
we get from the firmware will be pre-rotated to match the LCD panel mount.

This commit adds ply_pixel_buffer_set/get_device_rotation helpers to
help deal with this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
src/libply-splash-core/ply-pixel-buffer.c
src/libply-splash-core/ply-pixel-buffer.h

index 86e8e3f070be4802b3c6edc3739b6cd032e04e24..1599bcb55a5c35ba88999b7acf001367447395b6 100644 (file)
@@ -1079,4 +1079,34 @@ ply_pixel_buffer_set_device_scale (ply_pixel_buffer_t *buffer,
         buffer->logical_area.height = buffer->area.height / scale;
 }
 
+ply_pixel_buffer_rotation_t
+ply_pixel_buffer_get_device_rotation (ply_pixel_buffer_t *buffer)
+{
+        return buffer->device_rotation;
+}
+
+void
+ply_pixel_buffer_set_device_rotation (ply_pixel_buffer_t *buffer,
+                                      ply_pixel_buffer_rotation_t device_rotation)
+{
+        if (buffer->device_rotation == device_rotation)
+                return;
+
+        buffer->device_rotation = device_rotation;
+
+        if (device_rotation == PLY_PIXEL_BUFFER_ROTATE_CLOCKWISE ||
+            device_rotation == PLY_PIXEL_BUFFER_ROTATE_COUNTER_CLOCKWISE) {
+                unsigned long tmp = buffer->area.width;
+                buffer->area.width = buffer->area.height;
+                buffer->area.height = tmp;
+
+                ply_pixel_buffer_set_device_scale (buffer, buffer->device_scale);
+        }
+
+        while (ply_list_get_length (buffer->clip_areas) > 0) {
+                ply_pixel_buffer_pop_clip_area (buffer);
+        }
+        ply_pixel_buffer_push_clip_area (buffer, &buffer->area);
+}
+
 /* vim: set ts=4 sw=4 et ai ci cino={.5s,^-2,+.5s,t0,g0,e-2,n-2,p2s,(0,=.5s,:.5s */
index ea7f833d0600dd7ea3897bc0e4068ede868b2cd4..ddec47d18acff5c77a5bd4f9b3a2044819d0e1c9 100644 (file)
@@ -59,6 +59,12 @@ int  ply_pixel_buffer_get_device_scale (ply_pixel_buffer_t *buffer);
 void ply_pixel_buffer_set_device_scale (ply_pixel_buffer_t *buffer,
                                         int                 scale);
 
+ply_pixel_buffer_rotation_t
+ply_pixel_buffer_get_device_rotation (ply_pixel_buffer_t *buffer);
+/* Note calling this removes all pushed clip-areas */
+void ply_pixel_buffer_set_device_rotation (ply_pixel_buffer_t *buffer,
+                                           ply_pixel_buffer_rotation_t rotation);
+
 unsigned long ply_pixel_buffer_get_width (ply_pixel_buffer_t *buffer);
 unsigned long ply_pixel_buffer_get_height (ply_pixel_buffer_t *buffer);