| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/trees/thread_proxy.h" | 5 #include "cc/trees/thread_proxy.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "cc/base/thread.h" | 10 #include "cc/base/thread.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 const double kContextRecreationTickRate = 0.03; | 25 const double kContextRecreationTickRate = 0.03; |
| 26 | 26 |
| 27 // Measured in seconds. | 27 // Measured in seconds. |
| 28 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; | 28 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; |
| 29 | 29 |
| 30 } // namespace | 30 } // namespace |
| 31 | 31 |
| 32 namespace cc { | 32 namespace cc { |
| 33 | 33 |
| 34 scoped_ptr<Proxy> ThreadProxy::Create(LayerTreeHost* layer_tree_host, | 34 scoped_ptr<Proxy> ThreadProxy::Create(LayerTreeHost* layer_tree_host, |
| 35 scoped_ptr<Thread> implThread) { | 35 scoped_ptr<Thread> impl_thread) { |
| 36 return make_scoped_ptr( | 36 return make_scoped_ptr( |
| 37 new ThreadProxy(layer_tree_host, implThread.Pass())).PassAs<Proxy>(); | 37 new ThreadProxy(layer_tree_host, impl_thread.Pass())).PassAs<Proxy>(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 ThreadProxy::ThreadProxy(LayerTreeHost* layer_tree_host, | 40 ThreadProxy::ThreadProxy(LayerTreeHost* layer_tree_host, |
| 41 scoped_ptr<Thread> implThread) | 41 scoped_ptr<Thread> impl_thread) |
| 42 : Proxy(implThread.Pass()), | 42 : Proxy(impl_thread.Pass()), |
| 43 animate_requested_(false), | 43 animate_requested_(false), |
| 44 commit_requested_(false), | 44 commit_requested_(false), |
| 45 commit_request_sent_to_impl_thread_(false), | 45 commit_request_sent_to_impl_thread_(false), |
| 46 created_offscreen_context_provider_(false), | 46 created_offscreen_context_provider_(false), |
| 47 layer_tree_host_(layer_tree_host), | 47 layer_tree_host_(layer_tree_host), |
| 48 renderer_initialized_(false), | 48 renderer_initialized_(false), |
| 49 started_(false), | 49 started_(false), |
| 50 textures_acquired_(true), | 50 textures_acquired_(true), |
| 51 in_composite_and_readback_(false), | 51 in_composite_and_readback_(false), |
| 52 manage_tiles_pending_(false), | 52 manage_tiles_pending_(false), |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 void ThreadProxy::SetVisibleOnImplThread(CompletionEvent* completion, | 209 void ThreadProxy::SetVisibleOnImplThread(CompletionEvent* completion, |
| 210 bool visible) { | 210 bool visible) { |
| 211 TRACE_EVENT0("cc", "ThreadProxy::SetVisibleOnImplThread"); | 211 TRACE_EVENT0("cc", "ThreadProxy::SetVisibleOnImplThread"); |
| 212 layer_tree_host_impl_->SetVisible(visible); | 212 layer_tree_host_impl_->SetVisible(visible); |
| 213 scheduler_on_impl_thread_->SetVisible(visible); | 213 scheduler_on_impl_thread_->SetVisible(visible); |
| 214 completion->Signal(); | 214 completion->Signal(); |
| 215 } | 215 } |
| 216 | 216 |
| 217 bool ThreadProxy::InitializeRenderer() { | 217 bool ThreadProxy::InitializeRenderer() { |
| 218 TRACE_EVENT0("cc", "ThreadProxy::InitializeRenderer"); | 218 TRACE_EVENT0("cc", "ThreadProxy::InitializeRenderer"); |
| 219 // Make a blocking call to initializeRendererOnImplThread. The results of that | 219 // Make a blocking call to InitializeRendererOnImplThread. The results of that |
| 220 // call are pushed into the initialize_succeeded and capabilities local | 220 // call are pushed into the initialize_succeeded and capabilities local |
| 221 // variables. | 221 // variables. |
| 222 CompletionEvent completion; | 222 CompletionEvent completion; |
| 223 bool initialize_succeeded = false; | 223 bool initialize_succeeded = false; |
| 224 RendererCapabilities capabilities; | 224 RendererCapabilities capabilities; |
| 225 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 225 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 226 Proxy::ImplThread()->PostTask( | 226 Proxy::ImplThread()->PostTask( |
| 227 base::Bind(&ThreadProxy::InitializeRendererOnImplThread, | 227 base::Bind(&ThreadProxy::InitializeRendererOnImplThread, |
| 228 impl_thread_weak_ptr_, | 228 impl_thread_weak_ptr_, |
| 229 &completion, | 229 &completion, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 248 if (!output_surface) | 248 if (!output_surface) |
| 249 return false; | 249 return false; |
| 250 scoped_refptr<cc::ContextProvider> offscreen_context_provider; | 250 scoped_refptr<cc::ContextProvider> offscreen_context_provider; |
| 251 if (created_offscreen_context_provider_) { | 251 if (created_offscreen_context_provider_) { |
| 252 offscreen_context_provider = layer_tree_host_->client()-> | 252 offscreen_context_provider = layer_tree_host_->client()-> |
| 253 OffscreenContextProviderForCompositorThread(); | 253 OffscreenContextProviderForCompositorThread(); |
| 254 if (!offscreen_context_provider) | 254 if (!offscreen_context_provider) |
| 255 return false; | 255 return false; |
| 256 } | 256 } |
| 257 | 257 |
| 258 // Make a blocking call to recreateOutputSurfaceOnImplThread. The results of | 258 // Make a blocking call to RecreateOutputSurfaceOnImplThread. The results of |
| 259 // that call are pushed into the recreate_succeeded and capabilities local | 259 // that call are pushed into the recreate_succeeded and capabilities local |
| 260 // variables. | 260 // variables. |
| 261 CompletionEvent completion; | 261 CompletionEvent completion; |
| 262 bool recreate_succeeded = false; | 262 bool recreate_succeeded = false; |
| 263 RendererCapabilities capabilities; | 263 RendererCapabilities capabilities; |
| 264 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 264 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 265 Proxy::ImplThread()->PostTask( | 265 Proxy::ImplThread()->PostTask( |
| 266 base::Bind(&ThreadProxy::RecreateOutputSurfaceOnImplThread, | 266 base::Bind(&ThreadProxy::RecreateOutputSurfaceOnImplThread, |
| 267 impl_thread_weak_ptr_, | 267 impl_thread_weak_ptr_, |
| 268 &completion, | 268 &completion, |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 layer_tree_host_impl_->resource_provider()); | 438 layer_tree_host_impl_->resource_provider()); |
| 439 } | 439 } |
| 440 | 440 |
| 441 void ThreadProxy::SendManagedMemoryStats() { | 441 void ThreadProxy::SendManagedMemoryStats() { |
| 442 DCHECK(IsImplThread()); | 442 DCHECK(IsImplThread()); |
| 443 if (!layer_tree_host_impl_) | 443 if (!layer_tree_host_impl_) |
| 444 return; | 444 return; |
| 445 if (!layer_tree_host_->contents_texture_manager()) | 445 if (!layer_tree_host_->contents_texture_manager()) |
| 446 return; | 446 return; |
| 447 | 447 |
| 448 // If we are using impl-side painting, then sendManagedMemoryStats is called | 448 // If we are using impl-side painting, then SendManagedMemoryStats is called |
| 449 // directly after the tile manager's manage function, and doesn't need to | 449 // directly after the tile manager's manage function, and doesn't need to |
| 450 // interact with main thread's layer tree. | 450 // interact with main thread's layer tree. |
| 451 if (layer_tree_host_->settings().impl_side_painting) | 451 if (layer_tree_host_->settings().impl_side_painting) |
| 452 return; | 452 return; |
| 453 | 453 |
| 454 layer_tree_host_impl_->SendManagedMemoryStats( | 454 layer_tree_host_impl_->SendManagedMemoryStats( |
| 455 layer_tree_host_->contents_texture_manager()->MemoryVisibleBytes(), | 455 layer_tree_host_->contents_texture_manager()->MemoryVisibleBytes(), |
| 456 layer_tree_host_->contents_texture_manager()-> | 456 layer_tree_host_->contents_texture_manager()-> |
| 457 MemoryVisibleAndNearbyBytes(), | 457 MemoryVisibleAndNearbyBytes(), |
| 458 layer_tree_host_->contents_texture_manager()->MemoryUseBytes()); | 458 layer_tree_host_->contents_texture_manager()->MemoryUseBytes()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 486 base::Passed(&pending_deferred_commit_))); | 486 base::Passed(&pending_deferred_commit_))); |
| 487 } | 487 } |
| 488 | 488 |
| 489 bool ThreadProxy::CommitRequested() const { | 489 bool ThreadProxy::CommitRequested() const { |
| 490 DCHECK(IsMainThread()); | 490 DCHECK(IsMainThread()); |
| 491 return commit_requested_; | 491 return commit_requested_; |
| 492 } | 492 } |
| 493 | 493 |
| 494 void ThreadProxy::SetNeedsRedrawOnImplThread() { | 494 void ThreadProxy::SetNeedsRedrawOnImplThread() { |
| 495 DCHECK(IsImplThread()); | 495 DCHECK(IsImplThread()); |
| 496 TRACE_EVENT0("cc", "ThreadProxy::setNeedsRedrawOnImplThread"); | 496 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsRedrawOnImplThread"); |
| 497 scheduler_on_impl_thread_->SetNeedsRedraw(); | 497 scheduler_on_impl_thread_->SetNeedsRedraw(); |
| 498 } | 498 } |
| 499 | 499 |
| 500 void ThreadProxy::DidSwapUseIncompleteTileOnImplThread() { | 500 void ThreadProxy::DidSwapUseIncompleteTileOnImplThread() { |
| 501 DCHECK(IsImplThread()); | 501 DCHECK(IsImplThread()); |
| 502 TRACE_EVENT0("cc", "ThreadProxy::DidSwapUseIncompleteTileOnImplThread"); | 502 TRACE_EVENT0("cc", "ThreadProxy::DidSwapUseIncompleteTileOnImplThread"); |
| 503 scheduler_on_impl_thread_->DidSwapUseIncompleteTile(); | 503 scheduler_on_impl_thread_->DidSwapUseIncompleteTile(); |
| 504 } | 504 } |
| 505 | 505 |
| 506 void ThreadProxy::DidInitializeVisibleTileOnImplThread() { | 506 void ThreadProxy::DidInitializeVisibleTileOnImplThread() { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 return; | 623 return; |
| 624 | 624 |
| 625 if (defer_commits_) { | 625 if (defer_commits_) { |
| 626 pending_deferred_commit_ = begin_frame_state.Pass(); | 626 pending_deferred_commit_ = begin_frame_state.Pass(); |
| 627 layer_tree_host_->DidDeferCommit(); | 627 layer_tree_host_->DidDeferCommit(); |
| 628 TRACE_EVENT0("cc", "EarlyOut_DeferCommits"); | 628 TRACE_EVENT0("cc", "EarlyOut_DeferCommits"); |
| 629 return; | 629 return; |
| 630 } | 630 } |
| 631 | 631 |
| 632 // Do not notify the impl thread of commit requests that occur during | 632 // Do not notify the impl thread of commit requests that occur during |
| 633 // the apply/animate/layout part of the beginFrameAndCommit process since | 633 // the apply/animate/layout part of the BeginFrameAndCommit process since |
| 634 // those commit requests will get painted immediately. Once we have done | 634 // those commit requests will get painted immediately. Once we have done |
| 635 // the paint, commit_requested_ will be set to false to allow new commit | 635 // the paint, commit_requested_ will be set to false to allow new commit |
| 636 // requests to be scheduled. | 636 // requests to be scheduled. |
| 637 commit_requested_ = true; | 637 commit_requested_ = true; |
| 638 commit_request_sent_to_impl_thread_ = true; | 638 commit_request_sent_to_impl_thread_ = true; |
| 639 | 639 |
| 640 // On the other hand, the animationRequested flag needs to be cleared | 640 // On the other hand, the AnimationRequested flag needs to be cleared |
| 641 // here so that any animation requests generated by the apply or animate | 641 // here so that any animation requests generated by the apply or animate |
| 642 // callbacks will trigger another frame. | 642 // callbacks will trigger another frame. |
| 643 animate_requested_ = false; | 643 animate_requested_ = false; |
| 644 | 644 |
| 645 if (begin_frame_state) { | 645 if (begin_frame_state) { |
| 646 layer_tree_host_->ApplyScrollAndScale(*begin_frame_state->scroll_info); | 646 layer_tree_host_->ApplyScrollAndScale(*begin_frame_state->scroll_info); |
| 647 layer_tree_host_->SetImplTransform(begin_frame_state->impl_transform); | 647 layer_tree_host_->SetImplTransform(begin_frame_state->impl_transform); |
| 648 } | 648 } |
| 649 | 649 |
| 650 if (!in_composite_and_readback_ && !layer_tree_host_->visible()) { | 650 if (!in_composite_and_readback_ && !layer_tree_host_->visible()) { |
| 651 commit_requested_ = false; | 651 commit_requested_ = false; |
| 652 commit_request_sent_to_impl_thread_ = false; | 652 commit_request_sent_to_impl_thread_ = false; |
| 653 | 653 |
| 654 TRACE_EVENT0("cc", "EarlyOut_NotVisible"); | 654 TRACE_EVENT0("cc", "EarlyOut_NotVisible"); |
| 655 Proxy::ImplThread()->PostTask(base::Bind( | 655 Proxy::ImplThread()->PostTask(base::Bind( |
| 656 &ThreadProxy::BeginFrameAbortedOnImplThread, impl_thread_weak_ptr_)); | 656 &ThreadProxy::BeginFrameAbortedOnImplThread, impl_thread_weak_ptr_)); |
| 657 return; | 657 return; |
| 658 } | 658 } |
| 659 | 659 |
| 660 layer_tree_host_->WillBeginFrame(); | 660 layer_tree_host_->WillBeginFrame(); |
| 661 | 661 |
| 662 if (begin_frame_state) { | 662 if (begin_frame_state) { |
| 663 layer_tree_host_->UpdateAnimations( | 663 layer_tree_host_->UpdateAnimations( |
| 664 begin_frame_state->monotonic_frame_begin_time); | 664 begin_frame_state->monotonic_frame_begin_time); |
| 665 } | 665 } |
| 666 | 666 |
| 667 // Unlink any backings that the impl thread has evicted, so that we know to | 667 // Unlink any backings that the impl thread has evicted, so that we know to |
| 668 // re-paint them in updateLayers. | 668 // re-paint them in UpdateLayers. |
| 669 if (layer_tree_host_->contents_texture_manager()) { | 669 if (layer_tree_host_->contents_texture_manager()) { |
| 670 layer_tree_host_->contents_texture_manager()-> | 670 layer_tree_host_->contents_texture_manager()-> |
| 671 UnlinkAndClearEvictedBackings(); | 671 UnlinkAndClearEvictedBackings(); |
| 672 } | 672 } |
| 673 | 673 |
| 674 layer_tree_host_->Layout(); | 674 layer_tree_host_->Layout(); |
| 675 | 675 |
| 676 // Clear the commit flag after updating animations and layout here --- objects | 676 // Clear the commit flag after updating animations and layout here --- objects |
| 677 // that only layout when painted will trigger another setNeedsCommit inside | 677 // that only layout when painted will trigger another SetNeedsCommit inside |
| 678 // updateLayers. | 678 // UpdateLayers. |
| 679 commit_requested_ = false; | 679 commit_requested_ = false; |
| 680 commit_request_sent_to_impl_thread_ = false; | 680 commit_request_sent_to_impl_thread_ = false; |
| 681 | 681 |
| 682 if (!layer_tree_host_->InitializeRendererIfNeeded()) { | 682 if (!layer_tree_host_->InitializeRendererIfNeeded()) { |
| 683 TRACE_EVENT0("cc", "EarlyOut_InitializeFailed"); | 683 TRACE_EVENT0("cc", "EarlyOut_InitializeFailed"); |
| 684 return; | 684 return; |
| 685 } | 685 } |
| 686 | 686 |
| 687 scoped_ptr<ResourceUpdateQueue> queue = | 687 scoped_ptr<ResourceUpdateQueue> queue = |
| 688 make_scoped_ptr(new ResourceUpdateQueue); | 688 make_scoped_ptr(new ResourceUpdateQueue); |
| 689 layer_tree_host_->UpdateLayers( | 689 layer_tree_host_->UpdateLayers( |
| 690 queue.get(), | 690 queue.get(), |
| 691 begin_frame_state ? begin_frame_state->memory_allocation_limit_bytes | 691 begin_frame_state ? begin_frame_state->memory_allocation_limit_bytes |
| 692 : 0u); | 692 : 0u); |
| 693 | 693 |
| 694 // Once single buffered layers are committed, they cannot be modified until | 694 // Once single buffered layers are committed, they cannot be modified until |
| 695 // they are drawn by the impl thread. | 695 // they are drawn by the impl thread. |
| 696 textures_acquired_ = false; | 696 textures_acquired_ = false; |
| 697 | 697 |
| 698 layer_tree_host_->WillCommit(); | 698 layer_tree_host_->WillCommit(); |
| 699 // Before applying scrolls and calling animate, we set animate_requested_ to | 699 // Before applying scrolls and calling animate, we set animate_requested_ to |
| 700 // false. If it is true now, it means setNeedAnimate was called again, but | 700 // false. If it is true now, it means SetNeedAnimate was called again, but |
| 701 // during a state when commit_request_sent_to_impl_thread_ = true. We need to | 701 // during a state when commit_request_sent_to_impl_thread_ = true. We need to |
| 702 // force that call to happen again now so that the commit request is sent to | 702 // force that call to happen again now so that the commit request is sent to |
| 703 // the impl thread. | 703 // the impl thread. |
| 704 if (animate_requested_) { | 704 if (animate_requested_) { |
| 705 // Forces setNeedsAnimate to consider posting a commit task. | 705 // Forces SetNeedsAnimate to consider posting a commit task. |
| 706 animate_requested_ = false; | 706 animate_requested_ = false; |
| 707 SetNeedsAnimate(); | 707 SetNeedsAnimate(); |
| 708 } | 708 } |
| 709 | 709 |
| 710 scoped_refptr<cc::ContextProvider> offscreen_context_provider; | 710 scoped_refptr<cc::ContextProvider> offscreen_context_provider; |
| 711 if (renderer_capabilities_main_thread_copy_.using_offscreen_context3d && | 711 if (renderer_capabilities_main_thread_copy_.using_offscreen_context3d && |
| 712 layer_tree_host_->needs_offscreen_context()) { | 712 layer_tree_host_->needs_offscreen_context()) { |
| 713 offscreen_context_provider = layer_tree_host_->client()-> | 713 offscreen_context_provider = layer_tree_host_->client()-> |
| 714 OffscreenContextProviderForCompositorThread(); | 714 OffscreenContextProviderForCompositorThread(); |
| 715 if (offscreen_context_provider) | 715 if (offscreen_context_provider) |
| 716 created_offscreen_context_provider_ = true; | 716 created_offscreen_context_provider_ = true; |
| 717 } | 717 } |
| 718 | 718 |
| 719 // Notify the impl thread that the beginFrame has completed. This will | 719 // Notify the impl thread that the BeginFrame has completed. This will |
| 720 // begin the commit process, which is blocking from the main thread's | 720 // begin the commit process, which is blocking from the main thread's |
| 721 // point of view, but asynchronously performed on the impl thread, | 721 // point of view, but asynchronously performed on the impl thread, |
| 722 // coordinated by the Scheduler. | 722 // coordinated by the Scheduler. |
| 723 { | 723 { |
| 724 TRACE_EVENT0("cc", "commit"); | 724 TRACE_EVENT0("cc", "commit"); |
| 725 | 725 |
| 726 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 726 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 727 | 727 |
| 728 RenderingStatsInstrumentation* stats_instrumentation = | 728 RenderingStatsInstrumentation* stats_instrumentation = |
| 729 layer_tree_host_->rendering_stats_instrumentation(); | 729 layer_tree_host_->rendering_stats_instrumentation(); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 | 909 |
| 910 // Check for tree activation. | 910 // Check for tree activation. |
| 911 if (completion_event_for_commit_held_on_tree_activation_ && | 911 if (completion_event_for_commit_held_on_tree_activation_ && |
| 912 !layer_tree_host_impl_->pending_tree()) { | 912 !layer_tree_host_impl_->pending_tree()) { |
| 913 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation"); | 913 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation"); |
| 914 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); | 914 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); |
| 915 completion_event_for_commit_held_on_tree_activation_->Signal(); | 915 completion_event_for_commit_held_on_tree_activation_->Signal(); |
| 916 completion_event_for_commit_held_on_tree_activation_ = NULL; | 916 completion_event_for_commit_held_on_tree_activation_ = NULL; |
| 917 } | 917 } |
| 918 | 918 |
| 919 // Check for a pending compositeAndReadback. | 919 // Check for a pending CompositeAndReadback. |
| 920 if (readback_request_on_impl_thread_) { | 920 if (readback_request_on_impl_thread_) { |
| 921 readback_request_on_impl_thread_->success = false; | 921 readback_request_on_impl_thread_->success = false; |
| 922 if (draw_frame) { | 922 if (draw_frame) { |
| 923 layer_tree_host_impl_->Readback(readback_request_on_impl_thread_->pixels, | 923 layer_tree_host_impl_->Readback(readback_request_on_impl_thread_->pixels, |
| 924 readback_request_on_impl_thread_->rect); | 924 readback_request_on_impl_thread_->rect); |
| 925 readback_request_on_impl_thread_->success = | 925 readback_request_on_impl_thread_->success = |
| 926 !layer_tree_host_impl_->IsContextLost(); | 926 !layer_tree_host_impl_->IsContextLost(); |
| 927 } | 927 } |
| 928 readback_request_on_impl_thread_->completion.Signal(); | 928 readback_request_on_impl_thread_->completion.Signal(); |
| 929 readback_request_on_impl_thread_ = NULL; | 929 readback_request_on_impl_thread_ = NULL; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 output_surface_recreation_callback_.callback()); | 1053 output_surface_recreation_callback_.callback()); |
| 1054 else if (result == LayerTreeHost::RecreateSucceeded) | 1054 else if (result == LayerTreeHost::RecreateSucceeded) |
| 1055 output_surface_recreation_callback_.Cancel(); | 1055 output_surface_recreation_callback_.Cancel(); |
| 1056 } | 1056 } |
| 1057 | 1057 |
| 1058 void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion, | 1058 void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion, |
| 1059 InputHandler* handler) { | 1059 InputHandler* handler) { |
| 1060 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); | 1060 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); |
| 1061 DCHECK(IsImplThread()); | 1061 DCHECK(IsImplThread()); |
| 1062 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); | 1062 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); |
| 1063 const base::TimeDelta displayRefreshInterval = | 1063 const base::TimeDelta display_refresh_interval = |
| 1064 base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond / | 1064 base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond / |
| 1065 60); | 1065 60); |
| 1066 scoped_ptr<FrameRateController> frame_rate_controller; | 1066 scoped_ptr<FrameRateController> frame_rate_controller; |
| 1067 if (render_vsync_enabled_) { | 1067 if (render_vsync_enabled_) { |
| 1068 frame_rate_controller.reset( | 1068 frame_rate_controller.reset( |
| 1069 new FrameRateController(DelayBasedTimeSource::Create( | 1069 new FrameRateController(DelayBasedTimeSource::Create( |
| 1070 displayRefreshInterval, Proxy::ImplThread()))); | 1070 display_refresh_interval, Proxy::ImplThread()))); |
| 1071 } else { | 1071 } else { |
| 1072 frame_rate_controller.reset(new FrameRateController(Proxy::ImplThread())); | 1072 frame_rate_controller.reset(new FrameRateController(Proxy::ImplThread())); |
| 1073 } | 1073 } |
| 1074 SchedulerSettings scheduler_settings; | 1074 SchedulerSettings scheduler_settings; |
| 1075 scheduler_settings.impl_side_painting = | 1075 scheduler_settings.impl_side_painting = |
| 1076 layer_tree_host_->settings().impl_side_painting; | 1076 layer_tree_host_->settings().impl_side_painting; |
| 1077 scheduler_on_impl_thread_ = Scheduler::Create(this, | 1077 scheduler_on_impl_thread_ = Scheduler::Create(this, |
| 1078 frame_rate_controller.Pass(), | 1078 frame_rate_controller.Pass(), |
| 1079 scheduler_settings); | 1079 scheduler_settings); |
| 1080 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); | 1080 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1101 TRACE_EVENT0("cc", "ThreadProxy::InitializeRendererOnImplThread"); | 1101 TRACE_EVENT0("cc", "ThreadProxy::InitializeRendererOnImplThread"); |
| 1102 DCHECK(IsImplThread()); | 1102 DCHECK(IsImplThread()); |
| 1103 DCHECK(output_surface_before_initialization_on_impl_thread_.get()); | 1103 DCHECK(output_surface_before_initialization_on_impl_thread_.get()); |
| 1104 *initialize_succeeded = layer_tree_host_impl_->InitializeRenderer( | 1104 *initialize_succeeded = layer_tree_host_impl_->InitializeRenderer( |
| 1105 output_surface_before_initialization_on_impl_thread_.Pass()); | 1105 output_surface_before_initialization_on_impl_thread_.Pass()); |
| 1106 if (*initialize_succeeded) { | 1106 if (*initialize_succeeded) { |
| 1107 *capabilities = layer_tree_host_impl_->GetRendererCapabilities(); | 1107 *capabilities = layer_tree_host_impl_->GetRendererCapabilities(); |
| 1108 scheduler_on_impl_thread_->SetSwapBuffersCompleteSupported( | 1108 scheduler_on_impl_thread_->SetSwapBuffersCompleteSupported( |
| 1109 capabilities->using_swap_complete_callback); | 1109 capabilities->using_swap_complete_callback); |
| 1110 | 1110 |
| 1111 int maxFramesPending = layer_tree_host_impl_->output_surface()-> | 1111 int max_frames_pending = layer_tree_host_impl_->output_surface()-> |
| 1112 capabilities().max_frames_pending; | 1112 capabilities().max_frames_pending; |
| 1113 if (maxFramesPending <= 0) | 1113 if (max_frames_pending <= 0) |
| 1114 maxFramesPending = FrameRateController::DEFAULT_MAX_FRAMES_PENDING; | 1114 max_frames_pending = FrameRateController::DEFAULT_MAX_FRAMES_PENDING; |
| 1115 if (layer_tree_host_impl_->output_surface()->capabilities(). | 1115 if (layer_tree_host_impl_->output_surface()->capabilities(). |
| 1116 has_parent_compositor) | 1116 has_parent_compositor) |
| 1117 maxFramesPending = 1; | 1117 max_frames_pending = 1; |
| 1118 scheduler_on_impl_thread_->SetMaxFramesPending(maxFramesPending); | 1118 scheduler_on_impl_thread_->SetMaxFramesPending(max_frames_pending); |
| 1119 } | 1119 } |
| 1120 | 1120 |
| 1121 completion->Signal(); | 1121 completion->Signal(); |
| 1122 } | 1122 } |
| 1123 | 1123 |
| 1124 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { | 1124 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { |
| 1125 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); | 1125 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); |
| 1126 DCHECK(IsImplThread()); | 1126 DCHECK(IsImplThread()); |
| 1127 layer_tree_host_->DeleteContentsTexturesOnImplThread( | 1127 layer_tree_host_->DeleteContentsTexturesOnImplThread( |
| 1128 layer_tree_host_impl_->resource_provider()); | 1128 layer_tree_host_impl_->resource_provider()); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1311 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread, | 1311 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread, |
| 1312 impl_thread_weak_ptr_), | 1312 impl_thread_weak_ptr_), |
| 1313 delay); | 1313 delay); |
| 1314 } | 1314 } |
| 1315 | 1315 |
| 1316 void ThreadProxy::StartScrollbarAnimationOnImplThread() { | 1316 void ThreadProxy::StartScrollbarAnimationOnImplThread() { |
| 1317 layer_tree_host_impl_->StartScrollbarAnimation(base::TimeTicks::Now()); | 1317 layer_tree_host_impl_->StartScrollbarAnimation(base::TimeTicks::Now()); |
| 1318 } | 1318 } |
| 1319 | 1319 |
| 1320 } // namespace cc | 1320 } // namespace cc |
| OLD | NEW |