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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 int layer_tree_host_id, | 101 int layer_tree_host_id, |
102 RenderingStatsInstrumentation* rendering_stats_instrumentation) | 102 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
103 : layer_tree_host_id(layer_tree_host_id), | 103 : layer_tree_host_id(layer_tree_host_id), |
104 contents_texture_manager(NULL), | 104 contents_texture_manager(NULL), |
105 commit_completion_event(NULL), | 105 commit_completion_event(NULL), |
106 completion_event_for_commit_held_on_tree_activation(NULL), | 106 completion_event_for_commit_held_on_tree_activation(NULL), |
107 next_frame_is_newly_committed_frame(false), | 107 next_frame_is_newly_committed_frame(false), |
108 inside_draw(false), | 108 inside_draw(false), |
109 input_throttled_until_commit(false), | 109 input_throttled_until_commit(false), |
110 animations_frozen_until_next_draw(false), | 110 animations_frozen_until_next_draw(false), |
| 111 did_commit_after_animating(false), |
111 smoothness_priority_expiration_notifier( | 112 smoothness_priority_expiration_notifier( |
112 proxy->ImplThreadTaskRunner(), | 113 proxy->ImplThreadTaskRunner(), |
113 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)), | 114 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)), |
114 base::TimeDelta::FromMilliseconds( | 115 base::TimeDelta::FromMilliseconds( |
115 kSmoothnessTakesPriorityExpirationDelay * 1000)), | 116 kSmoothnessTakesPriorityExpirationDelay * 1000)), |
116 timing_history(rendering_stats_instrumentation), | 117 timing_history(rendering_stats_instrumentation), |
117 weak_factory(proxy) { | 118 weak_factory(proxy) { |
118 } | 119 } |
119 | 120 |
120 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} | 121 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 | 937 |
937 void ThreadProxy::ScheduledActionAnimate() { | 938 void ThreadProxy::ScheduledActionAnimate() { |
938 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate"); | 939 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionAnimate"); |
939 DCHECK(IsImplThread()); | 940 DCHECK(IsImplThread()); |
940 | 941 |
941 if (!impl().animations_frozen_until_next_draw) { | 942 if (!impl().animations_frozen_until_next_draw) { |
942 impl().animation_time = | 943 impl().animation_time = |
943 impl().layer_tree_host_impl->CurrentBeginFrameArgs().frame_time; | 944 impl().layer_tree_host_impl->CurrentBeginFrameArgs().frame_time; |
944 } | 945 } |
945 impl().layer_tree_host_impl->Animate(impl().animation_time); | 946 impl().layer_tree_host_impl->Animate(impl().animation_time); |
| 947 impl().did_commit_after_animating = false; |
946 } | 948 } |
947 | 949 |
948 void ThreadProxy::ScheduledActionCommit() { | 950 void ThreadProxy::ScheduledActionCommit() { |
949 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); | 951 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionCommit"); |
950 DCHECK(IsImplThread()); | 952 DCHECK(IsImplThread()); |
951 DCHECK(IsMainThreadBlocked()); | 953 DCHECK(IsMainThreadBlocked()); |
952 DCHECK(impl().commit_completion_event); | 954 DCHECK(impl().commit_completion_event); |
953 DCHECK(impl().current_resource_update_controller); | 955 DCHECK(impl().current_resource_update_controller); |
954 | 956 |
955 // Complete all remaining texture updates. | 957 // Complete all remaining texture updates. |
956 impl().current_resource_update_controller->Finalize(); | 958 impl().current_resource_update_controller->Finalize(); |
957 impl().current_resource_update_controller = nullptr; | 959 impl().current_resource_update_controller = nullptr; |
958 | 960 |
959 if (impl().animations_frozen_until_next_draw) { | 961 if (impl().animations_frozen_until_next_draw) { |
960 impl().animation_time = std::max( | 962 impl().animation_time = std::max( |
961 impl().animation_time, blocked_main().last_monotonic_frame_begin_time); | 963 impl().animation_time, blocked_main().last_monotonic_frame_begin_time); |
962 } | 964 } |
| 965 impl().did_commit_after_animating = true; |
963 | 966 |
964 blocked_main().main_thread_inside_commit = true; | 967 blocked_main().main_thread_inside_commit = true; |
965 impl().layer_tree_host_impl->BeginCommit(); | 968 impl().layer_tree_host_impl->BeginCommit(); |
966 layer_tree_host()->BeginCommitOnImplThread(impl().layer_tree_host_impl.get()); | 969 layer_tree_host()->BeginCommitOnImplThread(impl().layer_tree_host_impl.get()); |
967 layer_tree_host()->FinishCommitOnImplThread( | 970 layer_tree_host()->FinishCommitOnImplThread( |
968 impl().layer_tree_host_impl.get()); | 971 impl().layer_tree_host_impl.get()); |
969 blocked_main().main_thread_inside_commit = false; | 972 blocked_main().main_thread_inside_commit = false; |
970 | 973 |
971 bool hold_commit = layer_tree_host()->settings().impl_side_painting && | 974 bool hold_commit = layer_tree_host()->settings().impl_side_painting && |
972 blocked_main().commit_waits_for_activation; | 975 blocked_main().commit_waits_for_activation; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { | 1024 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { |
1022 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); | 1025 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); |
1023 DrawResult result; | 1026 DrawResult result; |
1024 | 1027 |
1025 DCHECK(IsImplThread()); | 1028 DCHECK(IsImplThread()); |
1026 DCHECK(impl().layer_tree_host_impl.get()); | 1029 DCHECK(impl().layer_tree_host_impl.get()); |
1027 | 1030 |
1028 impl().timing_history.DidStartDrawing(); | 1031 impl().timing_history.DidStartDrawing(); |
1029 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); | 1032 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); |
1030 | 1033 |
| 1034 if (impl().did_commit_after_animating) { |
| 1035 impl().layer_tree_host_impl->Animate(impl().animation_time); |
| 1036 impl().did_commit_after_animating = false; |
| 1037 } |
| 1038 |
1031 if (impl().layer_tree_host_impl->pending_tree()) | 1039 if (impl().layer_tree_host_impl->pending_tree()) |
1032 impl().layer_tree_host_impl->pending_tree()->UpdateDrawProperties(); | 1040 impl().layer_tree_host_impl->pending_tree()->UpdateDrawProperties(); |
1033 | 1041 |
1034 // This method is called on a forced draw, regardless of whether we are able | 1042 // This method is called on a forced draw, regardless of whether we are able |
1035 // to produce a frame, as the calling site on main thread is blocked until its | 1043 // to produce a frame, as the calling site on main thread is blocked until its |
1036 // request completes, and we signal completion here. If CanDraw() is false, we | 1044 // request completes, and we signal completion here. If CanDraw() is false, we |
1037 // will indicate success=false to the caller, but we must still signal | 1045 // will indicate success=false to the caller, but we must still signal |
1038 // completion to avoid deadlock. | 1046 // completion to avoid deadlock. |
1039 | 1047 |
1040 // We guard PrepareToDraw() with CanDraw() because it always returns a valid | 1048 // We guard PrepareToDraw() with CanDraw() because it always returns a valid |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1386 | 1394 |
1387 impl().timing_history.DidActivateSyncTree(); | 1395 impl().timing_history.DidActivateSyncTree(); |
1388 } | 1396 } |
1389 | 1397 |
1390 void ThreadProxy::DidManageTiles() { | 1398 void ThreadProxy::DidManageTiles() { |
1391 DCHECK(IsImplThread()); | 1399 DCHECK(IsImplThread()); |
1392 impl().scheduler->DidManageTiles(); | 1400 impl().scheduler->DidManageTiles(); |
1393 } | 1401 } |
1394 | 1402 |
1395 } // namespace cc | 1403 } // namespace cc |
OLD | NEW |