Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 33f3b1e

Browse files
committed
[vsync_waiter] add AwaitVSyncForSecondaryCallback()
1 parent ccaae8d commit 33f3b1e

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

shell/common/vsync_waiter.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void VsyncWaiter::ScheduleSecondaryCallback(uintptr_t id,
8787
return;
8888
}
8989
}
90-
AwaitVSync();
90+
AwaitVSyncForSecondaryCallback();
9191
}
9292

9393
void VsyncWaiter::FireCallback(fml::TimePoint frame_start_time,

shell/common/vsync_waiter.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,29 @@ class VsyncWaiter : public std::enable_shared_from_this<VsyncWaiter> {
4242

4343
VsyncWaiter(TaskRunners task_runners);
4444

45+
// There are two distinct situations where VsyncWaiter wishes to awaken at
46+
// the next vsync. Although the functionality can be the same, the intent is
47+
// different, therefore it makes sense to have a method for each intent.
48+
49+
// The intent of AwaitVSync() is that the Animator wishes to produce a frame.
50+
// The underlying implementation can choose to be aware of this intent when
51+
// it comes to implementing backpressure and other scheduling invariants.
52+
//
4553
// Implementations are meant to override this method and arm their vsync
4654
// latches when in response to this invocation. On vsync, they are meant to
4755
// invoke the |FireCallback| method once (and only once) with the appropriate
4856
// arguments. This method should not block the current thread.
4957
virtual void AwaitVSync() = 0;
5058

59+
// The intent of AwaitVSyncForSecondaryCallback() is simply to wake up at the
60+
// next vsync.
61+
//
62+
// Because there is no association with frame scheduling, underlying
63+
// implementations do not need to worry about maintaining invariants or
64+
// backpressure. The default implementation is to simply follow the same logic
65+
// as AwaitVSync().
66+
virtual void AwaitVSyncForSecondaryCallback() { AwaitVSync(); }
67+
5168
void FireCallback(fml::TimePoint frame_start_time,
5269
fml::TimePoint frame_target_time,
5370
bool pause_secondary_tasks = true);

0 commit comments

Comments
 (0)