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

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

Issue 2314323003: cc: Remove ScopedTrackers in SingleThreadProxy. (Closed)
Patch Set: scopedtrackers: rebase Created 4 years, 3 months 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
« no previous file with comments | « cc/scheduler/scheduler.cc ('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/single_thread_proxy.h" 5 #include "cc/trees/single_thread_proxy.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/profiler/scoped_tracker.h" 9 #include "base/profiler/scoped_tracker.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 void SingleThreadProxy::SetNeedsUpdateLayers() { 181 void SingleThreadProxy::SetNeedsUpdateLayers() {
182 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); 182 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers");
183 DCHECK(task_runner_provider_->IsMainThread()); 183 DCHECK(task_runner_provider_->IsMainThread());
184 SetNeedsCommit(); 184 SetNeedsCommit();
185 } 185 }
186 186
187 void SingleThreadProxy::DoCommit() { 187 void SingleThreadProxy::DoCommit() {
188 TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit"); 188 TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit");
189 DCHECK(task_runner_provider_->IsMainThread()); 189 DCHECK(task_runner_provider_->IsMainThread());
190 190
191 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 is
192 // fixed.
193 tracked_objects::ScopedTracker tracking_profile1(
194 FROM_HERE_WITH_EXPLICIT_FUNCTION("461509 SingleThreadProxy::DoCommit1"));
195 layer_tree_host_->WillCommit(); 191 layer_tree_host_->WillCommit();
196 devtools_instrumentation::ScopedCommitTrace commit_task( 192 devtools_instrumentation::ScopedCommitTrace commit_task(
197 layer_tree_host_->id()); 193 layer_tree_host_->id());
198 194
199 // Commit immediately. 195 // Commit immediately.
200 { 196 {
201 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
202 // is fixed.
203 tracked_objects::ScopedTracker tracking_profile2(
204 FROM_HERE_WITH_EXPLICIT_FUNCTION(
205 "461509 SingleThreadProxy::DoCommit2"));
206 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); 197 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_);
207 DebugScopedSetImplThread impl(task_runner_provider_); 198 DebugScopedSetImplThread impl(task_runner_provider_);
208 199
209 // This CapturePostTasks should be destroyed before CommitComplete() is 200 // This CapturePostTasks should be destroyed before CommitComplete() is
210 // called since that goes out to the embedder, and we want the embedder 201 // called since that goes out to the embedder, and we want the embedder
211 // to receive its callbacks before that. 202 // to receive its callbacks before that.
212 commit_blocking_task_runner_.reset(new BlockingTaskRunner::CapturePostTasks( 203 commit_blocking_task_runner_.reset(new BlockingTaskRunner::CapturePostTasks(
213 task_runner_provider_->blocking_main_thread_task_runner())); 204 task_runner_provider_->blocking_main_thread_task_runner()));
214 205
215 layer_tree_host_impl_->ReadyToCommit(); 206 layer_tree_host_impl_->ReadyToCommit();
216 layer_tree_host_impl_->BeginCommit(); 207 layer_tree_host_impl_->BeginCommit();
217 208
218 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
219 // is fixed.
220 tracked_objects::ScopedTracker tracking_profile6(
221 FROM_HERE_WITH_EXPLICIT_FUNCTION(
222 "461509 SingleThreadProxy::DoCommit6"));
223 if (layer_tree_host_impl_->EvictedUIResourcesExist()) 209 if (layer_tree_host_impl_->EvictedUIResourcesExist())
224 layer_tree_host_->RecreateUIResources(); 210 layer_tree_host_->RecreateUIResources();
225 211
226 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
227 // is fixed.
228 tracked_objects::ScopedTracker tracking_profile7(
229 FROM_HERE_WITH_EXPLICIT_FUNCTION(
230 "461509 SingleThreadProxy::DoCommit7"));
231 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); 212 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get());
232 213
233 if (scheduler_on_impl_thread_) 214 if (scheduler_on_impl_thread_)
234 scheduler_on_impl_thread_->DidCommit(); 215 scheduler_on_impl_thread_->DidCommit();
235 216
236 layer_tree_host_impl_->CommitComplete(); 217 layer_tree_host_impl_->CommitComplete();
237 218
238 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
239 // is fixed.
240 tracked_objects::ScopedTracker tracking_profile8(
241 FROM_HERE_WITH_EXPLICIT_FUNCTION(
242 "461509 SingleThreadProxy::DoCommit8"));
243 // Commit goes directly to the active tree, but we need to synchronously 219 // Commit goes directly to the active tree, but we need to synchronously
244 // "activate" the tree still during commit to satisfy any potential 220 // "activate" the tree still during commit to satisfy any potential
245 // SetNextCommitWaitsForActivation calls. Unfortunately, the tree 221 // SetNextCommitWaitsForActivation calls. Unfortunately, the tree
246 // might not be ready to draw, so DidActivateSyncTree must set 222 // might not be ready to draw, so DidActivateSyncTree must set
247 // the flag to force the tree to not draw until textures are ready. 223 // the flag to force the tree to not draw until textures are ready.
248 NotifyReadyToActivate(); 224 NotifyReadyToActivate();
249 } 225 }
250 } 226 }
251 227
252 void SingleThreadProxy::CommitComplete() { 228 void SingleThreadProxy::CommitComplete() {
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 544
569 DrawResult SingleThreadProxy::DoComposite(LayerTreeHostImpl::FrameData* frame) { 545 DrawResult SingleThreadProxy::DoComposite(LayerTreeHostImpl::FrameData* frame) {
570 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite"); 546 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite");
571 547
572 DrawResult draw_result; 548 DrawResult draw_result;
573 bool draw_frame; 549 bool draw_frame;
574 { 550 {
575 DebugScopedSetImplThread impl(task_runner_provider_); 551 DebugScopedSetImplThread impl(task_runner_provider_);
576 base::AutoReset<bool> mark_inside(&inside_draw_, true); 552 base::AutoReset<bool> mark_inside(&inside_draw_, true);
577 553
578 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
579 // is fixed.
580 tracked_objects::ScopedTracker tracking_profile1(
581 FROM_HERE_WITH_EXPLICIT_FUNCTION(
582 "461509 SingleThreadProxy::DoComposite1"));
583
584 // We guard PrepareToDraw() with CanDraw() because it always returns a valid 554 // We guard PrepareToDraw() with CanDraw() because it always returns a valid
585 // frame, so can only be used when such a frame is possible. Since 555 // frame, so can only be used when such a frame is possible. Since
586 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on 556 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on
587 // CanDraw() as well. 557 // CanDraw() as well.
588 if (!ShouldComposite()) { 558 if (!ShouldComposite()) {
589 return DRAW_ABORTED_CANT_DRAW; 559 return DRAW_ABORTED_CANT_DRAW;
590 } 560 }
591 561
592 // This CapturePostTasks should be destroyed before 562 // This CapturePostTasks should be destroyed before
593 // DidCommitAndDrawFrame() is called since that goes out to the 563 // DidCommitAndDrawFrame() is called since that goes out to the
594 // embedder, and we want the embedder to receive its callbacks before that. 564 // embedder, and we want the embedder to receive its callbacks before that.
595 // NOTE: This maintains consistent ordering with the ThreadProxy since 565 // NOTE: This maintains consistent ordering with the ThreadProxy since
596 // the DidCommitAndDrawFrame() must be post-tasked from the impl thread 566 // the DidCommitAndDrawFrame() must be post-tasked from the impl thread
597 // there as the main thread is not blocked, so any posted tasks inside 567 // there as the main thread is not blocked, so any posted tasks inside
598 // the swap buffers will execute first. 568 // the swap buffers will execute first.
599 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); 569 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_);
600 BlockingTaskRunner::CapturePostTasks blocked( 570 BlockingTaskRunner::CapturePostTasks blocked(
601 task_runner_provider_->blocking_main_thread_task_runner()); 571 task_runner_provider_->blocking_main_thread_task_runner());
602 572
603 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
604 // is fixed.
605 tracked_objects::ScopedTracker tracking_profile2(
606 FROM_HERE_WITH_EXPLICIT_FUNCTION(
607 "461509 SingleThreadProxy::DoComposite2"));
608 draw_result = layer_tree_host_impl_->PrepareToDraw(frame); 573 draw_result = layer_tree_host_impl_->PrepareToDraw(frame);
609 draw_frame = draw_result == DRAW_SUCCESS; 574 draw_frame = draw_result == DRAW_SUCCESS;
610 if (draw_frame) { 575 if (draw_frame) {
611 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
612 // is fixed.
613 tracked_objects::ScopedTracker tracking_profile3(
614 FROM_HERE_WITH_EXPLICIT_FUNCTION(
615 "461509 SingleThreadProxy::DoComposite3"));
616 layer_tree_host_impl_->DrawLayers(frame); 576 layer_tree_host_impl_->DrawLayers(frame);
617
618 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
619 // is fixed.
620 tracked_objects::ScopedTracker tracking_profile8(
621 FROM_HERE_WITH_EXPLICIT_FUNCTION(
622 "461509 SingleThreadProxy::DoComposite8"));
623 if (layer_tree_host_impl_->SwapBuffers(*frame)) { 577 if (layer_tree_host_impl_->SwapBuffers(*frame)) {
624 if (scheduler_on_impl_thread_) 578 if (scheduler_on_impl_thread_)
625 scheduler_on_impl_thread_->DidSwapBuffers(); 579 scheduler_on_impl_thread_->DidSwapBuffers();
626 client_->DidPostSwapBuffers(); 580 client_->DidPostSwapBuffers();
627 } 581 }
628 } 582 }
629
630 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
631 // is fixed.
632 tracked_objects::ScopedTracker tracking_profile4(
633 FROM_HERE_WITH_EXPLICIT_FUNCTION(
634 "461509 SingleThreadProxy::DoComposite4"));
635 layer_tree_host_impl_->DidDrawAllLayers(*frame); 583 layer_tree_host_impl_->DidDrawAllLayers(*frame);
636 584
637 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
638 // is fixed.
639 tracked_objects::ScopedTracker tracking_profile5(
640 FROM_HERE_WITH_EXPLICIT_FUNCTION(
641 "461509 SingleThreadProxy::DoComposite5"));
642 bool start_ready_animations = draw_frame; 585 bool start_ready_animations = draw_frame;
643 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); 586 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
644 } 587 }
645 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 is
646 // fixed.
647 tracked_objects::ScopedTracker tracking_profile9(
648 FROM_HERE_WITH_EXPLICIT_FUNCTION(
649 "461509 SingleThreadProxy::DoComposite9"));
650 DidCommitAndDrawFrame(); 588 DidCommitAndDrawFrame();
651 589
652 return draw_result; 590 return draw_result;
653 } 591 }
654 592
655 void SingleThreadProxy::DidCommitAndDrawFrame() { 593 void SingleThreadProxy::DidCommitAndDrawFrame() {
656 if (next_frame_is_newly_committed_frame_) { 594 if (next_frame_is_newly_committed_frame_) {
657 DebugScopedSetMainThread main(task_runner_provider_); 595 DebugScopedSetMainThread main(task_runner_provider_);
658 next_frame_is_newly_committed_frame_ = false; 596 next_frame_is_newly_committed_frame_ = false;
659 layer_tree_host_->DidCommitAndDrawFrame(); 597 layer_tree_host_->DidCommitAndDrawFrame();
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 void SingleThreadProxy::DidFinishImplFrame() { 767 void SingleThreadProxy::DidFinishImplFrame() {
830 layer_tree_host_impl_->DidFinishImplFrame(); 768 layer_tree_host_impl_->DidFinishImplFrame();
831 #if DCHECK_IS_ON() 769 #if DCHECK_IS_ON()
832 DCHECK(inside_impl_frame_) 770 DCHECK(inside_impl_frame_)
833 << "DidFinishImplFrame called while not inside an impl frame!"; 771 << "DidFinishImplFrame called while not inside an impl frame!";
834 inside_impl_frame_ = false; 772 inside_impl_frame_ = false;
835 #endif 773 #endif
836 } 774 }
837 775
838 } // namespace cc 776 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698