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/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "cc/debug/benchmark_instrumentation.h" | 9 #include "cc/debug/benchmark_instrumentation.h" |
10 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" |
(...skipping 15 matching lines...) Expand all Loading... | |
26 return make_scoped_ptr( | 26 return make_scoped_ptr( |
27 new SingleThreadProxy(layer_tree_host, client)).PassAs<Proxy>(); | 27 new SingleThreadProxy(layer_tree_host, client)).PassAs<Proxy>(); |
28 } | 28 } |
29 | 29 |
30 SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layer_tree_host, | 30 SingleThreadProxy::SingleThreadProxy(LayerTreeHost* layer_tree_host, |
31 LayerTreeHostSingleThreadClient* client) | 31 LayerTreeHostSingleThreadClient* client) |
32 : Proxy(NULL), | 32 : Proxy(NULL), |
33 layer_tree_host_(layer_tree_host), | 33 layer_tree_host_(layer_tree_host), |
34 client_(client), | 34 client_(client), |
35 created_offscreen_context_provider_(false), | 35 created_offscreen_context_provider_(false), |
36 weak_factory_(this), | |
36 next_frame_is_newly_committed_frame_(false), | 37 next_frame_is_newly_committed_frame_(false), |
37 inside_draw_(false) { | 38 inside_draw_(false), |
39 defer_commits_(false), | |
40 finish_commit_deferred_(false) { | |
38 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); | 41 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); |
39 DCHECK(Proxy::IsMainThread()); | 42 DCHECK(Proxy::IsMainThread()); |
40 DCHECK(layer_tree_host); | 43 DCHECK(layer_tree_host); |
41 | 44 |
42 // Impl-side painting not supported without threaded compositing. | 45 // Impl-side painting not supported without threaded compositing. |
43 CHECK(!layer_tree_host->settings().impl_side_painting) | 46 CHECK(!layer_tree_host->settings().impl_side_painting) |
44 << "Threaded compositing must be enabled to use impl-side painting."; | 47 << "Threaded compositing must be enabled to use impl-side painting."; |
45 } | 48 } |
46 | 49 |
47 void SingleThreadProxy::Start() { | 50 void SingleThreadProxy::Start() { |
48 DebugScopedSetImplThread impl(this); | 51 DebugScopedSetImplThread impl(this); |
49 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); | 52 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); |
53 SchedulerSettings scheduler_settings(layer_tree_host_->settings()); | |
54 scheduler_on_impl_thread_ = | |
55 Scheduler::Create(this, scheduler_settings, layer_tree_host_->id()); | |
56 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); | |
50 } | 57 } |
51 | 58 |
52 SingleThreadProxy::~SingleThreadProxy() { | 59 SingleThreadProxy::~SingleThreadProxy() { |
53 TRACE_EVENT0("cc", "SingleThreadProxy::~SingleThreadProxy"); | 60 TRACE_EVENT0("cc", "SingleThreadProxy::~SingleThreadProxy"); |
54 DCHECK(Proxy::IsMainThread()); | 61 DCHECK(Proxy::IsMainThread()); |
55 // Make sure Stop() got called or never Started. | 62 // Make sure Stop() got called or never Started. |
56 DCHECK(!layer_tree_host_impl_); | 63 DCHECK(!layer_tree_host_impl_); |
57 } | 64 } |
58 | 65 |
59 bool SingleThreadProxy::CompositeAndReadback(void* pixels, | 66 bool SingleThreadProxy::CompositeAndReadback(void* pixels, |
60 const gfx::Rect& rect) { | 67 const gfx::Rect& rect) { |
61 TRACE_EVENT0("cc", "SingleThreadProxy::CompositeAndReadback"); | 68 TRACE_EVENT0("cc", "SingleThreadProxy::CompositeAndReadback"); |
62 DCHECK(Proxy::IsMainThread()); | 69 DCHECK(Proxy::IsMainThread()); |
63 | 70 // TODO(enne): make this go through the SetNeedsForcedCommitForReadback logic. |
64 gfx::Rect device_viewport_damage_rect = rect; | 71 bool do_commit = true; |
65 | 72 bool for_readback = true; |
66 LayerTreeHostImpl::FrameData frame; | 73 gfx::Rect device_viewport_damage_rect(rect); |
67 if (!CommitAndComposite(gfx::FrameTime::Now(), | 74 if (CommitAndCompositeInternal(gfx::FrameTime::Now(), |
68 device_viewport_damage_rect, | 75 device_viewport_damage_rect, |
69 true, // for_readback | 76 do_commit, |
70 &frame)) | 77 for_readback).draw_result != |
78 DrawSwapReadbackResult::DRAW_SUCCESS) | |
71 return false; | 79 return false; |
72 | 80 |
73 { | 81 { |
74 DebugScopedSetImplThread impl(this); | 82 DebugScopedSetImplThread impl(this); |
75 layer_tree_host_impl_->Readback(pixels, rect); | 83 layer_tree_host_impl_->Readback(pixels, rect); |
76 | 84 |
77 if (layer_tree_host_impl_->IsContextLost()) | 85 if (layer_tree_host_impl_->IsContextLost()) |
78 return false; | 86 return false; |
79 } | 87 } |
80 | 88 |
(...skipping 11 matching lines...) Expand all Loading... | |
92 | 100 |
93 bool SingleThreadProxy::IsStarted() const { | 101 bool SingleThreadProxy::IsStarted() const { |
94 DCHECK(Proxy::IsMainThread()); | 102 DCHECK(Proxy::IsMainThread()); |
95 return layer_tree_host_impl_; | 103 return layer_tree_host_impl_; |
96 } | 104 } |
97 | 105 |
98 void SingleThreadProxy::SetLayerTreeHostClientReady() { | 106 void SingleThreadProxy::SetLayerTreeHostClientReady() { |
99 TRACE_EVENT0("cc", "SingleThreadProxy::SetLayerTreeHostClientReady"); | 107 TRACE_EVENT0("cc", "SingleThreadProxy::SetLayerTreeHostClientReady"); |
100 // Scheduling is controlled by the embedder in the single thread case, so | 108 // Scheduling is controlled by the embedder in the single thread case, so |
101 // nothing to do. | 109 // nothing to do. |
110 DCHECK(Proxy::IsMainThread()); | |
111 DebugScopedSetImplThread impl(this); | |
112 scheduler_on_impl_thread_->SetCanStart(); | |
102 } | 113 } |
103 | 114 |
104 void SingleThreadProxy::SetVisible(bool visible) { | 115 void SingleThreadProxy::SetVisible(bool visible) { |
105 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); | 116 TRACE_EVENT0("cc", "SingleThreadProxy::SetVisible"); |
106 DebugScopedSetImplThread impl(this); | 117 DebugScopedSetImplThread impl(this); |
107 layer_tree_host_impl_->SetVisible(visible); | 118 layer_tree_host_impl_->SetVisible(visible); |
119 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); | |
108 | 120 |
109 // Changing visibility could change ShouldComposite(). | 121 // Changing visibility could change ShouldComposite(). |
110 UpdateBackgroundAnimateTicking(); | 122 UpdateBackgroundAnimateTicking(); |
111 } | 123 } |
112 | 124 |
113 void SingleThreadProxy::CreateAndInitializeOutputSurface() { | 125 void SingleThreadProxy::CreateAndInitializeOutputSurface() { |
114 TRACE_EVENT0( | 126 TRACE_EVENT0( |
115 "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface"); | 127 "cc", "SingleThreadProxy::CreateAndInitializeOutputSurface"); |
116 DCHECK(Proxy::IsMainThread()); | 128 DCHECK(Proxy::IsMainThread()); |
117 | 129 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 } else if (offscreen_context_provider.get()) { | 166 } else if (offscreen_context_provider.get()) { |
155 offscreen_context_provider->VerifyContexts(); | 167 offscreen_context_provider->VerifyContexts(); |
156 offscreen_context_provider = NULL; | 168 offscreen_context_provider = NULL; |
157 } | 169 } |
158 | 170 |
159 layer_tree_host_impl_->SetOffscreenContextProvider( | 171 layer_tree_host_impl_->SetOffscreenContextProvider( |
160 offscreen_context_provider); | 172 offscreen_context_provider); |
161 } | 173 } |
162 | 174 |
163 OnOutputSurfaceInitializeAttempted(initialized); | 175 OnOutputSurfaceInitializeAttempted(initialized); |
176 | |
177 // This must happen after OnCreateAndInitializeOutputSurfaceAttempted as it | |
178 // causes a commit and the output surface needs to be initialized beforehand. | |
179 if (initialized) { | |
180 DebugScopedSetImplThread impl(this); | |
181 scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface(); | |
182 } | |
164 } | 183 } |
165 | 184 |
166 void SingleThreadProxy::OnOutputSurfaceInitializeAttempted(bool success) { | 185 void SingleThreadProxy::OnOutputSurfaceInitializeAttempted(bool success) { |
167 LayerTreeHost::CreateResult result = | 186 LayerTreeHost::CreateResult result = |
168 layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); | 187 layer_tree_host_->OnCreateAndInitializeOutputSurfaceAttempted(success); |
169 if (result == LayerTreeHost::CreateFailedButTryAgain) { | 188 if (result == LayerTreeHost::CreateFailedButTryAgain) { |
170 // Force another recreation attempt to happen by requesting another commit. | 189 if (!weak_ptr_) |
171 SetNeedsCommit(); | 190 weak_ptr_ = weak_factory_.GetWeakPtr(); |
danakj
2014/02/20 20:56:40
I don't think you need a member variable for this.
enne (OOO)
2014/02/20 21:07:13
It seemed silly to create a new weak pointer every
danakj
2014/02/20 21:09:47
This is called rarely, and I think it's not a typi
enne (OOO)
2014/02/21 19:34:09
Removed weak pointer.
| |
191 Proxy::MainThreadTaskRunner()->PostTask( | |
192 FROM_HERE, | |
193 base::Bind(&SingleThreadProxy::CreateAndInitializeOutputSurface, | |
194 weak_ptr_)); | |
172 } | 195 } |
173 } | 196 } |
174 | 197 |
175 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { | 198 const RendererCapabilities& SingleThreadProxy::GetRendererCapabilities() const { |
176 DCHECK(Proxy::IsMainThread()); | 199 DCHECK(Proxy::IsMainThread()); |
177 DCHECK(!layer_tree_host_->output_surface_lost()); | 200 DCHECK(!layer_tree_host_->output_surface_lost()); |
178 return renderer_capabilities_for_main_thread_; | 201 return renderer_capabilities_for_main_thread_; |
179 } | 202 } |
180 | 203 |
181 void SingleThreadProxy::SetNeedsAnimate() { | 204 void SingleThreadProxy::SetNeedsAnimate() { |
182 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsAnimate"); | 205 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsAnimate"); |
183 DCHECK(Proxy::IsMainThread()); | 206 DCHECK(Proxy::IsMainThread()); |
184 client_->ScheduleAnimation(); | 207 SetNeedsCommit(); |
185 } | 208 } |
186 | 209 |
187 void SingleThreadProxy::SetNeedsUpdateLayers() { | 210 void SingleThreadProxy::SetNeedsUpdateLayers() { |
188 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); | 211 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); |
189 DCHECK(Proxy::IsMainThread()); | 212 DCHECK(Proxy::IsMainThread()); |
190 client_->ScheduleComposite(); | 213 SetNeedsCommit(); |
191 } | 214 } |
192 | 215 |
193 void SingleThreadProxy::DoCommit(scoped_ptr<ResourceUpdateQueue> queue) { | 216 void SingleThreadProxy::DoCommit(base::TimeTicks frame_begin_time) { |
194 TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit"); | 217 TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit"); |
195 DCHECK(Proxy::IsMainThread()); | 218 DCHECK(Proxy::IsMainThread()); |
219 layer_tree_host_->WillBeginMainFrame(); | |
220 layer_tree_host_->Layout(); | |
221 layer_tree_host_->AnimateLayers(frame_begin_time); | |
222 | |
223 if (PrioritizedResourceManager* contents_texture_manager = | |
224 layer_tree_host_->contents_texture_manager()) { | |
225 contents_texture_manager->UnlinkAndClearEvictedBackings(); | |
226 contents_texture_manager->SetMaxMemoryLimitBytes( | |
227 layer_tree_host_impl_->memory_allocation_limit_bytes()); | |
228 contents_texture_manager->SetExternalPriorityCutoff( | |
229 layer_tree_host_impl_->memory_allocation_priority_cutoff()); | |
230 } | |
231 | |
232 scoped_ptr<ResourceUpdateQueue> queue = | |
233 make_scoped_ptr(new ResourceUpdateQueue); | |
234 | |
235 layer_tree_host_->UpdateLayers(queue.get()); | |
236 | |
237 layer_tree_host_->WillCommit(); | |
238 | |
196 // Commit immediately. | 239 // Commit immediately. |
197 { | 240 { |
198 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 241 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
199 DebugScopedSetImplThread impl(this); | 242 DebugScopedSetImplThread impl(this); |
200 | 243 |
201 // This CapturePostTasks should be destroyed before CommitComplete() is | 244 // This CapturePostTasks should be destroyed before CommitComplete() is |
202 // called since that goes out to the embedder, and we want the embedder | 245 // called since that goes out to the embedder, and we want the embedder |
203 // to receive its callbacks before that. | 246 // to receive its callbacks before that. |
204 BlockingTaskRunner::CapturePostTasks blocked; | 247 BlockingTaskRunner::CapturePostTasks blocked; |
205 | 248 |
(...skipping 13 matching lines...) Expand all Loading... | |
219 layer_tree_host_impl_->resource_provider()); | 262 layer_tree_host_impl_->resource_provider()); |
220 update_controller->Finalize(); | 263 update_controller->Finalize(); |
221 | 264 |
222 if (layer_tree_host_impl_->EvictedUIResourcesExist()) | 265 if (layer_tree_host_impl_->EvictedUIResourcesExist()) |
223 layer_tree_host_->RecreateUIResources(); | 266 layer_tree_host_->RecreateUIResources(); |
224 | 267 |
225 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); | 268 layer_tree_host_->FinishCommitOnImplThread(layer_tree_host_impl_.get()); |
226 | 269 |
227 layer_tree_host_impl_->CommitComplete(); | 270 layer_tree_host_impl_->CommitComplete(); |
228 | 271 |
272 UpdateBackgroundAnimateTicking(); | |
273 | |
229 #ifndef NDEBUG | 274 #ifndef NDEBUG |
230 // In the single-threaded case, the scale and scroll deltas should never be | 275 // In the single-threaded case, the scale and scroll deltas should never be |
231 // touched on the impl layer tree. | 276 // touched on the impl layer tree. |
232 scoped_ptr<ScrollAndScaleSet> scroll_info = | 277 scoped_ptr<ScrollAndScaleSet> scroll_info = |
233 layer_tree_host_impl_->ProcessScrollDeltas(); | 278 layer_tree_host_impl_->ProcessScrollDeltas(); |
234 DCHECK(!scroll_info->scrolls.size()); | 279 DCHECK(!scroll_info->scrolls.size()); |
235 DCHECK_EQ(1.f, scroll_info->page_scale_delta); | 280 DCHECK_EQ(1.f, scroll_info->page_scale_delta); |
236 #endif | 281 #endif |
237 | 282 |
238 RenderingStatsInstrumentation* stats_instrumentation = | 283 RenderingStatsInstrumentation* stats_instrumentation = |
239 layer_tree_host_->rendering_stats_instrumentation(); | 284 layer_tree_host_->rendering_stats_instrumentation(); |
240 BenchmarkInstrumentation::IssueMainThreadRenderingStatsEvent( | 285 BenchmarkInstrumentation::IssueMainThreadRenderingStatsEvent( |
241 stats_instrumentation->main_thread_rendering_stats()); | 286 stats_instrumentation->main_thread_rendering_stats()); |
242 stats_instrumentation->AccumulateAndClearMainThreadStats(); | 287 stats_instrumentation->AccumulateAndClearMainThreadStats(); |
243 } | 288 } |
244 layer_tree_host_->CommitComplete(); | 289 layer_tree_host_->CommitComplete(); |
290 layer_tree_host_->DidBeginMainFrame(); | |
291 timing_history_.DidCommit(); | |
292 | |
245 next_frame_is_newly_committed_frame_ = true; | 293 next_frame_is_newly_committed_frame_ = true; |
246 } | 294 } |
247 | 295 |
248 void SingleThreadProxy::SetNeedsCommit() { | 296 void SingleThreadProxy::SetNeedsCommit() { |
249 DCHECK(Proxy::IsMainThread()); | 297 scheduler_on_impl_thread_->SetNeedsCommit(); |
250 client_->ScheduleComposite(); | |
251 } | 298 } |
252 | 299 |
253 void SingleThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { | 300 void SingleThreadProxy::SetNeedsRedraw(const gfx::Rect& damage_rect) { |
254 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsRedraw"); | 301 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsRedraw"); |
302 DCHECK(Proxy::IsMainThread()); | |
303 DebugScopedSetImplThread impl(this); | |
255 SetNeedsRedrawRectOnImplThread(damage_rect); | 304 SetNeedsRedrawRectOnImplThread(damage_rect); |
256 client_->ScheduleComposite(); | |
257 } | 305 } |
258 | 306 |
259 void SingleThreadProxy::SetNextCommitWaitsForActivation() { | 307 void SingleThreadProxy::SetNextCommitWaitsForActivation() { |
260 // There is no activation here other than commit. So do nothing. | 308 // There is no activation here other than commit. So do nothing. |
309 DCHECK(Proxy::IsMainThread()); | |
261 } | 310 } |
262 | 311 |
263 void SingleThreadProxy::SetDeferCommits(bool defer_commits) { | 312 void SingleThreadProxy::SetDeferCommits(bool defer_commits) { |
264 // Thread-only feature. | 313 DCHECK(Proxy::IsMainThread()); |
265 NOTREACHED(); | 314 if (defer_commits_ == defer_commits) |
315 return; | |
316 | |
317 defer_commits_ = defer_commits; | |
318 if (!defer_commits_ && finish_commit_deferred_) { | |
319 scheduler_on_impl_thread_->FinishCommit(); | |
320 finish_commit_deferred_ = false; | |
321 } | |
266 } | 322 } |
267 | 323 |
268 bool SingleThreadProxy::CommitRequested() const { return false; } | 324 bool SingleThreadProxy::CommitRequested() const { |
325 DCHECK(Proxy::IsMainThread()); | |
326 return finish_commit_deferred_; | |
327 } | |
269 | 328 |
270 bool SingleThreadProxy::BeginMainFrameRequested() const { return false; } | 329 bool SingleThreadProxy::BeginMainFrameRequested() const { |
330 DCHECK(Proxy::IsMainThread()); | |
331 return finish_commit_deferred_; | |
332 } | |
271 | 333 |
272 size_t SingleThreadProxy::MaxPartialTextureUpdates() const { | 334 size_t SingleThreadProxy::MaxPartialTextureUpdates() const { |
273 return std::numeric_limits<size_t>::max(); | 335 return std::numeric_limits<size_t>::max(); |
274 } | 336 } |
275 | 337 |
276 void SingleThreadProxy::Stop() { | 338 void SingleThreadProxy::Stop() { |
277 TRACE_EVENT0("cc", "SingleThreadProxy::stop"); | 339 TRACE_EVENT0("cc", "SingleThreadProxy::stop"); |
278 DCHECK(Proxy::IsMainThread()); | 340 DCHECK(Proxy::IsMainThread()); |
279 { | 341 { |
280 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 342 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
281 DebugScopedSetImplThread impl(this); | 343 DebugScopedSetImplThread impl(this); |
282 | 344 |
283 layer_tree_host_->DeleteContentsTexturesOnImplThread( | 345 layer_tree_host_->DeleteContentsTexturesOnImplThread( |
284 layer_tree_host_impl_->resource_provider()); | 346 layer_tree_host_impl_->resource_provider()); |
347 scheduler_on_impl_thread_.reset(); | |
285 layer_tree_host_impl_.reset(); | 348 layer_tree_host_impl_.reset(); |
286 } | 349 } |
287 layer_tree_host_ = NULL; | 350 layer_tree_host_ = NULL; |
288 } | 351 } |
289 | 352 |
290 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { | 353 void SingleThreadProxy::OnCanDrawStateChanged(bool can_draw) { |
291 TRACE_EVENT1( | 354 TRACE_EVENT1( |
292 "cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); | 355 "cc", "SingleThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); |
293 DCHECK(Proxy::IsImplThread()); | 356 DCHECK(Proxy::IsImplThread()); |
294 UpdateBackgroundAnimateTicking(); | 357 UpdateBackgroundAnimateTicking(); |
358 scheduler_on_impl_thread_->SetCanDraw(can_draw); | |
295 } | 359 } |
296 | 360 |
297 void SingleThreadProxy::NotifyReadyToActivate() { | 361 void SingleThreadProxy::NotifyReadyToActivate() { |
298 // Thread-only feature. | 362 // Impl-side painting only. |
299 NOTREACHED(); | 363 NOTREACHED(); |
300 } | 364 } |
301 | 365 |
302 void SingleThreadProxy::SetNeedsRedrawOnImplThread() { | 366 void SingleThreadProxy::SetNeedsRedrawOnImplThread() { |
303 client_->ScheduleComposite(); | 367 scheduler_on_impl_thread_->SetNeedsRedraw(); |
304 } | 368 } |
305 | 369 |
306 void SingleThreadProxy::SetNeedsManageTilesOnImplThread() { | 370 void SingleThreadProxy::SetNeedsManageTilesOnImplThread() { |
307 // Thread-only/Impl-side-painting-only feature. | 371 // Impl-side painting only. |
308 NOTREACHED(); | 372 NOTREACHED(); |
309 } | 373 } |
310 | 374 |
311 void SingleThreadProxy::SetNeedsRedrawRectOnImplThread( | 375 void SingleThreadProxy::SetNeedsRedrawRectOnImplThread( |
312 const gfx::Rect& damage_rect) { | 376 const gfx::Rect& damage_rect) { |
313 // TODO(brianderson): Once we move render_widget scheduling into this class, | |
314 // we can treat redraw requests more efficiently than CommitAndRedraw | |
315 // requests. | |
316 layer_tree_host_impl_->SetViewportDamage(damage_rect); | 377 layer_tree_host_impl_->SetViewportDamage(damage_rect); |
317 SetNeedsCommit(); | 378 SetNeedsRedrawOnImplThread(); |
318 } | 379 } |
319 | 380 |
320 void SingleThreadProxy::DidInitializeVisibleTileOnImplThread() { | 381 void SingleThreadProxy::DidInitializeVisibleTileOnImplThread() { |
321 // Impl-side painting only. | 382 // Impl-side painting only. |
322 NOTREACHED(); | 383 NOTREACHED(); |
323 } | 384 } |
324 | 385 |
325 void SingleThreadProxy::SetNeedsCommitOnImplThread() { | 386 void SingleThreadProxy::SetNeedsCommitOnImplThread() { |
326 client_->ScheduleComposite(); | 387 scheduler_on_impl_thread_->SetNeedsCommit(); |
327 } | 388 } |
328 | 389 |
329 void SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread( | 390 void SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread( |
330 scoped_ptr<AnimationEventsVector> events, | 391 scoped_ptr<AnimationEventsVector> events, |
331 base::Time wall_clock_time) { | 392 base::Time wall_clock_time) { |
332 TRACE_EVENT0( | 393 TRACE_EVENT0( |
333 "cc", "SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); | 394 "cc", "SingleThreadProxy::PostAnimationEventsToMainThreadOnImplThread"); |
334 DCHECK(Proxy::IsImplThread()); | 395 DCHECK(Proxy::IsImplThread()); |
335 DebugScopedSetMainThread main(this); | 396 DebugScopedSetMainThread main(this); |
336 layer_tree_host_->SetAnimationEvents(events.Pass(), wall_clock_time); | 397 layer_tree_host_->SetAnimationEvents(events.Pass(), wall_clock_time); |
(...skipping 26 matching lines...) Expand all Loading... | |
363 return; | 424 return; |
364 | 425 |
365 layer_tree_host_impl_->SendManagedMemoryStats( | 426 layer_tree_host_impl_->SendManagedMemoryStats( |
366 contents_texture_manager->MemoryVisibleBytes(), | 427 contents_texture_manager->MemoryVisibleBytes(), |
367 contents_texture_manager->MemoryVisibleAndNearbyBytes(), | 428 contents_texture_manager->MemoryVisibleAndNearbyBytes(), |
368 contents_texture_manager->MemoryUseBytes()); | 429 contents_texture_manager->MemoryUseBytes()); |
369 } | 430 } |
370 | 431 |
371 bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; } | 432 bool SingleThreadProxy::IsInsideDraw() { return inside_draw_; } |
372 | 433 |
434 void SingleThreadProxy::DidActivatePendingTree() { | |
435 // Impl-side painting only. | |
436 NOTREACHED(); | |
437 } | |
438 | |
439 void SingleThreadProxy::DidManageTiles() { | |
440 // Impl-side painting only. | |
441 NOTREACHED(); | |
442 } | |
443 | |
373 void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() { | 444 void SingleThreadProxy::DidLoseOutputSurfaceOnImplThread() { |
374 TRACE_EVENT0("cc", "SingleThreadProxy::DidLoseOutputSurfaceOnImplThread"); | 445 TRACE_EVENT0("cc", "SingleThreadProxy::DidLoseOutputSurfaceOnImplThread"); |
375 // Cause a commit so we can notice the lost context. | 446 { |
376 SetNeedsCommitOnImplThread(); | 447 DebugScopedSetMainThread main(this); |
448 // This must happen before we notify the scheduler as it may try to recreate | |
449 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. | |
450 layer_tree_host_->DidLoseOutputSurface(); | |
451 } | |
452 | |
453 // TODO(enne): this client call could maybe be removed. | |
377 client_->DidAbortSwapBuffers(); | 454 client_->DidAbortSwapBuffers(); |
455 | |
456 scheduler_on_impl_thread_->DidLoseOutputSurface(); | |
378 } | 457 } |
379 | 458 |
380 void SingleThreadProxy::DidSwapBuffersOnImplThread() { | 459 void SingleThreadProxy::DidSwapBuffersOnImplThread() { |
460 // TODO(enne): Maybe this is redundant with DidCommitAndDrawFrame and can be | |
461 // removed? | |
381 client_->DidPostSwapBuffers(); | 462 client_->DidPostSwapBuffers(); |
382 } | 463 } |
383 | 464 |
384 void SingleThreadProxy::OnSwapBuffersCompleteOnImplThread() { | 465 void SingleThreadProxy::OnSwapBuffersCompleteOnImplThread() { |
385 TRACE_EVENT0("cc", "SingleThreadProxy::OnSwapBuffersCompleteOnImplThread"); | 466 TRACE_EVENT0("cc", "SingleThreadProxy::OnSwapBuffersCompleteOnImplThread"); |
386 client_->DidCompleteSwapBuffers(); | 467 client_->DidCompleteSwapBuffers(); |
387 } | 468 } |
388 | 469 |
389 // Called by the legacy scheduling path (e.g. where render_widget does the | 470 void SingleThreadProxy::BeginImplFrame(const BeginFrameArgs& args) { |
390 // scheduling) | 471 TRACE_EVENT0("cc", "ThreadProxy::BeginImplFrame"); |
472 scheduler_on_impl_thread_->BeginImplFrame(args); | |
473 } | |
474 | |
391 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { | 475 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { |
392 TRACE_EVENT0("cc", "SingleThreadProxy::CompositeImmediately"); | 476 TRACE_EVENT0("cc", "SingleThreadProxy::CompositeImmediately"); |
477 bool do_commit = true; | |
478 bool for_readback = false; | |
393 gfx::Rect device_viewport_damage_rect; | 479 gfx::Rect device_viewport_damage_rect; |
394 | 480 CommitAndCompositeInternal(gfx::FrameTime::Now(), |
395 LayerTreeHostImpl::FrameData frame; | 481 device_viewport_damage_rect, |
396 if (CommitAndComposite(frame_begin_time, | 482 do_commit, |
397 device_viewport_damage_rect, | 483 for_readback); |
398 false, // for_readback | |
399 &frame)) { | |
400 { | |
401 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | |
402 DebugScopedSetImplThread impl(this); | |
403 | |
404 // This CapturePostTasks should be destroyed before | |
405 // DidCommitAndDrawFrame() is called since that goes out to the embedder, | |
406 // and we want the embedder to receive its callbacks before that. | |
407 // NOTE: This maintains consistent ordering with the ThreadProxy since | |
408 // the DidCommitAndDrawFrame() must be post-tasked from the impl thread | |
409 // there as the main thread is not blocked, so any posted tasks inside | |
410 // the swap buffers will execute first. | |
411 BlockingTaskRunner::CapturePostTasks blocked; | |
412 | |
413 layer_tree_host_impl_->SwapBuffers(frame); | |
414 } | |
415 DidSwapFrame(); | |
416 } | |
417 } | 484 } |
418 | 485 |
419 scoped_ptr<base::Value> SingleThreadProxy::AsValue() const { | 486 scoped_ptr<base::Value> SingleThreadProxy::AsValue() const { |
420 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 487 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
421 { | 488 { |
422 // The following line casts away const modifiers because it is just | 489 // The following line casts away const modifiers because it is just |
423 // setting debug state. We still want the AsValue() function and its | 490 // setting debug state. We still want the AsValue() function and its |
424 // call chain to be const throughout. | 491 // call chain to be const throughout. |
425 DebugScopedSetImplThread impl(const_cast<SingleThreadProxy*>(this)); | 492 DebugScopedSetImplThread impl(const_cast<SingleThreadProxy*>(this)); |
426 | 493 |
427 state->Set("layer_tree_host_impl", | 494 state->Set("layer_tree_host_impl", |
428 layer_tree_host_impl_->AsValue().release()); | 495 layer_tree_host_impl_->AsValue().release()); |
429 } | 496 } |
430 return state.PassAs<base::Value>(); | 497 return state.PassAs<base::Value>(); |
431 } | 498 } |
432 | 499 |
433 void SingleThreadProxy::ForceSerializeOnSwapBuffers() { | 500 void SingleThreadProxy::ForceSerializeOnSwapBuffers() { |
434 { | 501 { |
435 DebugScopedSetImplThread impl(this); | 502 DebugScopedSetImplThread impl(this); |
436 if (layer_tree_host_impl_->renderer()) { | 503 if (layer_tree_host_impl_->renderer()) { |
437 DCHECK(!layer_tree_host_->output_surface_lost()); | 504 DCHECK(!layer_tree_host_->output_surface_lost()); |
438 layer_tree_host_impl_->renderer()->DoNoOp(); | 505 layer_tree_host_impl_->renderer()->DoNoOp(); |
439 } | 506 } |
440 } | 507 } |
441 } | 508 } |
442 | 509 |
443 bool SingleThreadProxy::CommitAndComposite( | 510 bool SingleThreadProxy::ShouldComposite() const { |
444 base::TimeTicks frame_begin_time, | 511 DCHECK(Proxy::IsImplThread()); |
445 const gfx::Rect& device_viewport_damage_rect, | 512 return scheduler_on_impl_thread_->WillDrawIfNeeded(); |
446 bool for_readback, | 513 } |
447 LayerTreeHostImpl::FrameData* frame) { | |
448 TRACE_EVENT0("cc", "SingleThreadProxy::CommitAndComposite"); | |
449 DCHECK(Proxy::IsMainThread()); | |
450 | 514 |
451 if (!layer_tree_host_->InitializeOutputSurfaceIfNeeded()) | 515 void SingleThreadProxy::UpdateBackgroundAnimateTicking() { |
452 return false; | 516 DCHECK(Proxy::IsImplThread()); |
517 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( | |
518 !ShouldComposite() && layer_tree_host_impl_->active_tree()->root_layer()); | |
519 } | |
453 | 520 |
454 layer_tree_host_->AnimateLayers(frame_begin_time); | 521 scoped_refptr<ContextProvider> SingleThreadProxy::OffscreenContextProvider() { |
455 | |
456 if (PrioritizedResourceManager* contents_texture_manager = | |
457 layer_tree_host_->contents_texture_manager()) { | |
458 contents_texture_manager->UnlinkAndClearEvictedBackings(); | |
459 contents_texture_manager->SetMaxMemoryLimitBytes( | |
460 layer_tree_host_impl_->memory_allocation_limit_bytes()); | |
461 contents_texture_manager->SetExternalPriorityCutoff( | |
462 layer_tree_host_impl_->memory_allocation_priority_cutoff()); | |
463 } | |
464 | |
465 scoped_ptr<ResourceUpdateQueue> queue = | |
466 make_scoped_ptr(new ResourceUpdateQueue); | |
467 layer_tree_host_->UpdateLayers(queue.get()); | |
468 | |
469 layer_tree_host_->WillCommit(); | |
470 | |
471 scoped_refptr<ContextProvider> offscreen_context_provider; | 522 scoped_refptr<ContextProvider> offscreen_context_provider; |
472 if (renderer_capabilities_for_main_thread_.using_offscreen_context3d && | 523 if (renderer_capabilities_for_main_thread_.using_offscreen_context3d && |
473 layer_tree_host_->needs_offscreen_context()) { | 524 layer_tree_host_->needs_offscreen_context()) { |
474 offscreen_context_provider = | 525 offscreen_context_provider = |
475 layer_tree_host_->client()->OffscreenContextProvider(); | 526 layer_tree_host_->client()->OffscreenContextProvider(); |
476 if (offscreen_context_provider.get() && | 527 if (offscreen_context_provider.get() && |
477 !offscreen_context_provider->BindToCurrentThread()) | 528 !offscreen_context_provider->BindToCurrentThread()) |
478 offscreen_context_provider = NULL; | 529 offscreen_context_provider = NULL; |
479 | 530 |
480 if (offscreen_context_provider.get()) | 531 if (offscreen_context_provider.get()) |
481 created_offscreen_context_provider_ = true; | 532 created_offscreen_context_provider_ = true; |
482 } | 533 } |
483 | 534 return offscreen_context_provider; |
484 DoCommit(queue.Pass()); | |
485 bool result = DoComposite(offscreen_context_provider, | |
486 frame_begin_time, | |
487 device_viewport_damage_rect, | |
488 for_readback, | |
489 frame); | |
490 layer_tree_host_->DidBeginMainFrame(); | |
491 return result; | |
492 } | 535 } |
493 | 536 |
494 bool SingleThreadProxy::ShouldComposite() const { | 537 DrawSwapReadbackResult::DrawResult SingleThreadProxy::DoComposite( |
495 DCHECK(Proxy::IsImplThread()); | |
496 return layer_tree_host_impl_->visible() && | |
497 layer_tree_host_impl_->CanDraw(); | |
498 } | |
499 | |
500 void SingleThreadProxy::UpdateBackgroundAnimateTicking() { | |
501 DCHECK(Proxy::IsImplThread()); | |
502 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( | |
503 !ShouldComposite() && layer_tree_host_impl_->active_tree()->root_layer()); | |
504 } | |
505 | |
506 bool SingleThreadProxy::DoComposite( | |
507 scoped_refptr<ContextProvider> offscreen_context_provider, | 538 scoped_refptr<ContextProvider> offscreen_context_provider, |
508 base::TimeTicks frame_begin_time, | 539 base::TimeTicks frame_begin_time, |
509 const gfx::Rect& device_viewport_damage_rect, | 540 const gfx::Rect& device_viewport_damage_rect, |
510 bool for_readback, | 541 bool for_readback, |
511 LayerTreeHostImpl::FrameData* frame) { | 542 LayerTreeHostImpl::FrameData* frame) { |
512 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite"); | 543 TRACE_EVENT0("cc", "SingleThreadProxy::DoComposite"); |
513 DCHECK(!layer_tree_host_->output_surface_lost()); | 544 DCHECK(!layer_tree_host_->output_surface_lost()); |
514 | 545 |
515 bool lost_output_surface = false; | 546 bool lost_output_surface = false; |
516 { | 547 { |
517 DebugScopedSetImplThread impl(this); | 548 DebugScopedSetImplThread impl(this); |
518 base::AutoReset<bool> mark_inside(&inside_draw_, true); | 549 base::AutoReset<bool> mark_inside(&inside_draw_, true); |
519 | 550 |
520 layer_tree_host_impl_->SetOffscreenContextProvider( | 551 layer_tree_host_impl_->SetOffscreenContextProvider( |
521 offscreen_context_provider); | 552 offscreen_context_provider); |
522 | 553 |
523 bool can_do_readback = layer_tree_host_impl_->renderer()->CanReadPixels(); | 554 bool can_do_readback = layer_tree_host_impl_->renderer()->CanReadPixels(); |
524 | 555 |
525 // We guard PrepareToDraw() with CanDraw() because it always returns a valid | 556 // We guard PrepareToDraw() with CanDraw() because it always returns a valid |
526 // frame, so can only be used when such a frame is possible. Since | 557 // frame, so can only be used when such a frame is possible. Since |
527 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on | 558 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on |
528 // CanDraw() as well. | 559 // CanDraw() as well. |
529 if (!ShouldComposite() || (for_readback && !can_do_readback)) { | 560 if (!ShouldComposite() || (for_readback && !can_do_readback)) { |
530 UpdateBackgroundAnimateTicking(); | 561 UpdateBackgroundAnimateTicking(); |
531 return false; | 562 return DrawSwapReadbackResult::DRAW_ABORTED_CANT_DRAW; |
532 } | 563 } |
533 | 564 |
534 layer_tree_host_impl_->Animate( | 565 layer_tree_host_impl_->Animate( |
535 layer_tree_host_impl_->CurrentFrameTimeTicks(), | 566 layer_tree_host_impl_->CurrentFrameTimeTicks(), |
536 layer_tree_host_impl_->CurrentFrameTime()); | 567 layer_tree_host_impl_->CurrentFrameTime()); |
537 UpdateBackgroundAnimateTicking(); | 568 UpdateBackgroundAnimateTicking(); |
538 | 569 |
539 if (!layer_tree_host_impl_->IsContextLost()) { | 570 if (!layer_tree_host_impl_->IsContextLost()) { |
540 layer_tree_host_impl_->PrepareToDraw(frame, device_viewport_damage_rect); | 571 layer_tree_host_impl_->PrepareToDraw(frame, device_viewport_damage_rect); |
541 layer_tree_host_impl_->DrawLayers(frame, frame_begin_time); | 572 layer_tree_host_impl_->DrawLayers(frame, frame_begin_time); |
542 layer_tree_host_impl_->DidDrawAllLayers(*frame); | 573 layer_tree_host_impl_->DidDrawAllLayers(*frame); |
543 } | 574 } |
544 lost_output_surface = layer_tree_host_impl_->IsContextLost(); | 575 lost_output_surface = layer_tree_host_impl_->IsContextLost(); |
545 | 576 |
546 bool start_ready_animations = true; | 577 bool start_ready_animations = true; |
547 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); | 578 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
548 | 579 |
549 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); | 580 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); |
550 } | 581 } |
551 | 582 |
552 if (lost_output_surface) { | 583 if (lost_output_surface) { |
553 ContextProvider* offscreen_contexts = | 584 ContextProvider* offscreen_contexts = |
554 layer_tree_host_impl_->offscreen_context_provider(); | 585 layer_tree_host_impl_->offscreen_context_provider(); |
555 if (offscreen_contexts) | 586 if (offscreen_contexts) |
556 offscreen_contexts->VerifyContexts(); | 587 offscreen_contexts->VerifyContexts(); |
557 layer_tree_host_->DidLoseOutputSurface(); | 588 DidLoseOutputSurfaceOnImplThread(); |
558 return false; | 589 if (for_readback) |
590 return DrawSwapReadbackResult::DRAW_ABORTED_CONTEXT_LOST; | |
559 } | 591 } |
560 | 592 |
561 return true; | 593 return DrawSwapReadbackResult::DRAW_SUCCESS; |
562 } | 594 } |
563 | 595 |
564 void SingleThreadProxy::DidSwapFrame() { | 596 void SingleThreadProxy::DidCommitAndDrawFrame() { |
565 if (next_frame_is_newly_committed_frame_) { | 597 if (next_frame_is_newly_committed_frame_) { |
566 next_frame_is_newly_committed_frame_ = false; | 598 next_frame_is_newly_committed_frame_ = false; |
567 layer_tree_host_->DidCommitAndDrawFrame(); | 599 layer_tree_host_->DidCommitAndDrawFrame(); |
568 } | 600 } |
569 } | 601 } |
570 | 602 |
571 bool SingleThreadProxy::CommitPendingForTesting() { return false; } | 603 bool SingleThreadProxy::CommitPendingForTesting() { return false; } |
572 | 604 |
605 scoped_ptr<base::Value> SingleThreadProxy::SchedulerStateAsValueForTesting() { | |
606 DebugScopedSetImplThread impl(this); | |
607 return scheduler_on_impl_thread_->StateAsValue().Pass(); | |
608 } | |
609 | |
610 void SingleThreadProxy::SetNeedsBeginImplFrame(bool enable) { | |
611 if (OutputSurface* surface = layer_tree_host_impl_->output_surface()) | |
612 surface->SetNeedsBeginImplFrame(enable); | |
613 } | |
614 | |
615 void SingleThreadProxy::ScheduledActionSendBeginMainFrame() { | |
616 if (defer_commits_) { | |
617 DCHECK(!finish_commit_deferred_); | |
618 finish_commit_deferred_ = true; | |
619 return; | |
620 } | |
621 timing_history_.DidBeginMainFrame(); | |
622 | |
623 // This is poorly named, but tells the scheduler that we are ready to | |
624 // start the commit. In threaded mode, this is when the uploads are done. | |
625 // In single-threaded mode, it doesn't really matter. Doing no work here | |
626 // and all the work in commit prevents needless carrying of state (like | |
627 // the upload queue) from BeginMainFrame to commit. | |
628 scheduler_on_impl_thread_->FinishCommit(); | |
629 } | |
630 | |
631 DrawSwapReadbackResult | |
632 SingleThreadProxy::ScheduledActionDrawAndSwapIfPossible() { | |
633 bool do_commit = false; | |
634 bool for_readback = false; | |
635 gfx::Rect device_viewport_damage_rect; | |
636 return CommitAndCompositeInternal(gfx::FrameTime::Now(), | |
637 device_viewport_damage_rect, | |
638 do_commit, | |
639 for_readback); | |
640 } | |
641 | |
642 DrawSwapReadbackResult SingleThreadProxy::ScheduledActionDrawAndSwapForced() { | |
643 return ScheduledActionDrawAndSwapIfPossible(); | |
644 } | |
645 | |
646 DrawSwapReadbackResult SingleThreadProxy::ScheduledActionDrawAndReadback() { | |
647 // The SingleThreadProxy never asks for a commit for readback, | |
648 // so this should never happen. | |
649 NOTREACHED(); | |
650 DrawSwapReadbackResult result; | |
651 return result; | |
652 } | |
653 | |
654 DrawSwapReadbackResult SingleThreadProxy::CommitAndCompositeInternal( | |
655 base::TimeTicks frame_begin_time, | |
656 gfx::Rect device_viewport_damage_rect, | |
657 bool do_commit, | |
658 bool for_readback) { | |
659 DCHECK(Proxy::IsMainThread()); | |
660 DrawSwapReadbackResult result; | |
661 | |
662 if (!layer_tree_host_->InitializeOutputSurfaceIfNeeded()) { | |
663 result.draw_result = DrawSwapReadbackResult::DRAW_ABORTED_CONTEXT_LOST; | |
664 return result; | |
665 } | |
666 | |
667 if (do_commit) | |
668 DoCommit(frame_begin_time); | |
669 | |
670 scoped_refptr<ContextProvider> offscreen_context_provider = | |
671 OffscreenContextProvider(); | |
danakj
2014/02/20 20:56:40
Hm ok one more question.
Is it going to be confus
enne (OOO)
2014/02/20 21:07:13
Is there an ordering issue that you're concerned a
danakj
2014/02/20 21:09:47
Just consistency. It comes to mind because when wr
| |
672 LayerTreeHostImpl::FrameData frame; | |
673 timing_history_.DidStartDrawing(); | |
674 result.draw_result = DoComposite(offscreen_context_provider, | |
675 frame_begin_time, | |
676 device_viewport_damage_rect, | |
677 for_readback, | |
678 &frame); | |
679 if (result.draw_result != DrawSwapReadbackResult::DRAW_SUCCESS) | |
680 return result; | |
681 | |
682 timing_history_.DidFinishDrawing(); | |
683 | |
684 result.did_readback = for_readback; | |
685 | |
686 { | |
687 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | |
688 DebugScopedSetImplThread impl(this); | |
689 | |
690 // This CapturePostTasks should be destroyed before | |
691 // DidCommitAndDrawFrame() is called since that goes out to the embedder, | |
692 // and we want the embedder to receive its callbacks before that. | |
693 // NOTE: This maintains consistent ordering with the ThreadProxy since | |
694 // the DidCommitAndDrawFrame() must be post-tasked from the impl thread | |
695 // there as the main thread is not blocked, so any posted tasks inside | |
696 // the swap buffers will execute first. | |
697 BlockingTaskRunner::CapturePostTasks blocked; | |
698 result.did_swap = layer_tree_host_impl_->SwapBuffers(frame); | |
699 } | |
700 | |
701 DidCommitAndDrawFrame(); | |
702 | |
703 return result; | |
704 } | |
705 | |
706 void SingleThreadProxy::ScheduledActionCommit() { | |
707 DebugScopedSetMainThread main(this); | |
708 DoCommit(gfx::FrameTime::Now()); | |
709 } | |
710 | |
711 void SingleThreadProxy::ScheduledActionUpdateVisibleTiles() { | |
712 // Impl-side painting only. | |
713 NOTREACHED(); | |
714 } | |
715 | |
716 void SingleThreadProxy::ScheduledActionActivatePendingTree() { | |
717 // Impl-side painting only. | |
718 NOTREACHED(); | |
719 } | |
720 | |
721 void SingleThreadProxy::ScheduledActionBeginOutputSurfaceCreation() { | |
722 DebugScopedSetMainThread main(this); | |
723 layer_tree_host_->InitializeOutputSurfaceIfNeeded(); | |
724 } | |
725 | |
726 void SingleThreadProxy::ScheduledActionAcquireLayerTexturesForMainThread() { | |
727 scheduler_on_impl_thread_->SetMainThreadNeedsLayerTextures(); | |
728 } | |
729 | |
730 void SingleThreadProxy::ScheduledActionManageTiles() { | |
731 // Impl-side painting only. | |
732 NOTREACHED(); | |
733 } | |
734 | |
735 void SingleThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) {} | |
736 | |
737 base::TimeDelta SingleThreadProxy::DrawDurationEstimate() { | |
738 return timing_history_.DrawDurationEstimate(); | |
739 } | |
740 | |
741 base::TimeDelta SingleThreadProxy::BeginMainFrameToCommitDurationEstimate() { | |
742 return timing_history_.BeginMainFrameToCommitDurationEstimate(); | |
743 } | |
744 | |
745 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { | |
746 return timing_history_.CommitToActivateDurationEstimate(); | |
747 } | |
748 | |
749 void SingleThreadProxy::PostBeginImplFrameDeadline(const base::Closure& closure, | |
750 base::TimeTicks deadline) { | |
751 base::TimeDelta delta = deadline - gfx::FrameTime::Now(); | |
752 if (delta <= base::TimeDelta()) | |
753 delta = base::TimeDelta(); | |
754 Proxy::MainThreadTaskRunner()->PostDelayedTask(FROM_HERE, closure, delta); | |
755 } | |
756 | |
757 void SingleThreadProxy::DidBeginImplFrameDeadline() { | |
758 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); | |
759 } | |
760 | |
573 } // namespace cc | 761 } // namespace cc |
OLD | NEW |