-
Notifications
You must be signed in to change notification settings - Fork 112
avoid flicker when changing from lockscreen to waiting screen #1618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
// limitations under the License. | ||
|
||
#include "waiting.h" | ||
#include "lockscreen.h" | ||
|
||
#include "image.h" | ||
#include "ui_images.h" | ||
|
@@ -21,13 +22,12 @@ | |
#include <screen.h> | ||
#include <ui/ui_util.h> | ||
|
||
#include <stdbool.h> | ||
#include <string.h> | ||
|
||
static void _render(component_t* component) | ||
{ | ||
// TODO - add an interesting animation? | ||
ui_util_component_render_subcomponents(component); | ||
} | ||
typedef struct { | ||
bool show_logo; | ||
} data_t; | ||
|
||
/********************************** Component Functions **********************************/ | ||
|
||
|
@@ -36,7 +36,7 @@ static void _render(component_t* component) | |
*/ | ||
static component_functions_t _component_functions = { | ||
.cleanup = ui_util_component_cleanup, | ||
.render = _render, | ||
.render = ui_util_component_render_subcomponents, | ||
.on_event = NULL, | ||
}; | ||
|
||
|
@@ -47,6 +47,12 @@ static component_functions_t _component_functions = { | |
*/ | ||
component_t* waiting_create(void) | ||
{ | ||
data_t* data = malloc(sizeof(data_t)); | ||
if (!data) { | ||
Abort("Error: malloc waiting data"); | ||
} | ||
memset(data, 0, sizeof(data_t)); | ||
|
||
component_t* waiting = malloc(sizeof(component_t)); | ||
if (!waiting) { | ||
Abort("Error: malloc waiting"); | ||
|
@@ -57,14 +63,37 @@ component_t* waiting_create(void) | |
waiting->dimension.height = SCREEN_HEIGHT; | ||
waiting->position.top = 0; | ||
waiting->position.left = 0; | ||
waiting->data = data; | ||
|
||
ui_util_add_sub_component(waiting, lockscreen_create()); | ||
|
||
return waiting; | ||
} | ||
|
||
void waiting_switch_to_logo(component_t* component) | ||
{ | ||
data_t* data = (data_t*)component->data; | ||
if (data->show_logo) { | ||
return; | ||
} | ||
data->show_logo = true; | ||
|
||
if (component->sub_components.amount != 1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be an ASSERT. The subcomponent is clearly added in the constructor. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem with ASSERT is that they don't run in prod, and if the assumption is wrong for some reason, there will be a memory bug. I could do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, Abort is fine as well if you want it to be checked in prod There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
// Sanity check to avoid memory bugs, should never happen. | ||
Abort("waiting_switch_to_logo"); | ||
return; | ||
} | ||
|
||
ui_util_component_cleanup(component->sub_components.sub_components[0]); | ||
|
||
image_logo_data_t logo = image_logo_data(); | ||
component_t* bb2_logo = image_create( | ||
logo.buffer.data, | ||
logo.buffer.len, | ||
logo.dimensions.width, | ||
logo.dimensions.height, | ||
CENTER, | ||
waiting); | ||
ui_util_add_sub_component(waiting, bb2_logo); | ||
return waiting; | ||
component); | ||
|
||
component->sub_components.sub_components[0] = bb2_logo; | ||
NickeZ marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,16 +32,21 @@ void ui_screen_render_component(component_t* component) | |
UG_SendBuffer(); | ||
} | ||
|
||
static component_t* _waiting_screen = NULL; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This static could be inside There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, as it is needed by |
||
static component_t* _get_waiting_screen(void) | ||
{ | ||
static component_t* waiting_screen = NULL; | ||
if (waiting_screen == NULL) { | ||
waiting_screen = waiting_create(); | ||
if (waiting_screen == NULL) { | ||
if (_waiting_screen == NULL) { | ||
_waiting_screen = waiting_create(); | ||
if (_waiting_screen == NULL) { | ||
Abort("Could not create\nwaiting screen"); | ||
} | ||
} | ||
return waiting_screen; | ||
return _waiting_screen; | ||
} | ||
|
||
void screen_process_waiting_switch_to_logo(void) | ||
{ | ||
waiting_switch_to_logo(_get_waiting_screen()); | ||
} | ||
|
||
component_t* screen_process_get_top_component(void) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the lockscreen isn't a screen anymore, but a subcomponent, should we rename it to something like
locked_device_background
instead?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a need, in the end it's doing the same as before 🤷