OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CC_SCROLLBAR_LAYER_H_ | |
6 #define CC_SCROLLBAR_LAYER_H_ | |
7 | |
8 #include "cc/base/cc_export.h" | |
9 #include "cc/contents_scaling_layer.h" | |
10 #include "cc/resources/layer_updater.h" | |
11 #include "cc/scrollbar_theme_painter.h" | |
12 #include "third_party/WebKit/Source/Platform/chromium/public/WebScrollbar.h" | |
13 #include "third_party/WebKit/Source/Platform/chromium/public/WebScrollbarThemeGe
ometry.h" | |
14 | |
15 namespace cc { | |
16 class CachingBitmapContentLayerUpdater; | |
17 class ResourceUpdateQueue; | |
18 class Scrollbar; | |
19 class ScrollbarThemeComposite; | |
20 | |
21 class CC_EXPORT ScrollbarLayer : public ContentsScalingLayer { | |
22 public: | |
23 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) | |
24 OVERRIDE; | |
25 | |
26 static scoped_refptr<ScrollbarLayer> Create( | |
27 scoped_ptr<WebKit::WebScrollbar>, | |
28 scoped_ptr<ScrollbarThemePainter>, | |
29 scoped_ptr<WebKit::WebScrollbarThemeGeometry>, | |
30 int scrollLayerId); | |
31 | |
32 int scroll_layer_id() const { return scroll_layer_id_; } | |
33 void SetScrollLayerId(int id); | |
34 | |
35 virtual bool OpacityCanAnimateOnImplThread() const OVERRIDE; | |
36 | |
37 WebKit::WebScrollbar::Orientation Orientation() const; | |
38 | |
39 // Layer interface | |
40 virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) | |
41 OVERRIDE; | |
42 virtual void Update(ResourceUpdateQueue* queue, | |
43 const OcclusionTracker* occlusion, | |
44 RenderingStats* stats) OVERRIDE; | |
45 virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE; | |
46 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; | |
47 virtual void CalculateContentsScale(float ideal_contents_scale, | |
48 bool animating_transform_to_screen, | |
49 float* contents_scale_x, | |
50 float* contents_scale_y, | |
51 gfx::Size* contentBounds) OVERRIDE; | |
52 | |
53 virtual ScrollbarLayer* ToScrollbarLayer() OVERRIDE; | |
54 | |
55 protected: | |
56 ScrollbarLayer( | |
57 scoped_ptr<WebKit::WebScrollbar>, | |
58 scoped_ptr<ScrollbarThemePainter>, | |
59 scoped_ptr<WebKit::WebScrollbarThemeGeometry>, | |
60 int scrollLayerId); | |
61 virtual ~ScrollbarLayer(); | |
62 | |
63 private: | |
64 void UpdatePart(CachingBitmapContentLayerUpdater* painter, | |
65 LayerUpdater::Resource* resource, | |
66 gfx::Rect rect, | |
67 ResourceUpdateQueue* queue, | |
68 RenderingStats* stats); | |
69 void CreateUpdaterIfNeeded(); | |
70 gfx::Rect ScrollbarLayerRectToContentRect(gfx::Rect layer_rect) const; | |
71 | |
72 bool is_dirty() const { return !dirty_rect_.IsEmpty(); } | |
73 | |
74 int MaxTextureSize(); | |
75 float ClampScaleToMaxTextureSize(float scale); | |
76 | |
77 scoped_ptr<WebKit::WebScrollbar> scrollbar_; | |
78 scoped_ptr<ScrollbarThemePainter> painter_; | |
79 scoped_ptr<WebKit::WebScrollbarThemeGeometry> geometry_; | |
80 gfx::Size thumb_size_; | |
81 int scroll_layer_id_; | |
82 | |
83 unsigned texture_format_; | |
84 | |
85 gfx::RectF dirty_rect_; | |
86 | |
87 scoped_refptr<CachingBitmapContentLayerUpdater> back_track_updater_; | |
88 scoped_refptr<CachingBitmapContentLayerUpdater> fore_track_updater_; | |
89 scoped_refptr<CachingBitmapContentLayerUpdater> thumb_updater_; | |
90 | |
91 // All the parts of the scrollbar except the thumb | |
92 scoped_ptr<LayerUpdater::Resource> back_track_; | |
93 scoped_ptr<LayerUpdater::Resource> fore_track_; | |
94 scoped_ptr<LayerUpdater::Resource> thumb_; | |
95 }; | |
96 | |
97 } // namespace cc | |
98 | |
99 #endif // CC_SCROLLBAR_LAYER_H_ | |
OLD | NEW |