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 "cc/base/cc_export.h" | 8 #include "cc/base/cc_export.h" |
9 #include "cc/input/scrollbar.h" | 9 #include "cc/input/scrollbar.h" |
10 #include "cc/layers/contents_scaling_layer.h" | 10 #include "cc/layers/contents_scaling_layer.h" |
| 11 #include "cc/layers/scrollbar_layer_interface.h" |
11 #include "cc/layers/scrollbar_theme_painter.h" | 12 #include "cc/layers/scrollbar_theme_painter.h" |
12 #include "cc/resources/layer_updater.h" | 13 #include "cc/resources/layer_updater.h" |
13 #include "cc/resources/scoped_ui_resource.h" | 14 #include "cc/resources/scoped_ui_resource.h" |
14 | 15 |
15 namespace cc { | 16 namespace cc { |
16 class ScrollbarThemeComposite; | 17 class ScrollbarThemeComposite; |
17 | 18 |
18 class CC_EXPORT PaintedScrollbarLayer : public ContentsScalingLayer { | 19 class CC_EXPORT PaintedScrollbarLayer : public ScrollbarLayerInterface, |
| 20 public ContentsScalingLayer { |
19 public: | 21 public: |
20 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) | 22 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) |
21 OVERRIDE; | 23 OVERRIDE; |
22 | 24 |
23 static scoped_refptr<PaintedScrollbarLayer> Create( | 25 static scoped_refptr<PaintedScrollbarLayer> Create( |
24 scoped_ptr<Scrollbar> scrollbar, | 26 scoped_ptr<Scrollbar> scrollbar, |
25 int scroll_layer_id); | 27 int scroll_layer_id); |
26 | 28 |
27 int scroll_layer_id() const { return scroll_layer_id_; } | 29 virtual bool OpacityCanAnimateOnImplThread() const OVERRIDE; |
28 void SetScrollLayerId(int id); | 30 virtual ScrollbarLayerInterface* ToScrollbarLayer() OVERRIDE; |
29 | 31 |
30 virtual bool OpacityCanAnimateOnImplThread() const OVERRIDE; | 32 // ScrollbarLayerInterface |
| 33 virtual int ScrollLayerId() const OVERRIDE; |
| 34 virtual void SetScrollLayerId(int id) OVERRIDE; |
31 | 35 |
32 ScrollbarOrientation Orientation() const; | 36 virtual ScrollbarOrientation orientation() const OVERRIDE; |
33 | 37 |
34 // Layer interface | 38 // Layer interface |
35 virtual bool Update(ResourceUpdateQueue* queue, | 39 virtual bool Update(ResourceUpdateQueue* queue, |
36 const OcclusionTracker* occlusion) OVERRIDE; | 40 const OcclusionTracker* occlusion) OVERRIDE; |
37 virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE; | 41 virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE; |
38 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; | 42 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; |
39 virtual void CalculateContentsScale(float ideal_contents_scale, | 43 virtual void CalculateContentsScale(float ideal_contents_scale, |
40 float device_scale_factor, | 44 float device_scale_factor, |
41 float page_scale_factor, | 45 float page_scale_factor, |
42 bool animating_transform_to_screen, | 46 bool animating_transform_to_screen, |
43 float* contents_scale_x, | 47 float* contents_scale_x, |
44 float* contents_scale_y, | 48 float* contents_scale_y, |
45 gfx::Size* content_bounds) OVERRIDE; | 49 gfx::Size* content_bounds) OVERRIDE; |
46 | 50 |
47 virtual PaintedScrollbarLayer* ToScrollbarLayer() OVERRIDE; | |
48 | |
49 protected: | 51 protected: |
50 PaintedScrollbarLayer(scoped_ptr<Scrollbar> scrollbar, int scroll_layer_id); | 52 PaintedScrollbarLayer(scoped_ptr<Scrollbar> scrollbar, int scroll_layer_id); |
51 virtual ~PaintedScrollbarLayer(); | 53 virtual ~PaintedScrollbarLayer(); |
52 | 54 |
53 // For unit tests | 55 // For unit tests |
54 UIResourceId track_resource_id() { | 56 UIResourceId track_resource_id() { |
55 return track_resource_.get() ? track_resource_->id() : 0; | 57 return track_resource_.get() ? track_resource_->id() : 0; |
56 } | 58 } |
57 UIResourceId thumb_resource_id() { | 59 UIResourceId thumb_resource_id() { |
58 return thumb_resource_.get() ? thumb_resource_->id() : 0; | 60 return thumb_resource_.get() ? thumb_resource_->id() : 0; |
59 } | 61 } |
60 void UpdateThumbAndTrackGeometry(); | 62 void UpdateThumbAndTrackGeometry(); |
61 | 63 |
62 private: | 64 private: |
63 gfx::Rect ScrollbarLayerRectToContentRect(gfx::Rect layer_rect) const; | 65 gfx::Rect ScrollbarLayerRectToContentRect(gfx::Rect layer_rect) const; |
64 gfx::Rect OriginThumbRect() const; | 66 gfx::Rect OriginThumbRect() const; |
65 | 67 |
66 int MaxTextureSize(); | 68 int MaxTextureSize(); |
67 float ClampScaleToMaxTextureSize(float scale); | 69 float ClampScaleToMaxTextureSize(float scale); |
68 | 70 |
69 scoped_refptr<UIResourceBitmap> RasterizeScrollbarPart(gfx::Rect rect, | 71 scoped_refptr<UIResourceBitmap> RasterizeScrollbarPart(gfx::Rect rect, |
70 ScrollbarPart part); | 72 ScrollbarPart part); |
71 | 73 |
72 scoped_ptr<Scrollbar> scrollbar_; | 74 scoped_ptr<Scrollbar> scrollbar_; |
| 75 int scroll_layer_id_; |
73 | 76 |
74 // Snapshot of properties taken in UpdateThumbAndTrackGeometry and used in | 77 // Snapshot of properties taken in UpdateThumbAndTrackGeometry and used in |
75 // PushPropertiesTo. | 78 // PushPropertiesTo. |
76 int thumb_thickness_; | 79 int thumb_thickness_; |
77 int thumb_length_; | 80 int thumb_length_; |
78 gfx::Point location_; | 81 gfx::Point location_; |
79 gfx::Rect track_rect_; | 82 gfx::Rect track_rect_; |
80 | 83 |
81 int scroll_layer_id_; | |
82 | |
83 scoped_ptr<ScopedUIResource> track_resource_; | 84 scoped_ptr<ScopedUIResource> track_resource_; |
84 scoped_ptr<ScopedUIResource> thumb_resource_; | 85 scoped_ptr<ScopedUIResource> thumb_resource_; |
85 | 86 |
86 DISALLOW_COPY_AND_ASSIGN(PaintedScrollbarLayer); | 87 DISALLOW_COPY_AND_ASSIGN(PaintedScrollbarLayer); |
87 }; | 88 }; |
88 | 89 |
89 } // namespace cc | 90 } // namespace cc |
90 | 91 |
91 #endif // CC_LAYERS_PAINTED_SCROLLBAR_LAYER_H_ | 92 #endif // CC_LAYERS_PAINTED_SCROLLBAR_LAYER_H_ |
OLD | NEW |