| 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 <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 bool Contains(const Layer* other) const; | 53 bool Contains(const Layer* other) const; |
| 54 | 54 |
| 55 // The transform, relative to the parent. | 55 // The transform, relative to the parent. |
| 56 void SetTransform(const ui::Transform& transform); | 56 void SetTransform(const ui::Transform& transform); |
| 57 const ui::Transform& transform() const { return transform_; } | 57 const ui::Transform& transform() const { return transform_; } |
| 58 | 58 |
| 59 // The bounds, relative to the parent. | 59 // The bounds, relative to the parent. |
| 60 void SetBounds(const gfx::Rect& bounds); | 60 void SetBounds(const gfx::Rect& bounds); |
| 61 const gfx::Rect& bounds() const { return bounds_; } | 61 const gfx::Rect& bounds() const { return bounds_; } |
| 62 | 62 |
| 63 // Sets |visible_|. The Layer is drawn by Draw() only when visible_ is true. |
| 64 bool visible() const { return visible_; } |
| 65 void set_visible(bool visible) { visible_ = visible; } |
| 66 |
| 63 // Converts a point from the coordinates of |source| to the coordinates of | 67 // Converts a point from the coordinates of |source| to the coordinates of |
| 64 // |target|. Necessarily, |source| and |target| must inhabit the same Layer | 68 // |target|. Necessarily, |source| and |target| must inhabit the same Layer |
| 65 // tree. | 69 // tree. |
| 66 static void ConvertPointToLayer(const Layer* source, | 70 static void ConvertPointToLayer(const Layer* source, |
| 67 const Layer* target, | 71 const Layer* target, |
| 68 gfx::Point* point); | 72 gfx::Point* point); |
| 69 | 73 |
| 70 // See description in View for details | 74 // See description in View for details |
| 71 void SetFillsBoundsOpaquely(bool fills_bounds_opaquely); | 75 void SetFillsBoundsOpaquely(bool fills_bounds_opaquely); |
| 72 bool fills_bounds_opaquely() const { return fills_bounds_opaquely_; } | 76 bool fills_bounds_opaquely() const { return fills_bounds_opaquely_; } |
| 73 | 77 |
| 74 const gfx::Rect& hole_rect() const { return hole_rect_; } | 78 const gfx::Rect& hole_rect() const { return hole_rect_; } |
| 75 | 79 |
| 76 // The compositor. | 80 // The compositor. |
| 77 const Compositor* compositor() const { return compositor_; } | 81 const Compositor* compositor() const { return compositor_; } |
| 78 Compositor* compositor() { return compositor_; } | 82 Compositor* compositor() { return compositor_; } |
| 79 | 83 |
| 80 // Passing NULL will cause the layer to get a texture from its compositor. | 84 // Passing NULL will cause the layer to get a texture from its compositor. |
| 81 void SetTexture(ui::Texture* texture); | 85 void SetTexture(ui::Texture* texture); |
| 82 const ui::Texture* texture() const { return texture_.get(); } | 86 const ui::Texture* texture() const { return texture_.get(); } |
| 83 | 87 |
| 84 // Resets the canvas of the texture. | 88 // Resets the canvas of the texture. |
| 85 void SetCanvas(const SkCanvas& canvas, const gfx::Point& origin); | 89 void SetCanvas(const SkCanvas& canvas, const gfx::Point& origin); |
| 86 | 90 |
| 87 // Adds |invalid_rect| to the Layer's pending invalid rect, and schedules a | 91 // Adds |invalid_rect| to the Layer's pending invalid rect, and schedules a |
| 88 // repaint if the Layer has an associated LayerDelegate that can handle the | 92 // repaint if the Layer has an associated LayerDelegate that can handle the |
| 89 // repaint. | 93 // repaint. |
| 90 void SchedulePaint(const gfx::Rect& invalid_rect); | 94 void SchedulePaint(const gfx::Rect& invalid_rect); |
| 91 | 95 |
| 92 // Draws the layer with hole if hole is non empty. | 96 // Draws the layer with hole if hole is non empty. |
| 93 // hole looks like: | 97 // hole looks like: |
| 94 // | 98 // |
| 95 // layer____________________________ | 99 // layer____________________________ |
| 96 // |xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| | 100 // |xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| |
| 97 // |xxxxxxxxxxxxx top xxxxxxxxxxxxxx| | 101 // |xxxxxxxxxxxxx top xxxxxxxxxxxxxx| |
| 98 // |________________________________| | 102 // |________________________________| |
| 99 // |xxxxx| |xxxxx| | 103 // |xxxxx| |xxxxx| |
| 100 // |xxxxx| Hole Rect |xxxxx| | 104 // |xxxxx| Hole Rect |xxxxx| |
| 101 // |left | (not composited) |right| | 105 // |left | (not composited) |right| |
| 102 // |_____|____________________|_____| | 106 // |_____|____________________|_____| |
| 103 // |xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| | 107 // |xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx| |
| 104 // |xxxxxxxxxx bottom xxxxxxxxxxxxxx| | 108 // |xxxxxxxxxx bottom xxxxxxxxxxxxxx| |
| 105 // |________________________________| | 109 // |________________________________| |
| 106 // | 110 // |
| 107 // Legend: | 111 // Legend: |
| 108 // composited area: x | 112 // composited area: x |
| 109 void Draw(); | 113 void Draw(); |
| 110 | 114 |
| 115 // Draws a tree of Layers, by calling Draw() on each in the hierarchy starting |
| 116 // with the receiver. |
| 117 void DrawTree(); |
| 118 |
| 111 private: | 119 private: |
| 112 // calls Texture::Draw only if the region to be drawn is non empty | 120 // calls Texture::Draw only if the region to be drawn is non empty |
| 113 void DrawRegion(const ui::TextureDrawParams& params, | 121 void DrawRegion(const ui::TextureDrawParams& params, |
| 114 const gfx::Rect& region_to_draw); | 122 const gfx::Rect& region_to_draw); |
| 115 | 123 |
| 116 // Called during the Draw() pass to freshen the Layer's contents from the | 124 // Called during the Draw() pass to freshen the Layer's contents from the |
| 117 // delegate. | 125 // delegate. |
| 118 void UpdateLayerCanvas(); | 126 void UpdateLayerCanvas(); |
| 119 | 127 |
| 120 // A hole in a layer is an area in the layer that does not get drawn | 128 // A hole in a layer is an area in the layer that does not get drawn |
| (...skipping 16 matching lines...) Expand all Loading... |
| 137 scoped_refptr<ui::Texture> texture_; | 145 scoped_refptr<ui::Texture> texture_; |
| 138 | 146 |
| 139 Layer* parent_; | 147 Layer* parent_; |
| 140 | 148 |
| 141 std::vector<Layer*> children_; | 149 std::vector<Layer*> children_; |
| 142 | 150 |
| 143 ui::Transform transform_; | 151 ui::Transform transform_; |
| 144 | 152 |
| 145 gfx::Rect bounds_; | 153 gfx::Rect bounds_; |
| 146 | 154 |
| 155 bool visible_; |
| 156 |
| 147 bool fills_bounds_opaquely_; | 157 bool fills_bounds_opaquely_; |
| 148 | 158 |
| 149 gfx::Rect hole_rect_; | 159 gfx::Rect hole_rect_; |
| 150 | 160 |
| 151 gfx::Rect invalid_rect_; | 161 gfx::Rect invalid_rect_; |
| 152 | 162 |
| 153 LayerDelegate* delegate_; | 163 LayerDelegate* delegate_; |
| 154 | 164 |
| 155 DISALLOW_COPY_AND_ASSIGN(Layer); | 165 DISALLOW_COPY_AND_ASSIGN(Layer); |
| 156 }; | 166 }; |
| 157 | 167 |
| 158 } // namespace ui | 168 } // namespace ui |
| 159 | 169 |
| 160 #endif // UI_GFX_COMPOSITOR_LAYER_H_ | 170 #endif // UI_GFX_COMPOSITOR_LAYER_H_ |
| OLD | NEW |