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