| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <bitset> | 10 #include <bitset> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <unordered_map> | 14 #include <unordered_map> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/callback.h" | 17 #include "base/callback.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 20 #include "cc/animation/layer_tree_mutator.h" | 20 #include "cc/animation/layer_tree_mutator.h" |
| 21 #include "cc/base/cc_export.h" | 21 #include "cc/base/cc_export.h" |
| 22 #include "cc/base/synced_property.h" | 22 #include "cc/base/synced_property.h" |
| 23 #include "cc/debug/micro_benchmark_controller_impl.h" | 23 #include "cc/debug/micro_benchmark_controller_impl.h" |
| 24 #include "cc/input/input_handler.h" | 24 #include "cc/input/input_handler.h" |
| 25 #include "cc/input/scrollbar_animation_controller.h" | 25 #include "cc/input/scrollbar_animation_controller.h" |
| 26 #include "cc/input/top_controls_manager_client.h" | 26 #include "cc/input/top_controls_manager_client.h" |
| 27 #include "cc/layers/layer_collections.h" | 27 #include "cc/layers/layer_collections.h" |
| 28 #include "cc/layers/render_pass_sink.h" | 28 #include "cc/layers/render_pass_sink.h" |
| 29 #include "cc/output/begin_frame_args.h" | 29 #include "cc/output/begin_frame_args.h" |
| 30 #include "cc/output/delegating_renderer.h" |
| 30 #include "cc/output/managed_memory_policy.h" | 31 #include "cc/output/managed_memory_policy.h" |
| 31 #include "cc/output/output_surface_client.h" | 32 #include "cc/output/output_surface_client.h" |
| 32 #include "cc/output/renderer.h" | 33 #include "cc/output/renderer.h" |
| 33 #include "cc/quads/render_pass.h" | 34 #include "cc/quads/render_pass.h" |
| 34 #include "cc/resources/resource_provider.h" | 35 #include "cc/resources/resource_provider.h" |
| 35 #include "cc/resources/ui_resource_client.h" | 36 #include "cc/resources/ui_resource_client.h" |
| 36 #include "cc/scheduler/begin_frame_tracker.h" | 37 #include "cc/scheduler/begin_frame_tracker.h" |
| 37 #include "cc/scheduler/commit_earlyout_reason.h" | 38 #include "cc/scheduler/commit_earlyout_reason.h" |
| 38 #include "cc/scheduler/draw_result.h" | 39 #include "cc/scheduler/draw_result.h" |
| 39 #include "cc/scheduler/video_frame_controller.h" | 40 #include "cc/scheduler/video_frame_controller.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 virtual void OnDrawForOutputSurface(bool resourceless_software_draw) = 0; | 133 virtual void OnDrawForOutputSurface(bool resourceless_software_draw) = 0; |
| 133 | 134 |
| 134 protected: | 135 protected: |
| 135 virtual ~LayerTreeHostImplClient() {} | 136 virtual ~LayerTreeHostImplClient() {} |
| 136 }; | 137 }; |
| 137 | 138 |
| 138 // LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering | 139 // LayerTreeHostImpl owns the LayerImpl trees as well as associated rendering |
| 139 // state. | 140 // state. |
| 140 class CC_EXPORT LayerTreeHostImpl | 141 class CC_EXPORT LayerTreeHostImpl |
| 141 : public InputHandler, | 142 : public InputHandler, |
| 142 public RendererClient, | |
| 143 public TileManagerClient, | 143 public TileManagerClient, |
| 144 public OutputSurfaceClient, | 144 public OutputSurfaceClient, |
| 145 public TopControlsManagerClient, | 145 public TopControlsManagerClient, |
| 146 public ScrollbarAnimationControllerClient, | 146 public ScrollbarAnimationControllerClient, |
| 147 public VideoFrameControllerClient, | 147 public VideoFrameControllerClient, |
| 148 public LayerTreeMutatorClient, | 148 public LayerTreeMutatorClient, |
| 149 public MutatorHostClient, | 149 public MutatorHostClient, |
| 150 public base::SupportsWeakPtr<LayerTreeHostImpl> { | 150 public base::SupportsWeakPtr<LayerTreeHostImpl> { |
| 151 public: | 151 public: |
| 152 static std::unique_ptr<LayerTreeHostImpl> Create( | 152 static std::unique_ptr<LayerTreeHostImpl> Create( |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 virtual void BeginCommit(); | 240 virtual void BeginCommit(); |
| 241 virtual void CommitComplete(); | 241 virtual void CommitComplete(); |
| 242 virtual void UpdateAnimationState(bool start_ready_animations); | 242 virtual void UpdateAnimationState(bool start_ready_animations); |
| 243 bool Mutate(base::TimeTicks monotonic_time); | 243 bool Mutate(base::TimeTicks monotonic_time); |
| 244 void ActivateAnimations(); | 244 void ActivateAnimations(); |
| 245 void Animate(); | 245 void Animate(); |
| 246 void AnimatePendingTreeAfterCommit(); | 246 void AnimatePendingTreeAfterCommit(); |
| 247 void MainThreadHasStoppedFlinging(); | 247 void MainThreadHasStoppedFlinging(); |
| 248 void DidAnimateScrollOffset(); | 248 void DidAnimateScrollOffset(); |
| 249 void SetViewportDamage(const gfx::Rect& damage_rect); | 249 void SetViewportDamage(const gfx::Rect& damage_rect); |
| 250 void SetFullViewportDamage(); |
| 250 | 251 |
| 251 void SetTreeLayerFilterMutated(ElementId element_id, | 252 void SetTreeLayerFilterMutated(ElementId element_id, |
| 252 LayerTreeImpl* tree, | 253 LayerTreeImpl* tree, |
| 253 const FilterOperations& filters); | 254 const FilterOperations& filters); |
| 254 void SetTreeLayerOpacityMutated(ElementId element_id, | 255 void SetTreeLayerOpacityMutated(ElementId element_id, |
| 255 LayerTreeImpl* tree, | 256 LayerTreeImpl* tree, |
| 256 float opacity); | 257 float opacity); |
| 257 void SetTreeLayerTransformMutated(ElementId element_id, | 258 void SetTreeLayerTransformMutated(ElementId element_id, |
| 258 LayerTreeImpl* tree, | 259 LayerTreeImpl* tree, |
| 259 const gfx::Transform& transform); | 260 const gfx::Transform& transform); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 | 330 |
| 330 DrawMode GetDrawMode() const; | 331 DrawMode GetDrawMode() const; |
| 331 | 332 |
| 332 // Viewport size in draw space: this size is in physical pixels and is used | 333 // Viewport size in draw space: this size is in physical pixels and is used |
| 333 // for draw properties, tilings, quads and render passes. | 334 // for draw properties, tilings, quads and render passes. |
| 334 gfx::Size DrawViewportSize() const; | 335 gfx::Size DrawViewportSize() const; |
| 335 | 336 |
| 336 // Viewport rect in view space used for tiling prioritization. | 337 // Viewport rect in view space used for tiling prioritization. |
| 337 const gfx::Rect ViewportRectForTilePriority() const; | 338 const gfx::Rect ViewportRectForTilePriority() const; |
| 338 | 339 |
| 339 // RendererClient implementation. | |
| 340 void SetFullRootLayerDamage() override; | |
| 341 | |
| 342 // TileManagerClient implementation. | 340 // TileManagerClient implementation. |
| 343 void NotifyReadyToActivate() override; | 341 void NotifyReadyToActivate() override; |
| 344 void NotifyReadyToDraw() override; | 342 void NotifyReadyToDraw() override; |
| 345 void NotifyAllTileTasksCompleted() override; | 343 void NotifyAllTileTasksCompleted() override; |
| 346 void NotifyTileStateChanged(const Tile* tile) override; | 344 void NotifyTileStateChanged(const Tile* tile) override; |
| 347 std::unique_ptr<RasterTilePriorityQueue> BuildRasterQueue( | 345 std::unique_ptr<RasterTilePriorityQueue> BuildRasterQueue( |
| 348 TreePriority tree_priority, | 346 TreePriority tree_priority, |
| 349 RasterTilePriorityQueue::Type type) override; | 347 RasterTilePriorityQueue::Type type) override; |
| 350 std::unique_ptr<EvictionTilePriorityQueue> BuildEvictionQueue( | 348 std::unique_ptr<EvictionTilePriorityQueue> BuildEvictionQueue( |
| 351 TreePriority tree_priority) override; | 349 TreePriority tree_priority) override; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 bool use_msaa() const { return use_msaa_; } | 413 bool use_msaa() const { return use_msaa_; } |
| 416 | 414 |
| 417 GpuRasterizationStatus gpu_rasterization_status() const { | 415 GpuRasterizationStatus gpu_rasterization_status() const { |
| 418 return gpu_rasterization_status_; | 416 return gpu_rasterization_status_; |
| 419 } | 417 } |
| 420 | 418 |
| 421 bool create_low_res_tiling() const { | 419 bool create_low_res_tiling() const { |
| 422 return settings_.create_low_res_tiling && !use_gpu_rasterization_; | 420 return settings_.create_low_res_tiling && !use_gpu_rasterization_; |
| 423 } | 421 } |
| 424 ResourcePool* resource_pool() { return resource_pool_.get(); } | 422 ResourcePool* resource_pool() { return resource_pool_.get(); } |
| 425 Renderer* renderer() { return renderer_.get(); } | 423 DelegatingRenderer* renderer() { return renderer_.get(); } |
| 426 ImageDecodeController* image_decode_controller() { | 424 ImageDecodeController* image_decode_controller() { |
| 427 return image_decode_controller_.get(); | 425 return image_decode_controller_.get(); |
| 428 } | 426 } |
| 429 const RendererCapabilitiesImpl& GetRendererCapabilities() const; | 427 const RendererCapabilitiesImpl& GetRendererCapabilities() const; |
| 430 | 428 |
| 431 bool SwapBuffers(const FrameData& frame); | 429 bool SwapBuffers(const FrameData& frame); |
| 432 virtual void WillBeginImplFrame(const BeginFrameArgs& args); | 430 virtual void WillBeginImplFrame(const BeginFrameArgs& args); |
| 433 virtual void DidFinishImplFrame(); | 431 virtual void DidFinishImplFrame(); |
| 434 void DidModifyTilePriorities(); | 432 void DidModifyTilePriorities(); |
| 435 | 433 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 | 557 |
| 560 // Returns the amount of delta that can be applied to scroll_node, taking | 558 // Returns the amount of delta that can be applied to scroll_node, taking |
| 561 // page scale into account. | 559 // page scale into account. |
| 562 gfx::Vector2dF ComputeScrollDelta(ScrollNode* scroll_node, | 560 gfx::Vector2dF ComputeScrollDelta(ScrollNode* scroll_node, |
| 563 const gfx::Vector2dF& delta); | 561 const gfx::Vector2dF& delta); |
| 564 | 562 |
| 565 void ScheduleMicroBenchmark(std::unique_ptr<MicroBenchmarkImpl> benchmark); | 563 void ScheduleMicroBenchmark(std::unique_ptr<MicroBenchmarkImpl> benchmark); |
| 566 | 564 |
| 567 CompositorFrameMetadata MakeCompositorFrameMetadata() const; | 565 CompositorFrameMetadata MakeCompositorFrameMetadata() const; |
| 568 // Viewport rectangle and clip in nonflipped window space. These rects | 566 // Viewport rectangle and clip in nonflipped window space. These rects |
| 569 // should only be used by Renderer subclasses to populate glViewport/glClip | 567 // should only be used in the CompositorFrame to describe the physical |
| 570 // and their software-mode equivalents. | 568 // viewport for drawing. |
| 571 gfx::Rect DeviceViewport() const; | 569 gfx::Rect DeviceViewport() const; |
| 572 | 570 |
| 573 // When a SwapPromiseMonitor is created on the impl thread, it calls | 571 // When a SwapPromiseMonitor is created on the impl thread, it calls |
| 574 // InsertSwapPromiseMonitor() to register itself with LayerTreeHostImpl. | 572 // InsertSwapPromiseMonitor() to register itself with LayerTreeHostImpl. |
| 575 // When the monitor is destroyed, it calls RemoveSwapPromiseMonitor() | 573 // When the monitor is destroyed, it calls RemoveSwapPromiseMonitor() |
| 576 // to unregister itself. | 574 // to unregister itself. |
| 577 void InsertSwapPromiseMonitor(SwapPromiseMonitor* monitor); | 575 void InsertSwapPromiseMonitor(SwapPromiseMonitor* monitor); |
| 578 void RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor); | 576 void RemoveSwapPromiseMonitor(SwapPromiseMonitor* monitor); |
| 579 | 577 |
| 580 // TODO(weiliangc): Replace RequiresHighResToDraw with scheduler waits for | 578 // TODO(weiliangc): Replace RequiresHighResToDraw with scheduler waits for |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 std::unique_ptr<ResourceProvider> resource_provider_; | 733 std::unique_ptr<ResourceProvider> resource_provider_; |
| 736 bool content_is_suitable_for_gpu_rasterization_; | 734 bool content_is_suitable_for_gpu_rasterization_; |
| 737 bool has_gpu_rasterization_trigger_; | 735 bool has_gpu_rasterization_trigger_; |
| 738 bool use_gpu_rasterization_; | 736 bool use_gpu_rasterization_; |
| 739 bool use_msaa_; | 737 bool use_msaa_; |
| 740 GpuRasterizationStatus gpu_rasterization_status_; | 738 GpuRasterizationStatus gpu_rasterization_status_; |
| 741 bool tree_resources_for_gpu_rasterization_dirty_; | 739 bool tree_resources_for_gpu_rasterization_dirty_; |
| 742 std::unique_ptr<RasterBufferProvider> raster_buffer_provider_; | 740 std::unique_ptr<RasterBufferProvider> raster_buffer_provider_; |
| 743 std::unique_ptr<TileTaskManager> tile_task_manager_; | 741 std::unique_ptr<TileTaskManager> tile_task_manager_; |
| 744 std::unique_ptr<ResourcePool> resource_pool_; | 742 std::unique_ptr<ResourcePool> resource_pool_; |
| 745 std::unique_ptr<Renderer> renderer_; | 743 std::unique_ptr<DelegatingRenderer> renderer_; |
| 746 std::unique_ptr<ImageDecodeController> image_decode_controller_; | 744 std::unique_ptr<ImageDecodeController> image_decode_controller_; |
| 747 | 745 |
| 748 GlobalStateThatImpactsTilePriority global_tile_state_; | 746 GlobalStateThatImpactsTilePriority global_tile_state_; |
| 749 | 747 |
| 750 // Tree currently being drawn. | 748 // Tree currently being drawn. |
| 751 std::unique_ptr<LayerTreeImpl> active_tree_; | 749 std::unique_ptr<LayerTreeImpl> active_tree_; |
| 752 | 750 |
| 753 // In impl-side painting mode, tree with possibly incomplete rasterized | 751 // In impl-side painting mode, tree with possibly incomplete rasterized |
| 754 // content. May be promoted to active by ActivatePendingTree(). | 752 // content. May be promoted to active by ActivatePendingTree(). |
| 755 std::unique_ptr<LayerTreeImpl> pending_tree_; | 753 std::unique_ptr<LayerTreeImpl> pending_tree_; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 | 848 |
| 851 std::unique_ptr<PendingTreeDurationHistogramTimer> | 849 std::unique_ptr<PendingTreeDurationHistogramTimer> |
| 852 pending_tree_duration_timer_; | 850 pending_tree_duration_timer_; |
| 853 | 851 |
| 854 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); | 852 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); |
| 855 }; | 853 }; |
| 856 | 854 |
| 857 } // namespace cc | 855 } // namespace cc |
| 858 | 856 |
| 859 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_ | 857 #endif // CC_TREES_LAYER_TREE_HOST_IMPL_H_ |
| OLD | NEW |