| 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_LAYERS_LAYER_IMPL_H_ | 5 #ifndef CC_LAYERS_LAYER_IMPL_H_ |
| 6 #define CC_LAYERS_LAYER_IMPL_H_ | 6 #define CC_LAYERS_LAYER_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
| 19 #include "base/values.h" | 19 #include "base/values.h" |
| 20 #include "cc/animation/target_property.h" | 20 #include "cc/animation/target_property.h" |
| 21 #include "cc/base/cc_export.h" | 21 #include "cc/base/cc_export.h" |
| 22 #include "cc/base/region.h" | 22 #include "cc/base/region.h" |
| 23 #include "cc/base/synced_property.h" | 23 #include "cc/base/synced_property.h" |
| 24 #include "cc/debug/frame_timing_request.h" | 24 #include "cc/debug/frame_timing_request.h" |
| 25 #include "cc/input/input_handler.h" | 25 #include "cc/input/input_handler.h" |
| 26 #include "cc/layers/draw_properties.h" | 26 #include "cc/layers/draw_properties.h" |
| 27 #include "cc/layers/layer_lists.h" | 27 #include "cc/layers/layer_collections.h" |
| 28 #include "cc/layers/layer_position_constraint.h" | 28 #include "cc/layers/layer_position_constraint.h" |
| 29 #include "cc/layers/performance_properties.h" | 29 #include "cc/layers/performance_properties.h" |
| 30 #include "cc/layers/render_surface_impl.h" | 30 #include "cc/layers/render_surface_impl.h" |
| 31 #include "cc/output/filter_operations.h" | 31 #include "cc/output/filter_operations.h" |
| 32 #include "cc/quads/shared_quad_state.h" | 32 #include "cc/quads/shared_quad_state.h" |
| 33 #include "cc/resources/resource_provider.h" | 33 #include "cc/resources/resource_provider.h" |
| 34 #include "cc/tiles/tile_priority.h" | 34 #include "cc/tiles/tile_priority.h" |
| 35 #include "skia/ext/refptr.h" | 35 #include "skia/ext/refptr.h" |
| 36 #include "third_party/skia/include/core/SkColor.h" | 36 #include "third_party/skia/include/core/SkColor.h" |
| 37 #include "third_party/skia/include/core/SkImageFilter.h" | 37 #include "third_party/skia/include/core/SkImageFilter.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 void OnFilterAnimated(const FilterOperations& filters); | 97 void OnFilterAnimated(const FilterOperations& filters); |
| 98 void OnOpacityAnimated(float opacity); | 98 void OnOpacityAnimated(float opacity); |
| 99 void OnTransformAnimated(const gfx::Transform& transform); | 99 void OnTransformAnimated(const gfx::Transform& transform); |
| 100 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset); | 100 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset); |
| 101 void OnTransformIsPotentiallyAnimatingChanged(bool is_animating); | 101 void OnTransformIsPotentiallyAnimatingChanged(bool is_animating); |
| 102 bool IsActive() const; | 102 bool IsActive() const; |
| 103 | 103 |
| 104 // Tree structure. | 104 // Tree structure. |
| 105 LayerImpl* parent() { return parent_; } | 105 LayerImpl* parent() { return parent_; } |
| 106 const LayerImpl* parent() const { return parent_; } | 106 const LayerImpl* parent() const { return parent_; } |
| 107 const OwnedLayerImplList& children() const { return children_; } | 107 const LayerImplList& children() const { return children_; } |
| 108 OwnedLayerImplList& children() { return children_; } | 108 LayerImplList& children() { return children_; } |
| 109 LayerImpl* child_at(size_t index) const { return children_[index].get(); } | 109 LayerImpl* child_at(size_t index) const { return children_[index]; } |
| 110 void AddChild(scoped_ptr<LayerImpl> child); | 110 void AddChild(scoped_ptr<LayerImpl> child); |
| 111 scoped_ptr<LayerImpl> RemoveChild(LayerImpl* child); | 111 scoped_ptr<LayerImpl> RemoveChild(LayerImpl* child); |
| 112 void SetParent(LayerImpl* parent); | 112 void SetParent(LayerImpl* parent); |
| 113 | 113 |
| 114 // Warning: This does not preserve tree structure invariants. | |
| 115 void ClearChildList(); | |
| 116 | |
| 117 bool HasAncestor(const LayerImpl* ancestor) const; | 114 bool HasAncestor(const LayerImpl* ancestor) const; |
| 118 | 115 |
| 119 void SetScrollParent(LayerImpl* parent); | 116 void SetScrollParent(LayerImpl* parent); |
| 120 | 117 |
| 121 LayerImpl* scroll_parent() { return scroll_parent_; } | 118 LayerImpl* scroll_parent() { return scroll_parent_; } |
| 122 const LayerImpl* scroll_parent() const { return scroll_parent_; } | 119 const LayerImpl* scroll_parent() const { return scroll_parent_; } |
| 123 | 120 |
| 124 void SetScrollChildren(std::set<LayerImpl*>* children); | 121 void SetScrollChildren(std::set<LayerImpl*>* children); |
| 125 | 122 |
| 126 std::set<LayerImpl*>* scroll_children() { return scroll_children_.get(); } | 123 std::set<LayerImpl*>* scroll_children() { return scroll_children_.get(); } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 } | 186 } |
| 190 | 187 |
| 191 void PassCopyRequests(std::vector<scoped_ptr<CopyOutputRequest>>* requests); | 188 void PassCopyRequests(std::vector<scoped_ptr<CopyOutputRequest>>* requests); |
| 192 // Can only be called when the layer has a copy request. | 189 // Can only be called when the layer has a copy request. |
| 193 void TakeCopyRequestsAndTransformToTarget( | 190 void TakeCopyRequestsAndTransformToTarget( |
| 194 std::vector<scoped_ptr<CopyOutputRequest>>* request); | 191 std::vector<scoped_ptr<CopyOutputRequest>>* request); |
| 195 bool HasCopyRequest() const { return !copy_requests_.empty(); } | 192 bool HasCopyRequest() const { return !copy_requests_.empty(); } |
| 196 bool AnchestorHasCopyRequest() const; | 193 bool AnchestorHasCopyRequest() const; |
| 197 | 194 |
| 198 void SetMaskLayer(scoped_ptr<LayerImpl> mask_layer); | 195 void SetMaskLayer(scoped_ptr<LayerImpl> mask_layer); |
| 199 LayerImpl* mask_layer() { return mask_layer_.get(); } | 196 LayerImpl* mask_layer() { return mask_layer_; } |
| 200 const LayerImpl* mask_layer() const { return mask_layer_.get(); } | 197 const LayerImpl* mask_layer() const { return mask_layer_; } |
| 201 scoped_ptr<LayerImpl> TakeMaskLayer(); | 198 scoped_ptr<LayerImpl> TakeMaskLayer(); |
| 202 | 199 |
| 203 void SetReplicaLayer(scoped_ptr<LayerImpl> replica_layer); | 200 void SetReplicaLayer(scoped_ptr<LayerImpl> replica_layer); |
| 204 LayerImpl* replica_layer() { return replica_layer_.get(); } | 201 LayerImpl* replica_layer() { return replica_layer_; } |
| 205 const LayerImpl* replica_layer() const { return replica_layer_.get(); } | 202 const LayerImpl* replica_layer() const { return replica_layer_; } |
| 206 scoped_ptr<LayerImpl> TakeReplicaLayer(); | 203 scoped_ptr<LayerImpl> TakeReplicaLayer(); |
| 207 | 204 |
| 208 bool has_mask() const { return !!mask_layer_; } | 205 bool has_mask() const { return !!mask_layer_; } |
| 209 bool has_replica() const { return !!replica_layer_; } | 206 bool has_replica() const { return !!replica_layer_; } |
| 210 bool replica_has_mask() const { | 207 bool replica_has_mask() const { |
| 211 return replica_layer_ && (mask_layer_ || replica_layer_->mask_layer_); | 208 return replica_layer_ && (mask_layer_ || replica_layer_->mask_layer_); |
| 212 } | 209 } |
| 213 | 210 |
| 214 LayerTreeImpl* layer_tree_impl() const { return layer_tree_impl_; } | 211 LayerTreeImpl* layer_tree_impl() const { return layer_tree_impl_; } |
| 215 | 212 |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 void AppendDebugBorderQuad(RenderPass* render_pass, | 627 void AppendDebugBorderQuad(RenderPass* render_pass, |
| 631 const gfx::Size& bounds, | 628 const gfx::Size& bounds, |
| 632 const SharedQuadState* shared_quad_state, | 629 const SharedQuadState* shared_quad_state, |
| 633 AppendQuadsData* append_quads_data, | 630 AppendQuadsData* append_quads_data, |
| 634 SkColor color, | 631 SkColor color, |
| 635 float width) const; | 632 float width) const; |
| 636 | 633 |
| 637 gfx::Rect GetScaledEnclosingRectInTargetSpace(float scale) const; | 634 gfx::Rect GetScaledEnclosingRectInTargetSpace(float scale) const; |
| 638 | 635 |
| 639 private: | 636 private: |
| 637 // Warning: This does not preserve tree structure invariants. |
| 638 void ClearChildList(); |
| 639 |
| 640 void ValidateQuadResourcesInternal(DrawQuad* quad) const; | 640 void ValidateQuadResourcesInternal(DrawQuad* quad) const; |
| 641 | 641 |
| 642 void NoteLayerPropertyChangedForDescendantsInternal(); | 642 void NoteLayerPropertyChangedForDescendantsInternal(); |
| 643 void PushLayerPropertyChangedForSubtreeInternal(); | 643 void PushLayerPropertyChangedForSubtreeInternal(); |
| 644 | 644 |
| 645 virtual const char* LayerTypeAsString() const; | 645 virtual const char* LayerTypeAsString() const; |
| 646 | 646 |
| 647 // Properties internal to LayerImpl | 647 // Properties internal to LayerImpl |
| 648 LayerImpl* parent_; | 648 LayerImpl* parent_; |
| 649 OwnedLayerImplList children_; | 649 LayerImplList children_; |
| 650 | 650 |
| 651 LayerImpl* scroll_parent_; | 651 LayerImpl* scroll_parent_; |
| 652 | 652 |
| 653 // Storing a pointer to a set rather than a set since this will be rarely | 653 // Storing a pointer to a set rather than a set since this will be rarely |
| 654 // used. If this pointer turns out to be too heavy, we could have this (and | 654 // used. If this pointer turns out to be too heavy, we could have this (and |
| 655 // the scroll parent above) be stored in a LayerImpl -> scroll_info | 655 // the scroll parent above) be stored in a LayerImpl -> scroll_info |
| 656 // map somewhere. | 656 // map somewhere. |
| 657 scoped_ptr<std::set<LayerImpl*>> scroll_children_; | 657 scoped_ptr<std::set<LayerImpl*>> scroll_children_; |
| 658 | 658 |
| 659 LayerImpl* clip_parent_; | 659 LayerImpl* clip_parent_; |
| 660 scoped_ptr<std::set<LayerImpl*>> clip_children_; | 660 scoped_ptr<std::set<LayerImpl*>> clip_children_; |
| 661 | 661 |
| 662 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to | 662 // mask_layer_ can be temporarily stolen during tree sync, we need this ID to |
| 663 // confirm newly assigned layer is still the previous one | 663 // confirm newly assigned layer is still the previous one |
| 664 int mask_layer_id_; | 664 int mask_layer_id_; |
| 665 scoped_ptr<LayerImpl> mask_layer_; | 665 LayerImpl* mask_layer_; |
| 666 int replica_layer_id_; // ditto | 666 int replica_layer_id_; // ditto |
| 667 scoped_ptr<LayerImpl> replica_layer_; | 667 LayerImpl* replica_layer_; |
| 668 int layer_id_; | 668 int layer_id_; |
| 669 LayerTreeImpl* layer_tree_impl_; | 669 LayerTreeImpl* layer_tree_impl_; |
| 670 | 670 |
| 671 gfx::Vector2dF bounds_delta_; | 671 gfx::Vector2dF bounds_delta_; |
| 672 | 672 |
| 673 // Properties synchronized from the associated Layer. | 673 // Properties synchronized from the associated Layer. |
| 674 gfx::Point3F transform_origin_; | 674 gfx::Point3F transform_origin_; |
| 675 gfx::Size bounds_; | 675 gfx::Size bounds_; |
| 676 int scroll_clip_layer_id_; | 676 int scroll_clip_layer_id_; |
| 677 | 677 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 // If true, the layer or one of its descendants has a touch handler. | 781 // If true, the layer or one of its descendants has a touch handler. |
| 782 bool layer_or_descendant_has_touch_handler_; | 782 bool layer_or_descendant_has_touch_handler_; |
| 783 bool sorted_for_recursion_; | 783 bool sorted_for_recursion_; |
| 784 | 784 |
| 785 DISALLOW_COPY_AND_ASSIGN(LayerImpl); | 785 DISALLOW_COPY_AND_ASSIGN(LayerImpl); |
| 786 }; | 786 }; |
| 787 | 787 |
| 788 } // namespace cc | 788 } // namespace cc |
| 789 | 789 |
| 790 #endif // CC_LAYERS_LAYER_IMPL_H_ | 790 #endif // CC_LAYERS_LAYER_IMPL_H_ |
| OLD | NEW |