OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 UI_GFX_COMPOSITOR_LAYER_H_ | 5 #ifndef UI_GFX_COMPOSITOR_LAYER_H_ |
6 #define UI_GFX_COMPOSITOR_LAYER_H_ | 6 #define UI_GFX_COMPOSITOR_LAYER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 // Removes a Layer from this Layer. | 37 // Removes a Layer from this Layer. |
38 void Remove(Layer* child); | 38 void Remove(Layer* child); |
39 | 39 |
40 // Returns the child Layers. | 40 // Returns the child Layers. |
41 const std::vector<Layer*>& children() { return children_; } | 41 const std::vector<Layer*>& children() { return children_; } |
42 | 42 |
43 // The parent. | 43 // The parent. |
44 const Layer* parent() const { return parent_; } | 44 const Layer* parent() const { return parent_; } |
45 Layer* parent() { return parent_; } | 45 Layer* parent() { return parent_; } |
46 | 46 |
| 47 // Returns true if this Layer contains |other| somewhere in its children. |
| 48 bool Contains(const Layer* other) const; |
| 49 |
47 // The transform, relative to the parent. | 50 // The transform, relative to the parent. |
48 void SetTransform(const ui::Transform& transform); | 51 void SetTransform(const ui::Transform& transform); |
49 const ui::Transform& transform() const { return transform_; } | 52 const ui::Transform& transform() const { return transform_; } |
50 | 53 |
51 // The bounds, relative to the parent. | 54 // The bounds, relative to the parent. |
52 void SetBounds(const gfx::Rect& bounds); | 55 void SetBounds(const gfx::Rect& bounds); |
53 const gfx::Rect& bounds() const { return bounds_; } | 56 const gfx::Rect& bounds() const { return bounds_; } |
54 | 57 |
| 58 // Converts a point from the coordinates of |source| to the coordinates of |
| 59 // |target|. Necessarily, |source| and |target| must inhabit the same Layer |
| 60 // tree. |
| 61 static void ConvertPointToLayer(const Layer* source, |
| 62 const Layer* target, |
| 63 gfx::Point* point); |
| 64 |
55 // See description in View for details | 65 // See description in View for details |
56 void SetFillsBoundsOpaquely(bool fills_bounds_opaquely); | 66 void SetFillsBoundsOpaquely(bool fills_bounds_opaquely); |
57 bool fills_bounds_opaquely() const { return fills_bounds_opaquely_; } | 67 bool fills_bounds_opaquely() const { return fills_bounds_opaquely_; } |
58 | 68 |
59 const gfx::Rect& hole_rect() const { return hole_rect_; } | 69 const gfx::Rect& hole_rect() const { return hole_rect_; } |
60 | 70 |
61 // The compositor. | 71 // The compositor. |
62 const Compositor* compositor() const { return compositor_; } | 72 const Compositor* compositor() const { return compositor_; } |
63 Compositor* compositor() { return compositor_; } | 73 Compositor* compositor() { return compositor_; } |
64 | 74 |
(...skipping 30 matching lines...) Expand all Loading... |
95 | 105 |
96 // A hole in a layer is an area in the layer that does not get drawn | 106 // A hole in a layer is an area in the layer that does not get drawn |
97 // because this area is covered up with another layer which is known to be | 107 // because this area is covered up with another layer which is known to be |
98 // opaque. | 108 // opaque. |
99 // This method computes the dimension of the hole (if there is one) | 109 // This method computes the dimension of the hole (if there is one) |
100 // based on whether one of its child nodes is always opaque. | 110 // based on whether one of its child nodes is always opaque. |
101 // Note: For simpicity's sake, currently a hole is only created if the child | 111 // Note: For simpicity's sake, currently a hole is only created if the child |
102 // view has no transfrom with respect to its parent. | 112 // view has no transfrom with respect to its parent. |
103 void RecomputeHole(); | 113 void RecomputeHole(); |
104 | 114 |
| 115 bool ConvertPointForAncestor(const Layer* ancestor, gfx::Point* point) const; |
| 116 bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const; |
| 117 |
| 118 bool GetTransformRelativeTo(const Layer* ancestor, |
| 119 Transform* transform) const; |
| 120 |
105 Compositor* compositor_; | 121 Compositor* compositor_; |
106 | 122 |
107 scoped_refptr<ui::Texture> texture_; | 123 scoped_refptr<ui::Texture> texture_; |
108 | 124 |
109 Layer* parent_; | 125 Layer* parent_; |
110 | 126 |
111 std::vector<Layer*> children_; | 127 std::vector<Layer*> children_; |
112 | 128 |
113 ui::Transform transform_; | 129 ui::Transform transform_; |
114 | 130 |
115 gfx::Rect bounds_; | 131 gfx::Rect bounds_; |
116 | 132 |
117 bool fills_bounds_opaquely_; | 133 bool fills_bounds_opaquely_; |
118 | 134 |
119 gfx::Rect hole_rect_; | 135 gfx::Rect hole_rect_; |
120 | 136 |
121 DISALLOW_COPY_AND_ASSIGN(Layer); | 137 DISALLOW_COPY_AND_ASSIGN(Layer); |
122 }; | 138 }; |
123 | 139 |
124 } // namespace ui | 140 } // namespace ui |
125 | 141 |
126 #endif // UI_GFX_COMPOSITOR_LAYER_H_ | 142 #endif // UI_GFX_COMPOSITOR_LAYER_H_ |
OLD | NEW |