Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: cc/trees/thread_proxy.cc

Issue 595973002: Moving background animation ticking from LayerTreeHostImpl into the Scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scheduler-timesource-refactor
Patch Set: ALL TESTS PASS LOCALLY!!!! Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« cc/trees/single_thread_proxy.cc ('K') | « cc/trees/thread_proxy.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/thread_proxy.h" 5 #include "cc/trees/thread_proxy.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 &completion, 169 &completion,
170 visible)); 170 visible));
171 completion.Wait(); 171 completion.Wait();
172 } 172 }
173 173
174 void ThreadProxy::SetVisibleOnImplThread(CompletionEvent* completion, 174 void ThreadProxy::SetVisibleOnImplThread(CompletionEvent* completion,
175 bool visible) { 175 bool visible) {
176 TRACE_EVENT0("cc", "ThreadProxy::SetVisibleOnImplThread"); 176 TRACE_EVENT0("cc", "ThreadProxy::SetVisibleOnImplThread");
177 impl().layer_tree_host_impl->SetVisible(visible); 177 impl().layer_tree_host_impl->SetVisible(visible);
178 impl().scheduler->SetVisible(visible); 178 impl().scheduler->SetVisible(visible);
179 UpdateBackgroundAnimateTicking();
180 completion->Signal(); 179 completion->Signal();
181 } 180 }
182 181
183 void ThreadProxy::UpdateBackgroundAnimateTicking() {
184 bool should_background_tick =
185 !impl().scheduler->WillDrawIfNeeded() &&
186 impl().layer_tree_host_impl->active_tree()->root_layer();
187 impl().layer_tree_host_impl->UpdateBackgroundAnimateTicking(
188 should_background_tick);
189 }
190
191 void ThreadProxy::DidLoseOutputSurface() { 182 void ThreadProxy::DidLoseOutputSurface() {
192 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface"); 183 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface");
193 DCHECK(IsMainThread()); 184 DCHECK(IsMainThread());
194 layer_tree_host()->DidLoseOutputSurface(); 185 layer_tree_host()->DidLoseOutputSurface();
195 186
196 { 187 {
197 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 188 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
198 189
199 // Return lost resources to their owners immediately. 190 // Return lost resources to their owners immediately.
200 BlockingTaskRunner::CapturePostTasks blocked( 191 BlockingTaskRunner::CapturePostTasks blocked(
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 342
352 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { 343 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) {
353 impl().layer_tree_host_impl->WillBeginImplFrame(args); 344 impl().layer_tree_host_impl->WillBeginImplFrame(args);
354 } 345 }
355 346
356 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { 347 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) {
357 TRACE_EVENT1( 348 TRACE_EVENT1(
358 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); 349 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw);
359 DCHECK(IsImplThread()); 350 DCHECK(IsImplThread());
360 impl().scheduler->SetCanDraw(can_draw); 351 impl().scheduler->SetCanDraw(can_draw);
361 UpdateBackgroundAnimateTicking();
362 } 352 }
363 353
364 void ThreadProxy::NotifyReadyToActivate() { 354 void ThreadProxy::NotifyReadyToActivate() {
365 TRACE_EVENT0("cc", "ThreadProxy::NotifyReadyToActivate"); 355 TRACE_EVENT0("cc", "ThreadProxy::NotifyReadyToActivate");
366 impl().scheduler->NotifyReadyToActivate(); 356 impl().scheduler->NotifyReadyToActivate();
367 } 357 }
368 358
369 void ThreadProxy::SetNeedsCommitOnImplThread() { 359 void ThreadProxy::SetNeedsCommitOnImplThread() {
370 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread"); 360 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread");
371 DCHECK(IsImplThread()); 361 DCHECK(IsImplThread());
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 if (did_handle) 916 if (did_handle)
927 SetInputThrottledUntilCommitOnImplThread(false); 917 SetInputThrottledUntilCommitOnImplThread(false);
928 impl().layer_tree_host_impl->BeginMainFrameAborted(did_handle); 918 impl().layer_tree_host_impl->BeginMainFrameAborted(did_handle);
929 impl().scheduler->BeginMainFrameAborted(did_handle); 919 impl().scheduler->BeginMainFrameAborted(did_handle);
930 } 920 }
931 921
932 void ThreadProxy::ScheduledActionAnimate() { 922 void ThreadProxy::ScheduledActionAnimate() {
933 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate"); 923 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate");
934 DCHECK(IsImplThread()); 924 DCHECK(IsImplThread());
935 925
926 // Don't animate if there is no root layer.
927 // TODO(mithro): Both Animate and UpdateAnimationState already have a
928 // "!active_tree_->root_layer()" check?
929 if (!impl().layer_tree_host_impl->active_tree()->root_layer()) {
930 return;
931 }
932
936 impl().animation_time = 933 impl().animation_time =
937 impl().layer_tree_host_impl->CurrentBeginFrameArgs().frame_time; 934 impl().layer_tree_host_impl->CurrentBeginFrameArgs().frame_time;
938 impl().layer_tree_host_impl->Animate(impl().animation_time); 935 impl().layer_tree_host_impl->Animate(impl().animation_time);
936
937 // If animations are not visible, update the state now as
938 // ScheduledActionDrawAndSwapIfPossible will never be called.
939 if (!impl().layer_tree_host_impl->AnimationsAreVisible()) {
brianderson 2014/11/04 18:54:38 Should we make this part of the aborted draw and s
mithro-old 2014/11/04 22:16:50 As far as I can tell, ScheduledActionDrawAndSwapIf
brianderson 2014/11/04 23:32:19 Sure, can you open a bug?
mithro-old 2014/11/05 00:02:36 Will do when this code lands (incase this changes)
940 impl().layer_tree_host_impl->UpdateAnimationState(true);
941 }
939 } 942 }
940 943
941 void ThreadProxy::ScheduledActionCommit() { 944 void ThreadProxy::ScheduledActionCommit() {
942 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); 945 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit");
943 DCHECK(IsImplThread()); 946 DCHECK(IsImplThread());
944 DCHECK(IsMainThreadBlocked()); 947 DCHECK(IsMainThreadBlocked());
945 DCHECK(impl().commit_completion_event); 948 DCHECK(impl().commit_completion_event);
946 DCHECK(impl().current_resource_update_controller); 949 DCHECK(impl().current_resource_update_controller);
947 950
948 // Complete all remaining texture updates. 951 // Complete all remaining texture updates.
(...skipping 23 matching lines...) Expand all
972 impl().commit_completion_event->Signal(); 975 impl().commit_completion_event->Signal();
973 impl().commit_completion_event = NULL; 976 impl().commit_completion_event = NULL;
974 } 977 }
975 978
976 // Delay this step until afer the main thread has been released as it's 979 // Delay this step until afer the main thread has been released as it's
977 // often a good bit of work to update the tree and prepare the new frame. 980 // often a good bit of work to update the tree and prepare the new frame.
978 impl().layer_tree_host_impl->CommitComplete(); 981 impl().layer_tree_host_impl->CommitComplete();
979 982
980 SetInputThrottledUntilCommitOnImplThread(false); 983 SetInputThrottledUntilCommitOnImplThread(false);
981 984
982 UpdateBackgroundAnimateTicking();
983
984 impl().next_frame_is_newly_committed_frame = true; 985 impl().next_frame_is_newly_committed_frame = true;
985 986
986 impl().timing_history.DidCommit(); 987 impl().timing_history.DidCommit();
987 } 988 }
988 989
989 void ThreadProxy::ScheduledActionUpdateVisibleTiles() { 990 void ThreadProxy::ScheduledActionUpdateVisibleTiles() {
990 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionUpdateVisibleTiles"); 991 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionUpdateVisibleTiles");
991 DCHECK(IsImplThread()); 992 DCHECK(IsImplThread());
992 impl().layer_tree_host_impl->UpdateVisibleTiles(); 993 impl().layer_tree_host_impl->UpdateVisibleTiles();
993 } 994 }
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
1351 DCHECK(IsImplThread()); 1352 DCHECK(IsImplThread());
1352 1353
1353 if (impl().completion_event_for_commit_held_on_tree_activation) { 1354 if (impl().completion_event_for_commit_held_on_tree_activation) {
1354 TRACE_EVENT_INSTANT0( 1355 TRACE_EVENT_INSTANT0(
1355 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD); 1356 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD);
1356 DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting); 1357 DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting);
1357 impl().completion_event_for_commit_held_on_tree_activation->Signal(); 1358 impl().completion_event_for_commit_held_on_tree_activation->Signal();
1358 impl().completion_event_for_commit_held_on_tree_activation = NULL; 1359 impl().completion_event_for_commit_held_on_tree_activation = NULL;
1359 } 1360 }
1360 1361
1361 UpdateBackgroundAnimateTicking();
1362
1363 impl().timing_history.DidActivateSyncTree(); 1362 impl().timing_history.DidActivateSyncTree();
1364 } 1363 }
1365 1364
1366 void ThreadProxy::DidManageTiles() { 1365 void ThreadProxy::DidManageTiles() {
1367 DCHECK(IsImplThread()); 1366 DCHECK(IsImplThread());
1368 impl().scheduler->DidManageTiles(); 1367 impl().scheduler->DidManageTiles();
1369 } 1368 }
1370 1369
1371 } // namespace cc 1370 } // namespace cc
OLDNEW
« cc/trees/single_thread_proxy.cc ('K') | « cc/trees/thread_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698