OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 CC_LAYERS_SCROLLBAR_LAYER_H_ | 5 #ifndef CC_LAYERS_SCROLLBAR_LAYER_H_ |
6 #define CC_LAYERS_SCROLLBAR_LAYER_H_ | 6 #define CC_LAYERS_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_theme_painter.h" | 11 #include "cc/layers/scrollbar_theme_painter.h" |
12 #include "cc/resources/layer_updater.h" | 12 #include "cc/resources/layer_updater.h" |
13 | 13 |
14 namespace cc { | 14 namespace cc { |
15 class CachingBitmapContentLayerUpdater; | 15 class CachingBitmapContentLayerUpdater; |
16 class ResourceUpdateQueue; | 16 class ResourceUpdateQueue; |
17 class ScrollbarThemeComposite; | 17 class ScrollbarThemeComposite; |
18 | 18 |
19 class CC_EXPORT ScrollbarLayer : public ContentsScalingLayer { | 19 class CC_EXPORT ScrollbarLayer : public ContentsScalingLayer { |
20 public: | 20 public: |
21 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) | 21 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) |
22 OVERRIDE; | 22 OVERRIDE; |
23 | 23 |
24 static scoped_refptr<ScrollbarLayer> Create( | 24 static scoped_refptr<ScrollbarLayer> Create( |
25 scoped_ptr<Scrollbar> scrollbar, | 25 scoped_ptr<Scrollbar> scrollbar, |
26 int scroll_layer_id); | 26 int scroll_layer_id, |
27 bool is_solid_color); | |
jamesr
2013/07/03 21:26:24
this being a bool makes callsites really hard to r
| |
27 | 28 |
28 int scroll_layer_id() const { return scroll_layer_id_; } | 29 int scroll_layer_id() const { return scroll_layer_id_; } |
29 void SetScrollLayerId(int id); | 30 void SetScrollLayerId(int id); |
30 | 31 |
31 virtual bool OpacityCanAnimateOnImplThread() const OVERRIDE; | 32 virtual bool OpacityCanAnimateOnImplThread() const OVERRIDE; |
32 | 33 |
33 ScrollbarOrientation Orientation() const; | 34 ScrollbarOrientation Orientation() const; |
35 bool is_solid_color() const { return is_solid_color_; } | |
34 | 36 |
35 // Layer interface | 37 // Layer interface |
36 virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) | 38 virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) |
37 OVERRIDE; | 39 OVERRIDE; |
38 virtual void Update(ResourceUpdateQueue* queue, | 40 virtual void Update(ResourceUpdateQueue* queue, |
39 const OcclusionTracker* occlusion) OVERRIDE; | 41 const OcclusionTracker* occlusion) OVERRIDE; |
40 virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE; | 42 virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE; |
41 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; | 43 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; |
42 virtual void CalculateContentsScale(float ideal_contents_scale, | 44 virtual void CalculateContentsScale(float ideal_contents_scale, |
43 float device_scale_factor, | 45 float device_scale_factor, |
44 float page_scale_factor, | 46 float page_scale_factor, |
45 bool animating_transform_to_screen, | 47 bool animating_transform_to_screen, |
46 float* contents_scale_x, | 48 float* contents_scale_x, |
47 float* contents_scale_y, | 49 float* contents_scale_y, |
48 gfx::Size* content_bounds) OVERRIDE; | 50 gfx::Size* content_bounds) OVERRIDE; |
49 | 51 |
50 virtual ScrollbarLayer* ToScrollbarLayer() OVERRIDE; | 52 virtual ScrollbarLayer* ToScrollbarLayer() OVERRIDE; |
51 | 53 |
52 protected: | 54 protected: |
53 ScrollbarLayer(scoped_ptr<Scrollbar> scrollbar, | 55 ScrollbarLayer(scoped_ptr<Scrollbar> scrollbar, |
54 int scroll_layer_id); | 56 int scroll_layer_id, |
57 bool is_solid_color); | |
55 virtual ~ScrollbarLayer(); | 58 virtual ~ScrollbarLayer(); |
56 | 59 |
57 private: | 60 private: |
58 void UpdatePart(CachingBitmapContentLayerUpdater* painter, | 61 void UpdatePart(CachingBitmapContentLayerUpdater* painter, |
59 LayerUpdater::Resource* resource, | 62 LayerUpdater::Resource* resource, |
60 gfx::Rect rect, | 63 gfx::Rect rect, |
61 ResourceUpdateQueue* queue); | 64 ResourceUpdateQueue* queue); |
62 void CreateUpdaterIfNeeded(); | 65 void CreateUpdaterIfNeeded(); |
63 gfx::Rect ScrollbarLayerRectToContentRect(gfx::Rect layer_rect) const; | 66 gfx::Rect ScrollbarLayerRectToContentRect(gfx::Rect layer_rect) const; |
64 gfx::Rect OriginThumbRect() const; | 67 gfx::Rect OriginThumbRect() const; |
65 | 68 |
66 bool is_dirty() const { return !dirty_rect_.IsEmpty(); } | 69 bool is_dirty() const { return !dirty_rect_.IsEmpty(); } |
67 | 70 |
68 int MaxTextureSize(); | 71 int MaxTextureSize(); |
69 float ClampScaleToMaxTextureSize(float scale); | 72 float ClampScaleToMaxTextureSize(float scale); |
70 | 73 |
71 scoped_ptr<Scrollbar> scrollbar_; | 74 scoped_ptr<Scrollbar> scrollbar_; |
72 | 75 |
73 int thumb_thickness_; | 76 int thumb_thickness_; |
74 int thumb_length_; | 77 int thumb_length_; |
75 gfx::Rect track_rect_; | 78 gfx::Rect track_rect_; |
76 int scroll_layer_id_; | 79 int scroll_layer_id_; |
80 bool is_solid_color_; | |
77 | 81 |
78 unsigned texture_format_; | 82 unsigned texture_format_; |
79 | 83 |
80 gfx::RectF dirty_rect_; | 84 gfx::RectF dirty_rect_; |
81 | 85 |
82 scoped_refptr<CachingBitmapContentLayerUpdater> track_updater_; | 86 scoped_refptr<CachingBitmapContentLayerUpdater> track_updater_; |
83 scoped_refptr<CachingBitmapContentLayerUpdater> thumb_updater_; | 87 scoped_refptr<CachingBitmapContentLayerUpdater> thumb_updater_; |
84 | 88 |
85 // All the parts of the scrollbar except the thumb | 89 // All the parts of the scrollbar except the thumb |
86 scoped_ptr<LayerUpdater::Resource> track_; | 90 scoped_ptr<LayerUpdater::Resource> track_; |
87 scoped_ptr<LayerUpdater::Resource> thumb_; | 91 scoped_ptr<LayerUpdater::Resource> thumb_; |
88 | 92 |
89 DISALLOW_COPY_AND_ASSIGN(ScrollbarLayer); | 93 DISALLOW_COPY_AND_ASSIGN(ScrollbarLayer); |
90 }; | 94 }; |
91 | 95 |
92 } // namespace cc | 96 } // namespace cc |
93 | 97 |
94 #endif // CC_LAYERS_SCROLLBAR_LAYER_H_ | 98 #endif // CC_LAYERS_SCROLLBAR_LAYER_H_ |
OLD | NEW |