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/single_thread_proxy.h" | 5 #include "cc/trees/single_thread_proxy.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/profiler/scoped_tracker.h" | 8 #include "base/profiler/scoped_tracker.h" |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "cc/debug/benchmark_instrumentation.h" | 10 #include "cc/debug/benchmark_instrumentation.h" |
11 #include "cc/debug/devtools_instrumentation.h" | 11 #include "cc/debug/devtools_instrumentation.h" |
12 #include "cc/output/context_provider.h" | 12 #include "cc/output/context_provider.h" |
13 #include "cc/output/output_surface.h" | 13 #include "cc/output/output_surface.h" |
14 #include "cc/quads/draw_quad.h" | 14 #include "cc/quads/draw_quad.h" |
15 #include "cc/scheduler/commit_earlyout_reason.h" | 15 #include "cc/scheduler/commit_earlyout_reason.h" |
16 #include "cc/scheduler/compositor_timing_history.h" | 16 #include "cc/scheduler/compositor_timing_history.h" |
17 #include "cc/scheduler/scheduler.h" | 17 #include "cc/scheduler/scheduler.h" |
18 #include "cc/trees/layer_tree_host.h" | 18 #include "cc/trees/layer_tree_host.h" |
19 #include "cc/trees/layer_tree_host_single_thread_client.h" | 19 #include "cc/trees/layer_tree_host_single_thread_client.h" |
20 #include "cc/trees/layer_tree_impl.h" | 20 #include "cc/trees/layer_tree_impl.h" |
21 #include "cc/trees/scoped_abort_remaining_swap_promises.h" | 21 #include "cc/trees/scoped_abort_remaining_swap_promises.h" |
22 | 22 |
23 namespace cc { | 23 namespace cc { |
24 | 24 |
25 scoped_ptr<Proxy> SingleThreadProxy::Create( | 25 scoped_ptr<Proxy> SingleThreadProxy::Create( |
26 LayerTreeHost* layer_tree_host, | 26 LayerTreeHost* layer_tree_host, |
27 LayerTreeHostSingleThreadClient* client, | 27 LayerTreeHostSingleThreadClient* client, |
28 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 28 TaskRunnerProvider* task_runner_provider, |
29 scoped_ptr<BeginFrameSource> external_begin_frame_source) { | 29 scoped_ptr<BeginFrameSource> external_begin_frame_source) { |
30 return make_scoped_ptr(new SingleThreadProxy( | 30 return make_scoped_ptr( |
31 layer_tree_host, | 31 new SingleThreadProxy(layer_tree_host, client, task_runner_provider, |
32 client, | 32 external_begin_frame_source.Pass())); |
33 main_task_runner, | |
34 external_begin_frame_source.Pass())); | |
35 } | 33 } |
36 | 34 |
37 SingleThreadProxy::SingleThreadProxy( | 35 SingleThreadProxy::SingleThreadProxy( |
38 LayerTreeHost* layer_tree_host, | 36 LayerTreeHost* layer_tree_host, |
39 LayerTreeHostSingleThreadClient* client, | 37 LayerTreeHostSingleThreadClient* client, |
40 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 38 TaskRunnerProvider* task_runner_provider, |
41 scoped_ptr<BeginFrameSource> external_begin_frame_source) | 39 scoped_ptr<BeginFrameSource> external_begin_frame_source) |
42 : Proxy(main_task_runner, NULL), | 40 : layer_tree_host_(layer_tree_host), |
43 layer_tree_host_(layer_tree_host), | |
44 client_(client), | 41 client_(client), |
| 42 task_runner_provider_(task_runner_provider), |
45 external_begin_frame_source_(external_begin_frame_source.Pass()), | 43 external_begin_frame_source_(external_begin_frame_source.Pass()), |
46 next_frame_is_newly_committed_frame_(false), | 44 next_frame_is_newly_committed_frame_(false), |
47 #if DCHECK_IS_ON() | 45 #if DCHECK_IS_ON() |
48 inside_impl_frame_(false), | 46 inside_impl_frame_(false), |
49 #endif | 47 #endif |
50 inside_draw_(false), | 48 inside_draw_(false), |
51 defer_commits_(false), | 49 defer_commits_(false), |
52 animate_requested_(false), | 50 animate_requested_(false), |
53 commit_requested_(false), | 51 commit_requested_(false), |
54 inside_synchronous_composite_(false), | 52 inside_synchronous_composite_(false), |
55 output_surface_creation_requested_(false), | 53 output_surface_creation_requested_(false), |
56 weak_factory_(this) { | 54 weak_factory_(this) { |
57 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); | 55 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); |
58 DCHECK(Proxy::IsMainThread()); | 56 DCHECK(task_runner_provider_); |
| 57 DCHECK(task_runner_provider_->IsMainThread()); |
59 DCHECK(layer_tree_host); | 58 DCHECK(layer_tree_host); |
60 | 59 |
61 if (layer_tree_host->settings().single_thread_proxy_scheduler && | 60 if (layer_tree_host->settings().single_thread_proxy_scheduler && |
62 !scheduler_on_impl_thread_) { | 61 !scheduler_on_impl_thread_) { |
63 SchedulerSettings scheduler_settings( | 62 SchedulerSettings scheduler_settings( |
64 layer_tree_host->settings().ToSchedulerSettings()); | 63 layer_tree_host->settings().ToSchedulerSettings()); |
65 scheduler_settings.commit_to_active_tree = CommitToActiveTree(); | 64 scheduler_settings.commit_to_active_tree = CommitToActiveTree(); |
66 | 65 |
67 scoped_ptr<CompositorTimingHistory> compositor_timing_history( | 66 scoped_ptr<CompositorTimingHistory> compositor_timing_history( |
68 new CompositorTimingHistory( | 67 new CompositorTimingHistory( |
69 CompositorTimingHistory::BROWSER_UMA, | 68 CompositorTimingHistory::BROWSER_UMA, |
70 layer_tree_host->rendering_stats_instrumentation())); | 69 layer_tree_host->rendering_stats_instrumentation())); |
71 | 70 |
72 scheduler_on_impl_thread_ = Scheduler::Create( | 71 scheduler_on_impl_thread_ = Scheduler::Create( |
73 this, scheduler_settings, layer_tree_host_->id(), | 72 this, scheduler_settings, layer_tree_host_->id(), |
74 MainThreadTaskRunner(), external_begin_frame_source_.get(), | 73 task_runner_provider_->MainThreadTaskRunner(), |
75 compositor_timing_history.Pass()); | 74 external_begin_frame_source_.get(), compositor_timing_history.Pass()); |
76 } | 75 } |
77 } | 76 } |
78 | 77 |
79 void SingleThreadProxy::Start() { | 78 void SingleThreadProxy::Start() { |
80 DebugScopedSetImplThread impl(this); | 79 DebugScopedSetImplThread impl(task_runner_provider_); |
81 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); | 80 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); |
82 } | 81 } |
83 | 82 |
84 SingleThreadProxy::~SingleThreadProxy() { | 83 SingleThreadProxy::~SingleThreadProxy() { |
85 TRACE_EVENT0("cc", "SingleThreadProxy::~SingleThreadProxy"); | 84 TRACE_EVENT0("cc", "SingleThreadProxy::~SingleThreadProxy"); |
86 DCHECK(Proxy::IsMainThread()); | 85 DCHECK(task_runner_provider_->IsMainThread()); |
87 // Make sure Stop() got called or never Started. | 86 // Make sure Stop() got called or never Started. |
88 DCHECK(!layer_tree_host_impl_); | 87 DCHECK(!layer_tree_host_impl_); |
89 } | 88 } |
90 | 89 |
91 void SingleThreadProxy::FinishAllRendering() { | 90 void SingleThreadProxy::FinishAllRendering() { |
92 TRACE_EVENT0("cc", "SingleThreadProxy::FinishAllRendering"); | 91 TRACE_EVENT0("cc", "SingleThreadProxy::FinishAllRendering"); |
93 DCHECK(Proxy::IsMainThread()); | 92 DCHECK(task_runner_provider_->IsMainThread()); |
94 { | 93 { |
95 DebugScopedSetImplThread impl(this); | 94 DebugScopedSetImplThread impl(task_runner_provider_); |
96 layer_tree_host_impl_->FinishAllRendering(); | 95 layer_tree_host_impl_->FinishAllRendering(); |
97 } | 96 } |
98 } | 97 } |
99 | 98 |
100 bool SingleThreadProxy::IsStarted() const { | 99 bool SingleThreadProxy::IsStarted() const { |
101 DCHECK(Proxy::IsMainThread()); | 100 DCHECK(task_runner_provider_->IsMainThread()); |
102 return layer_tree_host_impl_; | 101 return layer_tree_host_impl_; |
103 } | 102 } |
104 | 103 |
105 bool SingleThreadProxy::CommitToActiveTree() const { | 104 bool SingleThreadProxy::CommitToActiveTree() const { |
106 // With SingleThreadProxy we skip the pending tree and commit directly to the | 105 // With SingleThreadProxy we skip the pending tree and commit directly to the |
107 // active tree. | 106 // active tree. |
108 return true; | 107 return true; |
109 } | 108 } |
110 | 109 |
111 void SingleThreadProxy::SetVisible(bool visible) { | 110 void SingleThreadProxy::SetVisible(bool visible) { |
112 TRACE_EVENT1("cc", "SingleThreadProxy::SetVisible", "visible", visible); | 111 TRACE_EVENT1("cc", "SingleThreadProxy::SetVisible", "visible", visible); |
113 DebugScopedSetImplThread impl(this); | 112 DebugScopedSetImplThread impl(task_runner_provider_); |
114 | 113 |
115 layer_tree_host_impl_->SetVisible(visible); | 114 layer_tree_host_impl_->SetVisible(visible); |
116 | 115 |
117 if (scheduler_on_impl_thread_) | 116 if (scheduler_on_impl_thread_) |
118 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); | 117 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); |
119 } | 118 } |
120 | 119 |
121 void SingleThreadProxy::SetThrottleFrameProduction(bool throttle) { | 120 void SingleThreadProxy::SetThrottleFrameProduction(bool throttle) { |
122 TRACE_EVENT1("cc", "SingleThreadProxy::SetThrottleFrameProduction", | 121 TRACE_EVENT1("cc", "SingleThreadProxy::SetThrottleFrameProduction", |
123 "throttle", throttle); | 122 "throttle", throttle); |
124 DebugScopedSetImplThread impl(this); | 123 DebugScopedSetImplThread impl(task_runner_provider_); |
125 if (scheduler_on_impl_thread_) | 124 if (scheduler_on_impl_thread_) |
126 scheduler_on_impl_thread_->SetThrottleFrameProduction(throttle); | 125 scheduler_on_impl_thread_->SetThrottleFrameProduction(throttle); |
127 } | 126 } |
128 | 127 |
129 void SingleThreadProxy::RequestNewOutputSurface() { | 128 void SingleThreadProxy::RequestNewOutputSurface() { |
130 DCHECK(Proxy::IsMainThread()); | 129 DCHECK(task_runner_provider_->IsMainThread()); |
131 DCHECK(layer_tree_host_->output_surface_lost()); | 130 DCHECK(layer_tree_host_->output_surface_lost()); |
132 output_surface_creation_callback_.Cancel(); | 131 output_surface_creation_callback_.Cancel(); |
133 if (output_surface_creation_requested_) | 132 if (output_surface_creation_requested_) |
134 return; | 133 return; |
135 output_surface_creation_requested_ = true; | 134 output_surface_creation_requested_ = true; |
136 layer_tree_host_->RequestNewOutputSurface(); | 135 layer_tree_host_->RequestNewOutputSurface(); |
137 } | 136 } |
138 | 137 |
139 void SingleThreadProxy::ReleaseOutputSurface() { | 138 void SingleThreadProxy::ReleaseOutputSurface() { |
140 // |layer_tree_host_| should already be aware of this. | 139 // |layer_tree_host_| should already be aware of this. |
141 DCHECK(layer_tree_host_->output_surface_lost()); | 140 DCHECK(layer_tree_host_->output_surface_lost()); |
142 | 141 |
143 if (scheduler_on_impl_thread_) | 142 if (scheduler_on_impl_thread_) |
144 scheduler_on_impl_thread_->DidLoseOutputSurface(); | 143 scheduler_on_impl_thread_->DidLoseOutputSurface(); |
145 return layer_tree_host_impl_->ReleaseOutputSurface(); | 144 return layer_tree_host_impl_->ReleaseOutputSurface(); |
146 } | 145 } |
147 | 146 |
148 void SingleThreadProxy::SetOutputSurface(OutputSurface* output_surface) { | 147 void SingleThreadProxy::SetOutputSurface(OutputSurface* output_surface) { |
149 DCHECK(Proxy::IsMainThread()); | 148 DCHECK(task_runner_provider_->IsMainThread()); |
150 DCHECK(layer_tree_host_->output_surface_lost()); | 149 DCHECK(layer_tree_host_->output_surface_lost()); |
151 DCHECK(output_surface_creation_requested_); | 150 DCHECK(output_surface_creation_requested_); |
152 renderer_capabilities_for_main_thread_ = RendererCapabilities(); | 151 renderer_capabilities_for_main_thread_ = RendererCapabilities(); |
153 | 152 |
154 bool success; | 153 bool success; |
155 { | 154 { |
156 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 155 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
157 DebugScopedSetImplThread impl(this); | 156 DebugScopedSetImplThread impl(task_runner_provider_); |
158 success = layer_tree_host_impl_->InitializeRenderer(output_surface); | 157 success = layer_tree_host_impl_->InitializeRenderer(output_surface); |
159 } | 158 } |
160 | 159 |
161 if (success) { | 160 if (success) { |
162 layer_tree_host_->DidInitializeOutputSurface(); | 161 layer_tree_host_->DidInitializeOutputSurface(); |
163 if (scheduler_on_impl_thread_) | 162 if (scheduler_on_impl_thread_) |
164 scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface(); | 163 scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface(); |
165 else if (!inside_synchronous_composite_) | 164 else if (!inside_synchronous_composite_) |
166 SetNeedsCommit(); | 165 SetNeedsCommit(); |
167 output_surface_creation_requested_ = false; | 166 output_surface_creation_requested_ = false; |
168 } else { | 167 } else { |
169 // DidFailToInitializeOutputSurface is treated as a RequestNewOutputSurface, | 168 // DidFailToInitializeOutputSurface is treated as a RequestNewOutputSurface, |
170 // and so output_surface_creation_requested remains true. | 169 // and so output_surface_creation_requested remains true. |
171 layer_tree_host_->DidFailToInitializeOutputSurface(); | 170 layer_tree_host_->DidFailToInitializeOutputSurface(); |
172 } | 171 } |
173 } | 172 } |
174 | 173 |
175 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { | 174 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { |
176 DCHECK(Proxy::IsMainThread()); | 175 DCHECK(task_runner_provider_->IsMainThread()); |
177 DCHECK(!layer_tree_host_->output_surface_lost()); | 176 DCHECK(!layer_tree_host_->output_surface_lost()); |
178 return renderer_capabilities_for_main_thread_; | 177 return renderer_capabilities_for_main_thread_; |
179 } | 178 } |
180 | 179 |
181 void SingleThreadProxy::SetNeedsAnimate() { | 180 void SingleThreadProxy::SetNeedsAnimate() { |
182 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsAnimate"); | 181 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsAnimate"); |
183 DCHECK(Proxy::IsMainThread()); | 182 DCHECK(task_runner_provider_->IsMainThread()); |
184 client_->ScheduleAnimation(); | 183 client_->ScheduleAnimation(); |
185 if (animate_requested_) | 184 if (animate_requested_) |
186 return; | 185 return; |
187 animate_requested_ = true; | 186 animate_requested_ = true; |
188 DebugScopedSetImplThread impl(this); | 187 DebugScopedSetImplThread impl(task_runner_provider_); |
189 if (scheduler_on_impl_thread_) | 188 if (scheduler_on_impl_thread_) |
190 scheduler_on_impl_thread_->SetNeedsBeginMainFrame(); | 189 scheduler_on_impl_thread_->SetNeedsBeginMainFrame(); |
191 } | 190 } |
192 | 191 |
193 void SingleThreadProxy::SetNeedsUpdateLayers() { | 192 void SingleThreadProxy::SetNeedsUpdateLayers() { |
194 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); | 193 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); |
195 DCHECK(Proxy::IsMainThread()); | 194 DCHECK(task_runner_provider_->IsMainThread()); |
196 SetNeedsCommit(); | 195 SetNeedsCommit(); |
197 } | 196 } |
198 | 197 |
199 void SingleThreadProxy::DoCommit() { | 198 void SingleThreadProxy::DoCommit() { |
200 TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit"); | 199 TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit"); |
201 DCHECK(Proxy::IsMainThread()); | 200 DCHECK(task_runner_provider_->IsMainThread()); |
202 | 201 |
203 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 is | 202 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 is |
204 // fixed. | 203 // fixed. |
205 tracked_objects::ScopedTracker tracking_profile1( | 204 tracked_objects::ScopedTracker tracking_profile1( |
206 FROM_HERE_WITH_EXPLICIT_FUNCTION("461509 SingleThreadProxy::DoCommit1")); | 205 FROM_HERE_WITH_EXPLICIT_FUNCTION("461509 SingleThreadProxy::DoCommit1")); |
207 layer_tree_host_->WillCommit(); | 206 layer_tree_host_->WillCommit(); |
208 devtools_instrumentation::ScopedCommitTrace commit_task( | 207 devtools_instrumentation::ScopedCommitTrace commit_task( |
209 layer_tree_host_->id()); | 208 layer_tree_host_->id()); |
210 | 209 |
211 // Commit immediately. | 210 // Commit immediately. |
212 { | 211 { |
213 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 | 212 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 |
214 // is fixed. | 213 // is fixed. |
215 tracked_objects::ScopedTracker tracking_profile2( | 214 tracked_objects::ScopedTracker tracking_profile2( |
216 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 215 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
217 "461509 SingleThreadProxy::DoCommit2")); | 216 "461509 SingleThreadProxy::DoCommit2")); |
218 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 217 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
219 DebugScopedSetImplThread impl(this); | 218 DebugScopedSetImplThread impl(task_runner_provider_); |
220 | 219 |
221 // This CapturePostTasks should be destroyed before CommitComplete() is | 220 // This CapturePostTasks should be destroyed before CommitComplete() is |
222 // called since that goes out to the embedder, and we want the embedder | 221 // called since that goes out to the embedder, and we want the embedder |
223 // to receive its callbacks before that. | 222 // to receive its callbacks before that. |
224 commit_blocking_task_runner_.reset(new BlockingTaskRunner::CapturePostTasks( | 223 commit_blocking_task_runner_.reset(new BlockingTaskRunner::CapturePostTasks( |
225 blocking_main_thread_task_runner())); | 224 task_runner_provider_->blocking_main_thread_task_runner())); |
226 | 225 |
227 layer_tree_host_impl_->BeginCommit(); | 226 layer_tree_host_impl_->BeginCommit(); |
228 | 227 |
229 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 | 228 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 |
230 // is fixed. | 229 // is fixed. |
231 tracked_objects::ScopedTracker tracking_profile6( | 230 tracked_objects::ScopedTracker tracking_profile6( |
232 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 231 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
233 "461509 SingleThreadProxy::DoCommit6")); | 232 "461509 SingleThreadProxy::DoCommit6")); |
234 if (layer_tree_host_impl_->EvictedUIResourcesExist()) | 233 if (layer_tree_host_impl_->EvictedUIResourcesExist()) |
235 layer_tree_host_->RecreateUIResources(); | 234 layer_tree_host_->RecreateUIResources(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 } | 268 } |
270 } | 269 } |
271 | 270 |
272 void SingleThreadProxy::CommitComplete() { | 271 void SingleThreadProxy::CommitComplete() { |
273 // Commit complete happens on the main side after activate to satisfy any | 272 // Commit complete happens on the main side after activate to satisfy any |
274 // SetNextCommitWaitsForActivation calls. | 273 // SetNextCommitWaitsForActivation calls. |
275 DCHECK(!layer_tree_host_impl_->pending_tree()) | 274 DCHECK(!layer_tree_host_impl_->pending_tree()) |
276 << "Activation is expected to have synchronously occurred by now."; | 275 << "Activation is expected to have synchronously occurred by now."; |
277 DCHECK(commit_blocking_task_runner_); | 276 DCHECK(commit_blocking_task_runner_); |
278 | 277 |
279 DebugScopedSetMainThread main(this); | 278 DebugScopedSetMainThread main(task_runner_provider_); |
280 commit_blocking_task_runner_.reset(); | 279 commit_blocking_task_runner_.reset(); |
281 layer_tree_host_->CommitComplete(); | 280 layer_tree_host_->CommitComplete(); |
282 layer_tree_host_->DidBeginMainFrame(); | 281 layer_tree_host_->DidBeginMainFrame(); |
283 | 282 |
284 next_frame_is_newly_committed_frame_ = true; | 283 next_frame_is_newly_committed_frame_ = true; |
285 } | 284 } |
286 | 285 |
287 void SingleThreadProxy::SetNeedsCommit() { | 286 void SingleThreadProxy::SetNeedsCommit() { |
288 DCHECK(Proxy::IsMainThread()); | 287 DCHECK(task_runner_provider_->IsMainThread()); |
289 client_->ScheduleComposite(); | 288 client_->ScheduleComposite(); |
290 if (commit_requested_) | 289 if (commit_requested_) |
291 return; | 290 return; |
292 commit_requested_ = true; | 291 commit_requested_ = true; |
293 DebugScopedSetImplThread impl(this); | 292 DebugScopedSetImplThread impl(task_runner_provider_); |
294 if (scheduler_on_impl_thread_) | 293 if (scheduler_on_impl_thread_) |
295 scheduler_on_impl_thread_->SetNeedsBeginMainFrame(); | 294 scheduler_on_impl_thread_->SetNeedsBeginMainFrame(); |
296 } | 295 } |
297 | 296 |
298 void SingleThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { | 297 void SingleThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { |
299 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsRedraw"); | 298 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsRedraw"); |
300 DCHECK(Proxy::IsMainThread()); | 299 DCHECK(task_runner_provider_->IsMainThread()); |
301 DebugScopedSetImplThread impl(this); | 300 DebugScopedSetImplThread impl(task_runner_provider_); |
302 client_->ScheduleComposite(); | 301 client_->ScheduleComposite(); |
303 SetNeedsRedrawRectOnImplThread(damage_rect); | 302 SetNeedsRedrawRectOnImplThread(damage_rect); |
304 } | 303 } |
305 | 304 |
306 void SingleThreadProxy::SetNextCommitWaitsForActivation() { | 305 void SingleThreadProxy::SetNextCommitWaitsForActivation() { |
307 // Activation always forced in commit, so nothing to do. | 306 // Activation always forced in commit, so nothing to do. |
308 DCHECK(Proxy::IsMainThread()); | 307 DCHECK(task_runner_provider_->IsMainThread()); |
309 } | 308 } |
310 | 309 |
311 void SingleThreadProxy::SetDeferCommits(bool defer_commits) { | 310 void SingleThreadProxy::SetDeferCommits(bool defer_commits) { |
312 DCHECK(Proxy::IsMainThread()); | 311 DCHECK(task_runner_provider_->IsMainThread()); |
313 // Deferring commits only makes sense if there's a scheduler. | 312 // Deferring commits only makes sense if there's a scheduler. |
314 if (!scheduler_on_impl_thread_) | 313 if (!scheduler_on_impl_thread_) |
315 return; | 314 return; |
316 if (defer_commits_ == defer_commits) | 315 if (defer_commits_ == defer_commits) |
317 return; | 316 return; |
318 | 317 |
319 if (defer_commits) | 318 if (defer_commits) |
320 TRACE_EVENT_ASYNC_BEGIN0("cc", "SingleThreadProxy::SetDeferCommits", this); | 319 TRACE_EVENT_ASYNC_BEGIN0("cc", "SingleThreadProxy::SetDeferCommits", this); |
321 else | 320 else |
322 TRACE_EVENT_ASYNC_END0("cc", "SingleThreadProxy::SetDeferCommits", this); | 321 TRACE_EVENT_ASYNC_END0("cc", "SingleThreadProxy::SetDeferCommits", this); |
323 | 322 |
324 defer_commits_ = defer_commits; | 323 defer_commits_ = defer_commits; |
325 scheduler_on_impl_thread_->SetDeferCommits(defer_commits); | 324 scheduler_on_impl_thread_->SetDeferCommits(defer_commits); |
326 } | 325 } |
327 | 326 |
328 bool SingleThreadProxy::CommitRequested() const { | 327 bool SingleThreadProxy::CommitRequested() const { |
329 DCHECK(Proxy::IsMainThread()); | 328 DCHECK(task_runner_provider_->IsMainThread()); |
330 return commit_requested_; | 329 return commit_requested_; |
331 } | 330 } |
332 | 331 |
333 bool SingleThreadProxy::BeginMainFrameRequested() const { | 332 bool SingleThreadProxy::BeginMainFrameRequested() const { |
334 DCHECK(Proxy::IsMainThread()); | 333 DCHECK(task_runner_provider_->IsMainThread()); |
335 // If there is no scheduler, then there can be no pending begin frame, | 334 // If there is no scheduler, then there can be no pending begin frame, |
336 // as all frames are all manually initiated by the embedder of cc. | 335 // as all frames are all manually initiated by the embedder of cc. |
337 if (!scheduler_on_impl_thread_) | 336 if (!scheduler_on_impl_thread_) |
338 return false; | 337 return false; |
339 return commit_requested_; | 338 return commit_requested_; |
340 } | 339 } |
341 | 340 |
342 void SingleThreadProxy::Stop() { | 341 void SingleThreadProxy::Stop() { |
343 TRACE_EVENT0("cc", "SingleThreadProxy::stop"); | 342 TRACE_EVENT0("cc", "SingleThreadProxy::stop"); |
344 DCHECK(Proxy::IsMainThread()); | 343 DCHECK(task_runner_provider_->IsMainThread()); |
345 { | 344 { |
346 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 345 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
347 DebugScopedSetImplThread impl(this); | 346 DebugScopedSetImplThread impl(task_runner_provider_); |
348 | 347 |
349 BlockingTaskRunner::CapturePostTasks blocked( | 348 BlockingTaskRunner::CapturePostTasks blocked( |
350 blocking_main_thread_task_runner()); | 349 task_runner_provider_->blocking_main_thread_task_runner()); |
351 scheduler_on_impl_thread_ = nullptr; | 350 scheduler_on_impl_thread_ = nullptr; |
352 layer_tree_host_impl_ = nullptr; | 351 layer_tree_host_impl_ = nullptr; |
353 } | 352 } |
354 layer_tree_host_ = NULL; | 353 layer_tree_host_ = NULL; |
355 } | 354 } |
356 | 355 |
357 void SingleThreadProxy::OnResourcelessSoftareDrawStateChanged( | 356 void SingleThreadProxy::OnResourcelessSoftareDrawStateChanged( |
358 bool resourceless_draw) { | 357 bool resourceless_draw) { |
359 NOTREACHED(); | 358 NOTREACHED(); |
360 } | 359 } |
361 | 360 |
362 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { | 361 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { |
363 TRACE_EVENT1( | 362 TRACE_EVENT1( |
364 "cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); | 363 "cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); |
365 DCHECK(Proxy::IsImplThread()); | 364 DCHECK(task_runner_provider_->IsImplThread()); |
366 if (scheduler_on_impl_thread_) | 365 if (scheduler_on_impl_thread_) |
367 scheduler_on_impl_thread_->SetCanDraw(can_draw); | 366 scheduler_on_impl_thread_->SetCanDraw(can_draw); |
368 } | 367 } |
369 | 368 |
370 void SingleThreadProxy::NotifyReadyToActivate() { | 369 void SingleThreadProxy::NotifyReadyToActivate() { |
371 TRACE_EVENT0("cc", "SingleThreadProxy::NotifyReadyToActivate"); | 370 TRACE_EVENT0("cc", "SingleThreadProxy::NotifyReadyToActivate"); |
372 DebugScopedSetImplThread impl(this); | 371 DebugScopedSetImplThread impl(task_runner_provider_); |
373 if (scheduler_on_impl_thread_) | 372 if (scheduler_on_impl_thread_) |
374 scheduler_on_impl_thread_->NotifyReadyToActivate(); | 373 scheduler_on_impl_thread_->NotifyReadyToActivate(); |
375 } | 374 } |
376 | 375 |
377 void SingleThreadProxy::NotifyReadyToDraw() { | 376 void SingleThreadProxy::NotifyReadyToDraw() { |
378 TRACE_EVENT0("cc", "SingleThreadProxy::NotifyReadyToDraw"); | 377 TRACE_EVENT0("cc", "SingleThreadProxy::NotifyReadyToDraw"); |
379 DebugScopedSetImplThread impl(this); | 378 DebugScopedSetImplThread impl(task_runner_provider_); |
380 if (scheduler_on_impl_thread_) | 379 if (scheduler_on_impl_thread_) |
381 scheduler_on_impl_thread_->NotifyReadyToDraw(); | 380 scheduler_on_impl_thread_->NotifyReadyToDraw(); |
382 } | 381 } |
383 | 382 |
384 void SingleThreadProxy::SetNeedsRedrawOnImplThread() { | 383 void SingleThreadProxy::SetNeedsRedrawOnImplThread() { |
385 client_->ScheduleComposite(); | 384 client_->ScheduleComposite(); |
386 if (scheduler_on_impl_thread_) | 385 if (scheduler_on_impl_thread_) |
387 scheduler_on_impl_thread_->SetNeedsRedraw(); | 386 scheduler_on_impl_thread_->SetNeedsRedraw(); |
388 } | 387 } |
389 | 388 |
(...skipping 26 matching lines...) Expand all Loading... |
416 "needs_begin_frames", needs_begin_frames); | 415 "needs_begin_frames", needs_begin_frames); |
417 // In tests the layer tree is destroyed after the scheduler is. | 416 // In tests the layer tree is destroyed after the scheduler is. |
418 if (scheduler_on_impl_thread_) | 417 if (scheduler_on_impl_thread_) |
419 scheduler_on_impl_thread_->SetVideoNeedsBeginFrames(needs_begin_frames); | 418 scheduler_on_impl_thread_->SetVideoNeedsBeginFrames(needs_begin_frames); |
420 } | 419 } |
421 | 420 |
422 void SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread( | 421 void SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread( |
423 scoped_ptr<AnimationEventsVector> events) { | 422 scoped_ptr<AnimationEventsVector> events) { |
424 TRACE_EVENT0( | 423 TRACE_EVENT0( |
425 "cc", "SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); | 424 "cc", "SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); |
426 DCHECK(Proxy::IsImplThread()); | 425 DCHECK(task_runner_provider_->IsImplThread()); |
427 DebugScopedSetMainThread main(this); | 426 DebugScopedSetMainThread main(task_runner_provider_); |
428 layer_tree_host_->SetAnimationEvents(events.Pass()); | 427 layer_tree_host_->SetAnimationEvents(events.Pass()); |
429 } | 428 } |
430 | 429 |
431 bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; } | 430 bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; } |
432 | 431 |
433 void SingleThreadProxy::DidActivateSyncTree() { | 432 void SingleThreadProxy::DidActivateSyncTree() { |
434 // Synchronously call to CommitComplete. Resetting | 433 // Synchronously call to CommitComplete. Resetting |
435 // |commit_blocking_task_runner| would make sure all tasks posted during | 434 // |commit_blocking_task_runner| would make sure all tasks posted during |
436 // commit/activation before CommitComplete. | 435 // commit/activation before CommitComplete. |
437 CommitComplete(); | 436 CommitComplete(); |
438 } | 437 } |
439 | 438 |
440 void SingleThreadProxy::WillPrepareTiles() { | 439 void SingleThreadProxy::WillPrepareTiles() { |
441 DCHECK(Proxy::IsImplThread()); | 440 DCHECK(task_runner_provider_->IsImplThread()); |
442 if (scheduler_on_impl_thread_) | 441 if (scheduler_on_impl_thread_) |
443 scheduler_on_impl_thread_->WillPrepareTiles(); | 442 scheduler_on_impl_thread_->WillPrepareTiles(); |
444 } | 443 } |
445 | 444 |
446 void SingleThreadProxy::DidPrepareTiles() { | 445 void SingleThreadProxy::DidPrepareTiles() { |
447 DCHECK(Proxy::IsImplThread()); | 446 DCHECK(task_runner_provider_->IsImplThread()); |
448 if (scheduler_on_impl_thread_) | 447 if (scheduler_on_impl_thread_) |
449 scheduler_on_impl_thread_->DidPrepareTiles(); | 448 scheduler_on_impl_thread_->DidPrepareTiles(); |
450 } | 449 } |
451 | 450 |
452 void SingleThreadProxy::DidCompletePageScaleAnimationOnImplThread() { | 451 void SingleThreadProxy::DidCompletePageScaleAnimationOnImplThread() { |
453 layer_tree_host_->DidCompletePageScaleAnimation(); | 452 layer_tree_host_->DidCompletePageScaleAnimation(); |
454 } | 453 } |
455 | 454 |
456 void SingleThreadProxy::UpdateRendererCapabilitiesOnImplThread() { | 455 void SingleThreadProxy::UpdateRendererCapabilitiesOnImplThread() { |
457 DCHECK(IsImplThread()); | 456 DCHECK(task_runner_provider_->IsImplThread()); |
458 renderer_capabilities_for_main_thread_ = | 457 renderer_capabilities_for_main_thread_ = |
459 layer_tree_host_impl_->GetRendererCapabilities().MainThreadCapabilities(); | 458 layer_tree_host_impl_->GetRendererCapabilities().MainThreadCapabilities(); |
460 } | 459 } |
461 | 460 |
462 void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() { | 461 void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() { |
463 TRACE_EVENT0("cc", "SingleThreadProxy::DidLoseOutputSurfaceOnImplThread"); | 462 TRACE_EVENT0("cc", "SingleThreadProxy::DidLoseOutputSurfaceOnImplThread"); |
464 { | 463 { |
465 DebugScopedSetMainThread main(this); | 464 DebugScopedSetMainThread main(task_runner_provider_); |
466 // This must happen before we notify the scheduler as it may try to recreate | 465 // This must happen before we notify the scheduler as it may try to recreate |
467 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. | 466 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. |
468 layer_tree_host_->DidLoseOutputSurface(); | 467 layer_tree_host_->DidLoseOutputSurface(); |
469 } | 468 } |
470 client_->DidAbortSwapBuffers(); | 469 client_->DidAbortSwapBuffers(); |
471 if (scheduler_on_impl_thread_) | 470 if (scheduler_on_impl_thread_) |
472 scheduler_on_impl_thread_->DidLoseOutputSurface(); | 471 scheduler_on_impl_thread_->DidLoseOutputSurface(); |
473 } | 472 } |
474 | 473 |
475 void SingleThreadProxy::CommitVSyncParameters(base::TimeTicks timebase, | 474 void SingleThreadProxy::CommitVSyncParameters(base::TimeTicks timebase, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 | 508 |
510 void SingleThreadProxy::PostFrameTimingEventsOnImplThread( | 509 void SingleThreadProxy::PostFrameTimingEventsOnImplThread( |
511 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 510 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
512 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 511 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
513 layer_tree_host_->RecordFrameTimingEvents(composite_events.Pass(), | 512 layer_tree_host_->RecordFrameTimingEvents(composite_events.Pass(), |
514 main_frame_events.Pass()); | 513 main_frame_events.Pass()); |
515 } | 514 } |
516 | 515 |
517 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { | 516 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { |
518 TRACE_EVENT0("cc,benchmark", "SingleThreadProxy::CompositeImmediately"); | 517 TRACE_EVENT0("cc,benchmark", "SingleThreadProxy::CompositeImmediately"); |
519 DCHECK(Proxy::IsMainThread()); | 518 DCHECK(task_runner_provider_->IsMainThread()); |
520 #if DCHECK_IS_ON() | 519 #if DCHECK_IS_ON() |
521 DCHECK(!inside_impl_frame_); | 520 DCHECK(!inside_impl_frame_); |
522 #endif | 521 #endif |
523 base::AutoReset<bool> inside_composite(&inside_synchronous_composite_, true); | 522 base::AutoReset<bool> inside_composite(&inside_synchronous_composite_, true); |
524 | 523 |
525 if (layer_tree_host_->output_surface_lost()) { | 524 if (layer_tree_host_->output_surface_lost()) { |
526 RequestNewOutputSurface(); | 525 RequestNewOutputSurface(); |
527 // RequestNewOutputSurface could have synchronously created an output | 526 // RequestNewOutputSurface could have synchronously created an output |
528 // surface, so check again before returning. | 527 // surface, so check again before returning. |
529 if (layer_tree_host_->output_surface_lost()) | 528 if (layer_tree_host_->output_surface_lost()) |
530 return; | 529 return; |
531 } | 530 } |
532 | 531 |
533 BeginFrameArgs begin_frame_args(BeginFrameArgs::Create( | 532 BeginFrameArgs begin_frame_args(BeginFrameArgs::Create( |
534 BEGINFRAME_FROM_HERE, frame_begin_time, base::TimeTicks(), | 533 BEGINFRAME_FROM_HERE, frame_begin_time, base::TimeTicks(), |
535 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL)); | 534 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL)); |
536 | 535 |
537 // Start the impl frame. | 536 // Start the impl frame. |
538 { | 537 { |
539 DebugScopedSetImplThread impl(this); | 538 DebugScopedSetImplThread impl(task_runner_provider_); |
540 WillBeginImplFrame(begin_frame_args); | 539 WillBeginImplFrame(begin_frame_args); |
541 } | 540 } |
542 | 541 |
543 // Run the "main thread" and get it to commit. | 542 // Run the "main thread" and get it to commit. |
544 { | 543 { |
545 #if DCHECK_IS_ON() | 544 #if DCHECK_IS_ON() |
546 DCHECK(inside_impl_frame_); | 545 DCHECK(inside_impl_frame_); |
547 #endif | 546 #endif |
548 DoBeginMainFrame(begin_frame_args); | 547 DoBeginMainFrame(begin_frame_args); |
549 DoCommit(); | 548 DoCommit(); |
550 | 549 |
551 DCHECK_EQ(0u, layer_tree_host_->num_queued_swap_promises()) | 550 DCHECK_EQ(0u, layer_tree_host_->num_queued_swap_promises()) |
552 << "Commit should always succeed and transfer promises."; | 551 << "Commit should always succeed and transfer promises."; |
553 } | 552 } |
554 | 553 |
555 // Finish the impl frame. | 554 // Finish the impl frame. |
556 { | 555 { |
557 DebugScopedSetImplThread impl(this); | 556 DebugScopedSetImplThread impl(task_runner_provider_); |
558 layer_tree_host_impl_->ActivateSyncTree(); | 557 layer_tree_host_impl_->ActivateSyncTree(); |
559 DCHECK( | 558 DCHECK( |
560 !layer_tree_host_impl_->active_tree()->needs_update_draw_properties()); | 559 !layer_tree_host_impl_->active_tree()->needs_update_draw_properties()); |
561 layer_tree_host_impl_->PrepareTiles(); | 560 layer_tree_host_impl_->PrepareTiles(); |
562 layer_tree_host_impl_->SynchronouslyInitializeAllTiles(); | 561 layer_tree_host_impl_->SynchronouslyInitializeAllTiles(); |
563 | 562 |
564 // TODO(danakj): Don't do this last... we prepared the wrong things. D: | 563 // TODO(danakj): Don't do this last... we prepared the wrong things. D: |
565 layer_tree_host_impl_->Animate(); | 564 layer_tree_host_impl_->Animate(); |
566 | 565 |
567 LayerTreeHostImpl::FrameData frame; | 566 LayerTreeHostImpl::FrameData frame; |
568 DoComposite(&frame); | 567 DoComposite(&frame); |
569 | 568 |
570 // DoComposite could abort, but because this is a synchronous composite | 569 // DoComposite could abort, but because this is a synchronous composite |
571 // another draw will never be scheduled, so break remaining promises. | 570 // another draw will never be scheduled, so break remaining promises. |
572 layer_tree_host_impl_->active_tree()->BreakSwapPromises( | 571 layer_tree_host_impl_->active_tree()->BreakSwapPromises( |
573 SwapPromise::SWAP_FAILS); | 572 SwapPromise::SWAP_FAILS); |
574 | 573 |
575 DidFinishImplFrame(); | 574 DidFinishImplFrame(); |
576 } | 575 } |
577 } | 576 } |
578 | 577 |
579 bool SingleThreadProxy::SupportsImplScrolling() const { | 578 bool SingleThreadProxy::SupportsImplScrolling() const { |
580 return false; | 579 return false; |
581 } | 580 } |
582 | 581 |
583 bool SingleThreadProxy::ShouldComposite() const { | 582 bool SingleThreadProxy::ShouldComposite() const { |
584 DCHECK(Proxy::IsImplThread()); | 583 DCHECK(task_runner_provider_->IsImplThread()); |
585 return layer_tree_host_impl_->visible() && | 584 return layer_tree_host_impl_->visible() && |
586 layer_tree_host_impl_->CanDraw(); | 585 layer_tree_host_impl_->CanDraw(); |
587 } | 586 } |
588 | 587 |
589 void SingleThreadProxy::ScheduleRequestNewOutputSurface() { | 588 void SingleThreadProxy::ScheduleRequestNewOutputSurface() { |
590 if (output_surface_creation_callback_.IsCancelled() && | 589 if (output_surface_creation_callback_.IsCancelled() && |
591 !output_surface_creation_requested_) { | 590 !output_surface_creation_requested_) { |
592 output_surface_creation_callback_.Reset( | 591 output_surface_creation_callback_.Reset( |
593 base::Bind(&SingleThreadProxy::RequestNewOutputSurface, | 592 base::Bind(&SingleThreadProxy::RequestNewOutputSurface, |
594 weak_factory_.GetWeakPtr())); | 593 weak_factory_.GetWeakPtr())); |
595 MainThreadTaskRunner()->PostTask( | 594 task_runner_provider_->MainThreadTaskRunner()->PostTask( |
596 FROM_HERE, output_surface_creation_callback_.callback()); | 595 FROM_HERE, output_surface_creation_callback_.callback()); |
597 } | 596 } |
598 } | 597 } |
599 | 598 |
600 DrawResult SingleThreadProxy::DoComposite(LayerTreeHostImpl::FrameData* frame) { | 599 DrawResult SingleThreadProxy::DoComposite(LayerTreeHostImpl::FrameData* frame) { |
601 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite"); | 600 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite"); |
602 DCHECK(!layer_tree_host_->output_surface_lost()); | 601 DCHECK(!layer_tree_host_->output_surface_lost()); |
603 | 602 |
604 DrawResult draw_result; | 603 DrawResult draw_result; |
605 bool draw_frame; | 604 bool draw_frame; |
606 { | 605 { |
607 DebugScopedSetImplThread impl(this); | 606 DebugScopedSetImplThread impl(task_runner_provider_); |
608 base::AutoReset<bool> mark_inside(&inside_draw_, true); | 607 base::AutoReset<bool> mark_inside(&inside_draw_, true); |
609 | 608 |
610 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 | 609 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 |
611 // is fixed. | 610 // is fixed. |
612 tracked_objects::ScopedTracker tracking_profile1( | 611 tracked_objects::ScopedTracker tracking_profile1( |
613 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 612 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
614 "461509 SingleThreadProxy::DoComposite1")); | 613 "461509 SingleThreadProxy::DoComposite1")); |
615 | 614 |
616 // We guard PrepareToDraw() with CanDraw() because it always returns a valid | 615 // We guard PrepareToDraw() with CanDraw() because it always returns a valid |
617 // frame, so can only be used when such a frame is possible. Since | 616 // frame, so can only be used when such a frame is possible. Since |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); | 651 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
653 | 652 |
654 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 | 653 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 |
655 // is fixed. | 654 // is fixed. |
656 tracked_objects::ScopedTracker tracking_profile7( | 655 tracked_objects::ScopedTracker tracking_profile7( |
657 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 656 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
658 "461509 SingleThreadProxy::DoComposite7")); | 657 "461509 SingleThreadProxy::DoComposite7")); |
659 } | 658 } |
660 | 659 |
661 if (draw_frame) { | 660 if (draw_frame) { |
662 DebugScopedSetImplThread impl(this); | 661 DebugScopedSetImplThread impl(task_runner_provider_); |
663 | 662 |
664 // This CapturePostTasks should be destroyed before | 663 // This CapturePostTasks should be destroyed before |
665 // DidCommitAndDrawFrame() is called since that goes out to the | 664 // DidCommitAndDrawFrame() is called since that goes out to the |
666 // embedder, | 665 // embedder, |
667 // and we want the embedder to receive its callbacks before that. | 666 // and we want the embedder to receive its callbacks before that. |
668 // NOTE: This maintains consistent ordering with the ThreadProxy since | 667 // NOTE: This maintains consistent ordering with the ThreadProxy since |
669 // the DidCommitAndDrawFrame() must be post-tasked from the impl thread | 668 // the DidCommitAndDrawFrame() must be post-tasked from the impl thread |
670 // there as the main thread is not blocked, so any posted tasks inside | 669 // there as the main thread is not blocked, so any posted tasks inside |
671 // the swap buffers will execute first. | 670 // the swap buffers will execute first. |
672 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 671 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
673 | 672 |
674 BlockingTaskRunner::CapturePostTasks blocked( | 673 BlockingTaskRunner::CapturePostTasks blocked( |
675 blocking_main_thread_task_runner()); | 674 task_runner_provider_->blocking_main_thread_task_runner()); |
676 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 | 675 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 |
677 // is fixed. | 676 // is fixed. |
678 tracked_objects::ScopedTracker tracking_profile8( | 677 tracked_objects::ScopedTracker tracking_profile8( |
679 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 678 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
680 "461509 SingleThreadProxy::DoComposite8")); | 679 "461509 SingleThreadProxy::DoComposite8")); |
681 layer_tree_host_impl_->SwapBuffers(*frame); | 680 layer_tree_host_impl_->SwapBuffers(*frame); |
682 } | 681 } |
683 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 is | 682 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 is |
684 // fixed. | 683 // fixed. |
685 tracked_objects::ScopedTracker tracking_profile9( | 684 tracked_objects::ScopedTracker tracking_profile9( |
686 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 685 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
687 "461509 SingleThreadProxy::DoComposite9")); | 686 "461509 SingleThreadProxy::DoComposite9")); |
688 DidCommitAndDrawFrame(); | 687 DidCommitAndDrawFrame(); |
689 | 688 |
690 return draw_result; | 689 return draw_result; |
691 } | 690 } |
692 | 691 |
693 void SingleThreadProxy::DidCommitAndDrawFrame() { | 692 void SingleThreadProxy::DidCommitAndDrawFrame() { |
694 if (next_frame_is_newly_committed_frame_) { | 693 if (next_frame_is_newly_committed_frame_) { |
695 DebugScopedSetMainThread main(this); | 694 DebugScopedSetMainThread main(task_runner_provider_); |
696 next_frame_is_newly_committed_frame_ = false; | 695 next_frame_is_newly_committed_frame_ = false; |
697 layer_tree_host_->DidCommitAndDrawFrame(); | 696 layer_tree_host_->DidCommitAndDrawFrame(); |
698 } | 697 } |
699 } | 698 } |
700 | 699 |
701 bool SingleThreadProxy::MainFrameWillHappenForTesting() { | 700 bool SingleThreadProxy::MainFrameWillHappenForTesting() { |
702 if (layer_tree_host_->output_surface_lost()) | 701 if (layer_tree_host_->output_surface_lost()) |
703 return false; | 702 return false; |
704 if (!scheduler_on_impl_thread_) | 703 if (!scheduler_on_impl_thread_) |
705 return false; | 704 return false; |
(...skipping 29 matching lines...) Expand all Loading... |
735 // fall on the next. Doing it asynchronously instead matches the semantics of | 734 // fall on the next. Doing it asynchronously instead matches the semantics of |
736 // ThreadProxy::SetNeedsCommit where SetNeedsCommit will not cause a | 735 // ThreadProxy::SetNeedsCommit where SetNeedsCommit will not cause a |
737 // synchronous commit. | 736 // synchronous commit. |
738 #if DCHECK_IS_ON() | 737 #if DCHECK_IS_ON() |
739 DCHECK(inside_impl_frame_) | 738 DCHECK(inside_impl_frame_) |
740 << "BeginMainFrame should only be sent inside a BeginImplFrame"; | 739 << "BeginMainFrame should only be sent inside a BeginImplFrame"; |
741 #endif | 740 #endif |
742 const BeginFrameArgs& begin_frame_args = | 741 const BeginFrameArgs& begin_frame_args = |
743 layer_tree_host_impl_->CurrentBeginFrameArgs(); | 742 layer_tree_host_impl_->CurrentBeginFrameArgs(); |
744 | 743 |
745 MainThreadTaskRunner()->PostTask( | 744 task_runner_provider_->MainThreadTaskRunner()->PostTask( |
746 FROM_HERE, base::Bind(&SingleThreadProxy::BeginMainFrame, | 745 FROM_HERE, base::Bind(&SingleThreadProxy::BeginMainFrame, |
747 weak_factory_.GetWeakPtr(), begin_frame_args)); | 746 weak_factory_.GetWeakPtr(), begin_frame_args)); |
748 } | 747 } |
749 | 748 |
750 void SingleThreadProxy::SendBeginMainFrameNotExpectedSoon() { | 749 void SingleThreadProxy::SendBeginMainFrameNotExpectedSoon() { |
751 layer_tree_host_->BeginMainFrameNotExpectedSoon(); | 750 layer_tree_host_->BeginMainFrameNotExpectedSoon(); |
752 } | 751 } |
753 | 752 |
754 void SingleThreadProxy::BeginMainFrame(const BeginFrameArgs& begin_frame_args) { | 753 void SingleThreadProxy::BeginMainFrame(const BeginFrameArgs& begin_frame_args) { |
755 commit_requested_ = false; | 754 commit_requested_ = false; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 // search for CommitEarlyOutReason::FINISHED_NO_UPDATES inside | 805 // search for CommitEarlyOutReason::FINISHED_NO_UPDATES inside |
807 // thread_proxy.cc | 806 // thread_proxy.cc |
808 if (scheduler_on_impl_thread_) { | 807 if (scheduler_on_impl_thread_) { |
809 scheduler_on_impl_thread_->NotifyBeginMainFrameStarted(); | 808 scheduler_on_impl_thread_->NotifyBeginMainFrameStarted(); |
810 scheduler_on_impl_thread_->NotifyReadyToCommit(); | 809 scheduler_on_impl_thread_->NotifyReadyToCommit(); |
811 } | 810 } |
812 } | 811 } |
813 | 812 |
814 void SingleThreadProxy::BeginMainFrameAbortedOnImplThread( | 813 void SingleThreadProxy::BeginMainFrameAbortedOnImplThread( |
815 CommitEarlyOutReason reason) { | 814 CommitEarlyOutReason reason) { |
816 DebugScopedSetImplThread impl(this); | 815 DebugScopedSetImplThread impl(task_runner_provider_); |
817 DCHECK(scheduler_on_impl_thread_->CommitPending()); | 816 DCHECK(scheduler_on_impl_thread_->CommitPending()); |
818 DCHECK(!layer_tree_host_impl_->pending_tree()); | 817 DCHECK(!layer_tree_host_impl_->pending_tree()); |
819 | 818 |
820 layer_tree_host_impl_->BeginMainFrameAborted(reason); | 819 layer_tree_host_impl_->BeginMainFrameAborted(reason); |
821 scheduler_on_impl_thread_->BeginMainFrameAborted(reason); | 820 scheduler_on_impl_thread_->BeginMainFrameAborted(reason); |
822 } | 821 } |
823 | 822 |
824 DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapIfPossible() { | 823 DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapIfPossible() { |
825 DebugScopedSetImplThread impl(this); | 824 DebugScopedSetImplThread impl(task_runner_provider_); |
826 LayerTreeHostImpl::FrameData frame; | 825 LayerTreeHostImpl::FrameData frame; |
827 return DoComposite(&frame); | 826 return DoComposite(&frame); |
828 } | 827 } |
829 | 828 |
830 DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapForced() { | 829 DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapForced() { |
831 NOTREACHED(); | 830 NOTREACHED(); |
832 return INVALID_RESULT; | 831 return INVALID_RESULT; |
833 } | 832 } |
834 | 833 |
835 void SingleThreadProxy::ScheduledActionCommit() { | 834 void SingleThreadProxy::ScheduledActionCommit() { |
836 DebugScopedSetMainThread main(this); | 835 DebugScopedSetMainThread main(task_runner_provider_); |
837 DoCommit(); | 836 DoCommit(); |
838 } | 837 } |
839 | 838 |
840 void SingleThreadProxy::ScheduledActionAnimate() { | 839 void SingleThreadProxy::ScheduledActionAnimate() { |
841 TRACE_EVENT0("cc", "ScheduledActionAnimate"); | 840 TRACE_EVENT0("cc", "ScheduledActionAnimate"); |
842 DebugScopedSetImplThread impl(this); | 841 DebugScopedSetImplThread impl(task_runner_provider_); |
843 layer_tree_host_impl_->Animate(); | 842 layer_tree_host_impl_->Animate(); |
844 } | 843 } |
845 | 844 |
846 void SingleThreadProxy::ScheduledActionActivateSyncTree() { | 845 void SingleThreadProxy::ScheduledActionActivateSyncTree() { |
847 DebugScopedSetImplThread impl(this); | 846 DebugScopedSetImplThread impl(task_runner_provider_); |
848 layer_tree_host_impl_->ActivateSyncTree(); | 847 layer_tree_host_impl_->ActivateSyncTree(); |
849 } | 848 } |
850 | 849 |
851 void SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { | 850 void SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { |
852 DebugScopedSetMainThread main(this); | 851 DebugScopedSetMainThread main(task_runner_provider_); |
853 DCHECK(scheduler_on_impl_thread_); | 852 DCHECK(scheduler_on_impl_thread_); |
854 // If possible, create the output surface in a post task. Synchronously | 853 // If possible, create the output surface in a post task. Synchronously |
855 // creating the output surface makes tests more awkward since this differs | 854 // creating the output surface makes tests more awkward since this differs |
856 // from the ThreadProxy behavior. However, sometimes there is no | 855 // from the ThreadProxy behavior. However, sometimes there is no |
857 // task runner. | 856 // task runner. |
858 if (Proxy::MainThreadTaskRunner()) { | 857 if (task_runner_provider_->MainThreadTaskRunner()) { |
859 ScheduleRequestNewOutputSurface(); | 858 ScheduleRequestNewOutputSurface(); |
860 } else { | 859 } else { |
861 RequestNewOutputSurface(); | 860 RequestNewOutputSurface(); |
862 } | 861 } |
863 } | 862 } |
864 | 863 |
865 void SingleThreadProxy::ScheduledActionPrepareTiles() { | 864 void SingleThreadProxy::ScheduledActionPrepareTiles() { |
866 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionPrepareTiles"); | 865 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionPrepareTiles"); |
867 DebugScopedSetImplThread impl(this); | 866 DebugScopedSetImplThread impl(task_runner_provider_); |
868 layer_tree_host_impl_->PrepareTiles(); | 867 layer_tree_host_impl_->PrepareTiles(); |
869 } | 868 } |
870 | 869 |
871 void SingleThreadProxy::ScheduledActionInvalidateOutputSurface() { | 870 void SingleThreadProxy::ScheduledActionInvalidateOutputSurface() { |
872 NOTREACHED(); | 871 NOTREACHED(); |
873 } | 872 } |
874 | 873 |
875 void SingleThreadProxy::UpdateTopControlsState(TopControlsState constraints, | 874 void SingleThreadProxy::UpdateTopControlsState(TopControlsState constraints, |
876 TopControlsState current, | 875 TopControlsState current, |
877 bool animate) { | 876 bool animate) { |
878 NOTREACHED() << "Top Controls are used only in threaded mode"; | 877 NOTREACHED() << "Top Controls are used only in threaded mode"; |
879 } | 878 } |
880 | 879 |
881 void SingleThreadProxy::DidFinishImplFrame() { | 880 void SingleThreadProxy::DidFinishImplFrame() { |
882 layer_tree_host_impl_->DidFinishImplFrame(); | 881 layer_tree_host_impl_->DidFinishImplFrame(); |
883 #if DCHECK_IS_ON() | 882 #if DCHECK_IS_ON() |
884 DCHECK(inside_impl_frame_) | 883 DCHECK(inside_impl_frame_) |
885 << "DidFinishImplFrame called while not inside an impl frame!"; | 884 << "DidFinishImplFrame called while not inside an impl frame!"; |
886 inside_impl_frame_ = false; | 885 inside_impl_frame_ = false; |
887 #endif | 886 #endif |
888 } | 887 } |
889 | 888 |
890 void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { | 889 void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { |
891 layer_tree_host_->SendBeginFramesToChildren(args); | 890 layer_tree_host_->SendBeginFramesToChildren(args); |
892 } | 891 } |
893 | 892 |
894 } // namespace cc | 893 } // namespace cc |
OLD | NEW |