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