OLD | NEW |
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 Loading... |
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; | 384 main().can_cancel_commit = true; |
385 SendCommitRequestToImplThreadIfNeeded(); | 385 SendCommitRequestToImplThreadIfNeeded(); |
386 } | 386 } |
387 | 387 |
388 void ThreadProxy::SetNeedsUpdateLayers() { | 388 void ThreadProxy::SetNeedsUpdateLayers() { |
389 DCHECK(IsMainThread()); | 389 DCHECK(IsMainThread()); |
390 | 390 |
391 if (main().commit_request_sent_to_impl_thread) | 391 if (main().commit_request_sent_to_impl_thread) |
392 return; | 392 return; |
393 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsUpdateLayers"); | 393 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsUpdateLayers"); |
394 | 394 |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 make_scoped_ptr(new ResourceUpdateQueue); | 904 make_scoped_ptr(new ResourceUpdateQueue); |
905 | 905 |
906 bool updated = layer_tree_host()->UpdateLayers(queue.get()); | 906 bool updated = layer_tree_host()->UpdateLayers(queue.get()); |
907 | 907 |
908 // Once single buffered layers are committed, they cannot be modified until | 908 // Once single buffered layers are committed, they cannot be modified until |
909 // they are drawn by the impl thread. | 909 // they are drawn by the impl thread. |
910 main().textures_acquired = false; | 910 main().textures_acquired = false; |
911 | 911 |
912 layer_tree_host()->WillCommit(); | 912 layer_tree_host()->WillCommit(); |
913 | 913 |
| 914 // Before calling animate, we set main().animate_requested to false. If it is |
| 915 // true now, it means SetNeedAnimate was called again, but during a state when |
| 916 // main().commit_request_sent_to_impl_thread = true. We need to force that |
| 917 // call to happen again now so that the commit request is sent to the impl |
| 918 // thread. |
| 919 if (main().animate_requested) { |
| 920 // Forces SetNeedsAnimate to consider posting a commit task. |
| 921 main().animate_requested = false; |
| 922 SetNeedsAnimate(); |
| 923 } |
| 924 |
914 if (!updated && can_cancel_this_commit) { | 925 if (!updated && can_cancel_this_commit) { |
915 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoUpdates", TRACE_EVENT_SCOPE_THREAD); | 926 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoUpdates", TRACE_EVENT_SCOPE_THREAD); |
916 bool did_handle = true; | 927 bool did_handle = true; |
917 Proxy::ImplThreadTaskRunner()->PostTask( | 928 Proxy::ImplThreadTaskRunner()->PostTask( |
918 FROM_HERE, | 929 FROM_HERE, |
919 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, | 930 base::Bind(&ThreadProxy::BeginMainFrameAbortedOnImplThread, |
920 impl_thread_weak_ptr_, | 931 impl_thread_weak_ptr_, |
921 did_handle)); | 932 did_handle)); |
922 | 933 |
923 // Although the commit is internally aborted, this is because it has been | 934 // 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 | 935 // 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. | 936 // went through, and input should no longer be throttled, etc. |
926 layer_tree_host()->CommitComplete(); | 937 layer_tree_host()->CommitComplete(); |
927 layer_tree_host()->DidBeginMainFrame(); | 938 layer_tree_host()->DidBeginMainFrame(); |
928 return; | 939 return; |
929 } | 940 } |
930 | 941 |
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; | 942 scoped_refptr<ContextProvider> offscreen_context_provider; |
944 if (main().renderer_capabilities_main_thread_copy.using_offscreen_context3d && | 943 if (main().renderer_capabilities_main_thread_copy.using_offscreen_context3d && |
945 layer_tree_host()->needs_offscreen_context()) { | 944 layer_tree_host()->needs_offscreen_context()) { |
946 offscreen_context_provider = | 945 offscreen_context_provider = |
947 layer_tree_host()->client()->OffscreenContextProvider(); | 946 layer_tree_host()->client()->OffscreenContextProvider(); |
948 if (offscreen_context_provider.get()) | 947 if (offscreen_context_provider.get()) |
949 main().created_offscreen_context_provider = true; | 948 main().created_offscreen_context_provider = true; |
950 } | 949 } |
951 | 950 |
952 // Notify the impl thread that the main thread is ready to commit. This will | 951 // 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 Loading... |
1733 | 1732 |
1734 impl().timing_history.DidActivatePendingTree(); | 1733 impl().timing_history.DidActivatePendingTree(); |
1735 } | 1734 } |
1736 | 1735 |
1737 void ThreadProxy::DidManageTiles() { | 1736 void ThreadProxy::DidManageTiles() { |
1738 DCHECK(IsImplThread()); | 1737 DCHECK(IsImplThread()); |
1739 impl().scheduler->DidManageTiles(); | 1738 impl().scheduler->DidManageTiles(); |
1740 } | 1739 } |
1741 | 1740 |
1742 } // namespace cc | 1741 } // namespace cc |
OLD | NEW |