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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 | 186 |
| 187 #if !defined(NDEBUG) | 187 #if !defined(NDEBUG) |
| 188 // Returns layer info in a string format compatible with View::PrintViewGraph | 188 // Returns layer info in a string format compatible with View::PrintViewGraph |
| 189 // and Window::PrintWindowGraph. | 189 // and Window::PrintWindowGraph. |
| 190 // Layers which print their bounds opaquely are filled. | 190 // Layers which print their bounds opaquely are filled. |
| 191 // Layers with textures are green, layers without textures are red. | 191 // Layers with textures are green, layers without textures are red. |
| 192 std::string GetLayerInfo(); | 192 std::string GetLayerInfo(); |
| 193 #endif | 193 #endif |
| 194 | 194 |
| 195 private: | 195 private: |
| 196 struct LayerProperties { | |
| 197 public: | |
|
sky
2011/10/26 00:08:28
Indentation is off here. Should be like a class.
| |
| 198 ui::Layer* layer; | |
| 199 ui::Transform transform_relative_to_root; | |
| 200 }; | |
| 201 | |
| 196 // TODO(vollick): Eventually, if a non-leaf node has an opacity of less than | 202 // TODO(vollick): Eventually, if a non-leaf node has an opacity of less than |
| 197 // 1.0, we'll render to a separate texture, and then apply the alpha. | 203 // 1.0, we'll render to a separate texture, and then apply the alpha. |
| 198 // Currently, we multiply our opacity by all our ancestor's opacities and | 204 // Currently, we multiply our opacity by all our ancestor's opacities and |
| 199 // use the combined result, but this is only temporary. | 205 // use the combined result, but this is only temporary. |
| 200 float GetCombinedOpacity() const; | 206 float GetCombinedOpacity() const; |
| 201 | 207 |
| 202 // Called during the Draw() pass to freshen the Layer's contents from the | 208 // Called during the Draw() pass to freshen the Layer's contents from the |
| 203 // delegate. | 209 // delegate. |
| 204 void UpdateLayerCanvas(); | 210 void UpdateLayerCanvas(); |
| 205 | 211 |
| 212 // Called to indicate that a layer's properties have changed and that the | |
| 213 // holes for the layers must be recomputed. | |
| 214 void SetNeedsToRecomputeHole(); | |
| 215 | |
| 216 // Resets |hole_rect_| to the empty rect for all layers below and | |
| 217 // including this one. | |
| 218 void ClearHoleRects(); | |
| 219 | |
| 220 // Does a preorder traversal of layers starting with this layer. Omits layers | |
| 221 // which cannot punch a hole in another layer such as non visible layers | |
| 222 // and layers which don't fill their bounds opaquely. | |
| 223 void GetLayerProperties(std::vector<LayerProperties>* traversal, | |
|
sky
2011/10/26 00:08:28
our params last.
| |
| 224 const ui::Transform& current_transform); | |
| 225 | |
| 206 // A hole in a layer is an area in the layer that does not get drawn | 226 // A hole in a layer is an area in the layer that does not get drawn |
| 207 // because this area is covered up with another layer which is known to be | 227 // because this area is covered up with another layer which is known to be |
| 208 // opaque. | 228 // opaque. |
| 209 // This method computes the dimension of the hole (if there is one) | 229 // This method computes the dimension of the hole (if there is one) |
| 210 // based on whether one of its child nodes is always opaque. | 230 // based on whether one of its child nodes is always opaque. |
| 211 // Note: For simplicity's sake, currently a hole is only created if the child | 231 // Note: This method should only be called from the root. |
| 212 // view has no transform with respect to its parent. | |
| 213 void RecomputeHole(); | 232 void RecomputeHole(); |
| 214 | 233 |
| 215 // Returns true if the layer paints every pixel (fills_bounds_opaquely) | 234 void set_hole_rect(const gfx::Rect& hole_rect) { |
| 216 // and the alpha of the layer is 1.0f. | 235 hole_rect_ = hole_rect; |
| 217 bool IsCompletelyOpaque() const; | 236 } |
| 218 | 237 |
| 219 // Determines the regions that don't intersect |rect| and places the | 238 // Determines the regions that don't intersect |rect| and places the |
| 220 // result in |sides|. | 239 // result in |sides|. |
| 221 // | 240 // |
| 222 // rect_____________________________ | 241 // rect_____________________________ |
| 223 // |xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| | 242 // |xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| |
| 224 // |xxxxxxxxxxxxx top xxxxxxxxxxxxxx| | 243 // |xxxxxxxxxxxxx top xxxxxxxxxxxxxx| |
| 225 // |________________________________| | 244 // |________________________________| |
| 226 // |xxxxx| |xxxxx| | 245 // |xxxxx| |xxxxx| |
| 227 // |xxxxx|region_to_punch_out |xxxxx| | 246 // |xxxxx|region_to_punch_out |xxxxx| |
| 228 // |left | |right| | 247 // |left | |right| |
| 229 // |_____|____________________|_____| | 248 // |_____|____________________|_____| |
| 230 // |xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| | 249 // |xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| |
| 231 // |xxxxxxxxxx bottom xxxxxxxxxxxxxx| | 250 // |xxxxxxxxxx bottom xxxxxxxxxxxxxx| |
| 232 // |________________________________| | 251 // |________________________________| |
| 233 static void PunchHole(const gfx::Rect& rect, | 252 static void PunchHole(const gfx::Rect& rect, |
| 234 const gfx::Rect& region_to_punch_out, | 253 const gfx::Rect& region_to_punch_out, |
| 235 std::vector<gfx::Rect>* sides); | 254 std::vector<gfx::Rect>* sides); |
| 236 | 255 |
| 256 // Drops texture just for this layer. | |
| 257 void DropTexture(); | |
| 258 | |
| 237 // Drop all textures for layers below and including this one. Called when | 259 // Drop all textures for layers below and including this one. Called when |
| 238 // the layer is removed from a hierarchy. Textures will be re-generated if | 260 // the layer is removed from a hierarchy. Textures will be re-generated if |
| 239 // the layer is subsequently re-attached and needs to be drawn. | 261 // the layer is subsequently re-attached and needs to be drawn. |
| 240 void DropTextures(); | 262 void DropTextures(); |
| 241 | 263 |
| 242 bool ConvertPointForAncestor(const Layer* ancestor, gfx::Point* point) const; | 264 bool ConvertPointForAncestor(const Layer* ancestor, gfx::Point* point) const; |
| 243 bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const; | 265 bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const; |
| 244 | 266 |
| 245 bool GetTransformRelativeTo(const Layer* ancestor, | 267 bool GetTransformRelativeTo(const Layer* ancestor, |
| 246 Transform* transform) const; | 268 Transform* transform) const; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 | 309 |
| 288 gfx::Rect bounds_; | 310 gfx::Rect bounds_; |
| 289 | 311 |
| 290 // Visibility of this layer. See SetVisible/IsDrawn for more details. | 312 // Visibility of this layer. See SetVisible/IsDrawn for more details. |
| 291 bool visible_; | 313 bool visible_; |
| 292 | 314 |
| 293 bool fills_bounds_opaquely_; | 315 bool fills_bounds_opaquely_; |
| 294 | 316 |
| 295 gfx::Rect hole_rect_; | 317 gfx::Rect hole_rect_; |
| 296 | 318 |
| 319 bool recompute_hole_; | |
| 320 | |
| 297 gfx::Rect invalid_rect_; | 321 gfx::Rect invalid_rect_; |
| 298 | 322 |
| 299 // If true the layer is always up to date. | 323 // If true the layer is always up to date. |
| 300 bool layer_updated_externally_; | 324 bool layer_updated_externally_; |
| 301 | 325 |
| 302 float opacity_; | 326 float opacity_; |
| 303 | 327 |
| 304 LayerDelegate* delegate_; | 328 LayerDelegate* delegate_; |
| 305 | 329 |
| 306 scoped_ptr<LayerAnimationManager> animator_; | 330 scoped_ptr<LayerAnimationManager> animator_; |
| 307 | 331 |
| 308 #if defined(USE_WEBKIT_COMPOSITOR) | 332 #if defined(USE_WEBKIT_COMPOSITOR) |
| 309 WebKit::WebContentLayer web_layer_; | 333 WebKit::WebContentLayer web_layer_; |
| 310 #endif | 334 #endif |
| 311 | 335 |
| 312 DISALLOW_COPY_AND_ASSIGN(Layer); | 336 DISALLOW_COPY_AND_ASSIGN(Layer); |
| 313 }; | 337 }; |
| 314 | 338 |
| 315 } // namespace ui | 339 } // namespace ui |
| 316 | 340 |
| 317 #endif // UI_GFX_COMPOSITOR_LAYER_H_ | 341 #endif // UI_GFX_COMPOSITOR_LAYER_H_ |
| OLD | NEW |