| 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 #ifndef CC_TREES_LAYER_TREE_HOST_IMPL_H_ | 5 #ifndef CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
| 6 #define CC_TREES_LAYER_TREE_HOST_IMPL_H_ | 6 #define CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "cc/quads/render_pass.h" | 31 #include "cc/quads/render_pass.h" |
| 32 #include "cc/resources/resource_provider.h" | 32 #include "cc/resources/resource_provider.h" |
| 33 #include "cc/resources/ui_resource_client.h" | 33 #include "cc/resources/ui_resource_client.h" |
| 34 #include "cc/scheduler/begin_frame_tracker.h" | 34 #include "cc/scheduler/begin_frame_tracker.h" |
| 35 #include "cc/scheduler/commit_earlyout_reason.h" | 35 #include "cc/scheduler/commit_earlyout_reason.h" |
| 36 #include "cc/scheduler/draw_result.h" | 36 #include "cc/scheduler/draw_result.h" |
| 37 #include "cc/scheduler/video_frame_controller.h" | 37 #include "cc/scheduler/video_frame_controller.h" |
| 38 #include "cc/tiles/tile_manager.h" | 38 #include "cc/tiles/tile_manager.h" |
| 39 #include "cc/trees/layer_tree_settings.h" | 39 #include "cc/trees/layer_tree_settings.h" |
| 40 #include "cc/trees/mutator_host_client.h" | 40 #include "cc/trees/mutator_host_client.h" |
| 41 #include "cc/trees/proxy.h" | 41 #include "cc/trees/thread_verifier.h" |
| 42 #include "skia/ext/refptr.h" | 42 #include "skia/ext/refptr.h" |
| 43 #include "third_party/skia/include/core/SkColor.h" | 43 #include "third_party/skia/include/core/SkColor.h" |
| 44 #include "ui/gfx/geometry/rect.h" | 44 #include "ui/gfx/geometry/rect.h" |
| 45 | 45 |
| 46 namespace gfx { | 46 namespace gfx { |
| 47 class ScrollOffset; | 47 class ScrollOffset; |
| 48 } | 48 } |
| 49 | 49 |
| 50 namespace cc { | 50 namespace cc { |
| 51 | 51 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 public OutputSurfaceClient, | 141 public OutputSurfaceClient, |
| 142 public TopControlsManagerClient, | 142 public TopControlsManagerClient, |
| 143 public ScrollbarAnimationControllerClient, | 143 public ScrollbarAnimationControllerClient, |
| 144 public VideoFrameControllerClient, | 144 public VideoFrameControllerClient, |
| 145 public MutatorHostClient, | 145 public MutatorHostClient, |
| 146 public base::SupportsWeakPtr<LayerTreeHostImpl> { | 146 public base::SupportsWeakPtr<LayerTreeHostImpl> { |
| 147 public: | 147 public: |
| 148 static scoped_ptr<LayerTreeHostImpl> Create( | 148 static scoped_ptr<LayerTreeHostImpl> Create( |
| 149 const LayerTreeSettings& settings, | 149 const LayerTreeSettings& settings, |
| 150 LayerTreeHostImplClient* client, | 150 LayerTreeHostImplClient* client, |
| 151 Proxy* proxy, | 151 ThreadVerifier* thread_verifier, |
| 152 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 152 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 153 SharedBitmapManager* shared_bitmap_manager, | 153 SharedBitmapManager* shared_bitmap_manager, |
| 154 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 154 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 155 TaskGraphRunner* task_graph_runner, | 155 TaskGraphRunner* task_graph_runner, |
| 156 int id); | 156 int id); |
| 157 ~LayerTreeHostImpl() override; | 157 ~LayerTreeHostImpl() override; |
| 158 | 158 |
| 159 // InputHandler implementation | 159 // InputHandler implementation |
| 160 void BindToClient(InputHandlerClient* client) override; | 160 void BindToClient(InputHandlerClient* client) override; |
| 161 InputHandler::ScrollStatus ScrollBegin( | 161 InputHandler::ScrollStatus ScrollBegin( |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 | 405 |
| 406 LayerTreeImpl* active_tree() { return active_tree_.get(); } | 406 LayerTreeImpl* active_tree() { return active_tree_.get(); } |
| 407 const LayerTreeImpl* active_tree() const { return active_tree_.get(); } | 407 const LayerTreeImpl* active_tree() const { return active_tree_.get(); } |
| 408 LayerTreeImpl* pending_tree() { return pending_tree_.get(); } | 408 LayerTreeImpl* pending_tree() { return pending_tree_.get(); } |
| 409 const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); } | 409 const LayerTreeImpl* pending_tree() const { return pending_tree_.get(); } |
| 410 LayerTreeImpl* recycle_tree() { return recycle_tree_.get(); } | 410 LayerTreeImpl* recycle_tree() { return recycle_tree_.get(); } |
| 411 const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); } | 411 const LayerTreeImpl* recycle_tree() const { return recycle_tree_.get(); } |
| 412 // Returns the tree LTH synchronizes with. | 412 // Returns the tree LTH synchronizes with. |
| 413 LayerTreeImpl* sync_tree() { | 413 LayerTreeImpl* sync_tree() { |
| 414 // TODO(enne): This is bogus. It should return based on the value of | 414 // TODO(enne): This is bogus. It should return based on the value of |
| 415 // Proxy::CommitToActiveTree and not whether the pending tree exists. | 415 // CommitToActiveTree() and not whether the pending tree exists. |
| 416 return pending_tree_ ? pending_tree_.get() : active_tree_.get(); | 416 return pending_tree_ ? pending_tree_.get() : active_tree_.get(); |
| 417 } | 417 } |
| 418 virtual void CreatePendingTree(); | 418 virtual void CreatePendingTree(); |
| 419 virtual void ActivateSyncTree(); | 419 virtual void ActivateSyncTree(); |
| 420 | 420 |
| 421 // Shortcuts to layers on the active tree. | 421 // Shortcuts to layers on the active tree. |
| 422 LayerImpl* RootLayer() const; | 422 LayerImpl* RootLayer() const; |
| 423 LayerImpl* InnerViewportScrollLayer() const; | 423 LayerImpl* InnerViewportScrollLayer() const; |
| 424 LayerImpl* OuterViewportScrollLayer() const; | 424 LayerImpl* OuterViewportScrollLayer() const; |
| 425 LayerImpl* CurrentlyScrollingLayer() const; | 425 LayerImpl* CurrentlyScrollingLayer() const; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 ResourceProvider* resource_provider() { | 469 ResourceProvider* resource_provider() { |
| 470 return resource_provider_.get(); | 470 return resource_provider_.get(); |
| 471 } | 471 } |
| 472 TopControlsManager* top_controls_manager() { | 472 TopControlsManager* top_controls_manager() { |
| 473 return top_controls_manager_.get(); | 473 return top_controls_manager_.get(); |
| 474 } | 474 } |
| 475 const GlobalStateThatImpactsTilePriority& global_tile_state() { | 475 const GlobalStateThatImpactsTilePriority& global_tile_state() { |
| 476 return global_tile_state_; | 476 return global_tile_state_; |
| 477 } | 477 } |
| 478 | 478 |
| 479 Proxy* proxy() const { return proxy_; } | 479 ThreadVerifier* thread_verifier() const { return thread_verifier_; } |
| 480 | 480 |
| 481 AnimationRegistrar* animation_registrar() const { | 481 AnimationRegistrar* animation_registrar() const { |
| 482 return animation_registrar_.get(); | 482 return animation_registrar_.get(); |
| 483 } | 483 } |
| 484 AnimationHost* animation_host() const { return animation_host_.get(); } | 484 AnimationHost* animation_host() const { return animation_host_.get(); } |
| 485 | 485 |
| 486 void SetDebugState(const LayerTreeDebugState& new_debug_state); | 486 void SetDebugState(const LayerTreeDebugState& new_debug_state); |
| 487 const LayerTreeDebugState& debug_state() const { return debug_state_; } | 487 const LayerTreeDebugState& debug_state() const { return debug_state_; } |
| 488 | 488 |
| 489 gfx::Vector2dF accumulated_root_overscroll() const { | 489 gfx::Vector2dF accumulated_root_overscroll() const { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 | 545 |
| 546 // TODO(weiliangc): Replace RequiresHighResToDraw with scheduler waits for | 546 // TODO(weiliangc): Replace RequiresHighResToDraw with scheduler waits for |
| 547 // ReadyToDraw. crbug.com/469175 | 547 // ReadyToDraw. crbug.com/469175 |
| 548 void SetRequiresHighResToDraw() { requires_high_res_to_draw_ = true; } | 548 void SetRequiresHighResToDraw() { requires_high_res_to_draw_ = true; } |
| 549 void ResetRequiresHighResToDraw() { requires_high_res_to_draw_ = false; } | 549 void ResetRequiresHighResToDraw() { requires_high_res_to_draw_ = false; } |
| 550 bool RequiresHighResToDraw() const { return requires_high_res_to_draw_; } | 550 bool RequiresHighResToDraw() const { return requires_high_res_to_draw_; } |
| 551 | 551 |
| 552 // Only valid for synchronous (non-scheduled) single-threaded case. | 552 // Only valid for synchronous (non-scheduled) single-threaded case. |
| 553 void SynchronouslyInitializeAllTiles(); | 553 void SynchronouslyInitializeAllTiles(); |
| 554 | 554 |
| 555 bool SupportsImplScrolling() const; |
| 556 bool CommitToActiveTree() const; |
| 557 |
| 555 virtual void CreateResourceAndTileTaskWorkerPool( | 558 virtual void CreateResourceAndTileTaskWorkerPool( |
| 556 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, | 559 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, |
| 557 scoped_ptr<ResourcePool>* resource_pool); | 560 scoped_ptr<ResourcePool>* resource_pool); |
| 558 | 561 |
| 559 bool prepare_tiles_needed() const { return tile_priorities_dirty_; } | 562 bool prepare_tiles_needed() const { return tile_priorities_dirty_; } |
| 560 | 563 |
| 561 FrameTimingTracker* frame_timing_tracker() { | 564 FrameTimingTracker* frame_timing_tracker() { |
| 562 return frame_timing_tracker_.get(); | 565 return frame_timing_tracker_.get(); |
| 563 } | 566 } |
| 564 | 567 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 578 // the main frame args if it was scheduled. | 581 // the main frame args if it was scheduled. |
| 579 void RecordMainFrameTiming( | 582 void RecordMainFrameTiming( |
| 580 const BeginFrameArgs& start_of_main_frame_args, | 583 const BeginFrameArgs& start_of_main_frame_args, |
| 581 const BeginFrameArgs& expected_next_main_frame_args); | 584 const BeginFrameArgs& expected_next_main_frame_args); |
| 582 | 585 |
| 583 // Post the given frame timing events to the requester. | 586 // Post the given frame timing events to the requester. |
| 584 void PostFrameTimingEvents( | 587 void PostFrameTimingEvents( |
| 585 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 588 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
| 586 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events); | 589 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events); |
| 587 | 590 |
| 591 base::SingleThreadTaskRunner* GetTaskRunner() const { |
| 592 DCHECK(thread_verifier_); |
| 593 return thread_verifier_->HasImplThread() |
| 594 ? thread_verifier_->ImplThreadTaskRunner() |
| 595 : thread_verifier_->MainThreadTaskRunner(); |
| 596 } |
| 597 |
| 588 protected: | 598 protected: |
| 589 LayerTreeHostImpl( | 599 LayerTreeHostImpl( |
| 590 const LayerTreeSettings& settings, | 600 const LayerTreeSettings& settings, |
| 591 LayerTreeHostImplClient* client, | 601 LayerTreeHostImplClient* client, |
| 592 Proxy* proxy, | 602 ThreadVerifier* thread_verifier, |
| 593 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 603 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 594 SharedBitmapManager* shared_bitmap_manager, | 604 SharedBitmapManager* shared_bitmap_manager, |
| 595 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 605 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 596 TaskGraphRunner* task_graph_runner, | 606 TaskGraphRunner* task_graph_runner, |
| 597 int id); | 607 int id); |
| 598 | 608 |
| 599 // Virtual for testing. | 609 // Virtual for testing. |
| 600 virtual void AnimateLayers(base::TimeTicks monotonic_time); | 610 virtual void AnimateLayers(base::TimeTicks monotonic_time); |
| 601 | 611 |
| 602 bool is_likely_to_require_a_draw() const { | 612 bool is_likely_to_require_a_draw() const { |
| 603 return is_likely_to_require_a_draw_; | 613 return is_likely_to_require_a_draw_; |
| 604 } | 614 } |
| 605 | 615 |
| 606 // Removes empty or orphan RenderPasses from the frame. | 616 // Removes empty or orphan RenderPasses from the frame. |
| 607 static void RemoveRenderPasses(FrameData* frame); | 617 static void RemoveRenderPasses(FrameData* frame); |
| 608 | 618 |
| 609 LayerTreeHostImplClient* client_; | 619 LayerTreeHostImplClient* client_; |
| 610 Proxy* proxy_; | 620 ThreadVerifier* thread_verifier_; |
| 611 | 621 |
| 612 BeginFrameTracker current_begin_frame_tracker_; | 622 BeginFrameTracker current_begin_frame_tracker_; |
| 613 | 623 |
| 614 private: | 624 private: |
| 615 gfx::Vector2dF ScrollLayerWithViewportSpaceDelta( | 625 gfx::Vector2dF ScrollLayerWithViewportSpaceDelta( |
| 616 LayerImpl* layer_impl, | 626 LayerImpl* layer_impl, |
| 617 const gfx::PointF& viewport_point, | 627 const gfx::PointF& viewport_point, |
| 618 const gfx::Vector2dF& viewport_delta); | 628 const gfx::Vector2dF& viewport_delta); |
| 619 | 629 |
| 620 void CreateAndSetRenderer(); | 630 void CreateAndSetRenderer(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 void NotifySwapPromiseMonitorsOfForwardingToMainThread(); | 684 void NotifySwapPromiseMonitorsOfForwardingToMainThread(); |
| 675 | 685 |
| 676 void UpdateRootLayerStateForSynchronousInputHandler(); | 686 void UpdateRootLayerStateForSynchronousInputHandler(); |
| 677 | 687 |
| 678 void ScrollAnimationCreate(LayerImpl* layer_impl, | 688 void ScrollAnimationCreate(LayerImpl* layer_impl, |
| 679 const gfx::ScrollOffset& target_offset, | 689 const gfx::ScrollOffset& target_offset, |
| 680 const gfx::ScrollOffset& current_offset); | 690 const gfx::ScrollOffset& current_offset); |
| 681 bool ScrollAnimationUpdateTarget(LayerImpl* layer_impl, | 691 bool ScrollAnimationUpdateTarget(LayerImpl* layer_impl, |
| 682 const gfx::Vector2dF& scroll_delta); | 692 const gfx::Vector2dF& scroll_delta); |
| 683 | 693 |
| 684 base::SingleThreadTaskRunner* GetTaskRunner() const { | |
| 685 DCHECK(proxy_); | |
| 686 return proxy_->HasImplThread() ? proxy_->ImplThreadTaskRunner() | |
| 687 : proxy_->MainThreadTaskRunner(); | |
| 688 } | |
| 689 | |
| 690 typedef base::hash_map<UIResourceId, UIResourceData> | 694 typedef base::hash_map<UIResourceId, UIResourceData> |
| 691 UIResourceMap; | 695 UIResourceMap; |
| 692 UIResourceMap ui_resource_map_; | 696 UIResourceMap ui_resource_map_; |
| 693 | 697 |
| 694 // Resources that were evicted by EvictAllUIResources. Resources are removed | 698 // Resources that were evicted by EvictAllUIResources. Resources are removed |
| 695 // from this when they are touched by a create or destroy from the UI resource | 699 // from this when they are touched by a create or destroy from the UI resource |
| 696 // request queue. | 700 // request queue. |
| 697 std::set<UIResourceId> evicted_ui_resources_; | 701 std::set<UIResourceId> evicted_ui_resources_; |
| 698 | 702 |
| 699 OutputSurface* output_surface_; | 703 OutputSurface* output_surface_; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 scoped_ptr<FrameTimingTracker> frame_timing_tracker_; | 816 scoped_ptr<FrameTimingTracker> frame_timing_tracker_; |
| 813 | 817 |
| 814 scoped_ptr<Viewport> viewport_; | 818 scoped_ptr<Viewport> viewport_; |
| 815 | 819 |
| 816 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); | 820 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); |
| 817 }; | 821 }; |
| 818 | 822 |
| 819 } // namespace cc | 823 } // namespace cc |
| 820 | 824 |
| 821 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_ | 825 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
| OLD | NEW |