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 <hdegoede@redhat.com>
This commit is contained in:
Hans de Goede 2018-11-06 18:55:27 +01:00
parent e1e9e554d2
commit 385a008c83
2 changed files with 36 additions and 0 deletions

View 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 */

View 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);