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

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

Issue 68893031: Unifies LayerTreeHost::SetNeedsUpdateLayers and SetNeedsAnimate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: okay let's call it SetNeedsUpdateLayers Created 7 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 | Annotate | Revision Log
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 <string> 7 #include <string>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 LayerTreeHost* layer_tree_host, 55 LayerTreeHost* layer_tree_host,
56 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { 56 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) {
57 return make_scoped_ptr( 57 return make_scoped_ptr(
58 new ThreadProxy(layer_tree_host, impl_task_runner)).PassAs<Proxy>(); 58 new ThreadProxy(layer_tree_host, impl_task_runner)).PassAs<Proxy>();
59 } 59 }
60 60
61 ThreadProxy::ThreadProxy( 61 ThreadProxy::ThreadProxy(
62 LayerTreeHost* layer_tree_host, 62 LayerTreeHost* layer_tree_host,
63 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) 63 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner)
64 : Proxy(impl_task_runner), 64 : Proxy(impl_task_runner),
65 animate_requested_(false), 65 update_requested_(false),
66 commit_requested_(false), 66 commit_requested_(false),
67 commit_request_sent_to_impl_thread_(false), 67 commit_request_sent_to_impl_thread_(false),
68 created_offscreen_context_provider_(false), 68 created_offscreen_context_provider_(false),
69 layer_tree_host_(layer_tree_host), 69 layer_tree_host_(layer_tree_host),
70 started_(false), 70 started_(false),
71 textures_acquired_(true), 71 textures_acquired_(true),
72 in_composite_and_readback_(false), 72 in_composite_and_readback_(false),
73 manage_tiles_pending_(false), 73 manage_tiles_pending_(false),
74 commit_waits_for_activation_(false), 74 commit_waits_for_activation_(false),
75 inside_commit_(false), 75 inside_commit_(false),
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 base::Bind(&ThreadProxy::SetNeedsCommitOnImplThread, 323 base::Bind(&ThreadProxy::SetNeedsCommitOnImplThread,
324 impl_thread_weak_ptr_)); 324 impl_thread_weak_ptr_));
325 } 325 }
326 326
327 const RendererCapabilities& ThreadProxy::GetRendererCapabilities() const { 327 const RendererCapabilities& ThreadProxy::GetRendererCapabilities() const {
328 DCHECK(IsMainThread()); 328 DCHECK(IsMainThread());
329 DCHECK(!layer_tree_host_->output_surface_lost()); 329 DCHECK(!layer_tree_host_->output_surface_lost());
330 return renderer_capabilities_main_thread_copy_; 330 return renderer_capabilities_main_thread_copy_;
331 } 331 }
332 332
333 void ThreadProxy::SetNeedsAnimate() {
334 DCHECK(IsMainThread());
335 if (animate_requested_)
336 return;
337
338 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsAnimate");
339 animate_requested_ = true;
340 can_cancel_commit_ = false;
341 SendCommitRequestToImplThreadIfNeeded();
342 }
343
344 void ThreadProxy::SetNeedsUpdateLayers() { 333 void ThreadProxy::SetNeedsUpdateLayers() {
345 DCHECK(IsMainThread()); 334 DCHECK(IsMainThread());
346 335 if (update_requested_)
347 if (commit_request_sent_to_impl_thread_)
348 return; 336 return;
349 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsUpdateLayers"); 337 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsUpdateLayers");
350 338 update_requested_ = true;
351 SendCommitRequestToImplThreadIfNeeded(); 339 SendCommitRequestToImplThreadIfNeeded();
352 } 340 }
353 341
354 void ThreadProxy::SetNeedsCommit() { 342 void ThreadProxy::SetNeedsCommit() {
355 DCHECK(IsMainThread()); 343 DCHECK(IsMainThread());
356 // Unconditionally set here to handle SetNeedsCommit calls during a commit. 344 // Unconditionally set here to handle SetNeedsCommit calls during a commit.
357 can_cancel_commit_ = false; 345 can_cancel_commit_ = false;
358 346
359 if (commit_requested_) 347 if (commit_requested_)
360 return; 348 return;
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 } 719 }
732 720
733 // Do not notify the impl thread of commit requests that occur during 721 // Do not notify the impl thread of commit requests that occur during
734 // the apply/animate/layout part of the BeginMainFrameAndCommit process since 722 // the apply/animate/layout part of the BeginMainFrameAndCommit process since
735 // those commit requests will get painted immediately. Once we have done 723 // those commit requests will get painted immediately. Once we have done
736 // the paint, commit_requested_ will be set to false to allow new commit 724 // the paint, commit_requested_ will be set to false to allow new commit
737 // requests to be scheduled. 725 // requests to be scheduled.
738 commit_requested_ = true; 726 commit_requested_ = true;
739 commit_request_sent_to_impl_thread_ = true; 727 commit_request_sent_to_impl_thread_ = true;
740 728
741 // On the other hand, the AnimationRequested flag needs to be cleared 729 // On the other hand, the update_requested_ flag needs to be cleared
742 // here so that any animation requests generated by the apply or animate 730 // here so that any update requests generated by the apply or animate
743 // callbacks will trigger another frame. 731 // callbacks will trigger another frame.
744 animate_requested_ = false; 732 update_requested_ = false;
745 733
746 if (!in_composite_and_readback_ && !layer_tree_host_->visible()) { 734 if (!in_composite_and_readback_ && !layer_tree_host_->visible()) {
747 commit_requested_ = false; 735 commit_requested_ = false;
748 commit_request_sent_to_impl_thread_ = false; 736 commit_request_sent_to_impl_thread_ = false;
749 737
750 TRACE_EVENT0("cc", "EarlyOut_NotVisible"); 738 TRACE_EVENT0("cc", "EarlyOut_NotVisible");
751 bool did_handle = false; 739 bool did_handle = false;
752 Proxy::ImplThreadTaskRunner()->PostTask( 740 Proxy::ImplThreadTaskRunner()->PostTask(
753 FROM_HERE, 741 FROM_HERE,
754 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, 742 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 make_scoped_ptr(new ResourceUpdateQueue); 796 make_scoped_ptr(new ResourceUpdateQueue);
809 797
810 bool updated = layer_tree_host_->UpdateLayers(queue.get()); 798 bool updated = layer_tree_host_->UpdateLayers(queue.get());
811 799
812 // Once single buffered layers are committed, they cannot be modified until 800 // Once single buffered layers are committed, they cannot be modified until
813 // they are drawn by the impl thread. 801 // they are drawn by the impl thread.
814 textures_acquired_ = false; 802 textures_acquired_ = false;
815 803
816 layer_tree_host_->WillCommit(); 804 layer_tree_host_->WillCommit();
817 805
806 // Before calling animate, we set update_requested_ to false. If it is true
807 // now, it means SetNeedsUpdateLayers was called again, but during a state
808 // when commit_request_sent_to_impl_thread_ = true. We need to force that call
809 // to happen again now so that the commit request is sent to the impl thread.
810 if (update_requested_) {
811 // Forces SetNeedsUpdateLayers to consider posting a commit task.
812 update_requested_ = false;
813 SetNeedsUpdateLayers();
814 }
815
818 if (!updated && can_cancel_this_commit) { 816 if (!updated && can_cancel_this_commit) {
819 TRACE_EVENT0("cc", "EarlyOut_NoUpdates"); 817 TRACE_EVENT0("cc", "EarlyOut_NoUpdates");
820 bool did_handle = true; 818 bool did_handle = true;
821 Proxy::ImplThreadTaskRunner()->PostTask( 819 Proxy::ImplThreadTaskRunner()->PostTask(
822 FROM_HERE, 820 FROM_HERE,
823 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, 821 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread,
824 impl_thread_weak_ptr_, 822 impl_thread_weak_ptr_,
825 did_handle)); 823 did_handle));
826 824
827 // Although the commit is internally aborted, this is because it has been 825 // Although the commit is internally aborted, this is because it has been
828 // detected to be a no-op. From the perspective of an embedder, this commit 826 // detected to be a no-op. From the perspective of an embedder, this commit
829 // went through, and input should no longer be throttled, etc. 827 // went through, and input should no longer be throttled, etc.
830 layer_tree_host_->CommitComplete(); 828 layer_tree_host_->CommitComplete();
831 layer_tree_host_->DidBeginMainFrame(); 829 layer_tree_host_->DidBeginMainFrame();
832 return; 830 return;
833 } 831 }
834 832
835 // Before calling animate, we set animate_requested_ to false. If it is true
836 // now, it means SetNeedAnimate was called again, but during a state when
837 // commit_request_sent_to_impl_thread_ = true. We need to force that call to
838 // happen again now so that the commit request is sent to the impl thread.
839 if (animate_requested_) {
840 // Forces SetNeedsAnimate to consider posting a commit task.
841 animate_requested_ = false;
842 SetNeedsAnimate();
843 }
844
845 scoped_refptr<cc::ContextProvider> offscreen_context_provider; 833 scoped_refptr<cc::ContextProvider> offscreen_context_provider;
846 if (renderer_capabilities_main_thread_copy_.using_offscreen_context3d && 834 if (renderer_capabilities_main_thread_copy_.using_offscreen_context3d &&
847 layer_tree_host_->needs_offscreen_context()) { 835 layer_tree_host_->needs_offscreen_context()) {
848 offscreen_context_provider = 836 offscreen_context_provider =
849 layer_tree_host_->client()->OffscreenContextProvider(); 837 layer_tree_host_->client()->OffscreenContextProvider();
850 if (offscreen_context_provider.get()) 838 if (offscreen_context_provider.get())
851 created_offscreen_context_provider_ = true; 839 created_offscreen_context_provider_ = true;
852 } 840 }
853 841
854 // Notify the impl thread that the main thread is ready to commit. This will 842 // Notify the impl thread that the main thread is ready to commit. This will
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
1590 commit_to_activate_duration_history_.InsertSample( 1578 commit_to_activate_duration_history_.InsertSample(
1591 base::TimeTicks::HighResNow() - commit_complete_time_); 1579 base::TimeTicks::HighResNow() - commit_complete_time_);
1592 } 1580 }
1593 1581
1594 void ThreadProxy::DidManageTiles() { 1582 void ThreadProxy::DidManageTiles() {
1595 DCHECK(IsImplThread()); 1583 DCHECK(IsImplThread());
1596 scheduler_on_impl_thread_->DidManageTiles(); 1584 scheduler_on_impl_thread_->DidManageTiles();
1597 } 1585 }
1598 1586
1599 } // namespace cc 1587 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698