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 |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/observer_list.h" |
12 #include "ui/gfx/rect.h" | 13 #include "ui/gfx/rect.h" |
13 #include "ui/gfx/transform.h" | 14 #include "ui/gfx/transform.h" |
14 #include "ui/gfx/compositor/compositor.h" | 15 #include "ui/gfx/compositor/compositor.h" |
15 | 16 |
16 class SkCanvas; | 17 class SkCanvas; |
17 | 18 |
18 namespace ui { | 19 namespace ui { |
19 | 20 |
20 class Compositor; | 21 class Compositor; |
| 22 class LayerObserver; |
21 class Texture; | 23 class Texture; |
22 | 24 |
23 // Layer manages a texture, transform and a set of child Layers. Any View that | 25 // Layer manages a texture, transform and a set of child Layers. Any View that |
24 // has enabled layers ends up creating a Layer to manage the texture. | 26 // has enabled layers ends up creating a Layer to manage the texture. |
25 // | 27 // |
26 // NOTE: unlike Views, each Layer does *not* own its children views. If you | 28 // NOTE: unlike Views, each Layer does *not* own its children views. If you |
27 // delete a Layer and it has children, the parent of each child layer is set to | 29 // delete a Layer and it has children, the parent of each child layer is set to |
28 // NULL, but the children are not deleted. | 30 // NULL, but the children are not deleted. |
29 class COMPOSITOR_EXPORT Layer { | 31 class COMPOSITOR_EXPORT Layer { |
30 public: | 32 public: |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 const Compositor* compositor() const { return compositor_; } | 74 const Compositor* compositor() const { return compositor_; } |
73 Compositor* compositor() { return compositor_; } | 75 Compositor* compositor() { return compositor_; } |
74 | 76 |
75 // Passing NULL will cause the layer to get a texture from its compositor. | 77 // Passing NULL will cause the layer to get a texture from its compositor. |
76 void SetTexture(ui::Texture* texture); | 78 void SetTexture(ui::Texture* texture); |
77 const ui::Texture* texture() const { return texture_.get(); } | 79 const ui::Texture* texture() const { return texture_.get(); } |
78 | 80 |
79 // Resets the canvas of the texture. | 81 // Resets the canvas of the texture. |
80 void SetCanvas(const SkCanvas& canvas, const gfx::Point& origin); | 82 void SetCanvas(const SkCanvas& canvas, const gfx::Point& origin); |
81 | 83 |
| 84 // Layers do not own observers. It is the responsibility of the observer to |
| 85 // remove itself when it is done observing. |
| 86 void AddObserver(LayerObserver* observer); |
| 87 void RemoveObserver(LayerObserver* observer); |
| 88 |
82 // Draws the layer with hole if hole is non empty. | 89 // Draws the layer with hole if hole is non empty. |
83 // hole looks like: | 90 // hole looks like: |
84 // | 91 // |
85 // layer____________________________ | 92 // layer____________________________ |
86 // |xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| | 93 // |xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| |
87 // |xxxxxxxxxxxxx top xxxxxxxxxxxxxx| | 94 // |xxxxxxxxxxxxx top xxxxxxxxxxxxxx| |
88 // |________________________________| | 95 // |________________________________| |
89 // |xxxxx| |xxxxx| | 96 // |xxxxx| |xxxxx| |
90 // |xxxxx| Hole Rect |xxxxx| | 97 // |xxxxx| Hole Rect |xxxxx| |
91 // |left | (not composited) |right| | 98 // |left | (not composited) |right| |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 std::vector<Layer*> children_; | 134 std::vector<Layer*> children_; |
128 | 135 |
129 ui::Transform transform_; | 136 ui::Transform transform_; |
130 | 137 |
131 gfx::Rect bounds_; | 138 gfx::Rect bounds_; |
132 | 139 |
133 bool fills_bounds_opaquely_; | 140 bool fills_bounds_opaquely_; |
134 | 141 |
135 gfx::Rect hole_rect_; | 142 gfx::Rect hole_rect_; |
136 | 143 |
| 144 ObserverList<LayerObserver> observer_list_; |
| 145 |
137 DISALLOW_COPY_AND_ASSIGN(Layer); | 146 DISALLOW_COPY_AND_ASSIGN(Layer); |
138 }; | 147 }; |
139 | 148 |
140 } // namespace ui | 149 } // namespace ui |
141 | 150 |
142 #endif // UI_GFX_COMPOSITOR_LAYER_H_ | 151 #endif // UI_GFX_COMPOSITOR_LAYER_H_ |
OLD | NEW |