From 1ac882f041a8c57b78cedf2fa3655348e427ad81 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 21 Oct 2019 10:34:26 +0200 Subject: [PATCH] two-step: Fix wrong horizontal position of bgrt logo on left-side-up LCD panels MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/plugins/splash/two-step/plugin.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/plugins/splash/two-step/plugin.c b/src/plugins/splash/two-step/plugin.c index 950f755e..660890df 100644 --- a/src/plugins/splash/two-step/plugin.c +++ b/src/plugins/splash/two-step/plugin.c @@ -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; -- 2.47.3