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/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "cc/base/cc_export.h" | 9 #include "cc/base/cc_export.h" |
10 #include "cc/layers/layer.h" | 10 #include "cc/layers/contents_scaling_layer.h" |
11 #include "cc/resources/ui_resource_client.h" | 11 #include "cc/resources/ui_resource_client.h" |
12 #include "ui/gfx/rect.h" | 12 #include "ui/gfx/rect.h" |
13 | 13 |
14 namespace cc { | 14 namespace cc { |
15 | 15 |
16 class LayerTreeHost; | 16 class LayerTreeHost; |
17 class ScopedUIResource; | 17 class ScopedUIResource; |
18 | 18 |
19 class CC_EXPORT UIResourceLayer : public Layer { | 19 class CC_EXPORT UIResourceLayer : public ContentsScalingLayer { |
20 public: | 20 public: |
21 static scoped_refptr<UIResourceLayer> Create(); | 21 static scoped_refptr<UIResourceLayer> Create(); |
22 | 22 |
23 virtual bool DrawsContent() const OVERRIDE; | 23 virtual bool DrawsContent() const OVERRIDE; |
24 | 24 |
25 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; | 25 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; |
26 | 26 |
27 virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE; | 27 virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE; |
28 | 28 |
29 void SetBitmap(const SkBitmap& skbitmap); | 29 void SetBitmap(const SkBitmap& skbitmap); |
30 | 30 |
31 // An alternative way of setting the resource to allow for sharing. | 31 // An alternative way of setting the resource to allow for sharing. |
32 void SetUIResourceId(UIResourceId resource_id); | 32 void SetUIResourceId(UIResourceId resource_id); |
33 | 33 |
34 // Sets a UV transform to be used at draw time. Defaults to (0, 0) and (1, 1). | 34 // Sets a UV transform to be used at draw time. Defaults to (0, 0) and (1, 1). |
35 void SetUV(gfx::PointF top_left, gfx::PointF bottom_right); | 35 void SetUV(gfx::PointF top_left, gfx::PointF bottom_right); |
36 | 36 |
37 // Sets an opacity value per vertex. It will be multiplied by the layer | 37 // Sets an opacity value per vertex. It will be multiplied by the layer |
38 // opacity value. | 38 // opacity value. |
39 void SetVertexOpacity(float bottom_left, | 39 void SetVertexOpacity(float bottom_left, |
40 float top_left, | 40 float top_left, |
41 float top_right, | 41 float top_right, |
42 float bottom_right); | 42 float bottom_right); |
43 | 43 |
| 44 virtual void CalculateContentsScale(float ideal_contents_scale, |
| 45 float device_scale_factor, |
| 46 float page_scale_factor, |
| 47 bool animating_transform_to_screen, |
| 48 float* contents_scale_x, |
| 49 float* contents_scale_y, |
| 50 gfx::Size* content_bounds) OVERRIDE; |
| 51 |
44 class UIResourceHolder { | 52 class UIResourceHolder { |
45 public: | 53 public: |
46 virtual UIResourceId id() = 0; | 54 virtual UIResourceId id() = 0; |
47 virtual ~UIResourceHolder(); | 55 virtual ~UIResourceHolder(); |
48 }; | 56 }; |
49 | 57 |
50 protected: | 58 protected: |
51 UIResourceLayer(); | 59 UIResourceLayer(); |
52 virtual ~UIResourceLayer(); | 60 virtual ~UIResourceLayer(); |
53 | 61 |
54 scoped_ptr<UIResourceHolder> ui_resource_holder_; | 62 scoped_ptr<UIResourceHolder> ui_resource_holder_; |
55 SkBitmap bitmap_; | 63 SkBitmap bitmap_; |
56 | 64 |
57 gfx::PointF uv_top_left_; | 65 gfx::PointF uv_top_left_; |
58 gfx::PointF uv_bottom_right_; | 66 gfx::PointF uv_bottom_right_; |
59 float vertex_opacity_[4]; | 67 float vertex_opacity_[4]; |
60 | 68 |
61 private: | 69 private: |
62 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) | 70 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) |
63 OVERRIDE; | 71 OVERRIDE; |
64 void RecreateUIResourceHolder(); | 72 void RecreateUIResourceHolder(); |
65 | 73 |
66 | |
67 | |
68 DISALLOW_COPY_AND_ASSIGN(UIResourceLayer); | 74 DISALLOW_COPY_AND_ASSIGN(UIResourceLayer); |
69 }; | 75 }; |
70 | 76 |
71 } // namespace cc | 77 } // namespace cc |
72 | 78 |
73 #endif // CC_LAYERS_UI_RESOURCE_LAYER_H_ | 79 #endif // CC_LAYERS_UI_RESOURCE_LAYER_H_ |
OLD | NEW |