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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 | 331 |
332 void SingleThreadProxy::DidSwapBuffersCompleteOnImplThread() { | 332 void SingleThreadProxy::DidSwapBuffersCompleteOnImplThread() { |
333 TRACE_EVENT0("cc", "SingleThreadProxy::DidSwapBuffersCompleteOnImplThread"); | 333 TRACE_EVENT0("cc", "SingleThreadProxy::DidSwapBuffersCompleteOnImplThread"); |
334 client_->DidCompleteSwapBuffers(); | 334 client_->DidCompleteSwapBuffers(); |
335 } | 335 } |
336 | 336 |
337 // Called by the legacy scheduling path (e.g. where render_widget does the | 337 // Called by the legacy scheduling path (e.g. where render_widget does the |
338 // scheduling) | 338 // scheduling) |
339 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { | 339 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { |
340 TRACE_EVENT0("cc", "SingleThreadProxy::CompositeImmediately"); | 340 TRACE_EVENT0("cc", "SingleThreadProxy::CompositeImmediately"); |
| 341 DCHECK(Proxy::IsMainThread()); |
| 342 |
| 343 if (!layer_tree_host_->InitializeOutputSurfaceIfNeeded()) |
| 344 return; |
| 345 |
| 346 layer_tree_host_->AnimateLayers(frame_begin_time); |
| 347 |
| 348 if (PrioritizedResourceManager* contents_texture_manager = |
| 349 layer_tree_host_->contents_texture_manager()) { |
| 350 contents_texture_manager->UnlinkAndClearEvictedBackings(); |
| 351 contents_texture_manager->SetMaxMemoryLimitBytes( |
| 352 layer_tree_host_impl_->memory_allocation_limit_bytes()); |
| 353 contents_texture_manager->SetExternalPriorityCutoff( |
| 354 layer_tree_host_impl_->memory_allocation_priority_cutoff()); |
| 355 } |
| 356 |
| 357 scoped_ptr<ResourceUpdateQueue> queue = |
| 358 make_scoped_ptr(new ResourceUpdateQueue); |
| 359 layer_tree_host_->UpdateLayers(queue.get()); |
| 360 layer_tree_host_->WillCommit(); |
| 361 DoCommit(queue.Pass()); |
| 362 layer_tree_host_->DidBeginMainFrame(); |
341 | 363 |
342 LayerTreeHostImpl::FrameData frame; | 364 LayerTreeHostImpl::FrameData frame; |
343 if (CommitAndComposite(frame_begin_time, &frame)) { | 365 if (DoComposite(frame_begin_time, &frame)) { |
344 { | 366 { |
345 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 367 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
346 DebugScopedSetImplThread impl(this); | 368 DebugScopedSetImplThread impl(this); |
347 | 369 |
348 // This CapturePostTasks should be destroyed before | 370 // This CapturePostTasks should be destroyed before |
349 // DidCommitAndDrawFrame() is called since that goes out to the embedder, | 371 // DidCommitAndDrawFrame() is called since that goes out to the embedder, |
350 // and we want the embedder to receive its callbacks before that. | 372 // and we want the embedder to receive its callbacks before that. |
351 // NOTE: This maintains consistent ordering with the ThreadProxy since | 373 // NOTE: This maintains consistent ordering with the ThreadProxy since |
352 // the DidCommitAndDrawFrame() must be post-tasked from the impl thread | 374 // the DidCommitAndDrawFrame() must be post-tasked from the impl thread |
353 // there as the main thread is not blocked, so any posted tasks inside | 375 // there as the main thread is not blocked, so any posted tasks inside |
(...skipping 23 matching lines...) Expand all Loading... |
377 void SingleThreadProxy::ForceSerializeOnSwapBuffers() { | 399 void SingleThreadProxy::ForceSerializeOnSwapBuffers() { |
378 { | 400 { |
379 DebugScopedSetImplThread impl(this); | 401 DebugScopedSetImplThread impl(this); |
380 if (layer_tree_host_impl_->renderer()) { | 402 if (layer_tree_host_impl_->renderer()) { |
381 DCHECK(!layer_tree_host_->output_surface_lost()); | 403 DCHECK(!layer_tree_host_->output_surface_lost()); |
382 layer_tree_host_impl_->renderer()->DoNoOp(); | 404 layer_tree_host_impl_->renderer()->DoNoOp(); |
383 } | 405 } |
384 } | 406 } |
385 } | 407 } |
386 | 408 |
387 bool SingleThreadProxy::CommitAndComposite( | |
388 base::TimeTicks frame_begin_time, | |
389 LayerTreeHostImpl::FrameData* frame) { | |
390 TRACE_EVENT0("cc", "SingleThreadProxy::CommitAndComposite"); | |
391 DCHECK(Proxy::IsMainThread()); | |
392 | |
393 if (!layer_tree_host_->InitializeOutputSurfaceIfNeeded()) | |
394 return false; | |
395 | |
396 layer_tree_host_->AnimateLayers(frame_begin_time); | |
397 | |
398 if (PrioritizedResourceManager* contents_texture_manager = | |
399 layer_tree_host_->contents_texture_manager()) { | |
400 contents_texture_manager->UnlinkAndClearEvictedBackings(); | |
401 contents_texture_manager->SetMaxMemoryLimitBytes( | |
402 layer_tree_host_impl_->memory_allocation_limit_bytes()); | |
403 contents_texture_manager->SetExternalPriorityCutoff( | |
404 layer_tree_host_impl_->memory_allocation_priority_cutoff()); | |
405 } | |
406 | |
407 scoped_ptr<ResourceUpdateQueue> queue = | |
408 make_scoped_ptr(new ResourceUpdateQueue); | |
409 layer_tree_host_->UpdateLayers(queue.get()); | |
410 | |
411 layer_tree_host_->WillCommit(); | |
412 | |
413 DoCommit(queue.Pass()); | |
414 bool result = DoComposite(frame_begin_time, frame); | |
415 layer_tree_host_->DidBeginMainFrame(); | |
416 return result; | |
417 } | |
418 | |
419 bool SingleThreadProxy::ShouldComposite() const { | 409 bool SingleThreadProxy::ShouldComposite() const { |
420 DCHECK(Proxy::IsImplThread()); | 410 DCHECK(Proxy::IsImplThread()); |
421 return layer_tree_host_impl_->visible() && | 411 return layer_tree_host_impl_->visible() && |
422 layer_tree_host_impl_->CanDraw(); | 412 layer_tree_host_impl_->CanDraw(); |
423 } | 413 } |
424 | 414 |
425 void SingleThreadProxy::UpdateBackgroundAnimateTicking() { | 415 void SingleThreadProxy::UpdateBackgroundAnimateTicking() { |
426 DCHECK(Proxy::IsImplThread()); | 416 DCHECK(Proxy::IsImplThread()); |
427 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( | 417 layer_tree_host_impl_->UpdateBackgroundAnimateTicking( |
428 !ShouldComposite() && layer_tree_host_impl_->active_tree()->root_layer()); | 418 !ShouldComposite() && layer_tree_host_impl_->active_tree()->root_layer()); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 void SingleThreadProxy::DidSwapFrame() { | 466 void SingleThreadProxy::DidSwapFrame() { |
477 if (next_frame_is_newly_committed_frame_) { | 467 if (next_frame_is_newly_committed_frame_) { |
478 next_frame_is_newly_committed_frame_ = false; | 468 next_frame_is_newly_committed_frame_ = false; |
479 layer_tree_host_->DidCommitAndDrawFrame(); | 469 layer_tree_host_->DidCommitAndDrawFrame(); |
480 } | 470 } |
481 } | 471 } |
482 | 472 |
483 bool SingleThreadProxy::CommitPendingForTesting() { return false; } | 473 bool SingleThreadProxy::CommitPendingForTesting() { return false; } |
484 | 474 |
485 } // namespace cc | 475 } // namespace cc |
OLD | NEW |