From: Hans de Goede Date: Tue, 6 Nov 2018 17:55:27 +0000 (+0100) Subject: ply-pixel-buffer: Add ply_pixel_buffer_get/set_device_rotation helpers X-Git-Tag: 0.9.5~84^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=385a008c83e41d7958392bc4cf8aacb94965fe30;p=thirdparty%2Fplymouth.git ply-pixel-buffer: Add ply_pixel_buffer_get/set_device_rotation helpers 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 --- diff --git a/src/libply-splash-core/ply-pixel-buffer.c b/src/libply-splash-core/ply-pixel-buffer.c index 86e8e3f0..1599bcb5 100644 --- a/src/libply-splash-core/ply-pixel-buffer.c +++ b/src/libply-splash-core/ply-pixel-buffer.c @@ -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 */ diff --git a/src/libply-splash-core/ply-pixel-buffer.h b/src/libply-splash-core/ply-pixel-buffer.h index ea7f833d..ddec47d1 100644 --- a/src/libply-splash-core/ply-pixel-buffer.h +++ b/src/libply-splash-core/ply-pixel-buffer.h @@ -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);