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" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
13 #include "base/debug/trace_event_synthetic_delay.h" | 13 #include "base/debug/trace_event_synthetic_delay.h" |
14 #include "base/metrics/histogram.h" | |
15 #include "cc/base/swap_promise.h" | 14 #include "cc/base/swap_promise.h" |
16 #include "cc/debug/benchmark_instrumentation.h" | 15 #include "cc/debug/benchmark_instrumentation.h" |
17 #include "cc/debug/devtools_instrumentation.h" | 16 #include "cc/debug/devtools_instrumentation.h" |
18 #include "cc/input/input_handler.h" | 17 #include "cc/input/input_handler.h" |
19 #include "cc/output/context_provider.h" | 18 #include "cc/output/context_provider.h" |
20 #include "cc/output/output_surface.h" | 19 #include "cc/output/output_surface.h" |
21 #include "cc/quads/draw_quad.h" | 20 #include "cc/quads/draw_quad.h" |
22 #include "cc/resources/prioritized_resource_manager.h" | 21 #include "cc/resources/prioritized_resource_manager.h" |
23 #include "cc/scheduler/delay_based_time_source.h" | 22 #include "cc/scheduler/delay_based_time_source.h" |
24 #include "cc/scheduler/scheduler.h" | 23 #include "cc/scheduler/scheduler.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 impl_task_runner)).PassAs<Proxy>(); | 70 impl_task_runner)).PassAs<Proxy>(); |
72 } | 71 } |
73 | 72 |
74 ThreadProxy::ThreadProxy( | 73 ThreadProxy::ThreadProxy( |
75 LayerTreeHost* layer_tree_host, | 74 LayerTreeHost* layer_tree_host, |
76 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 75 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
77 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) | 76 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) |
78 : Proxy(main_task_runner, impl_task_runner), | 77 : Proxy(main_task_runner, impl_task_runner), |
79 main_thread_only_vars_unsafe_(this, layer_tree_host->id()), | 78 main_thread_only_vars_unsafe_(this, layer_tree_host->id()), |
80 main_thread_or_blocked_vars_unsafe_(layer_tree_host), | 79 main_thread_or_blocked_vars_unsafe_(layer_tree_host), |
81 compositor_thread_vars_unsafe_(this, layer_tree_host->id()) { | 80 compositor_thread_vars_unsafe_( |
| 81 this, |
| 82 layer_tree_host->id(), |
| 83 layer_tree_host->rendering_stats_instrumentation()) { |
82 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); | 84 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); |
83 DCHECK(IsMainThread()); | 85 DCHECK(IsMainThread()); |
84 DCHECK(this->layer_tree_host()); | 86 DCHECK(this->layer_tree_host()); |
85 } | 87 } |
86 | 88 |
87 ThreadProxy::MainThreadOnly::MainThreadOnly(ThreadProxy* proxy, | 89 ThreadProxy::MainThreadOnly::MainThreadOnly(ThreadProxy* proxy, |
88 int layer_tree_host_id) | 90 int layer_tree_host_id) |
89 : layer_tree_host_id(layer_tree_host_id), | 91 : layer_tree_host_id(layer_tree_host_id), |
90 animate_requested(false), | 92 animate_requested(false), |
91 commit_requested(false), | 93 commit_requested(false), |
(...skipping 12 matching lines...) Expand all Loading... |
104 commit_waits_for_activation(false), | 106 commit_waits_for_activation(false), |
105 main_thread_inside_commit(false) {} | 107 main_thread_inside_commit(false) {} |
106 | 108 |
107 ThreadProxy::MainThreadOrBlockedMainThread::~MainThreadOrBlockedMainThread() {} | 109 ThreadProxy::MainThreadOrBlockedMainThread::~MainThreadOrBlockedMainThread() {} |
108 | 110 |
109 PrioritizedResourceManager* | 111 PrioritizedResourceManager* |
110 ThreadProxy::MainThreadOrBlockedMainThread::contents_texture_manager() { | 112 ThreadProxy::MainThreadOrBlockedMainThread::contents_texture_manager() { |
111 return layer_tree_host->contents_texture_manager(); | 113 return layer_tree_host->contents_texture_manager(); |
112 } | 114 } |
113 | 115 |
114 ThreadProxy::CompositorThreadOnly::CompositorThreadOnly(ThreadProxy* proxy, | 116 ThreadProxy::CompositorThreadOnly::CompositorThreadOnly( |
115 int layer_tree_host_id) | 117 ThreadProxy* proxy, |
| 118 int layer_tree_host_id, |
| 119 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
116 : layer_tree_host_id(layer_tree_host_id), | 120 : layer_tree_host_id(layer_tree_host_id), |
117 contents_texture_manager(NULL), | 121 contents_texture_manager(NULL), |
118 commit_completion_event(NULL), | 122 commit_completion_event(NULL), |
119 completion_event_for_commit_held_on_tree_activation(NULL), | 123 completion_event_for_commit_held_on_tree_activation(NULL), |
120 next_frame_is_newly_committed_frame(false), | 124 next_frame_is_newly_committed_frame(false), |
121 inside_draw(false), | 125 inside_draw(false), |
122 input_throttled_until_commit(false), | 126 input_throttled_until_commit(false), |
123 animations_frozen_until_next_draw(false), | 127 animations_frozen_until_next_draw(false), |
124 did_commit_after_animating(false), | 128 did_commit_after_animating(false), |
125 smoothness_priority_expiration_notifier( | 129 smoothness_priority_expiration_notifier( |
126 proxy->ImplThreadTaskRunner(), | 130 proxy->ImplThreadTaskRunner(), |
127 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)), | 131 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)), |
128 base::TimeDelta::FromMilliseconds( | 132 base::TimeDelta::FromMilliseconds( |
129 kSmoothnessTakesPriorityExpirationDelay * 1000)), | 133 kSmoothnessTakesPriorityExpirationDelay * 1000)), |
| 134 timing_history(rendering_stats_instrumentation), |
130 weak_factory(proxy) { | 135 weak_factory(proxy) { |
131 } | 136 } |
132 | 137 |
133 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} | 138 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} |
134 | 139 |
135 ThreadProxy::~ThreadProxy() { | 140 ThreadProxy::~ThreadProxy() { |
136 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); | 141 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); |
137 DCHECK(IsMainThread()); | 142 DCHECK(IsMainThread()); |
138 DCHECK(!main().started); | 143 DCHECK(!main().started); |
139 } | 144 } |
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 } | 1051 } |
1047 | 1052 |
1048 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { | 1053 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { |
1049 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); | 1054 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); |
1050 DrawResult result; | 1055 DrawResult result; |
1051 | 1056 |
1052 DCHECK(IsImplThread()); | 1057 DCHECK(IsImplThread()); |
1053 DCHECK(impl().layer_tree_host_impl.get()); | 1058 DCHECK(impl().layer_tree_host_impl.get()); |
1054 | 1059 |
1055 impl().timing_history.DidStartDrawing(); | 1060 impl().timing_history.DidStartDrawing(); |
1056 base::TimeDelta draw_duration_estimate = DrawDurationEstimate(); | |
1057 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); | 1061 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); |
1058 | 1062 |
1059 if (impl().did_commit_after_animating) { | 1063 if (impl().did_commit_after_animating) { |
1060 impl().layer_tree_host_impl->Animate(impl().animation_time); | 1064 impl().layer_tree_host_impl->Animate(impl().animation_time); |
1061 impl().did_commit_after_animating = false; | 1065 impl().did_commit_after_animating = false; |
1062 } | 1066 } |
1063 | 1067 |
1064 if (impl().layer_tree_host_impl->pending_tree()) | 1068 if (impl().layer_tree_host_impl->pending_tree()) |
1065 impl().layer_tree_host_impl->pending_tree()->UpdateDrawProperties(); | 1069 impl().layer_tree_host_impl->pending_tree()->UpdateDrawProperties(); |
1066 | 1070 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 if (impl().next_frame_is_newly_committed_frame) { | 1126 if (impl().next_frame_is_newly_committed_frame) { |
1123 impl().next_frame_is_newly_committed_frame = false; | 1127 impl().next_frame_is_newly_committed_frame = false; |
1124 Proxy::MainThreadTaskRunner()->PostTask( | 1128 Proxy::MainThreadTaskRunner()->PostTask( |
1125 FROM_HERE, | 1129 FROM_HERE, |
1126 base::Bind(&ThreadProxy::DidCommitAndDrawFrame, main_thread_weak_ptr_)); | 1130 base::Bind(&ThreadProxy::DidCommitAndDrawFrame, main_thread_weak_ptr_)); |
1127 } | 1131 } |
1128 | 1132 |
1129 if (draw_frame) | 1133 if (draw_frame) |
1130 CheckOutputSurfaceStatusOnImplThread(); | 1134 CheckOutputSurfaceStatusOnImplThread(); |
1131 | 1135 |
1132 if (result == DRAW_SUCCESS) { | 1136 if (result == DRAW_SUCCESS) |
1133 base::TimeDelta draw_duration = impl().timing_history.DidFinishDrawing(); | 1137 impl().timing_history.DidFinishDrawing(); |
1134 | |
1135 base::TimeDelta draw_duration_overestimate; | |
1136 base::TimeDelta draw_duration_underestimate; | |
1137 if (draw_duration > draw_duration_estimate) | |
1138 draw_duration_underestimate = draw_duration - draw_duration_estimate; | |
1139 else | |
1140 draw_duration_overestimate = draw_duration_estimate - draw_duration; | |
1141 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.DrawDuration", | |
1142 draw_duration, | |
1143 base::TimeDelta::FromMilliseconds(1), | |
1144 base::TimeDelta::FromMilliseconds(100), | |
1145 50); | |
1146 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.DrawDurationUnderestimate", | |
1147 draw_duration_underestimate, | |
1148 base::TimeDelta::FromMilliseconds(1), | |
1149 base::TimeDelta::FromMilliseconds(100), | |
1150 50); | |
1151 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.DrawDurationOverestimate", | |
1152 draw_duration_overestimate, | |
1153 base::TimeDelta::FromMilliseconds(1), | |
1154 base::TimeDelta::FromMilliseconds(100), | |
1155 50); | |
1156 } | |
1157 | 1138 |
1158 DCHECK_NE(INVALID_RESULT, result); | 1139 DCHECK_NE(INVALID_RESULT, result); |
1159 return result; | 1140 return result; |
1160 } | 1141 } |
1161 | 1142 |
1162 void ThreadProxy::ScheduledActionManageTiles() { | 1143 void ThreadProxy::ScheduledActionManageTiles() { |
1163 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionManageTiles"); | 1144 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionManageTiles"); |
1164 DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting); | 1145 DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting); |
1165 impl().layer_tree_host_impl->ManageTiles(); | 1146 impl().layer_tree_host_impl->ManageTiles(); |
1166 } | 1147 } |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1455 | 1436 |
1456 impl().timing_history.DidActivateSyncTree(); | 1437 impl().timing_history.DidActivateSyncTree(); |
1457 } | 1438 } |
1458 | 1439 |
1459 void ThreadProxy::DidManageTiles() { | 1440 void ThreadProxy::DidManageTiles() { |
1460 DCHECK(IsImplThread()); | 1441 DCHECK(IsImplThread()); |
1461 impl().scheduler->DidManageTiles(); | 1442 impl().scheduler->DidManageTiles(); |
1462 } | 1443 } |
1463 | 1444 |
1464 } // namespace cc | 1445 } // namespace cc |
OLD | NEW |