| 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 10 matching lines...) Expand all  Loading... | 
|   21 #include "cc/layers/layer_client.h" |   21 #include "cc/layers/layer_client.h" | 
|   22 #include "cc/layers/surface_layer.h" |   22 #include "cc/layers/surface_layer.h" | 
|   23 #include "cc/layers/texture_layer_client.h" |   23 #include "cc/layers/texture_layer_client.h" | 
|   24 #include "cc/resources/texture_mailbox.h" |   24 #include "cc/resources/texture_mailbox.h" | 
|   25 #include "cc/surfaces/surface_id.h" |   25 #include "cc/surfaces/surface_id.h" | 
|   26 #include "third_party/skia/include/core/SkColor.h" |   26 #include "third_party/skia/include/core/SkColor.h" | 
|   27 #include "third_party/skia/include/core/SkRegion.h" |   27 #include "third_party/skia/include/core/SkRegion.h" | 
|   28 #include "ui/compositor/compositor.h" |   28 #include "ui/compositor/compositor.h" | 
|   29 #include "ui/compositor/layer_animation_delegate.h" |   29 #include "ui/compositor/layer_animation_delegate.h" | 
|   30 #include "ui/compositor/layer_delegate.h" |   30 #include "ui/compositor/layer_delegate.h" | 
 |   31 #include "ui/compositor/layer_observer.h" | 
