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" | |
17 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h" | 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebLayer.h" |
18 #include "third_party/skia/include/core/SkColor.h" | 17 #include "third_party/skia/include/core/SkColor.h" |
19 #include "third_party/skia/include/core/SkRegion.h" | 18 #include "third_party/skia/include/core/SkRegion.h" |
20 #include "ui/compositor/compositor.h" | 19 #include "ui/compositor/compositor.h" |
21 #include "ui/compositor/layer_animation_delegate.h" | 20 #include "ui/compositor/layer_animation_delegate.h" |
22 #include "ui/compositor/layer_delegate.h" | 21 #include "ui/compositor/layer_delegate.h" |
23 #include "ui/compositor/layer_type.h" | 22 #include "ui/compositor/layer_type.h" |
24 #include "ui/gfx/rect.h" | 23 #include "ui/gfx/rect.h" |
25 #include "ui/gfx/transform.h" | 24 #include "ui/gfx/transform.h" |
26 | 25 |
(...skipping 10 matching lines...) Expand all Loading... |
37 // A Layer can also be created without a texture, in which case it renders | 36 // A Layer can also be created without a texture, in which case it renders |
38 // nothing and is simply used as a node in a hierarchy of layers. | 37 // nothing and is simply used as a node in a hierarchy of layers. |
39 // Coordinate system used in layers is DIP (Density Independent Pixel) | 38 // Coordinate system used in layers is DIP (Density Independent Pixel) |
40 // coordinates unless explicitly mentioned as pixel coordinates. | 39 // coordinates unless explicitly mentioned as pixel coordinates. |
41 // | 40 // |
42 // NOTE: unlike Views, each Layer does *not* own its children views. If you | 41 // NOTE: unlike Views, each Layer does *not* own its children views. If you |
43 // delete a Layer and it has children, the parent of each child layer is set to | 42 // delete a Layer and it has children, the parent of each child layer is set to |
44 // NULL, but the children are not deleted. | 43 // NULL, but the children are not deleted. |
45 class COMPOSITOR_EXPORT Layer | 44 class COMPOSITOR_EXPORT Layer |
46 : public LayerAnimationDelegate, | 45 : public LayerAnimationDelegate, |
47 NON_EXPORTED_BASE(public WebKit::WebContentLayerClient), | 46 NON_EXPORTED_BASE(public WebKit::WebContentLayerClient) { |
48 NON_EXPORTED_BASE(public WebKit::WebExternalTextureLayerClient) { | |
49 public: | 47 public: |
50 Layer(); | 48 Layer(); |
51 explicit Layer(LayerType type); | 49 explicit Layer(LayerType type); |
52 virtual ~Layer(); | 50 virtual ~Layer(); |
53 | 51 |
54 // Retrieves the Layer's compositor. The Layer will walk up its parent chain | 52 // Retrieves the Layer's compositor. The Layer will walk up its parent chain |
55 // to locate it. Returns NULL if the Layer is not attached to a compositor. | 53 // to locate it. Returns NULL if the Layer is not attached to a compositor. |
56 Compositor* GetCompositor(); | 54 Compositor* GetCompositor(); |
57 | 55 |
58 // Called by the compositor when the Layer is set as its root Layer. This can | 56 // Called by the compositor when the Layer is set as its root Layer. This can |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 virtual void paintContents(WebKit::WebCanvas*, | 253 virtual void paintContents(WebKit::WebCanvas*, |
256 const WebKit::WebRect& clip, | 254 const WebKit::WebRect& clip, |
257 #if defined(WEBCONTENTLAYERCLIENT_FLOAT_OPAQUE_RECT) | 255 #if defined(WEBCONTENTLAYERCLIENT_FLOAT_OPAQUE_RECT) |
258 WebKit::WebFloatRect& opaque); | 256 WebKit::WebFloatRect& opaque); |
259 #else | 257 #else |
260 WebKit::WebRect& opaque); | 258 WebKit::WebRect& opaque); |
261 #endif | 259 #endif |
262 | 260 |
263 WebKit::WebLayer web_layer() { return web_layer_; } | 261 WebKit::WebLayer web_layer() { return web_layer_; } |
264 | 262 |
265 // WebExternalTextureLayerClient | |
266 virtual unsigned prepareTexture( | |
267 WebKit::WebTextureUpdater& /* updater */) OVERRIDE; | |
268 virtual WebKit::WebGraphicsContext3D* context() OVERRIDE; | |
269 | |
270 float device_scale_factor() const { return device_scale_factor_; } | 263 float device_scale_factor() const { return device_scale_factor_; } |
271 | 264 |
272 // Forces a render surface to be used on this layer. This has no positive | 265 // Forces a render surface to be used on this layer. This has no positive |
273 // impact, and is only used for benchmarking/testing purpose. | 266 // impact, and is only used for benchmarking/testing purpose. |
274 void SetForceRenderSurface(bool force); | 267 void SetForceRenderSurface(bool force); |
275 bool force_render_surface() const { return force_render_surface_; } | 268 bool force_render_surface() const { return force_render_surface_; } |
276 | 269 |
277 private: | 270 private: |
278 // TODO(vollick): Eventually, if a non-leaf node has an opacity of less than | 271 // TODO(vollick): Eventually, if a non-leaf node has an opacity of less than |
279 // 1.0, we'll render to a separate texture, and then apply the alpha. | 272 // 1.0, we'll render to a separate texture, and then apply the alpha. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 | 383 |
391 // A cached copy of |Compositor::device_scale_factor()|. | 384 // A cached copy of |Compositor::device_scale_factor()|. |
392 float device_scale_factor_; | 385 float device_scale_factor_; |
393 | 386 |
394 DISALLOW_COPY_AND_ASSIGN(Layer); | 387 DISALLOW_COPY_AND_ASSIGN(Layer); |
395 }; | 388 }; |
396 | 389 |
397 } // namespace ui | 390 } // namespace ui |
398 | 391 |
399 #endif // UI_COMPOSITOR_LAYER_H_ | 392 #endif // UI_COMPOSITOR_LAYER_H_ |
OLD | NEW |