Skip to content

Commit

Permalink
[cleanup] Simplify code that runs presentation callbacks.
Browse files Browse the repository at this point in the history
Directly dispatch the callbacks that need to be run on the
compositor thread in response to a presentation feedback.

BUG=none

Change-Id: I9e451816dd4cccd5dcb2ba2f72fc2e8c591561b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2843952
Commit-Queue: Behdad Bakhshinategh <behdadb@chromium.org>
Auto-Submit: Sadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: Behdad Bakhshinategh <behdadb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#875901}
  • Loading branch information
sadrulhc authored and Chromium LUCI CQ committed Apr 23, 2021
1 parent 72fc8f3 commit f6ed27a
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
7 changes: 2 additions & 5 deletions cc/trees/layer_tree_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4941,14 +4941,11 @@ void LayerTreeHostImpl::SetUkmSmoothnessDestination(

void LayerTreeHostImpl::NotifyDidPresentCompositorFrameOnImplThread(
uint32_t frame_token,
PresentationTimeCallbackBuffer::PendingCallbacks callbacks,
std::vector<LayerTreeHost::PresentationTimeCallback> callbacks,
const viz::FrameTimingDetails& details) {
frame_trackers_.NotifyFramePresented(frame_token,
details.presentation_feedback);
// The callbacks in |compositor_thread_callbacks| expect to be run on the
// compositor thread so we'll run them now.
for (LayerTreeHost::PresentationTimeCallback& callback :
callbacks.compositor_thread_callbacks) {
for (LayerTreeHost::PresentationTimeCallback& callback : callbacks) {
std::move(callback).Run(details.presentation_feedback);
}
}
Expand Down
2 changes: 1 addition & 1 deletion cc/trees/layer_tree_host_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ class CC_EXPORT LayerTreeHostImpl : public TileManagerClient,
// was presented.
void NotifyDidPresentCompositorFrameOnImplThread(
uint32_t frame_token,
PresentationTimeCallbackBuffer::PendingCallbacks callbacks,
std::vector<LayerTreeHost::PresentationTimeCallback> callbacks,
const viz::FrameTimingDetails& details);

CompositorFrameReportingController* compositor_frame_reporting_controller()
Expand Down
4 changes: 2 additions & 2 deletions cc/trees/layer_tree_host_impl_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class LayerTreeHostImplTest : public testing::Test,
const viz::FrameTimingDetails& details) override {
std::move(activated.main_thread_callbacks);
host_impl_->NotifyDidPresentCompositorFrameOnImplThread(
frame_token, std::move(activated), details);
frame_token, std::move(activated.compositor_thread_callbacks), details);
}
void NotifyAnimationWorkletStateChange(AnimationWorkletMutationState state,
ElementListType tree_type) override {}
Expand Down Expand Up @@ -1678,7 +1678,7 @@ class LayerTreeHostImplTestInvokeMainThreadCallbacks
const viz::FrameTimingDetails& details) override {
auto main_thread_callbacks = std::move(activated.main_thread_callbacks);
host_impl_->NotifyDidPresentCompositorFrameOnImplThread(
frame_token, std::move(activated), details);
frame_token, std::move(activated.compositor_thread_callbacks), details);
for (LayerTreeHost::PresentationTimeCallback& callback :
main_thread_callbacks) {
std::move(callback).Run(details.presentation_feedback);
Expand Down
2 changes: 1 addition & 1 deletion cc/trees/proxy_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ void ProxyImpl::DidPresentCompositorFrameOnImplThread(
const viz::FrameTimingDetails& details) {
auto main_thread_callbacks = std::move(activated.main_thread_callbacks);
host_impl_->NotifyDidPresentCompositorFrameOnImplThread(
frame_token, std::move(activated), details);
frame_token, std::move(activated.compositor_thread_callbacks), details);

MainThreadTaskRunner()->PostTask(
FROM_HERE, base::BindOnce(&ProxyMain::DidPresentCompositorFrame,
Expand Down
2 changes: 1 addition & 1 deletion cc/trees/single_thread_proxy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ void SingleThreadProxy::DidPresentCompositorFrameOnImplThread(
std::move(callbacks.main_thread_callbacks);
DebugScopedSetImplThread impl(task_runner_provider_);
host_impl_->NotifyDidPresentCompositorFrameOnImplThread(
frame_token, std::move(callbacks), details);
frame_token, std::move(callbacks.compositor_thread_callbacks), details);
{
DebugScopedSetMainThread main(task_runner_provider_);
layer_tree_host_->DidPresentCompositorFrame(
Expand Down

0 comments on commit f6ed27a

Please sign in to comment.