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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebContentLayerClie
nt.h" | 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebContentLayerClie
nt.h" |
| 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebExternalTextureL
ayerClient.h" |
16 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h" | 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h" |
17 #include "third_party/skia/include/core/SkColor.h" | 18 #include "third_party/skia/include/core/SkColor.h" |
18 #include "third_party/skia/include/core/SkRegion.h" | 19 #include "third_party/skia/include/core/SkRegion.h" |
19 #include "ui/compositor/compositor.h" | 20 #include "ui/compositor/compositor.h" |
20 #include "ui/compositor/layer_animation_delegate.h" | 21 #include "ui/compositor/layer_animation_delegate.h" |
21 #include "ui/compositor/layer_delegate.h" | 22 #include "ui/compositor/layer_delegate.h" |
22 #include "ui/compositor/layer_type.h" | 23 #include "ui/compositor/layer_type.h" |
23 #include "ui/gfx/rect.h" | 24 #include "ui/gfx/rect.h" |
24 #include "ui/gfx/transform.h" | 25 #include "ui/gfx/transform.h" |
25 | 26 |
26 class SkCanvas; | 27 class SkCanvas; |
27 | 28 |
28 namespace ui { | 29 namespace ui { |
29 | 30 |
30 class Compositor; | 31 class Compositor; |
31 class LayerAnimator; | 32 class LayerAnimator; |
32 class Texture; | 33 class Texture; |
33 | 34 |
34 // Layer manages a texture, transform and a set of child Layers. Any View that | 35 // Layer manages a texture, transform and a set of child Layers. Any View that |
35 // has enabled layers ends up creating a Layer to manage the texture. | 36 // has enabled layers ends up creating a Layer to manage the texture. |
36 // A Layer can also be created without a texture, in which case it renders | 37 // A Layer can also be created without a texture, in which case it renders |
37 // nothing and is simply used as a node in a hierarchy of layers. | 38 // nothing and is simply used as a node in a hierarchy of layers. |
38 // Coordinate system used in layers is DIP (Density Independent Pixel) | 39 // Coordinate system used in layers is DIP (Density Independent Pixel) |
39 // coordinates unless explicitly mentioned as pixel coordinates. | 40 // coordinates unless explicitly mentioned as pixel coordinates. |
40 // | 41 // |
41 // NOTE: unlike Views, each Layer does *not* own its children views. If you | 42 // NOTE: unlike Views, each Layer does *not* own its children views. If you |
42 // delete a Layer and it has children, the parent of each child layer is set to | 43 // delete a Layer and it has children, the parent of each child layer is set to |
43 // NULL, but the children are not deleted. | 44 // NULL, but the children are not deleted. |
44 class COMPOSITOR_EXPORT Layer : | 45 class COMPOSITOR_EXPORT Layer |
45 public LayerAnimationDelegate, | 46 : public LayerAnimationDelegate, |
46 NON_EXPORTED_BASE(public WebKit::WebContentLayerClient) { | 47 NON_EXPORTED_BASE(public WebKit::WebContentLayerClient), |
| 48 NON_EXPORTED_BASE(public WebKit::WebExternalTextureLayerClient) { |
47 public: | 49 public: |
48 Layer(); | 50 Layer(); |
49 explicit Layer(LayerType type); | 51 explicit Layer(LayerType type); |
50 virtual ~Layer(); | 52 virtual ~Layer(); |
51 | 53 |
52 // Retrieves the Layer's compositor. The Layer will walk up its parent chain | 54 // Retrieves the Layer's compositor. The Layer will walk up its parent chain |
53 // to locate it. Returns NULL if the Layer is not attached to a compositor. | 55 // to locate it. Returns NULL if the Layer is not attached to a compositor. |
54 Compositor* GetCompositor(); | 56 Compositor* GetCompositor(); |
55 | 57 |
56 // Called by the compositor when the Layer is set as its root Layer. This can | 58 // Called by the compositor when the Layer is set as its root Layer. This can |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 virtual void paintContents(WebKit::WebCanvas*, | 231 virtual void paintContents(WebKit::WebCanvas*, |
230 const WebKit::WebRect& clip, | 232 const WebKit::WebRect& clip, |
231 #if defined(WEBCONTENTLAYERCLIENT_FLOAT_OPAQUE_RECT) | 233 #if defined(WEBCONTENTLAYERCLIENT_FLOAT_OPAQUE_RECT) |
232 WebKit::WebFloatRect& opaque); | 234 WebKit::WebFloatRect& opaque); |
233 #else | 235 #else |
234 WebKit::WebRect& opaque); | 236 WebKit::WebRect& opaque); |
235 #endif | 237 #endif |
236 | 238 |
237 WebKit::WebLayer web_layer() { return web_layer_; } | 239 WebKit::WebLayer web_layer() { return web_layer_; } |
238 | 240 |
| 241 // WebExternalTextureLayerClient |
| 242 virtual unsigned prepareTexture( |
| 243 WebKit::WebTextureUpdater& /* updater */) OVERRIDE; |
| 244 virtual WebKit::WebGraphicsContext3D* context() OVERRIDE; |
| 245 |
239 float device_scale_factor() const { return device_scale_factor_; } | 246 float device_scale_factor() const { return device_scale_factor_; } |
240 | 247 |
241 // Forces a render surface to be used on this layer. This has no positive | 248 // Forces a render surface to be used on this layer. This has no positive |
242 // impact, and is only used for benchmarking/testing purpose. | 249 // impact, and is only used for benchmarking/testing purpose. |
243 void SetForceRenderSurface(bool force); | 250 void SetForceRenderSurface(bool force); |
244 bool force_render_surface() const { return force_render_surface_; } | 251 bool force_render_surface() const { return force_render_surface_; } |
245 | 252 |
246 private: | 253 private: |
247 // TODO(vollick): Eventually, if a non-leaf node has an opacity of less than | 254 // TODO(vollick): Eventually, if a non-leaf node has an opacity of less than |
248 // 1.0, we'll render to a separate texture, and then apply the alpha. | 255 // 1.0, we'll render to a separate texture, and then apply the alpha. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 352 |
346 // A cached copy of |Compositor::device_scale_factor()|. | 353 // A cached copy of |Compositor::device_scale_factor()|. |
347 float device_scale_factor_; | 354 float device_scale_factor_; |
348 | 355 |
349 DISALLOW_COPY_AND_ASSIGN(Layer); | 356 DISALLOW_COPY_AND_ASSIGN(Layer); |
350 }; | 357 }; |
351 | 358 |
352 } // namespace ui | 359 } // namespace ui |
353 | 360 |
354 #endif // UI_COMPOSITOR_LAYER_H_ | 361 #endif // UI_COMPOSITOR_LAYER_H_ |
OLD | NEW |