Skip to content

Commit

Permalink
WindowServer: Fix animations not triggering rendering
Browse files Browse the repository at this point in the history
When starting the first animation and while animations are ongoing we
need to make sure we trigger rendering.
  • Loading branch information
tomuta authored and awesomekling committed Jun 29, 2021
1 parent ab88f4e commit 85bb13e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions Userland/Services/WindowServer/Animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ void Animation::start()
{
m_running = true;
m_timer.start();
Compositor::the().animation_started({});
}

void Animation::stop()
Expand Down
24 changes: 19 additions & 5 deletions Userland/Services/WindowServer/Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()];
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions Userland/Services/WindowServer/Compositor.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class Compositor final : public Core::Object {
invalidate_screen();
}

void animation_started(Badge<Animation>);
void invalidate_occlusions() { m_occlusions_dirty = true; }
void overlay_rects_changed();

Expand Down

0 comments on commit 85bb13e

Please sign in to comment.