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_PAINTED_SCROLLBAR_LAYER_H_ | 5 #ifndef CC_LAYERS_PAINTED_SCROLLBAR_LAYER_H_ |
6 #define CC_LAYERS_PAINTED_SCROLLBAR_LAYER_H_ | 6 #define CC_LAYERS_PAINTED_SCROLLBAR_LAYER_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "cc/base/cc_export.h" | 9 #include "cc/base/cc_export.h" |
10 #include "cc/input/scrollbar.h" | 10 #include "cc/input/scrollbar.h" |
11 #include "cc/layers/layer.h" | 11 #include "cc/layers/layer.h" |
12 #include "cc/layers/scrollbar_layer_interface.h" | 12 #include "cc/layers/scrollbar_layer_interface.h" |
13 #include "cc/layers/scrollbar_theme_painter.h" | 13 #include "cc/layers/scrollbar_theme_painter.h" |
14 #include "cc/resources/scoped_ui_resource.h" | 14 #include "cc/resources/scoped_ui_resource.h" |
15 | 15 |
16 namespace cc { | 16 namespace cc { |
17 class ScrollbarThemeComposite; | 17 class ScrollbarThemeComposite; |
18 | 18 |
19 class CC_EXPORT PaintedScrollbarLayer : public ScrollbarLayerInterface, | 19 class CC_EXPORT PaintedScrollbarLayer : public ScrollbarLayerInterface, |
20 public Layer { | 20 public Layer { |
21 public: | 21 public: |
22 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; | 22 std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; |
23 | 23 |
24 static scoped_refptr<PaintedScrollbarLayer> Create( | 24 static scoped_refptr<PaintedScrollbarLayer> Create( |
25 scoped_ptr<Scrollbar> scrollbar, | 25 std::unique_ptr<Scrollbar> scrollbar, |
26 int scroll_layer_id); | 26 int scroll_layer_id); |
27 | 27 |
28 bool OpacityCanAnimateOnImplThread() const override; | 28 bool OpacityCanAnimateOnImplThread() const override; |
29 ScrollbarLayerInterface* ToScrollbarLayer() override; | 29 ScrollbarLayerInterface* ToScrollbarLayer() override; |
30 | 30 |
31 // ScrollbarLayerInterface | 31 // ScrollbarLayerInterface |
32 int ScrollLayerId() const override; | 32 int ScrollLayerId() const override; |
33 void SetScrollLayer(int layer_id) override; | 33 void SetScrollLayer(int layer_id) override; |
34 | 34 |
35 ScrollbarOrientation orientation() const override; | 35 ScrollbarOrientation orientation() const override; |
36 | 36 |
37 // Layer interface | 37 // Layer interface |
38 bool Update() override; | 38 bool Update() override; |
39 void SetLayerTreeHost(LayerTreeHost* host) override; | 39 void SetLayerTreeHost(LayerTreeHost* host) override; |
40 void PushPropertiesTo(LayerImpl* layer) override; | 40 void PushPropertiesTo(LayerImpl* layer) override; |
41 | 41 |
42 const gfx::Size& internal_content_bounds() const { | 42 const gfx::Size& internal_content_bounds() const { |
43 return internal_content_bounds_; | 43 return internal_content_bounds_; |
44 } | 44 } |
45 | 45 |
46 protected: | 46 protected: |
47 PaintedScrollbarLayer(scoped_ptr<Scrollbar> scrollbar, int scroll_layer_id); | 47 PaintedScrollbarLayer(std::unique_ptr<Scrollbar> scrollbar, |
| 48 int scroll_layer_id); |
48 ~PaintedScrollbarLayer() override; | 49 ~PaintedScrollbarLayer() override; |
49 | 50 |
50 // For unit tests | 51 // For unit tests |
51 UIResourceId track_resource_id() { | 52 UIResourceId track_resource_id() { |
52 return track_resource_.get() ? track_resource_->id() : 0; | 53 return track_resource_.get() ? track_resource_->id() : 0; |
53 } | 54 } |
54 UIResourceId thumb_resource_id() { | 55 UIResourceId thumb_resource_id() { |
55 return thumb_resource_.get() ? thumb_resource_->id() : 0; | 56 return thumb_resource_.get() ? thumb_resource_->id() : 0; |
56 } | 57 } |
57 void UpdateInternalContentScale(); | 58 void UpdateInternalContentScale(); |
(...skipping 12 matching lines...) Expand all Loading... |
70 return true; | 71 return true; |
71 } | 72 } |
72 | 73 |
73 int MaxTextureSize(); | 74 int MaxTextureSize(); |
74 float ClampScaleToMaxTextureSize(float scale); | 75 float ClampScaleToMaxTextureSize(float scale); |
75 | 76 |
76 UIResourceBitmap RasterizeScrollbarPart(const gfx::Rect& layer_rect, | 77 UIResourceBitmap RasterizeScrollbarPart(const gfx::Rect& layer_rect, |
77 const gfx::Rect& content_rect, | 78 const gfx::Rect& content_rect, |
78 ScrollbarPart part); | 79 ScrollbarPart part); |
79 | 80 |
80 scoped_ptr<Scrollbar> scrollbar_; | 81 std::unique_ptr<Scrollbar> scrollbar_; |
81 int scroll_layer_id_; | 82 int scroll_layer_id_; |
82 | 83 |
83 float internal_contents_scale_; | 84 float internal_contents_scale_; |
84 gfx::Size internal_content_bounds_; | 85 gfx::Size internal_content_bounds_; |
85 | 86 |
86 // Snapshot of properties taken in UpdateThumbAndTrackGeometry and used in | 87 // Snapshot of properties taken in UpdateThumbAndTrackGeometry and used in |
87 // PushPropertiesTo. | 88 // PushPropertiesTo. |
88 int thumb_thickness_; | 89 int thumb_thickness_; |
89 int thumb_length_; | 90 int thumb_length_; |
90 gfx::Point location_; | 91 gfx::Point location_; |
91 gfx::Rect track_rect_; | 92 gfx::Rect track_rect_; |
92 bool is_overlay_; | 93 bool is_overlay_; |
93 bool has_thumb_; | 94 bool has_thumb_; |
94 | 95 |
95 scoped_ptr<ScopedUIResource> track_resource_; | 96 std::unique_ptr<ScopedUIResource> track_resource_; |
96 scoped_ptr<ScopedUIResource> thumb_resource_; | 97 std::unique_ptr<ScopedUIResource> thumb_resource_; |
97 | 98 |
98 float thumb_opacity_; | 99 float thumb_opacity_; |
99 | 100 |
100 DISALLOW_COPY_AND_ASSIGN(PaintedScrollbarLayer); | 101 DISALLOW_COPY_AND_ASSIGN(PaintedScrollbarLayer); |
101 }; | 102 }; |
102 | 103 |
103 } // namespace cc | 104 } // namespace cc |
104 | 105 |
105 #endif // CC_LAYERS_PAINTED_SCROLLBAR_LAYER_H_ | 106 #endif // CC_LAYERS_PAINTED_SCROLLBAR_LAYER_H_ |
OLD | NEW |