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_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> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 16 #include "third_party/skia/include/core/SkColor.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebContentLa
yerClient.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebContentLa
yerClient.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebLayer.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebLayer.h" |
18 #include "ui/gfx/rect.h" | 19 #include "ui/gfx/rect.h" |
19 #include "ui/gfx/transform.h" | 20 #include "ui/gfx/transform.h" |
20 #include "ui/gfx/compositor/compositor.h" | 21 #include "ui/gfx/compositor/compositor.h" |
21 #include "ui/gfx/compositor/layer_animation_delegate.h" | 22 #include "ui/gfx/compositor/layer_animation_delegate.h" |
22 #include "ui/gfx/compositor/layer_delegate.h" | 23 #include "ui/gfx/compositor/layer_delegate.h" |
23 | 24 |
24 class SkCanvas; | 25 class SkCanvas; |
25 | 26 |
26 namespace ui { | 27 namespace ui { |
27 | 28 |
28 class Compositor; | 29 class Compositor; |
29 class LayerAnimator; | 30 class LayerAnimator; |
30 class Texture; | 31 class Texture; |
31 | 32 |
32 // Layer manages a texture, transform and a set of child Layers. Any View that | 33 // Layer manages a texture, transform and a set of child Layers. Any View that |
33 // has enabled layers ends up creating a Layer to manage the texture. | 34 // has enabled layers ends up creating a Layer to manage the texture. |
34 // A Layer can also be created without a texture, in which case it renders | 35 // A Layer can also be created without a texture, in which case it renders |
35 // nothing and is simply used as a node in a hierarchy of layers. | 36 // nothing and is simply used as a node in a hierarchy of layers. |
36 // | 37 // |
37 // NOTE: unlike Views, each Layer does *not* own its children views. If you | 38 // NOTE: unlike Views, each Layer does *not* own its children views. If you |
38 // delete a Layer and it has children, the parent of each child layer is set to | 39 // delete a Layer and it has children, the parent of each child layer is set to |
39 // NULL, but the children are not deleted. | 40 // NULL, but the children are not deleted. |
40 class COMPOSITOR_EXPORT Layer : | 41 class COMPOSITOR_EXPORT Layer : |
41 public LayerAnimationDelegate, | 42 public LayerAnimationDelegate, |
42 NON_EXPORTED_BASE(public WebKit::WebContentLayerClient) { | 43 NON_EXPORTED_BASE(public WebKit::WebContentLayerClient) { |
43 public: | 44 public: |
44 enum LayerType { | 45 enum LayerType { |
45 LAYER_HAS_NO_TEXTURE = 0, | 46 // A layer that is never drawn onscreen. |
46 LAYER_HAS_TEXTURE = 1 | 47 LAYER_NOT_DRAWN = 0, |
| 48 |
| 49 // A layer that has a texture. |
| 50 LAYER_TEXTURED = 1, |
| 51 |
| 52 // A layer that's drawn as a single color. |
| 53 LAYER_SOLID_COLOR = 2, |
47 }; | 54 }; |
48 | 55 |
49 Layer(); | 56 Layer(); |
50 explicit Layer(LayerType type); | 57 explicit Layer(LayerType type); |
51 virtual ~Layer(); | 58 virtual ~Layer(); |
52 | 59 |
53 // Retrieves the Layer's compositor. The Layer will walk up its parent chain | 60 // Retrieves the Layer's compositor. The Layer will walk up its parent chain |
54 // to locate it. Returns NULL if the Layer is not attached to a compositor. | 61 // to locate it. Returns NULL if the Layer is not attached to a compositor. |
55 Compositor* GetCompositor(); | 62 Compositor* GetCompositor(); |
56 | 63 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 void set_name(const std::string& name) { name_ = name; } | 169 void set_name(const std::string& name) { name_ = name; } |
163 | 170 |
164 const ui::Texture* texture() const { return texture_.get(); } | 171 const ui::Texture* texture() const { return texture_.get(); } |
165 | 172 |
166 // Assigns a new external texture. |texture| can be NULL to disable external | 173 // Assigns a new external texture. |texture| can be NULL to disable external |
167 // updates. | 174 // updates. |
168 // TODO(beng): This can be removed from the API when we are in a | 175 // TODO(beng): This can be removed from the API when we are in a |
169 // single-compositor world. | 176 // single-compositor world. |
170 void SetExternalTexture(ui::Texture* texture); | 177 void SetExternalTexture(ui::Texture* texture); |
171 | 178 |
172 // Resets the canvas of the texture. | 179 // Resets the canvas of the texture. May only be called for LAYER_TEXTURED. |
173 void SetCanvas(const SkCanvas& canvas, const gfx::Point& origin); | 180 void SetCanvas(const SkCanvas& canvas, const gfx::Point& origin); |
174 | 181 |
| 182 // Sets the layer's fill color. May only be called for LAYER_SOLID_COLOR. |
| 183 void SetColor(SkColor color); |
| 184 |
175 // Adds |invalid_rect| to the Layer's pending invalid rect and calls | 185 // Adds |invalid_rect| to the Layer's pending invalid rect and calls |
176 // ScheduleDraw(). | 186 // ScheduleDraw(). |
177 void SchedulePaint(const gfx::Rect& invalid_rect); | 187 void SchedulePaint(const gfx::Rect& invalid_rect); |
178 | 188 |
179 // Schedules a redraw of the layer tree at the compositor. | 189 // Schedules a redraw of the layer tree at the compositor. |
180 void ScheduleDraw(); | 190 void ScheduleDraw(); |
181 | 191 |
182 // Does drawing for the layer. | 192 // Does drawing for the layer. |
183 void Draw(); | 193 void Draw(); |
184 | 194 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 bool web_layer_is_accelerated_; | 355 bool web_layer_is_accelerated_; |
346 bool show_debug_borders_; | 356 bool show_debug_borders_; |
347 #endif | 357 #endif |
348 | 358 |
349 DISALLOW_COPY_AND_ASSIGN(Layer); | 359 DISALLOW_COPY_AND_ASSIGN(Layer); |
350 }; | 360 }; |
351 | 361 |
352 } // namespace ui | 362 } // namespace ui |
353 | 363 |
354 #endif // UI_GFX_COMPOSITOR_LAYER_H_ | 364 #endif // UI_GFX_COMPOSITOR_LAYER_H_ |
OLD | NEW |