| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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_IMPL_H_ | 5 #ifndef CC_TREES_LAYER_TREE_IMPL_H_ |
| 6 #define CC_TREES_LAYER_TREE_IMPL_H_ | 6 #define CC_TREES_LAYER_TREE_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <unordered_map> | 11 #include <unordered_map> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/ptr_util.h" |
| 15 #include "base/values.h" | 16 #include "base/values.h" |
| 16 #include "cc/base/synced_property.h" | 17 #include "cc/base/synced_property.h" |
| 17 #include "cc/input/event_listener_properties.h" | 18 #include "cc/input/event_listener_properties.h" |
| 18 #include "cc/input/layer_selection_bound.h" | 19 #include "cc/input/layer_selection_bound.h" |
| 19 #include "cc/layers/layer_impl.h" | 20 #include "cc/layers/layer_impl.h" |
| 20 #include "cc/layers/layer_list_iterator.h" | 21 #include "cc/layers/layer_list_iterator.h" |
| 21 #include "cc/output/begin_frame_args.h" | 22 #include "cc/output/begin_frame_args.h" |
| 22 #include "cc/output/renderer.h" | 23 #include "cc/output/renderer.h" |
| 23 #include "cc/output/swap_promise.h" | 24 #include "cc/output/swap_promise.h" |
| 24 #include "cc/resources/ui_resource_client.h" | 25 #include "cc/resources/ui_resource_client.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 58 |
| 58 typedef std::vector<UIResourceRequest> UIResourceRequestQueue; | 59 typedef std::vector<UIResourceRequest> UIResourceRequestQueue; |
| 59 typedef SyncedProperty<AdditionGroup<float>> SyncedTopControls; | 60 typedef SyncedProperty<AdditionGroup<float>> SyncedTopControls; |
| 60 typedef SyncedProperty<AdditionGroup<gfx::Vector2dF>> SyncedElasticOverscroll; | 61 typedef SyncedProperty<AdditionGroup<gfx::Vector2dF>> SyncedElasticOverscroll; |
| 61 | 62 |
| 62 class CC_EXPORT LayerTreeImpl { | 63 class CC_EXPORT LayerTreeImpl { |
| 63 public: | 64 public: |
| 64 // This is the number of times a fixed point has to be hit contiuously by a | 65 // This is the number of times a fixed point has to be hit contiuously by a |
| 65 // layer to consider it as jittering. | 66 // layer to consider it as jittering. |
| 66 const int kFixedPointHitsThreshold = 3; | 67 const int kFixedPointHitsThreshold = 3; |
| 67 static scoped_ptr<LayerTreeImpl> create( | 68 static std::unique_ptr<LayerTreeImpl> create( |
| 68 LayerTreeHostImpl* layer_tree_host_impl, | 69 LayerTreeHostImpl* layer_tree_host_impl, |
| 69 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, | 70 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor, |
| 70 scoped_refptr<SyncedTopControls> top_controls_shown_ratio, | 71 scoped_refptr<SyncedTopControls> top_controls_shown_ratio, |
| 71 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll) { | 72 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll) { |
| 72 return make_scoped_ptr( | 73 return base::WrapUnique( |
| 73 new LayerTreeImpl(layer_tree_host_impl, page_scale_factor, | 74 new LayerTreeImpl(layer_tree_host_impl, page_scale_factor, |
| 74 top_controls_shown_ratio, elastic_overscroll)); | 75 top_controls_shown_ratio, elastic_overscroll)); |
| 75 } | 76 } |
| 76 virtual ~LayerTreeImpl(); | 77 virtual ~LayerTreeImpl(); |
| 77 | 78 |
| 78 void Shutdown(); | 79 void Shutdown(); |
| 79 void ReleaseResources(); | 80 void ReleaseResources(); |
| 80 void RecreateResources(); | 81 void RecreateResources(); |
| 81 | 82 |
| 82 // Methods called by the layer tree that pass-through or access LTHI. | 83 // Methods called by the layer tree that pass-through or access LTHI. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 98 bool IsRecycleTree() const; | 99 bool IsRecycleTree() const; |
| 99 bool IsSyncTree() const; | 100 bool IsSyncTree() const; |
| 100 LayerImpl* FindActiveTreeLayerById(int id); | 101 LayerImpl* FindActiveTreeLayerById(int id); |
| 101 LayerImpl* FindPendingTreeLayerById(int id); | 102 LayerImpl* FindPendingTreeLayerById(int id); |
| 102 bool PinchGestureActive() const; | 103 bool PinchGestureActive() const; |
| 103 BeginFrameArgs CurrentBeginFrameArgs() const; | 104 BeginFrameArgs CurrentBeginFrameArgs() const; |
| 104 base::TimeDelta CurrentBeginFrameInterval() const; | 105 base::TimeDelta CurrentBeginFrameInterval() const; |
| 105 gfx::Rect DeviceViewport() const; | 106 gfx::Rect DeviceViewport() const; |
| 106 gfx::Size DrawViewportSize() const; | 107 gfx::Size DrawViewportSize() const; |
| 107 const gfx::Rect ViewportRectForTilePriority() const; | 108 const gfx::Rect ViewportRectForTilePriority() const; |
| 108 scoped_ptr<ScrollbarAnimationController> CreateScrollbarAnimationController( | 109 std::unique_ptr<ScrollbarAnimationController> |
| 109 int scroll_layer_id); | 110 CreateScrollbarAnimationController(int scroll_layer_id); |
| 110 void DidAnimateScrollOffset(); | 111 void DidAnimateScrollOffset(); |
| 111 bool use_gpu_rasterization() const; | 112 bool use_gpu_rasterization() const; |
| 112 GpuRasterizationStatus GetGpuRasterizationStatus() const; | 113 GpuRasterizationStatus GetGpuRasterizationStatus() const; |
| 113 bool create_low_res_tiling() const; | 114 bool create_low_res_tiling() const; |
| 114 bool RequiresHighResToDraw() const; | 115 bool RequiresHighResToDraw() const; |
| 115 bool SmoothnessTakesPriority() const; | 116 bool SmoothnessTakesPriority() const; |
| 116 VideoFrameControllerClient* GetVideoFrameControllerClient() const; | 117 VideoFrameControllerClient* GetVideoFrameControllerClient() const; |
| 117 AnimationHost* animation_host() const { | 118 AnimationHost* animation_host() const { |
| 118 return layer_tree_host_impl_->animation_host(); | 119 return layer_tree_host_impl_->animation_host(); |
| 119 } | 120 } |
| 120 | 121 |
| 121 // Tree specific methods exposed to layer-impl tree. | 122 // Tree specific methods exposed to layer-impl tree. |
| 122 // --------------------------------------------------------------------------- | 123 // --------------------------------------------------------------------------- |
| 123 void SetNeedsRedraw(); | 124 void SetNeedsRedraw(); |
| 124 | 125 |
| 125 // Tracing methods. | 126 // Tracing methods. |
| 126 // --------------------------------------------------------------------------- | 127 // --------------------------------------------------------------------------- |
| 127 void GetAllPrioritizedTilesForTracing( | 128 void GetAllPrioritizedTilesForTracing( |
| 128 std::vector<PrioritizedTile>* prioritized_tiles) const; | 129 std::vector<PrioritizedTile>* prioritized_tiles) const; |
| 129 void AsValueInto(base::trace_event::TracedValue* dict) const; | 130 void AsValueInto(base::trace_event::TracedValue* dict) const; |
| 130 | 131 |
| 131 // Other public methods | 132 // Other public methods |
| 132 // --------------------------------------------------------------------------- | 133 // --------------------------------------------------------------------------- |
| 133 LayerImpl* root_layer() const { return root_layer_; } | 134 LayerImpl* root_layer() const { return root_layer_; } |
| 134 void SetRootLayer(scoped_ptr<LayerImpl>); | 135 void SetRootLayer(std::unique_ptr<LayerImpl>); |
| 135 bool IsRootLayer(const LayerImpl* layer) const; | 136 bool IsRootLayer(const LayerImpl* layer) const; |
| 136 scoped_ptr<OwnedLayerImplList> DetachLayers(); | 137 std::unique_ptr<OwnedLayerImplList> DetachLayers(); |
| 137 void ClearLayers(); | 138 void ClearLayers(); |
| 138 | 139 |
| 139 void SetPropertyTrees(const PropertyTrees property_trees) { | 140 void SetPropertyTrees(const PropertyTrees property_trees) { |
| 140 property_trees_ = property_trees; | 141 property_trees_ = property_trees; |
| 141 property_trees_.is_main_thread = false; | 142 property_trees_.is_main_thread = false; |
| 142 property_trees_.is_active = IsActiveTree(); | 143 property_trees_.is_active = IsActiveTree(); |
| 143 property_trees_.transform_tree.set_source_to_parent_updates_allowed(false); | 144 property_trees_.transform_tree.set_source_to_parent_updates_allowed(false); |
| 144 } | 145 } |
| 145 PropertyTrees* property_trees() { return &property_trees_; } | 146 PropertyTrees* property_trees() { return &property_trees_; } |
| 146 | 147 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 void AddLayerShouldPushProperties(LayerImpl* layer); | 304 void AddLayerShouldPushProperties(LayerImpl* layer); |
| 304 void RemoveLayerShouldPushProperties(LayerImpl* layer); | 305 void RemoveLayerShouldPushProperties(LayerImpl* layer); |
| 305 std::unordered_set<LayerImpl*>& LayersThatShouldPushProperties(); | 306 std::unordered_set<LayerImpl*>& LayersThatShouldPushProperties(); |
| 306 bool LayerNeedsPushPropertiesForTesting(LayerImpl* layer); | 307 bool LayerNeedsPushPropertiesForTesting(LayerImpl* layer); |
| 307 | 308 |
| 308 // These should be called by LayerImpl's ctor/dtor. | 309 // These should be called by LayerImpl's ctor/dtor. |
| 309 void RegisterLayer(LayerImpl* layer); | 310 void RegisterLayer(LayerImpl* layer); |
| 310 void UnregisterLayer(LayerImpl* layer); | 311 void UnregisterLayer(LayerImpl* layer); |
| 311 | 312 |
| 312 // These manage ownership of the LayerImpl. | 313 // These manage ownership of the LayerImpl. |
| 313 void AddLayer(scoped_ptr<LayerImpl> layer); | 314 void AddLayer(std::unique_ptr<LayerImpl> layer); |
| 314 scoped_ptr<LayerImpl> RemoveLayer(int id); | 315 std::unique_ptr<LayerImpl> RemoveLayer(int id); |
| 315 | 316 |
| 316 size_t NumLayers(); | 317 size_t NumLayers(); |
| 317 | 318 |
| 318 void DidBecomeActive(); | 319 void DidBecomeActive(); |
| 319 | 320 |
| 320 // Set on the active tree when the viewport size recently changed | 321 // Set on the active tree when the viewport size recently changed |
| 321 // and the active tree's size is now out of date. | 322 // and the active tree's size is now out of date. |
| 322 bool ViewportSizeInvalid() const; | 323 bool ViewportSizeInvalid() const; |
| 323 void SetViewportSizeInvalid(); | 324 void SetViewportSizeInvalid(); |
| 324 void ResetViewportSizeInvalid(); | 325 void ResetViewportSizeInvalid(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 336 | 337 |
| 337 // Call this function when you expect there to be a swap buffer. | 338 // Call this function when you expect there to be a swap buffer. |
| 338 // See swap_promise.h for how to use SwapPromise. | 339 // See swap_promise.h for how to use SwapPromise. |
| 339 // | 340 // |
| 340 // A swap promise queued by QueueSwapPromise travels with the layer | 341 // A swap promise queued by QueueSwapPromise travels with the layer |
| 341 // information currently associated with the tree. For example, when | 342 // information currently associated with the tree. For example, when |
| 342 // a pending tree is activated, the swap promise is passed to the | 343 // a pending tree is activated, the swap promise is passed to the |
| 343 // active tree along with the layer information. Similarly, when a | 344 // active tree along with the layer information. Similarly, when a |
| 344 // new activation overwrites layer information on the active tree, | 345 // new activation overwrites layer information on the active tree, |
| 345 // queued swap promises are broken. | 346 // queued swap promises are broken. |
| 346 void QueueSwapPromise(scoped_ptr<SwapPromise> swap_promise); | 347 void QueueSwapPromise(std::unique_ptr<SwapPromise> swap_promise); |
| 347 | 348 |
| 348 // Queue a swap promise, pinned to this tree. Pinned swap promises | 349 // Queue a swap promise, pinned to this tree. Pinned swap promises |
| 349 // may only be queued on the active tree. | 350 // may only be queued on the active tree. |
| 350 // | 351 // |
| 351 // An active tree pinned swap promise will see only DidSwap() or | 352 // An active tree pinned swap promise will see only DidSwap() or |
| 352 // DidNotSwap(SWAP_FAILS). No DidActivate() will be seen because | 353 // DidNotSwap(SWAP_FAILS). No DidActivate() will be seen because |
| 353 // that has already happened prior to queueing of the swap promise. | 354 // that has already happened prior to queueing of the swap promise. |
| 354 // | 355 // |
| 355 // Pinned active tree swap promises will not be broken prematurely | 356 // Pinned active tree swap promises will not be broken prematurely |
| 356 // on the active tree if a new tree is activated. | 357 // on the active tree if a new tree is activated. |
| 357 void QueuePinnedSwapPromise(scoped_ptr<SwapPromise> swap_promise); | 358 void QueuePinnedSwapPromise(std::unique_ptr<SwapPromise> swap_promise); |
| 358 | 359 |
| 359 // Take the |new_swap_promise| and append it to |swap_promise_list_|. | 360 // Take the |new_swap_promise| and append it to |swap_promise_list_|. |
| 360 void PassSwapPromises(std::vector<scoped_ptr<SwapPromise>>* new_swap_promise); | 361 void PassSwapPromises( |
| 362 std::vector<std::unique_ptr<SwapPromise>>* new_swap_promise); |
| 361 void FinishSwapPromises(CompositorFrameMetadata* metadata); | 363 void FinishSwapPromises(CompositorFrameMetadata* metadata); |
| 362 void BreakSwapPromises(SwapPromise::DidNotSwapReason reason); | 364 void BreakSwapPromises(SwapPromise::DidNotSwapReason reason); |
| 363 | 365 |
| 364 void DidModifyTilePriorities(); | 366 void DidModifyTilePriorities(); |
| 365 | 367 |
| 366 ResourceId ResourceIdForUIResource(UIResourceId uid) const; | 368 ResourceId ResourceIdForUIResource(UIResourceId uid) const; |
| 367 void ProcessUIResourceRequestQueue(); | 369 void ProcessUIResourceRequestQueue(); |
| 368 | 370 |
| 369 bool IsUIResourceOpaque(UIResourceId uid) const; | 371 bool IsUIResourceOpaque(UIResourceId uid) const; |
| 370 | 372 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 } | 419 } |
| 418 bool SetCurrentTopControlsShownRatio(float ratio); | 420 bool SetCurrentTopControlsShownRatio(float ratio); |
| 419 float CurrentTopControlsShownRatio() const { | 421 float CurrentTopControlsShownRatio() const { |
| 420 return top_controls_shown_ratio_->Current(IsActiveTree()); | 422 return top_controls_shown_ratio_->Current(IsActiveTree()); |
| 421 } | 423 } |
| 422 void set_top_controls_height(float top_controls_height); | 424 void set_top_controls_height(float top_controls_height); |
| 423 float top_controls_height() const { return top_controls_height_; } | 425 float top_controls_height() const { return top_controls_height_; } |
| 424 void PushTopControlsFromMainThread(float top_controls_shown_ratio); | 426 void PushTopControlsFromMainThread(float top_controls_shown_ratio); |
| 425 | 427 |
| 426 void SetPendingPageScaleAnimation( | 428 void SetPendingPageScaleAnimation( |
| 427 scoped_ptr<PendingPageScaleAnimation> pending_animation); | 429 std::unique_ptr<PendingPageScaleAnimation> pending_animation); |
| 428 scoped_ptr<PendingPageScaleAnimation> TakePendingPageScaleAnimation(); | 430 std::unique_ptr<PendingPageScaleAnimation> TakePendingPageScaleAnimation(); |
| 429 | 431 |
| 430 void GatherFrameTimingRequestIds(std::vector<int64_t>* request_ids); | 432 void GatherFrameTimingRequestIds(std::vector<int64_t>* request_ids); |
| 431 | 433 |
| 432 void DidUpdateScrollOffset(int layer_id, int transform_id); | 434 void DidUpdateScrollOffset(int layer_id, int transform_id); |
| 433 void DidUpdateScrollState(int layer_id); | 435 void DidUpdateScrollState(int layer_id); |
| 434 | 436 |
| 435 bool IsAnimatingFilterProperty(const LayerImpl* layer) const; | 437 bool IsAnimatingFilterProperty(const LayerImpl* layer) const; |
| 436 bool IsAnimatingOpacityProperty(const LayerImpl* layer) const; | 438 bool IsAnimatingOpacityProperty(const LayerImpl* layer) const; |
| 437 bool IsAnimatingTransformProperty(const LayerImpl* layer) const; | 439 bool IsAnimatingTransformProperty(const LayerImpl* layer) const; |
| 438 | 440 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 | 522 |
| 521 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor_; | 523 scoped_refptr<SyncedProperty<ScaleGroup>> page_scale_factor_; |
| 522 float min_page_scale_factor_; | 524 float min_page_scale_factor_; |
| 523 float max_page_scale_factor_; | 525 float max_page_scale_factor_; |
| 524 | 526 |
| 525 float device_scale_factor_; | 527 float device_scale_factor_; |
| 526 float painted_device_scale_factor_; | 528 float painted_device_scale_factor_; |
| 527 | 529 |
| 528 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll_; | 530 scoped_refptr<SyncedElasticOverscroll> elastic_overscroll_; |
| 529 | 531 |
| 530 scoped_ptr<OwnedLayerImplList> layers_; | 532 std::unique_ptr<OwnedLayerImplList> layers_; |
| 531 LayerImplMap layer_id_map_; | 533 LayerImplMap layer_id_map_; |
| 532 // Set of layers that need to push properties. | 534 // Set of layers that need to push properties. |
| 533 std::unordered_set<LayerImpl*> layers_that_should_push_properties_; | 535 std::unordered_set<LayerImpl*> layers_that_should_push_properties_; |
| 534 | 536 |
| 535 std::unordered_map<uint64_t, ElementLayers> element_layers_map_; | 537 std::unordered_map<uint64_t, ElementLayers> element_layers_map_; |
| 536 | 538 |
| 537 // Maps from clip layer ids to scroll layer ids. Note that this only includes | 539 // Maps from clip layer ids to scroll layer ids. Note that this only includes |
| 538 // the subset of clip layers that act as scrolling containers. (This is | 540 // the subset of clip layers that act as scrolling containers. (This is |
| 539 // derived from LayerImpl::scroll_clip_layer_ and exists to avoid O(n) walks.) | 541 // derived from LayerImpl::scroll_clip_layer_ and exists to avoid O(n) walks.) |
| 540 std::unordered_map<int, int> clip_scroll_map_; | 542 std::unordered_map<int, int> clip_scroll_map_; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 559 bool needs_update_draw_properties_; | 561 bool needs_update_draw_properties_; |
| 560 | 562 |
| 561 // In impl-side painting mode, this is true when the tree may contain | 563 // In impl-side painting mode, this is true when the tree may contain |
| 562 // structural differences relative to the active tree. | 564 // structural differences relative to the active tree. |
| 563 bool needs_full_tree_sync_; | 565 bool needs_full_tree_sync_; |
| 564 | 566 |
| 565 bool next_activation_forces_redraw_; | 567 bool next_activation_forces_redraw_; |
| 566 | 568 |
| 567 bool has_ever_been_drawn_; | 569 bool has_ever_been_drawn_; |
| 568 | 570 |
| 569 std::vector<scoped_ptr<SwapPromise>> swap_promise_list_; | 571 std::vector<std::unique_ptr<SwapPromise>> swap_promise_list_; |
| 570 std::vector<scoped_ptr<SwapPromise>> pinned_swap_promise_list_; | 572 std::vector<std::unique_ptr<SwapPromise>> pinned_swap_promise_list_; |
| 571 | 573 |
| 572 UIResourceRequestQueue ui_resource_request_queue_; | 574 UIResourceRequestQueue ui_resource_request_queue_; |
| 573 | 575 |
| 574 int render_surface_layer_list_id_; | 576 int render_surface_layer_list_id_; |
| 575 | 577 |
| 576 bool have_scroll_event_handlers_; | 578 bool have_scroll_event_handlers_; |
| 577 EventListenerProperties event_listener_properties_[static_cast<size_t>( | 579 EventListenerProperties event_listener_properties_[static_cast<size_t>( |
| 578 EventListenerClass::kNumClasses)]; | 580 EventListenerClass::kNumClasses)]; |
| 579 | 581 |
| 580 // Whether or not Blink's viewport size was shrunk by the height of the top | 582 // Whether or not Blink's viewport size was shrunk by the height of the top |
| 581 // controls at the time of the last layout. | 583 // controls at the time of the last layout. |
| 582 bool top_controls_shrink_blink_size_; | 584 bool top_controls_shrink_blink_size_; |
| 583 float top_controls_height_; | 585 float top_controls_height_; |
| 584 | 586 |
| 585 // The amount that the top controls are shown from 0 (hidden) to 1 (fully | 587 // The amount that the top controls are shown from 0 (hidden) to 1 (fully |
| 586 // shown). | 588 // shown). |
| 587 scoped_refptr<SyncedTopControls> top_controls_shown_ratio_; | 589 scoped_refptr<SyncedTopControls> top_controls_shown_ratio_; |
| 588 | 590 |
| 589 scoped_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; | 591 std::unique_ptr<PendingPageScaleAnimation> pending_page_scale_animation_; |
| 590 | 592 |
| 591 private: | 593 private: |
| 592 DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl); | 594 DISALLOW_COPY_AND_ASSIGN(LayerTreeImpl); |
| 593 }; | 595 }; |
| 594 | 596 |
| 595 } // namespace cc | 597 } // namespace cc |
| 596 | 598 |
| 597 #endif // CC_TREES_LAYER_TREE_IMPL_H_ | 599 #endif // CC_TREES_LAYER_TREE_IMPL_H_ |
| OLD | NEW |