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