diff options
author | Tom <tomut@yahoo.com> | 2021-06-28 17:42:13 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-29 10:03:53 +0200 |
commit | 85bb13e081c5ccedfa2526d1cefdb58b67a99b52 (patch) | |
tree | 746b2149f69bbe753bdd1333225578ffcc718a99 | |
parent | ab88f4e082ac68537ba1a634481ec531450e0e0b (diff) | |
download | serenity-85bb13e081c5ccedfa2526d1cefdb58b67a99b52.zip |
WindowServer: Fix animations not triggering rendering
When starting the first animation and while animations are ongoing we
need to make sure we trigger rendering.
-rw-r--r-- | Userland/Services/WindowServer/Animation.cpp | 1 | ||||
-rw-r--r-- | Userland/Services/WindowServer/Compositor.cpp | 24 | ||||
-rw-r--r-- | Userland/Services/WindowServer/Compositor.h | 1 |
3 files changed, 21 insertions, 5 deletions
diff --git a/Userland/Services/WindowServer/Animation.cpp b/Userland/Services/WindowServer/Animation.cpp index 7ff6197a25..633331c156 100644 --- a/Userland/Services/WindowServer/Animation.cpp +++ b/Userland/Services/WindowServer/Animation.cpp @@ -29,6 +29,7 @@ void Animation::start() { m_running = true; m_timer.start(); + Compositor::the().animation_started({}); } void Animation::stop() diff --git a/Userland/Services/WindowServer/Compositor.cpp b/Userland/Services/WindowServer/Compositor.cpp index ac28b4315b..5ab367ff80 100644 --- a/Userland/Services/WindowServer/Compositor.cpp +++ b/Userland/Services/WindowServer/Compositor.cpp @@ -528,11 +528,16 @@ void Compositor::compose() m_invalidated_window = false; m_invalidated_cursor = false; - Screen::for_each([&](auto& screen) { - auto& screen_data = m_screen_data[screen.index()]; - update_animations(screen, screen_data.m_flush_special_rects); - return IterationDecision::Continue; - }); + if (!m_animations.is_empty()) { + Screen::for_each([&](auto& screen) { + auto& screen_data = m_screen_data[screen.index()]; + update_animations(screen, screen_data.m_flush_special_rects); + return IterationDecision::Continue; + }); + // As long as animations are running make sure we keep rendering frames + m_invalidated_any = true; + start_compose_async_timer(); + } if (need_to_draw_cursor) { auto& screen_data = m_screen_data[cursor_screen.index()]; @@ -1205,8 +1210,17 @@ void Compositor::recompute_occlusions() void Compositor::register_animation(Badge<Animation>, Animation& animation) { + bool was_empty = m_animations.is_empty(); auto result = m_animations.set(&animation); VERIFY(result == AK::HashSetResult::InsertedNewEntry); + if (was_empty) + start_compose_async_timer(); +} + +void Compositor::animation_started(Badge<Animation>) +{ + m_invalidated_any = true; + start_compose_async_timer(); } void Compositor::unregister_animation(Badge<Animation>, Animation& animation) diff --git a/Userland/Services/WindowServer/Compositor.h b/Userland/Services/WindowServer/Compositor.h index 75a046f481..3d9e719cb6 100644 --- a/Userland/Services/WindowServer/Compositor.h +++ b/Userland/Services/WindowServer/Compositor.h @@ -71,6 +71,7 @@ public: invalidate_screen(); } + void animation_started(Badge<Animation>); void invalidate_occlusions() { m_occlusions_dirty = true; } void overlay_rects_changed(); |