diff options
author | James Magahern <james@magahern.com> | 2019-02-09 14:54:37 -0800 |
---|---|---|
committer | James Magahern <james@magahern.com> | 2019-02-09 14:54:37 -0800 |
commit | 80eb12b7c165945b366491987c4c83ff426930bc (patch) | |
tree | 92789fccb12eb102d5c2c5d28d09ba932e17a73f /src/main.c | |
parent | Multi-monitor support (diff) |
Some potentially unnecessary performance optimizations
Keep track of which "layers" are dirty using a bitfield, and only redraw the ones that
are dirty.
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -124,6 +124,8 @@ static void handle_key_event(saver_state_t *state, XKeyEvent *event) password_buf[length + 1] = '\0'; } } + + set_layer_needs_draw(state, LAYER_PASSWORD, true); } static int poll_events(saver_state_t *state) @@ -256,6 +258,7 @@ void callback_prompt_user(const char *prompt, void *context) set_password_prompt(state, prompt); state->input_allowed = true; state->is_processing = false; + set_layer_needs_draw(state, LAYER_PROMPT, true); } void callback_authentication_result(int result, void *context) @@ -281,9 +284,18 @@ static void update(saver_state_t *state) static void draw(saver_state_t *state) { - draw_background(state); - draw_logo(state); + if (layer_needs_draw(state, LAYER_BACKGROUND)) { + draw_background(state, 0, 0, state->canvas_width, state->canvas_height); + } + + if (layer_needs_draw(state, LAYER_LOGO)) { + draw_logo(state); + } + draw_password_field(state); + + // Automatically reset this after every draw call + set_layer_needs_draw(state, LAYER_BACKGROUND, false); } static int runloop(cairo_surface_t *surface) |