| 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 has no onscreen representation (note that its children will |
| 46 LAYER_HAS_TEXTURE = 1 | 47 // still be drawn, though). |
| 48 LAYER_NOT_DRAWN = 0, |
| 49 |
| 50 // A layer that has a texture. |
| 51 LAYER_TEXTURED = 1, |
| 52 |
| 53 // A layer that's drawn as a single color. |
| 54 LAYER_SOLID_COLOR = 2, |
| 47 }; | 55 }; |
| 48 | 56 |
| 49 Layer(); | 57 Layer(); |
| 50 explicit Layer(LayerType type); | 58 explicit Layer(LayerType type); |
| 51 virtual ~Layer(); | 59 virtual ~Layer(); |
| 52 | 60 |
| 53 // Retrieves the Layer's compositor. The Layer will walk up its parent chain | 61 // 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. | 62 // to locate it. Returns NULL if the Layer is not attached to a compositor. |
| 55 Compositor* GetCompositor(); | 63 Compositor* GetCompositor(); |
| 56 | 64 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 void set_name(const std::string& name) { name_ = name; } | 164 void set_name(const std::string& name) { name_ = name; } |
| 157 | 165 |
| 158 const ui::Texture* texture() const { return texture_.get(); } | 166 const ui::Texture* texture() const { return texture_.get(); } |
| 159 | 167 |
| 160 // Assigns a new external texture. |texture| can be NULL to disable external | 168 // Assigns a new external texture. |texture| can be NULL to disable external |
| 161 // updates. | 169 // updates. |
| 162 // TODO(beng): This can be removed from the API when we are in a | 170 // TODO(beng): This can be removed from the API when we are in a |
| 163 // single-compositor world. | 171 // single-compositor world. |
| 164 void SetExternalTexture(ui::Texture* texture); | 172 void SetExternalTexture(ui::Texture* texture); |
| 165 | 173 |
| 166 // Resets the canvas of the texture. | 174 // Resets the canvas of the texture. May only be called for LAYER_TEXTURED. |
| 167 void SetCanvas(const SkCanvas& canvas, const gfx::Point& origin); | 175 void SetCanvas(const SkCanvas& canvas, const gfx::Point& origin); |
| 168 | 176 |
| 177 // Sets the layer's fill color. May only be called for LAYER_SOLID_COLOR. |
| 178 void SetColor(SkColor color); |
| 179 |
| 169 // Adds |invalid_rect| to the Layer's pending invalid rect and calls | 180 // Adds |invalid_rect| to the Layer's pending invalid rect and calls |
| 170 // ScheduleDraw(). | 181 // ScheduleDraw(). |
| 171 void SchedulePaint(const gfx::Rect& invalid_rect); | 182 void SchedulePaint(const gfx::Rect& invalid_rect); |
| 172 | 183 |
| 173 // Schedules a redraw of the layer tree at the compositor. | 184 // Schedules a redraw of the layer tree at the compositor. |
| 174 void ScheduleDraw(); | 185 void ScheduleDraw(); |
| 175 | 186 |
| 176 // Sometimes the Layer is being updated by something other than SetCanvas | 187 // Sometimes the Layer is being updated by something other than SetCanvas |
| 177 // (e.g. the GPU process on UI_COMPOSITOR_IMAGE_TRANSPORT). | 188 // (e.g. the GPU process on UI_COMPOSITOR_IMAGE_TRANSPORT). |
| 178 bool layer_updated_externally() const { return layer_updated_externally_; } | 189 bool layer_updated_externally() const { return layer_updated_externally_; } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 WebKit::WebLayer web_layer_; | 281 WebKit::WebLayer web_layer_; |
| 271 bool web_layer_is_accelerated_; | 282 bool web_layer_is_accelerated_; |
| 272 bool show_debug_borders_; | 283 bool show_debug_borders_; |
| 273 | 284 |
| 274 DISALLOW_COPY_AND_ASSIGN(Layer); | 285 DISALLOW_COPY_AND_ASSIGN(Layer); |
| 275 }; | 286 }; |
| 276 | 287 |
| 277 } // namespace ui | 288 } // namespace ui |
| 278 | 289 |
| 279 #endif // UI_GFX_COMPOSITOR_LAYER_H_ | 290 #endif // UI_GFX_COMPOSITOR_LAYER_H_ |
| OLD | NEW |