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