|   31 #include "ui/compositor/layer_type.h" |   32 #include "ui/compositor/layer_type.h" | 
|   32 #include "ui/gfx/geometry/rect.h" |   33 #include "ui/gfx/geometry/rect.h" | 
|   33 #include "ui/gfx/image/image_skia.h" |   34 #include "ui/gfx/image/image_skia.h" | 
|   34 #include "ui/gfx/transform.h" |   35 #include "ui/gfx/transform.h" | 
|   35  |   36  | 
|   36 class SkCanvas; |   37 class SkCanvas; | 
|   37  |   38  | 
|   38 namespace cc { |   39 namespace cc { | 
|   39 class ContentLayer; |   40 class ContentLayer; | 
|   40 class CopyOutputRequest; |   41 class CopyOutputRequest; | 
|   41 class Layer; |   42 class Layer; | 
|   42 class NinePatchLayer; |   43 class NinePatchLayer; | 
|   43 class ResourceUpdateQueue; |   44 class ResourceUpdateQueue; | 
|   44 class SolidColorLayer; |   45 class SolidColorLayer; | 
|   45 class SurfaceLayer; |   46 class SurfaceLayer; | 
|   46 class TextureLayer; |   47 class TextureLayer; | 
|   47 struct ReturnedResource; |   48 struct ReturnedResource; | 
|   48 typedef std::vector<ReturnedResource> ReturnedResourceArray; |   49 typedef std::vector<ReturnedResource> ReturnedResourceArray; | 
|   49 } |   50 } | 
|   50  |   51  | 
|   51 namespace ui { |   52 namespace ui { | 
|   52  |   53  | 
|   53 class Compositor; |   54 class Compositor; | 
|   54 class LayerAnimator; |   55 class LayerAnimator; | 
|   55 class LayerObserver; |  | 
|   56 class LayerOwner; |   56 class LayerOwner; | 
|   57 class LayerThreadedAnimationDelegate; |   57 class LayerThreadedAnimationDelegate; | 
|   58  |   58  | 
|   59 // Layer manages a texture, transform and a set of child Layers. Any View that |   59 // Layer manages a texture, transform and a set of child Layers. Any View that | 
|   60 // has enabled layers ends up creating a Layer to manage the texture. |   60 // has enabled layers ends up creating a Layer to manage the texture. | 
|   61 // A Layer can also be created without a texture, in which case it renders |   61 // A Layer can also be created without a texture, in which case it renders | 
|   62 // nothing and is simply used as a node in a hierarchy of layers. |   62 // nothing and is simply used as a node in a hierarchy of layers. | 
|   63 // Coordinate system used in layers is DIP (Density Independent Pixel) |   63 // Coordinate system used in layers is DIP (Density Independent Pixel) | 
|   64 // coordinates unless explicitly mentioned as pixel coordinates. |   64 // coordinates unless explicitly mentioned as pixel coordinates. | 
|   65 // |   65 // | 
|   66 // NOTE: Unlike Views, each Layer does *not* own its child Layers. If you |   66 // NOTE: Unlike Views, each Layer does *not* own its child Layers. If you | 
|   67 // delete a Layer and it has children, the parent of each child Layer is set to |   67 // delete a Layer and it has children, the parent of each child Layer is set to | 
|   68 // NULL, but the children are not deleted. |   68 // NULL, but the children are not deleted. | 
|   69 class COMPOSITOR_EXPORT Layer |   69 class COMPOSITOR_EXPORT Layer | 
|   70     : public LayerAnimationDelegate, |   70     : public LayerAnimationDelegate, | 
 |   71       public LayerObserver, | 
|   71       NON_EXPORTED_BASE(public cc::ContentLayerClient), |   72       NON_EXPORTED_BASE(public cc::ContentLayerClient), | 
|   72       NON_EXPORTED_BASE(public cc::TextureLayerClient), |   73       NON_EXPORTED_BASE(public cc::TextureLayerClient), | 
|   73       NON_EXPORTED_BASE(public cc::LayerClient) { |   74       NON_EXPORTED_BASE(public cc::LayerClient) { | 
|   74  public: |   75  public: | 
|   75   Layer(); |   76   Layer(); | 
|   76   explicit Layer(LayerType type); |   77   explicit Layer(LayerType type); | 
|   77   ~Layer() override; |   78   ~Layer() override; | 
|   78  |   79  | 
 |   80   // Note that only solid color and surface content is copied. | 
 |   81   std::unique_ptr<Layer> Clone() const; | 
 |   82  | 
|   79   // Retrieves the Layer's compositor. The Layer will walk up its parent chain |   83   // 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. |   84   // to locate it. Returns NULL if the Layer is not attached to a compositor. | 
|   81   Compositor* GetCompositor() { |   85   Compositor* GetCompositor() { | 
|   82     return const_cast<Compositor*>( |   86     return const_cast<Compositor*>( | 
|   83         const_cast<const Layer*>(this)->GetCompositor()); |   87         const_cast<const Layer*>(this)->GetCompositor()); | 
|   84   } |   88   } | 
|   85   const Compositor* GetCompositor() const; |   89   const Compositor* GetCompositor() const; | 
|   86  |   90  | 
|   87   // Called by the compositor when the Layer is set as its root Layer. This can |   91   // Called by the compositor when the Layer is set as its root Layer. This can | 
|   88   // only ever be called on the root layer. |   92   // only ever be called on the root layer. | 
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  287   bool TextureFlipped() const; |  291   bool TextureFlipped() const; | 
|  288  |  292  | 
|  289   // Begins showing content from a surface with a particular id. |  293   // Begins showing content from a surface with a particular id. | 
|  290   void SetShowSurface(const cc::SurfaceId& surface_id, |  294   void SetShowSurface(const cc::SurfaceId& surface_id, | 
|  291                       const cc::SurfaceLayer::SatisfyCallback& satisfy_callback, |  295                       const cc::SurfaceLayer::SatisfyCallback& satisfy_callback, | 
|  292                       const cc::SurfaceLayer::RequireCallback& require_callback, |  296                       const cc::SurfaceLayer::RequireCallback& require_callback, | 
|  293                       gfx::Size surface_size, |  297                       gfx::Size surface_size, | 
|  294                       float scale, |  298                       float scale, | 
|  295                       gfx::Size frame_size_in_dip); |  299                       gfx::Size frame_size_in_dip); | 
|  296  |  300  | 
 |  301   // Returns a new layer that mirrors this layer and is optionally synchronized | 
 |  302   // with the bounds thereof. Note that children are not mirrored, and that the | 
 |  303   // content is only mirrored if painted by a delegate or backed by a surface. | 
 |  304   std::unique_ptr<Layer> Mirror(); | 
 |  305  | 
 |  306   void set_sync_bounds(bool sync_bounds) { sync_bounds_ = sync_bounds; } | 
 |  307  | 
|  297   bool has_external_content() { |  308   bool has_external_content() { | 
|  298     return texture_layer_.get() || surface_layer_.get(); |  309     return texture_layer_.get() || surface_layer_.get(); | 
|  299   } |  310   } | 
|  300  |  311  | 
|  301   // Show a solid color instead of delegated or surface contents. |  312   // Show a solid color instead of delegated or surface contents. | 
|  302   void SetShowSolidColorContent(); |  313   void SetShowSolidColorContent(); | 
|  303  |  314  | 
|  304   // Sets the layer's fill color.  May only be called for LAYER_SOLID_COLOR. |  315   // Sets the layer's fill color.  May only be called for LAYER_SOLID_COLOR. | 
|  305   void SetColor(SkColor color); |  316   void SetColor(SkColor color); | 
|  306   SkColor GetTargetColor(); |  317   SkColor GetTargetColor() const; | 
|  307   SkColor background_color() const; |  318   SkColor background_color() const; | 
|  308  |  319  | 
|  309   // Updates the nine patch layer's image, aperture and border. May only be |  320   // Updates the nine patch layer's image, aperture and border. May only be | 
|  310   // called for LAYER_NINE_PATCH. |  321   // called for LAYER_NINE_PATCH. | 
|  311   void UpdateNinePatchLayerImage(const gfx::ImageSkia& image); |  322   void UpdateNinePatchLayerImage(const gfx::ImageSkia& image); | 
|  312   void UpdateNinePatchLayerAperture(const gfx::Rect& aperture_in_dip); |  323   void UpdateNinePatchLayerAperture(const gfx::Rect& aperture_in_dip); | 
|  313   void UpdateNinePatchLayerBorder(const gfx::Rect& border); |  324   void UpdateNinePatchLayerBorder(const gfx::Rect& border); | 
|  314   // Updates the area completely occluded by another layer, this can be an |  325   // Updates the area completely occluded by another layer, this can be an | 
|  315   // empty rectangle if nothing is occluded. |  326   // empty rectangle if nothing is occluded. | 
|  316   void UpdateNinePatchOcclusion(const gfx::Rect& occlusion); |  327   void UpdateNinePatchOcclusion(const gfx::Rect& occlusion); | 
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  407   float GetOpacityForAnimation() const override; |  418   float GetOpacityForAnimation() const override; | 
|  408   bool GetVisibilityForAnimation() const override; |  419   bool GetVisibilityForAnimation() const override; | 
|  409   float GetBrightnessForAnimation() const override; |  420   float GetBrightnessForAnimation() const override; | 
|  410   float GetGrayscaleForAnimation() const override; |  421   float GetGrayscaleForAnimation() const override; | 
|  411   SkColor GetColorForAnimation() const override; |  422   SkColor GetColorForAnimation() const override; | 
|  412   float GetDeviceScaleFactor() const override; |  423   float GetDeviceScaleFactor() const override; | 
|  413   cc::Layer* GetCcLayer() const override; |  424   cc::Layer* GetCcLayer() const override; | 
|  414   LayerThreadedAnimationDelegate* GetThreadedAnimationDelegate() override; |  425   LayerThreadedAnimationDelegate* GetThreadedAnimationDelegate() override; | 
|  415   LayerAnimatorCollection* GetLayerAnimatorCollection() override; |  426   LayerAnimatorCollection* GetLayerAnimatorCollection() override; | 
|  416  |  427  | 
 |  428   // LayerObserver: | 
 |  429   void LayerDestroyed(Layer* layer) override; | 
 |  430  | 
|  417   // Creates a corresponding composited layer for |type_|. |  431   // Creates a corresponding composited layer for |type_|. | 
|  418   void CreateCcLayer(); |  432   void CreateCcLayer(); | 
|  419  |  433  | 
|  420   // Recomputes and sets to |cc_layer_|. |  434   // Recomputes and sets to |cc_layer_|. | 
|  421   void RecomputeDrawsContentAndUVRect(); |  435   void RecomputeDrawsContentAndUVRect(); | 
|  422   void RecomputePosition(); |  436   void RecomputePosition(); | 
|  423  |  437  | 
|  424   // Set all filters which got applied to the layer. |  438   // Set all filters which got applied to the layer. | 
|  425   void SetLayerFilters(); |  439   void SetLayerFilters(); | 
|  426  |  440  | 
|  427   // Set all filters which got applied to the layer background. |  441   // Set all filters which got applied to the layer background. | 
|  428   void SetLayerBackgroundFilters(); |  442   void SetLayerBackgroundFilters(); | 
|  429  |  443  | 
|  430   // Cleanup |cc_layer_| and replaces it with |new_layer|. |  444   // Cleanup |cc_layer_| and replaces it with |new_layer|. | 
|  431   void SwitchToLayer(scoped_refptr<cc::Layer> new_layer); |  445   void SwitchToLayer(scoped_refptr<cc::Layer> new_layer); | 
|  432  |  446  | 
|  433   void SetCompositorForAnimatorsInTree(Compositor* compositor); |  447   void SetCompositorForAnimatorsInTree(Compositor* compositor); | 
|  434   void ResetCompositorForAnimatorsInTree(Compositor* compositor); |  448   void ResetCompositorForAnimatorsInTree(Compositor* compositor); | 
|  435  |  449  | 
|  436   const LayerType type_; |  450   const LayerType type_; | 
|  437  |  451  | 
|  438   Compositor* compositor_; |  452   Compositor* compositor_; | 
|  439  |  453  | 
|  440   Layer* parent_; |  454   Layer* parent_; | 
|  441  |  455  | 
|  442   // This layer's children, in bottom-to-top stacking order. |  456   // This layer's children, in bottom-to-top stacking order. | 
|  443   std::vector<Layer*> children_; |  457   std::vector<Layer*> children_; | 
|  444  |  458  | 
 |  459   class LayerMirror; | 
 |  460   std::vector<std::unique_ptr<LayerMirror>> mirrors_; | 
 |  461  | 
 |  462   // If true, changes to the bounds of this layer are propagated to mirrors. | 
 |  463   bool sync_bounds_ = false; | 
 |  464  | 
|  445   gfx::Rect bounds_; |  465   gfx::Rect bounds_; | 
|  446   gfx::Vector2dF subpixel_position_offset_; |  466   gfx::Vector2dF subpixel_position_offset_; | 
|  447  |  467  | 
|  448   // Visibility of this layer. See SetVisible/IsDrawn for more details. |  468   // Visibility of this layer. See SetVisible/IsDrawn for more details. | 
|  449   bool visible_; |  469   bool visible_; | 
|  450  |  470  | 
|  451   bool fills_bounds_opaquely_; |  471   bool fills_bounds_opaquely_; | 
|  452   bool fills_bounds_completely_; |  472   bool fills_bounds_completely_; | 
|  453  |  473  | 
|  454   // Union of damaged rects, in layer space, that SetNeedsDisplayRect should |  474   // 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 |  542   // The size of the frame or texture in DIP, set when SetShowDelegatedContent | 
|  523   // or SetTextureMailbox was called. |  543   // or SetTextureMailbox was called. | 
|  524   gfx::Size frame_size_in_dip_; |  544   gfx::Size frame_size_in_dip_; | 
|  525  |  545  | 
|  526   DISALLOW_COPY_AND_ASSIGN(Layer); |  546   DISALLOW_COPY_AND_ASSIGN(Layer); | 
|  527 }; |  547 }; | 
|  528  |  548  | 
|  529 }  // namespace ui |  549 }  // namespace ui | 
|  530  |  550  | 
|  531 #endif  // UI_COMPOSITOR_LAYER_H_ |  551 #endif  // UI_COMPOSITOR_LAYER_H_ | 
| OLD | NEW |