Chromium Code Reviews| 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 <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 178 // TODO(vollick): Eventually, if a non-leaf node has an opacity of less than | 178 // TODO(vollick): Eventually, if a non-leaf node has an opacity of less than |
| 179 // 1.0, we'll render to a separate texture, and then apply the alpha. | 179 // 1.0, we'll render to a separate texture, and then apply the alpha. |
| 180 // Currently, we multiply our opacity by all our ancestor's opacities and | 180 // Currently, we multiply our opacity by all our ancestor's opacities and |
| 181 // use the combined result, but this is only temporary. | 181 // use the combined result, but this is only temporary. |
| 182 float GetCombinedOpacity() const; | 182 float GetCombinedOpacity() const; |
| 183 | 183 |
| 184 // Called during the Draw() pass to freshen the Layer's contents from the | 184 // Called during the Draw() pass to freshen the Layer's contents from the |
| 185 // delegate. | 185 // delegate. |
| 186 void UpdateLayerCanvas(); | 186 void UpdateLayerCanvas(); |
| 187 | 187 |
| 188 // Resets |hole_rect_| to the empty rect for all layers below and | |
| 189 // including this one. | |
| 190 void ClearHoleRects(); | |
| 191 | |
| 192 // Does a preorder traversal of layers starting with this layer. Omits layers | |
| 193 // which cannot punch a hole in another layer such as non visible layers | |
|
sky
2011/10/24 15:44:52
'in another' -> 'in another'
| |
| 194 // and layers which don't fill their bounds opaquely. | |
| 195 void GeneratePreorderTraversal(std::vector<ui::Layer*>* layer_traversal); | |
| 196 | |
| 188 // A hole in a layer is an area in the layer that does not get drawn | 197 // A hole in a layer is an area in the layer that does not get drawn |
| 189 // because this area is covered up with another layer which is known to be | 198 // because this area is covered up with another layer which is known to be |
| 190 // opaque. | 199 // opaque. |
| 191 // This method computes the dimension of the hole (if there is one) | 200 // This method computes the dimension of the hole (if there is one) |
| 192 // based on whether one of its child nodes is always opaque. | 201 // based on whether one of its child nodes is always opaque. |
| 193 // Note: For simplicity's sake, currently a hole is only created if the child | 202 // Note: For simplicity's sake, currently a hole is only created if the child |
| 194 // view has no transform with respect to its parent. | 203 // view has no transform with respect to its parent. |
| 195 void RecomputeHole(); | 204 void RecomputeHole(); |
| 196 | 205 |
| 197 // Returns true if the layer paints every pixel (fills_bounds_opaquely) | 206 void set_hole_rect(const gfx::Rect& hole_rect) { |
| 198 // and the alpha of the layer is 1.0f. | 207 hole_rect_ = hole_rect; |
| 199 bool IsCompletelyOpaque() const; | 208 } |
| 200 | 209 |
| 201 // Determines the regions that don't intersect |rect| and places the | 210 // Determines the regions that don't intersect |rect| and places the |
| 202 // result in |sides|. | 211 // result in |sides|. |
| 203 // | 212 // |
| 204 // rect_____________________________ | 213 // rect_____________________________ |
| 205 // |xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| | 214 // |xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| |
| 206 // |xxxxxxxxxxxxx top xxxxxxxxxxxxxx| | 215 // |xxxxxxxxxxxxx top xxxxxxxxxxxxxx| |
| 207 // |________________________________| | 216 // |________________________________| |
| 208 // |xxxxx| |xxxxx| | 217 // |xxxxx| |xxxxx| |
| 209 // |xxxxx|region_to_punch_out |xxxxx| | 218 // |xxxxx|region_to_punch_out |xxxxx| |
| 210 // |left | |right| | 219 // |left | |right| |
| 211 // |_____|____________________|_____| | 220 // |_____|____________________|_____| |
| 212 // |xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| | 221 // |xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| |
| 213 // |xxxxxxxxxx bottom xxxxxxxxxxxxxx| | 222 // |xxxxxxxxxx bottom xxxxxxxxxxxxxx| |
| 214 // |________________________________| | 223 // |________________________________| |
| 215 static void PunchHole(const gfx::Rect& rect, | 224 static void PunchHole(const gfx::Rect& rect, |
| 216 const gfx::Rect& region_to_punch_out, | 225 const gfx::Rect& region_to_punch_out, |
| 217 std::vector<gfx::Rect>* sides); | 226 std::vector<gfx::Rect>* sides); |
| 218 | 227 |
| 228 // Drops texture just for this layer. | |
| 229 void DropTexture(); | |
| 230 | |
| 219 // Drop all textures for layers below and including this one. Called when | 231 // Drop all textures for layers below and including this one. Called when |
| 220 // the layer is removed from a hierarchy. Textures will be re-generated if | 232 // the layer is removed from a hierarchy. Textures will be re-generated if |
| 221 // the layer is subsequently re-attached and needs to be drawn. | 233 // the layer is subsequently re-attached and needs to be drawn. |
| 222 void DropTextures(); | 234 void DropTextures(); |
| 223 | 235 |
| 224 bool ConvertPointForAncestor(const Layer* ancestor, gfx::Point* point) const; | 236 bool ConvertPointForAncestor(const Layer* ancestor, gfx::Point* point) const; |
| 225 bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const; | 237 bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const; |
| 226 | 238 |
| 227 bool GetTransformRelativeTo(const Layer* ancestor, | 239 bool GetTransformRelativeTo(const Layer* ancestor, |
| 228 Transform* transform) const; | 240 Transform* transform) const; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 279 LayerDelegate* delegate_; | 291 LayerDelegate* delegate_; |
| 280 | 292 |
| 281 scoped_ptr<LayerAnimator> animator_; | 293 scoped_ptr<LayerAnimator> animator_; |
| 282 | 294 |
| 283 DISALLOW_COPY_AND_ASSIGN(Layer); | 295 DISALLOW_COPY_AND_ASSIGN(Layer); |
| 284 }; | 296 }; |
| 285 | 297 |
| 286 } // namespace ui | 298 } // namespace ui |
| 287 | 299 |
| 288 #endif // UI_GFX_COMPOSITOR_LAYER_H_ | 300 #endif // UI_GFX_COMPOSITOR_LAYER_H_ |
| OLD | NEW |