]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
two-step: Fix wrong horizontal position of bgrt logo on left-side-up LCD panels
authorHans de Goede <hdegoede@redhat.com>
Mon, 21 Oct 2019 08:34:26 +0000 (10:34 +0200)
committerHans de Goede <hdegoede@redhat.com>
Mon, 21 Oct 2019 08:39:52 +0000 (10:39 +0200)
On devices which have their LCD panel mounted 90° rotated with the left-side
of the physical LCD-panel up (at the top), we were using the wrong offset
for placing the bgrt graphics. We were directly using y_offset from the bgrt
as x_offset, but y_offset is from the top of the physical LCD which in this
case is the right side of the panel as seen by the user. Where as our x_offset
is defined to have 0 at the left side.

This commit fixes this issue by flipping the y_offset value on these panels
before using it as our x_offset.

This fixes the logo jumping 6 pixels to the left on an Asus T100HA, which
has such a panel and uses a bgrt y_offset of 512, which results in a flipped
y_offset of 518 (for some reason the log is not entirely centered triggering
this problem).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
src/plugins/splash/two-step/plugin.c

index 950f755e1f08ebfbe2ea76a347c0f71e1180cb1e..660890dfe9bcae2f67268cf5f4a4ec54766a601a 100644 (file)
@@ -163,6 +163,7 @@ struct _ply_boot_splash_plugin
         uint32_t                            background_start_color;
         uint32_t                            background_end_color;
         int                                 background_bgrt_raw_width;
+        int                                 background_bgrt_raw_height;
 
         double                              progress_bar_horizontal_alignment;
         double                              progress_bar_vertical_alignment;
@@ -499,6 +500,16 @@ view_set_bgrt_background (view_t *view)
             (panel_width - view->plugin->background_bgrt_raw_width) / 2 == sysfs_x_offset) {
                 if (panel_rotation == PLY_PIXEL_BUFFER_ROTATE_CLOCKWISE ||
                     panel_rotation == PLY_PIXEL_BUFFER_ROTATE_COUNTER_CLOCKWISE) {
+                        /*
+                         * For left side up panels the y_offset is from the
+                         * right side of the image once rotated upright (the
+                         * top of the physicial LCD panel is on the right side).
+                         * Our coordinates have the left side as 0, so we need
+                         * to "flip" the y_offset in this case.
+                         */
+                        if (panel_rotation == PLY_PIXEL_BUFFER_ROTATE_COUNTER_CLOCKWISE)
+                                sysfs_y_offset = panel_height - view->plugin->background_bgrt_raw_height - sysfs_y_offset;
+
                         /* 90 degrees rotated, swap x and y */
                         x_offset = sysfs_y_offset / panel_scale;
                         y_offset = sysfs_x_offset / panel_scale;
@@ -1641,6 +1652,7 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
                 ply_trace ("loading background bgrt image");
                 if (ply_image_load (plugin->background_bgrt_image)) {
                         plugin->background_bgrt_raw_width = ply_image_get_width (plugin->background_bgrt_image);
+                        plugin->background_bgrt_raw_height = ply_image_get_height (plugin->background_bgrt_image);
                 } else {
                         ply_image_free (plugin->background_bgrt_image);
                         plugin->background_bgrt_image = NULL;