| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_COMPOSITOR_LAYER_H_ | 5 #ifndef UI_COMPOSITOR_LAYER_H_ |
| 6 #define UI_COMPOSITOR_LAYER_H_ | 6 #define UI_COMPOSITOR_LAYER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 class COMPOSITOR_EXPORT Layer | 69 class COMPOSITOR_EXPORT Layer |
| 70 : public LayerAnimationDelegate, | 70 : public LayerAnimationDelegate, |
| 71 NON_EXPORTED_BASE(public cc::ContentLayerClient), | 71 NON_EXPORTED_BASE(public cc::ContentLayerClient), |
| 72 NON_EXPORTED_BASE(public cc::TextureLayerClient), | 72 NON_EXPORTED_BASE(public cc::TextureLayerClient), |
| 73 NON_EXPORTED_BASE(public cc::LayerClient) { | 73 NON_EXPORTED_BASE(public cc::LayerClient) { |
| 74 public: | 74 public: |
| 75 Layer(); | 75 Layer(); |
| 76 explicit Layer(LayerType type); | 76 explicit Layer(LayerType type); |
| 77 ~Layer() override; | 77 ~Layer() override; |
| 78 | 78 |
| 79 // Note that only solid color and surface content is copied. |
| 80 std::unique_ptr<Layer> Clone() const; |
| 81 |
| 82 // Returns a new layer that mirrors this layer and is optionally synchronized |
| 83 // with the bounds thereof. Note that children are not mirrored, and that the |
| 84 // content is only mirrored if painted by a delegate or backed by a surface. |
| 85 std::unique_ptr<Layer> Mirror(); |
| 86 |
| 87 void set_sync_bounds(bool sync_bounds) { sync_bounds_ = sync_bounds; } |
| 88 |
| 79 // Retrieves the Layer's compositor. The Layer will walk up its parent chain | 89 // Retrieves the Layer's compositor. The Layer will walk up its parent chain |
| 80 // to locate it. Returns NULL if the Layer is not attached to a compositor. | 90 // to locate it. Returns NULL if the Layer is not attached to a compositor. |
| 81 Compositor* GetCompositor() { | 91 Compositor* GetCompositor() { |
| 82 return const_cast<Compositor*>( | 92 return const_cast<Compositor*>( |
| 83 const_cast<const Layer*>(this)->GetCompositor()); | 93 const_cast<const Layer*>(this)->GetCompositor()); |
| 84 } | 94 } |
| 85 const Compositor* GetCompositor() const; | 95 const Compositor* GetCompositor() const; |
| 86 | 96 |
| 87 // Called by the compositor when the Layer is set as its root Layer. This can | 97 // Called by the compositor when the Layer is set as its root Layer. This can |
| 88 // only ever be called on the root layer. | 98 // only ever be called on the root layer. |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 | 306 |
| 297 bool has_external_content() { | 307 bool has_external_content() { |
| 298 return texture_layer_.get() || surface_layer_.get(); | 308 return texture_layer_.get() || surface_layer_.get(); |
| 299 } | 309 } |
| 300 | 310 |
| 301 // Show a solid color instead of delegated or surface contents. | 311 // Show a solid color instead of delegated or surface contents. |
| 302 void SetShowSolidColorContent(); | 312 void SetShowSolidColorContent(); |
| 303 | 313 |
| 304 // Sets the layer's fill color. May only be called for LAYER_SOLID_COLOR. | 314 // Sets the layer's fill color. May only be called for LAYER_SOLID_COLOR. |
| 305 void SetColor(SkColor color); | 315 void SetColor(SkColor color); |
| 306 SkColor GetTargetColor(); | 316 SkColor GetTargetColor() const; |
| 307 SkColor background_color() const; | 317 SkColor background_color() const; |
| 308 | 318 |
| 309 // Updates the nine patch layer's image, aperture and border. May only be | 319 // Updates the nine patch layer's image, aperture and border. May only be |
| 310 // called for LAYER_NINE_PATCH. | 320 // called for LAYER_NINE_PATCH. |
| 311 void UpdateNinePatchLayerImage(const gfx::ImageSkia& image); | 321 void UpdateNinePatchLayerImage(const gfx::ImageSkia& image); |
| 312 void UpdateNinePatchLayerAperture(const gfx::Rect& aperture_in_dip); | 322 void UpdateNinePatchLayerAperture(const gfx::Rect& aperture_in_dip); |
| 313 void UpdateNinePatchLayerBorder(const gfx::Rect& border); | 323 void UpdateNinePatchLayerBorder(const gfx::Rect& border); |
| 314 // Updates the area completely occluded by another layer, this can be an | 324 // Updates the area completely occluded by another layer, this can be an |
| 315 // empty rectangle if nothing is occluded. | 325 // empty rectangle if nothing is occluded. |
| 316 void UpdateNinePatchOcclusion(const gfx::Rect& occlusion); | 326 void UpdateNinePatchOcclusion(const gfx::Rect& occlusion); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 | 386 |
| 377 // Triggers a call to SwitchToLayer. | 387 // Triggers a call to SwitchToLayer. |
| 378 void SwitchCCLayerForTest(); | 388 void SwitchCCLayerForTest(); |
| 379 | 389 |
| 380 const cc::Region& damaged_region_for_testing() const { | 390 const cc::Region& damaged_region_for_testing() const { |
| 381 return damaged_region_; | 391 return damaged_region_; |
| 382 } | 392 } |
| 383 | 393 |
| 384 private: | 394 private: |
| 385 friend class LayerOwner; | 395 friend class LayerOwner; |
| 396 class LayerMirror; |
| 386 | 397 |
| 387 void CollectAnimators(std::vector<scoped_refptr<LayerAnimator> >* animators); | 398 void CollectAnimators(std::vector<scoped_refptr<LayerAnimator> >* animators); |
| 388 | 399 |
| 389 // Stacks |child| above or below |other|. Helper method for StackAbove() and | 400 // Stacks |child| above or below |other|. Helper method for StackAbove() and |
| 390 // StackBelow(). | 401 // StackBelow(). |
| 391 void StackRelativeTo(Layer* child, Layer* other, bool above); | 402 void StackRelativeTo(Layer* child, Layer* other, bool above); |
| 392 | 403 |
| 393 bool ConvertPointForAncestor(const Layer* ancestor, gfx::Point* point) const; | 404 bool ConvertPointForAncestor(const Layer* ancestor, gfx::Point* point) const; |
| 394 bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const; | 405 bool ConvertPointFromAncestor(const Layer* ancestor, gfx::Point* point) const; |
| 395 | 406 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 426 | 437 |
| 427 // Set all filters which got applied to the layer background. | 438 // Set all filters which got applied to the layer background. |
| 428 void SetLayerBackgroundFilters(); | 439 void SetLayerBackgroundFilters(); |
| 429 | 440 |
| 430 // Cleanup |cc_layer_| and replaces it with |new_layer|. | 441 // Cleanup |cc_layer_| and replaces it with |new_layer|. |
| 431 void SwitchToLayer(scoped_refptr<cc::Layer> new_layer); | 442 void SwitchToLayer(scoped_refptr<cc::Layer> new_layer); |
| 432 | 443 |
| 433 void SetCompositorForAnimatorsInTree(Compositor* compositor); | 444 void SetCompositorForAnimatorsInTree(Compositor* compositor); |
| 434 void ResetCompositorForAnimatorsInTree(Compositor* compositor); | 445 void ResetCompositorForAnimatorsInTree(Compositor* compositor); |
| 435 | 446 |
| 447 void OnMirrorDestroyed(LayerMirror* mirror); |
| 448 |
| 436 const LayerType type_; | 449 const LayerType type_; |
| 437 | 450 |
| 438 Compositor* compositor_; | 451 Compositor* compositor_; |
| 439 | 452 |
| 440 Layer* parent_; | 453 Layer* parent_; |
| 441 | 454 |
| 442 // This layer's children, in bottom-to-top stacking order. | 455 // This layer's children, in bottom-to-top stacking order. |
| 443 std::vector<Layer*> children_; | 456 std::vector<Layer*> children_; |
| 444 | 457 |
| 458 std::vector<std::unique_ptr<LayerMirror>> mirrors_; |
| 459 |
| 460 // If true, changes to the bounds of this layer are propagated to mirrors. |
| 461 bool sync_bounds_ = false; |
| 462 |
| 445 gfx::Rect bounds_; | 463 gfx::Rect bounds_; |
| 446 gfx::Vector2dF subpixel_position_offset_; | 464 gfx::Vector2dF subpixel_position_offset_; |
| 447 | 465 |
| 448 // Visibility of this layer. See SetVisible/IsDrawn for more details. | 466 // Visibility of this layer. See SetVisible/IsDrawn for more details. |
| 449 bool visible_; | 467 bool visible_; |
| 450 | 468 |
| 451 bool fills_bounds_opaquely_; | 469 bool fills_bounds_opaquely_; |
| 452 bool fills_bounds_completely_; | 470 bool fills_bounds_completely_; |
| 453 | 471 |
| 454 // Union of damaged rects, in layer space, that SetNeedsDisplayRect should | 472 // Union of damaged rects, in layer space, that SetNeedsDisplayRect should |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 // The size of the frame or texture in DIP, set when SetShowDelegatedContent | 540 // The size of the frame or texture in DIP, set when SetShowDelegatedContent |
| 523 // or SetTextureMailbox was called. | 541 // or SetTextureMailbox was called. |
| 524 gfx::Size frame_size_in_dip_; | 542 gfx::Size frame_size_in_dip_; |
| 525 | 543 |
| 526 DISALLOW_COPY_AND_ASSIGN(Layer); | 544 DISALLOW_COPY_AND_ASSIGN(Layer); |
| 527 }; | 545 }; |
| 528 | 546 |
| 529 } // namespace ui | 547 } // namespace ui |
| 530 | 548 |
| 531 #endif // UI_COMPOSITOR_LAYER_H_ | 549 #endif // UI_COMPOSITOR_LAYER_H_ |
| OLD | NEW |