summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Vovk <adrianvovk@gmail.com>2021-03-02 16:13:23 -0500
committerAdrian Vovk <adrianvovk@gmail.com>2021-03-02 16:13:23 -0500
commit64522226f4581fcaf45919172b349621adac58db (patch)
treef9deb35428bdb53c0e8393dce6b3692f917c0164
parentc74b3aef9c34c1c51b2c9c14f10f2906925ed380 (diff)
Fix BGRT fallback rendering
-rw-r--r--src/plugins/splash/two-step/plugin.c49
1 files changed, 39 insertions, 10 deletions
diff --git a/src/plugins/splash/two-step/plugin.c b/src/plugins/splash/two-step/plugin.c
index 01c0bd1c..eade1ac3 100644
--- a/src/plugins/splash/two-step/plugin.c
+++ b/src/plugins/splash/two-step/plugin.c
@@ -471,7 +471,7 @@ view_set_bgrt_background (view_t *view)
panel_rotation = PLY_PIXEL_BUFFER_ROTATE_UPRIGHT;
}
- if (have_panel_props) {
+ if (have_panel_props) {
ply_pixel_buffer_set_device_rotation (bgrt_buffer, panel_rotation);
ply_pixel_buffer_set_device_scale (bgrt_buffer, panel_scale);
}
@@ -561,6 +561,30 @@ view_set_bgrt_background (view_t *view)
}
}
+static void
+view_set_bgrt_fallback_background (view_t *view)
+{
+ int width, height, x_offset, y_offset;
+ int screen_width, screen_height, screen_scale;
+ ply_pixel_buffer_t *image_buffer;
+
+ screen_width = ply_pixel_display_get_width (view->display);
+ screen_height = ply_pixel_display_get_height (view->display);
+ screen_scale = ply_pixel_display_get_device_scale (view->display);
+
+ image_buffer = ply_image_get_buffer (view->plugin->background_bgrt_fallback_image);
+
+ width = ply_pixel_buffer_get_width (image_buffer);
+ height = ply_pixel_buffer_get_height (image_buffer);
+ x_offset = (screen_width - width) / 2;
+ y_offset = screen_height * 382 / 1000 - height / 2;
+
+ view->background_buffer = ply_pixel_buffer_new (screen_width * screen_scale, screen_height * screen_scale);
+ ply_pixel_buffer_set_device_scale (view->background_buffer, screen_scale);
+ ply_pixel_buffer_fill_with_hex_color (view->background_buffer, NULL, 0x000000);
+ ply_pixel_buffer_fill_with_buffer (view->background_buffer, image_buffer, x_offset, y_offset);
+}
+
static bool
view_load (view_t *view)
{
@@ -581,6 +605,9 @@ view_load (view_t *view)
view_set_bgrt_background (view);
+ if (!view->background_buffer && plugin->background_bgrt_fallback_image != NULL)
+ view_set_bgrt_fallback_background (view);
+
if (!view->background_buffer && plugin->background_tile_image != NULL) {
ply_trace ("tiling background to %lux%lu", screen_width, screen_height);
@@ -906,7 +933,7 @@ view_show_prompt (view_t *view,
view->lock_area.x =
view->dialog_area.x +
- (view->dialog_area.width -
+ (view->dialog_area.width -
(view->lock_area.width + entry_width)) / 2.0;
view->lock_area.y =
view->dialog_area.y +
@@ -1402,9 +1429,12 @@ draw_background (view_t *view,
ply_boot_splash_plugin_t *plugin;
ply_rectangle_t area;
bool use_black_background = false;
+ bool using_fw_background;
plugin = view->plugin;
+ using_fw_background = (plugin->background_bgrt_image || plugin->background_bgrt_fallback_image);
+
area.x = x;
area.y = y;
area.width = width;
@@ -1413,7 +1443,7 @@ draw_background (view_t *view,
/* When using the firmware logo as background and we should not use
* it for this mode, use solid black as background.
*/
- if (plugin->background_bgrt_image &&
+ if (using_fw_background &&
!plugin->mode_settings[plugin->mode].use_firmware_background)
use_black_background = true;
@@ -1422,7 +1452,7 @@ draw_background (view_t *view,
*/
if ((plugin->state == PLY_BOOT_SPLASH_DISPLAY_QUESTION_ENTRY ||
plugin->state == PLY_BOOT_SPLASH_DISPLAY_PASSWORD_ENTRY) &&
- plugin->background_bgrt_image && plugin->dialog_clears_firmware_background)
+ using_fw_background && plugin->dialog_clears_firmware_background)
use_black_background = true;
if (use_black_background)
@@ -1664,12 +1694,11 @@ show_splash_screen (ply_boot_splash_plugin_t *plugin,
plugin->background_bgrt_raw_height = ply_image_get_height (plugin->background_bgrt_image);
} else {
ply_trace ("loading background bgrt fallback image");
- if (ply_image_load (plugin->background_bgrt_fallback_image)) {
- plugin->background_bgrt_image = plugin->background_bgrt_fallback_image;
- plugin->background_bgrt_fallback_image = NULL;
- } else {
- ply_image_free (plugin->background_bgrt_image);
- plugin->background_bgrt_image = NULL;
+
+ ply_image_free (plugin->background_bgrt_image);
+ plugin->background_bgrt_image = NULL;
+
+ if (!ply_image_load (plugin->background_bgrt_fallback_image)) {
for (i = 0; i < PLY_BOOT_SPLASH_MODE_COUNT; i++)
plugin->mode_settings[i].use_firmware_background = false;
plugin->use_firmware_background = false;