| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 return make_scoped_ptr(new ThreadProxy(layer_tree_host, impl_task_runner)) | 67 return make_scoped_ptr(new ThreadProxy(layer_tree_host, impl_task_runner)) |
| 69 .PassAs<Proxy>(); | 68 .PassAs<Proxy>(); |
| 70 } | 69 } |
| 71 | 70 |
| 72 ThreadProxy::ThreadProxy( | 71 ThreadProxy::ThreadProxy( |
| 73 LayerTreeHost* layer_tree_host, | 72 LayerTreeHost* layer_tree_host, |
| 74 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) | 73 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) |
| 75 : Proxy(impl_task_runner), | 74 : Proxy(impl_task_runner), |
| 76 main_thread_only_vars_unsafe_(this, layer_tree_host->id()), | 75 main_thread_only_vars_unsafe_(this, layer_tree_host->id()), |
| 77 main_thread_or_blocked_vars_unsafe_(layer_tree_host), | 76 main_thread_or_blocked_vars_unsafe_(layer_tree_host), |
| 78 compositor_thread_vars_unsafe_(this, layer_tree_host->id()) { | 77 compositor_thread_vars_unsafe_( |
| 78 this, |
| 79 layer_tree_host->id(), |
| 80 layer_tree_host->rendering_stats_instrumentation()) { |
| 79 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); | 81 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); |
| 80 DCHECK(IsMainThread()); | 82 DCHECK(IsMainThread()); |
| 81 DCHECK(this->layer_tree_host()); | 83 DCHECK(this->layer_tree_host()); |
| 82 } | 84 } |
| 83 | 85 |
| 84 ThreadProxy::MainThreadOnly::MainThreadOnly(ThreadProxy* proxy, | 86 ThreadProxy::MainThreadOnly::MainThreadOnly(ThreadProxy* proxy, |
| 85 int layer_tree_host_id) | 87 int layer_tree_host_id) |
| 86 : layer_tree_host_id(layer_tree_host_id), | 88 : layer_tree_host_id(layer_tree_host_id), |
| 87 animate_requested(false), | 89 animate_requested(false), |
| 88 commit_requested(false), | 90 commit_requested(false), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 101 commit_waits_for_activation(false), | 103 commit_waits_for_activation(false), |
| 102 main_thread_inside_commit(false) {} | 104 main_thread_inside_commit(false) {} |
| 103 | 105 |
| 104 ThreadProxy::MainThreadOrBlockedMainThread::~MainThreadOrBlockedMainThread() {} | 106 ThreadProxy::MainThreadOrBlockedMainThread::~MainThreadOrBlockedMainThread() {} |
| 105 | 107 |
| 106 PrioritizedResourceManager* | 108 PrioritizedResourceManager* |
| 107 ThreadProxy::MainThreadOrBlockedMainThread::contents_texture_manager() { | 109 ThreadProxy::MainThreadOrBlockedMainThread::contents_texture_manager() { |
| 108 return layer_tree_host->contents_texture_manager(); | 110 return layer_tree_host->contents_texture_manager(); |
| 109 } | 111 } |
| 110 | 112 |
| 111 ThreadProxy::CompositorThreadOnly::CompositorThreadOnly(ThreadProxy* proxy, | 113 ThreadProxy::CompositorThreadOnly::CompositorThreadOnly( |
| 112 int layer_tree_host_id) | 114 ThreadProxy* proxy, |
| 115 int layer_tree_host_id, |
| 116 RenderingStatsInstrumentation* rendering_stats_instrumentation) |
| 113 : layer_tree_host_id(layer_tree_host_id), | 117 : layer_tree_host_id(layer_tree_host_id), |
| 114 contents_texture_manager(NULL), | 118 contents_texture_manager(NULL), |
| 115 commit_completion_event(NULL), | 119 commit_completion_event(NULL), |
| 116 completion_event_for_commit_held_on_tree_activation(NULL), | 120 completion_event_for_commit_held_on_tree_activation(NULL), |
| 117 next_frame_is_newly_committed_frame(false), | 121 next_frame_is_newly_committed_frame(false), |
| 118 inside_draw(false), | 122 inside_draw(false), |
| 119 input_throttled_until_commit(false), | 123 input_throttled_until_commit(false), |
| 120 animations_frozen_until_next_draw(false), | 124 animations_frozen_until_next_draw(false), |
| 121 did_commit_after_animating(false), | 125 did_commit_after_animating(false), |
| 122 smoothness_priority_expiration_notifier( | 126 smoothness_priority_expiration_notifier( |
| 123 proxy->ImplThreadTaskRunner(), | 127 proxy->ImplThreadTaskRunner(), |
| 124 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)), | 128 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)), |
| 125 base::TimeDelta::FromMilliseconds( | 129 base::TimeDelta::FromMilliseconds( |
| 126 kSmoothnessTakesPriorityExpirationDelay * 1000)), | 130 kSmoothnessTakesPriorityExpirationDelay * 1000)), |
| 131 timing_history(rendering_stats_instrumentation), |
| 127 weak_factory(proxy) { | 132 weak_factory(proxy) { |
| 128 } | 133 } |
| 129 | 134 |
| 130 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} | 135 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} |
| 131 | 136 |
| 132 ThreadProxy::~ThreadProxy() { | 137 ThreadProxy::~ThreadProxy() { |
| 133 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); | 138 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); |
| 134 DCHECK(IsMainThread()); | 139 DCHECK(IsMainThread()); |
| 135 DCHECK(!main().started); | 140 DCHECK(!main().started); |
| 136 } | 141 } |
| (...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 } | 1048 } |
| 1044 | 1049 |
| 1045 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { | 1050 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { |
| 1046 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); | 1051 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); |
| 1047 DrawResult result; | 1052 DrawResult result; |
| 1048 | 1053 |
| 1049 DCHECK(IsImplThread()); | 1054 DCHECK(IsImplThread()); |
| 1050 DCHECK(impl().layer_tree_host_impl.get()); | 1055 DCHECK(impl().layer_tree_host_impl.get()); |
| 1051 | 1056 |
| 1052 impl().timing_history.DidStartDrawing(); | 1057 impl().timing_history.DidStartDrawing(); |
| 1053 base::TimeDelta draw_duration_estimate = DrawDurationEstimate(); | |
| 1054 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); | 1058 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); |
| 1055 | 1059 |
| 1056 if (impl().did_commit_after_animating) { | 1060 if (impl().did_commit_after_animating) { |
| 1057 impl().layer_tree_host_impl->Animate(impl().animation_time); | 1061 impl().layer_tree_host_impl->Animate(impl().animation_time); |
| 1058 impl().did_commit_after_animating = false; | 1062 impl().did_commit_after_animating = false; |
| 1059 } | 1063 } |
| 1060 | 1064 |
| 1061 if (impl().layer_tree_host_impl->pending_tree()) | 1065 if (impl().layer_tree_host_impl->pending_tree()) |
| 1062 impl().layer_tree_host_impl->pending_tree()->UpdateDrawProperties(); | 1066 impl().layer_tree_host_impl->pending_tree()->UpdateDrawProperties(); |
| 1063 | 1067 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 if (impl().next_frame_is_newly_committed_frame) { | 1122 if (impl().next_frame_is_newly_committed_frame) { |
| 1119 impl().next_frame_is_newly_committed_frame = false; | 1123 impl().next_frame_is_newly_committed_frame = false; |
| 1120 Proxy::MainThreadTaskRunner()->PostTask( | 1124 Proxy::MainThreadTaskRunner()->PostTask( |
| 1121 FROM_HERE, | 1125 FROM_HERE, |
| 1122 base::Bind(&ThreadProxy::DidCommitAndDrawFrame, main_thread_weak_ptr_)); | 1126 base::Bind(&ThreadProxy::DidCommitAndDrawFrame, main_thread_weak_ptr_)); |
| 1123 } | 1127 } |
| 1124 | 1128 |
| 1125 if (draw_frame) | 1129 if (draw_frame) |
| 1126 CheckOutputSurfaceStatusOnImplThread(); | 1130 CheckOutputSurfaceStatusOnImplThread(); |
| 1127 | 1131 |
| 1128 if (result == DRAW_SUCCESS) { | 1132 if (result == DRAW_SUCCESS) |
| 1129 base::TimeDelta draw_duration = impl().timing_history.DidFinishDrawing(); | 1133 impl().timing_history.DidFinishDrawing(); |
| 1130 | |
| 1131 base::TimeDelta draw_duration_overestimate; | |
| 1132 base::TimeDelta draw_duration_underestimate; | |
| 1133 if (draw_duration > draw_duration_estimate) | |
| 1134 draw_duration_underestimate = draw_duration - draw_duration_estimate; | |
| 1135 else | |
| 1136 draw_duration_overestimate = draw_duration_estimate - draw_duration; | |
| 1137 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.DrawDuration", | |
| 1138 draw_duration, | |
| 1139 base::TimeDelta::FromMilliseconds(1), | |
| 1140 base::TimeDelta::FromMilliseconds(100), | |
| 1141 50); | |
| 1142 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.DrawDurationUnderestimate", | |
| 1143 draw_duration_underestimate, | |
| 1144 base::TimeDelta::FromMilliseconds(1), | |
| 1145 base::TimeDelta::FromMilliseconds(100), | |
| 1146 50); | |
| 1147 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer.DrawDurationOverestimate", | |
| 1148 draw_duration_overestimate, | |
| 1149 base::TimeDelta::FromMilliseconds(1), | |
| 1150 base::TimeDelta::FromMilliseconds(100), | |
| 1151 50); | |
| 1152 } | |
| 1153 | 1134 |
| 1154 DCHECK_NE(INVALID_RESULT, result); | 1135 DCHECK_NE(INVALID_RESULT, result); |
| 1155 return result; | 1136 return result; |
| 1156 } | 1137 } |
| 1157 | 1138 |
| 1158 void ThreadProxy::ScheduledActionManageTiles() { | 1139 void ThreadProxy::ScheduledActionManageTiles() { |
| 1159 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionManageTiles"); | 1140 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionManageTiles"); |
| 1160 DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting); | 1141 DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting); |
| 1161 impl().layer_tree_host_impl->ManageTiles(); | 1142 impl().layer_tree_host_impl->ManageTiles(); |
| 1162 } | 1143 } |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 | 1432 |
| 1452 impl().timing_history.DidActivateSyncTree(); | 1433 impl().timing_history.DidActivateSyncTree(); |
| 1453 } | 1434 } |
| 1454 | 1435 |
| 1455 void ThreadProxy::DidManageTiles() { | 1436 void ThreadProxy::DidManageTiles() { |
| 1456 DCHECK(IsImplThread()); | 1437 DCHECK(IsImplThread()); |
| 1457 impl().scheduler->DidManageTiles(); | 1438 impl().scheduler->DidManageTiles(); |
| 1458 } | 1439 } |
| 1459 | 1440 |
| 1460 } // namespace cc | 1441 } // namespace cc |
| OLD | NEW |