OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CC_LAYERS_UI_RESOURCE_LAYER_H_ | 5 #ifndef CC_LAYERS_UI_RESOURCE_LAYER_H_ |
6 #define CC_LAYERS_UI_RESOURCE_LAYER_H_ | 6 #define CC_LAYERS_UI_RESOURCE_LAYER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "cc/base/cc_export.h" | 10 #include "cc/base/cc_export.h" |
11 #include "cc/layers/layer.h" | 11 #include "cc/layers/layer.h" |
12 #include "cc/resources/ui_resource_client.h" | 12 #include "cc/resources/ui_resource_client.h" |
13 #include "ui/gfx/geometry/rect.h" | 13 #include "ui/gfx/geometry/rect.h" |
14 | 14 |
15 namespace cc { | 15 namespace cc { |
16 | 16 |
17 class LayerTreeHost; | 17 class LayerTreeHost; |
18 class ScopedUIResource; | 18 class ScopedUIResource; |
19 | 19 |
20 class CC_EXPORT UIResourceLayer : public Layer { | 20 class CC_EXPORT UIResourceLayer : public Layer { |
21 public: | 21 public: |
22 static scoped_refptr<UIResourceLayer> Create(const LayerSettings& settings); | 22 static scoped_refptr<UIResourceLayer> Create(); |
23 | 23 |
24 void PushPropertiesTo(LayerImpl* layer) override; | 24 void PushPropertiesTo(LayerImpl* layer) override; |
25 | 25 |
26 void SetLayerTreeHost(LayerTreeHost* host) override; | 26 void SetLayerTreeHost(LayerTreeHost* host) override; |
27 | 27 |
28 void SetBitmap(const SkBitmap& skbitmap); | 28 void SetBitmap(const SkBitmap& skbitmap); |
29 | 29 |
30 // An alternative way of setting the resource to allow for sharing. If you use | 30 // An alternative way of setting the resource to allow for sharing. If you use |
31 // this method, you are responsible for updating the ID if the layer moves | 31 // this method, you are responsible for updating the ID if the layer moves |
32 // between compositors. | 32 // between compositors. |
33 void SetUIResourceId(UIResourceId resource_id); | 33 void SetUIResourceId(UIResourceId resource_id); |
34 | 34 |
35 // Sets a UV transform to be used at draw time. Defaults to (0, 0) and (1, 1). | 35 // Sets a UV transform to be used at draw time. Defaults to (0, 0) and (1, 1). |
36 void SetUV(const gfx::PointF& top_left, const gfx::PointF& bottom_right); | 36 void SetUV(const gfx::PointF& top_left, const gfx::PointF& bottom_right); |
37 | 37 |
38 // Sets an opacity value per vertex. It will be multiplied by the layer | 38 // Sets an opacity value per vertex. It will be multiplied by the layer |
39 // opacity value. | 39 // opacity value. |
40 void SetVertexOpacity(float bottom_left, | 40 void SetVertexOpacity(float bottom_left, |
41 float top_left, | 41 float top_left, |
42 float top_right, | 42 float top_right, |
43 float bottom_right); | 43 float bottom_right); |
44 | 44 |
45 class UIResourceHolder { | 45 class UIResourceHolder { |
46 public: | 46 public: |
47 virtual UIResourceId id() = 0; | 47 virtual UIResourceId id() = 0; |
48 virtual ~UIResourceHolder(); | 48 virtual ~UIResourceHolder(); |
49 }; | 49 }; |
50 | 50 |
51 protected: | 51 protected: |
52 explicit UIResourceLayer(const LayerSettings& settings); | 52 UIResourceLayer(); |
53 ~UIResourceLayer() override; | 53 ~UIResourceLayer() override; |
54 | 54 |
55 bool HasDrawableContent() const override; | 55 bool HasDrawableContent() const override; |
56 | 56 |
57 scoped_ptr<UIResourceHolder> ui_resource_holder_; | 57 scoped_ptr<UIResourceHolder> ui_resource_holder_; |
58 SkBitmap bitmap_; | 58 SkBitmap bitmap_; |
59 | 59 |
60 gfx::PointF uv_top_left_; | 60 gfx::PointF uv_top_left_; |
61 gfx::PointF uv_bottom_right_; | 61 gfx::PointF uv_bottom_right_; |
62 float vertex_opacity_[4]; | 62 float vertex_opacity_[4]; |
63 | 63 |
64 private: | 64 private: |
65 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; | 65 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; |
66 void RecreateUIResourceHolder(); | 66 void RecreateUIResourceHolder(); |
67 | 67 |
68 DISALLOW_COPY_AND_ASSIGN(UIResourceLayer); | 68 DISALLOW_COPY_AND_ASSIGN(UIResourceLayer); |
69 }; | 69 }; |
70 | 70 |
71 } // namespace cc | 71 } // namespace cc |
72 | 72 |
73 #endif // CC_LAYERS_UI_RESOURCE_LAYER_H_ | 73 #endif // CC_LAYERS_UI_RESOURCE_LAYER_H_ |
OLD | NEW |