| 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/task_runner_provider.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 TaskRunnerProvider* task_runner_provider, |
| 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 TaskRunnerProvider* task_runner_provider() const { |
| 480 return task_runner_provider_; |
| 481 } |
| 480 | 482 |
| 481 AnimationRegistrar* animation_registrar() const { | 483 AnimationRegistrar* animation_registrar() const { |
| 482 return animation_registrar_.get(); | 484 return animation_registrar_.get(); |
| 483 } | 485 } |
| 484 AnimationHost* animation_host() const { return animation_host_.get(); } | 486 AnimationHost* animation_host() const { return animation_host_.get(); } |
| 485 | 487 |
| 486 void SetDebugState(const LayerTreeDebugState& new_debug_state); | 488 void SetDebugState(const LayerTreeDebugState& new_debug_state); |
| 487 const LayerTreeDebugState& debug_state() const { return debug_state_; } | 489 const LayerTreeDebugState& debug_state() const { return debug_state_; } |
| 488 | 490 |
| 489 gfx::Vector2dF accumulated_root_overscroll() const { | 491 gfx::Vector2dF accumulated_root_overscroll() const { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 | 547 |
| 546 // TODO(weiliangc): Replace RequiresHighResToDraw with scheduler waits for | 548 // TODO(weiliangc): Replace RequiresHighResToDraw with scheduler waits for |
| 547 // ReadyToDraw. crbug.com/469175 | 549 // ReadyToDraw. crbug.com/469175 |
| 548 void SetRequiresHighResToDraw() { requires_high_res_to_draw_ = true; } | 550 void SetRequiresHighResToDraw() { requires_high_res_to_draw_ = true; } |
| 549 void ResetRequiresHighResToDraw() { requires_high_res_to_draw_ = false; } | 551 void ResetRequiresHighResToDraw() { requires_high_res_to_draw_ = false; } |
| 550 bool RequiresHighResToDraw() const { return requires_high_res_to_draw_; } | 552 bool RequiresHighResToDraw() const { return requires_high_res_to_draw_; } |
| 551 | 553 |
| 552 // Only valid for synchronous (non-scheduled) single-threaded case. | 554 // Only valid for synchronous (non-scheduled) single-threaded case. |
| 553 void SynchronouslyInitializeAllTiles(); | 555 void SynchronouslyInitializeAllTiles(); |
| 554 | 556 |
| 557 bool SupportsImplScrolling() const; |
| 558 bool CommitToActiveTree() const; |
| 559 |
| 555 virtual void CreateResourceAndTileTaskWorkerPool( | 560 virtual void CreateResourceAndTileTaskWorkerPool( |
| 556 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, | 561 scoped_ptr<TileTaskWorkerPool>* tile_task_worker_pool, |
| 557 scoped_ptr<ResourcePool>* resource_pool); | 562 scoped_ptr<ResourcePool>* resource_pool); |
| 558 | 563 |
| 559 bool prepare_tiles_needed() const { return tile_priorities_dirty_; } | 564 bool prepare_tiles_needed() const { return tile_priorities_dirty_; } |
| 560 | 565 |
| 561 FrameTimingTracker* frame_timing_tracker() { | 566 FrameTimingTracker* frame_timing_tracker() { |
| 562 return frame_timing_tracker_.get(); | 567 return frame_timing_tracker_.get(); |
| 563 } | 568 } |
| 564 | 569 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 578 // the main frame args if it was scheduled. | 583 // the main frame args if it was scheduled. |
| 579 void RecordMainFrameTiming( | 584 void RecordMainFrameTiming( |
| 580 const BeginFrameArgs& start_of_main_frame_args, | 585 const BeginFrameArgs& start_of_main_frame_args, |
| 581 const BeginFrameArgs& expected_next_main_frame_args); | 586 const BeginFrameArgs& expected_next_main_frame_args); |
| 582 | 587 |
| 583 // Post the given frame timing events to the requester. | 588 // Post the given frame timing events to the requester. |
| 584 void PostFrameTimingEvents( | 589 void PostFrameTimingEvents( |
| 585 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 590 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
| 586 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events); | 591 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events); |
| 587 | 592 |
| 593 base::SingleThreadTaskRunner* GetTaskRunner() const { |
| 594 DCHECK(task_runner_provider_); |
| 595 return task_runner_provider_->HasImplThread() |
| 596 ? task_runner_provider_->ImplThreadTaskRunner() |
| 597 : task_runner_provider_->MainThreadTaskRunner(); |
| 598 } |
| 599 |
| 588 protected: | 600 protected: |
| 589 LayerTreeHostImpl( | 601 LayerTreeHostImpl( |
| 590 const LayerTreeSettings& settings, | 602 const LayerTreeSettings& settings, |
| 591 LayerTreeHostImplClient* client, | 603 LayerTreeHostImplClient* client, |
| 592 Proxy* proxy, | 604 TaskRunnerProvider* task_runner_provider, |
| 593 RenderingStatsInstrumentation* rendering_stats_instrumentation, | 605 RenderingStatsInstrumentation* rendering_stats_instrumentation, |
| 594 SharedBitmapManager* shared_bitmap_manager, | 606 SharedBitmapManager* shared_bitmap_manager, |
| 595 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 607 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
| 596 TaskGraphRunner* task_graph_runner, | 608 TaskGraphRunner* task_graph_runner, |
| 597 int id); | 609 int id); |
| 598 | 610 |
| 599 // Virtual for testing. | 611 // Virtual for testing. |
| 600 virtual void AnimateLayers(base::TimeTicks monotonic_time); | 612 virtual void AnimateLayers(base::TimeTicks monotonic_time); |
| 601 | 613 |
| 602 bool is_likely_to_require_a_draw() const { | 614 bool is_likely_to_require_a_draw() const { |
| 603 return is_likely_to_require_a_draw_; | 615 return is_likely_to_require_a_draw_; |
| 604 } | 616 } |
| 605 | 617 |
| 606 // Removes empty or orphan RenderPasses from the frame. | 618 // Removes empty or orphan RenderPasses from the frame. |
| 607 static void RemoveRenderPasses(FrameData* frame); | 619 static void RemoveRenderPasses(FrameData* frame); |
| 608 | 620 |
| 609 LayerTreeHostImplClient* client_; | 621 LayerTreeHostImplClient* client_; |
| 610 Proxy* proxy_; | 622 TaskRunnerProvider* task_runner_provider_; |
| 611 | 623 |
| 612 BeginFrameTracker current_begin_frame_tracker_; | 624 BeginFrameTracker current_begin_frame_tracker_; |
| 613 | 625 |
| 614 private: | 626 private: |
| 615 gfx::Vector2dF ScrollLayerWithViewportSpaceDelta( | 627 gfx::Vector2dF ScrollLayerWithViewportSpaceDelta( |
| 616 LayerImpl* layer_impl, | 628 LayerImpl* layer_impl, |
| 617 const gfx::PointF& viewport_point, | 629 const gfx::PointF& viewport_point, |
| 618 const gfx::Vector2dF& viewport_delta); | 630 const gfx::Vector2dF& viewport_delta); |
| 619 | 631 |
| 620 void CreateAndSetRenderer(); | 632 void CreateAndSetRenderer(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 void NotifySwapPromiseMonitorsOfForwardingToMainThread(); | 686 void NotifySwapPromiseMonitorsOfForwardingToMainThread(); |
| 675 | 687 |
| 676 void UpdateRootLayerStateForSynchronousInputHandler(); | 688 void UpdateRootLayerStateForSynchronousInputHandler(); |
| 677 | 689 |
| 678 void ScrollAnimationCreate(LayerImpl* layer_impl, | 690 void ScrollAnimationCreate(LayerImpl* layer_impl, |
| 679 const gfx::ScrollOffset& target_offset, | 691 const gfx::ScrollOffset& target_offset, |
| 680 const gfx::ScrollOffset& current_offset); | 692 const gfx::ScrollOffset& current_offset); |
| 681 bool ScrollAnimationUpdateTarget(LayerImpl* layer_impl, | 693 bool ScrollAnimationUpdateTarget(LayerImpl* layer_impl, |
| 682 const gfx::Vector2dF& scroll_delta); | 694 const gfx::Vector2dF& scroll_delta); |
| 683 | 695 |
| 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> | 696 typedef base::hash_map<UIResourceId, UIResourceData> |
| 691 UIResourceMap; | 697 UIResourceMap; |
| 692 UIResourceMap ui_resource_map_; | 698 UIResourceMap ui_resource_map_; |
| 693 | 699 |
| 694 // Resources that were evicted by EvictAllUIResources. Resources are removed | 700 // 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 | 701 // from this when they are touched by a create or destroy from the UI resource |
| 696 // request queue. | 702 // request queue. |
| 697 std::set<UIResourceId> evicted_ui_resources_; | 703 std::set<UIResourceId> evicted_ui_resources_; |
| 698 | 704 |
| 699 OutputSurface* output_surface_; | 705 OutputSurface* output_surface_; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 scoped_ptr<FrameTimingTracker> frame_timing_tracker_; | 818 scoped_ptr<FrameTimingTracker> frame_timing_tracker_; |
| 813 | 819 |
| 814 scoped_ptr<Viewport> viewport_; | 820 scoped_ptr<Viewport> viewport_; |
| 815 | 821 |
| 816 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); | 822 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); |
| 817 }; | 823 }; |
| 818 | 824 |
| 819 } // namespace cc | 825 } // namespace cc |
| 820 | 826 |
| 821 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_ | 827 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
| OLD | NEW |