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

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

Issue 178123003: Make it possible to cancel commits following an animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Made test less strict. Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « cc/trees/layer_tree_host_unittest_animation.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/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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 return main().renderer_capabilities_main_thread_copy; 374 return main().renderer_capabilities_main_thread_copy;
375 } 375 }
376 376
377 void ThreadProxy::SetNeedsAnimate() { 377 void ThreadProxy::SetNeedsAnimate() {
378 DCHECK(IsMainThread()); 378 DCHECK(IsMainThread());
379 if (main().animate_requested) 379 if (main().animate_requested)
380 return; 380 return;
381 381
382 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsAnimate"); 382 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsAnimate");
383 main().animate_requested = true; 383 main().animate_requested = true;
384 main().can_cancel_commit = false;
385 SendCommitRequestToImplThreadIfNeeded(); 384 SendCommitRequestToImplThreadIfNeeded();
386 } 385 }
387 386
388 void ThreadProxy::SetNeedsUpdateLayers() { 387 void ThreadProxy::SetNeedsUpdateLayers() {
389 DCHECK(IsMainThread()); 388 DCHECK(IsMainThread());
390 389
391 if (main().commit_request_sent_to_impl_thread) 390 if (main().commit_request_sent_to_impl_thread)
392 return; 391 return;
393 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsUpdateLayers"); 392 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsUpdateLayers");
394 393
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 make_scoped_ptr(new ResourceUpdateQueue); 903 make_scoped_ptr(new ResourceUpdateQueue);
905 904
906 bool updated = layer_tree_host()->UpdateLayers(queue.get()); 905 bool updated = layer_tree_host()->UpdateLayers(queue.get());
907 906
908 // Once single buffered layers are committed, they cannot be modified until 907 // Once single buffered layers are committed, they cannot be modified until
909 // they are drawn by the impl thread. 908 // they are drawn by the impl thread.
910 main().textures_acquired = false; 909 main().textures_acquired = false;
911 910
912 layer_tree_host()->WillCommit(); 911 layer_tree_host()->WillCommit();
913 912
913 // Before calling animate, we set main().animate_requested to false. If it is
914 // true now, it means SetNeedAnimate was called again, but during a state when
915 // main().commit_request_sent_to_impl_thread = true. We need to force that
916 // call to happen again now so that the commit request is sent to the impl
917 // thread.
918 if (main().animate_requested) {
919 // Forces SetNeedsAnimate to consider posting a commit task.
920 main().animate_requested = false;
921 SetNeedsAnimate();
922 }
923
914 if (!updated && can_cancel_this_commit) { 924 if (!updated && can_cancel_this_commit) {
915 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoUpdates", TRACE_EVENT_SCOPE_THREAD); 925 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoUpdates", TRACE_EVENT_SCOPE_THREAD);
916 bool did_handle = true; 926 bool did_handle = true;
917 Proxy::ImplThreadTaskRunner()->PostTask( 927 Proxy::ImplThreadTaskRunner()->PostTask(
918 FROM_HERE, 928 FROM_HERE,
919 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, 929 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread,
920 impl_thread_weak_ptr_, 930 impl_thread_weak_ptr_,
921 did_handle)); 931 did_handle));
922 932
923 // Although the commit is internally aborted, this is because it has been 933 // Although the commit is internally aborted, this is because it has been
924 // detected to be a no-op. From the perspective of an embedder, this commit 934 // detected to be a no-op. From the perspective of an embedder, this commit
925 // went through, and input should no longer be throttled, etc. 935 // went through, and input should no longer be throttled, etc.
926 layer_tree_host()->CommitComplete(); 936 layer_tree_host()->CommitComplete();
927 layer_tree_host()->DidBeginMainFrame(); 937 layer_tree_host()->DidBeginMainFrame();
928 return; 938 return;
929 } 939 }
930 940
931 // Before calling animate, we set main().animate_requested to false. If it is
932 // true
933 // now, it means SetNeedAnimate was called again, but during a state when
934 // main().commit_request_sent_to_impl_thread = true. We need to force that
935 // call to
936 // happen again now so that the commit request is sent to the impl thread.
937 if (main().animate_requested) {
938 // Forces SetNeedsAnimate to consider posting a commit task.
939 main().animate_requested = false;
940 SetNeedsAnimate();
941 }
942
943 scoped_refptr<ContextProvider> offscreen_context_provider; 941 scoped_refptr<ContextProvider> offscreen_context_provider;
944 if (main().renderer_capabilities_main_thread_copy.using_offscreen_context3d && 942 if (main().renderer_capabilities_main_thread_copy.using_offscreen_context3d &&
945 layer_tree_host()->needs_offscreen_context()) { 943 layer_tree_host()->needs_offscreen_context()) {
946 offscreen_context_provider = 944 offscreen_context_provider =
947 layer_tree_host()->client()->OffscreenContextProvider(); 945 layer_tree_host()->client()->OffscreenContextProvider();
948 if (offscreen_context_provider.get()) 946 if (offscreen_context_provider.get())
949 main().created_offscreen_context_provider = true; 947 main().created_offscreen_context_provider = true;
950 } 948 }
951 949
952 // Notify the impl thread that the main thread is ready to commit. This will 950 // Notify the impl thread that the main thread is ready to commit. This will
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
1733 1731
1734 impl().timing_history.DidActivatePendingTree(); 1732 impl().timing_history.DidActivatePendingTree();
1735 } 1733 }
1736 1734
1737 void ThreadProxy::DidManageTiles() { 1735 void ThreadProxy::DidManageTiles() {
1738 DCHECK(IsImplThread()); 1736 DCHECK(IsImplThread());
1739 impl().scheduler->DidManageTiles(); 1737 impl().scheduler->DidManageTiles();
1740 } 1738 }
1741 1739
1742 } // namespace cc 1740 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest_animation.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698