diff options
author | Niklas Haas <git@haasn.xyz> | 2021-02-01 19:05:35 +0300 |
---|---|---|
committer | Jean-Baptiste Kempf <jb@videolan.org> | 2021-02-06 12:50:52 +0300 |
commit | eab4ef6a5e191dd0beea066dff532e5776f59bf6 (patch) | |
tree | 46513b57e8c0706cb9c61701a6eb6db5b66545dd /examples | |
parent | 61b654567826d3d9ecf358edcb51e7d0985c4f66 (diff) |
dav1dplay: Only repaint the window when necessary
The current playback loop triggers a repaint on any single event,
including spammy events such as SDL_MOUSEMOTION.
Fix this by only repainting on SDL_WINDOWEVENT_EXPOSED, which is defined
as the event sent when the window was damaged and needs to be repainted,
as well as on new frames.
Fixes https://code.videolan.org/videolan/dav1d/-/issues/356
Diffstat (limited to 'examples')
-rw-r--r-- | examples/dav1dplay.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/dav1dplay.c b/examples/dav1dplay.c index e5379f4..89a2008 100644 --- a/examples/dav1dplay.c +++ b/examples/dav1dplay.c @@ -723,6 +723,8 @@ int main(int argc, char **argv) } else if (e->type == SDL_WINDOWEVENT) { if (e->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) { // TODO: Handle window resizes + } else if(e->window.event == SDL_WINDOWEVENT_EXPOSED) { + dp_rd_ctx_render(rd_ctx); } } else if (e->type == SDL_KEYDOWN) { SDL_KeyboardEvent *kbde = (SDL_KeyboardEvent *)e; @@ -763,14 +765,12 @@ int main(int argc, char **argv) // Do not update textures during termination if (!dp_rd_ctx_should_terminate(rd_ctx)) { dp_rd_ctx_update_with_dav1d_picture(rd_ctx, p); + dp_rd_ctx_render(rd_ctx); n_out++; } destroy_pic(p); num_frame_events--; } - // Do not render during termination - if (!dp_rd_ctx_should_terminate(rd_ctx)) - dp_rd_ctx_render(rd_ctx); } out:; |