OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef PINCH_ZOOM_SCROLLBAR_LAYER_IMPL_H_ | |
6 #define PINCH_ZOOM_SCROLLBAR_LAYER_IMPL_H_ | |
7 | |
8 #include "cc/cc_export.h" | |
9 #include "cc/scoped_resource.h" | |
10 #include "cc/scrollbar_layer_impl_base.h" | |
11 #include "ui/gfx/rect.h" | |
12 | |
13 namespace cc { | |
14 | |
15 class PinchZoomViewport; | |
16 | |
17 // PinchZoomScrollbarState exists to store the state associated with a | |
18 // PinchZoomScrollbarLayerImpl, so the latter can be treated as an inexpensive | |
19 // wrapper that can be cheaply created and discarded. | |
Ian Vollick
2013/01/15 20:33:48
We should design a system that allows impl-only la
| |
20 class CC_EXPORT PinchZoomScrollbarState { | |
21 public: | |
22 PinchZoomScrollbarState(WebKit::WebScrollbar::Orientation, | |
23 PinchZoomViewport* owner); | |
24 ~PinchZoomScrollbarState(); | |
25 | |
26 WebKit::WebScrollbar::Orientation orientation() const { | |
27 return orientation_; | |
28 } | |
29 | |
30 scoped_ptr<ScopedResource>& thumb_texture() { | |
31 return thumb_texture_; | |
32 } | |
33 | |
34 gfx::Rect& thumb_rect() { | |
35 return thumb_rect_; | |
36 } | |
37 | |
38 float& thumb_position() { | |
39 return thumb_position_; | |
40 } | |
41 | |
42 int& track_length() { | |
43 return track_length_; | |
44 } | |
45 | |
46 int& maximum_position() { | |
47 return maximum_position_; | |
48 } | |
49 | |
50 gfx::SizeF layout_viewport_size() const; | |
51 gfx::Vector2dF zoomed_viewport_offset() const; | |
52 float total_page_scale_factor() const; | |
53 float device_scale_factor() const; | |
54 LayerImpl* root_scroll_layer(); | |
55 | |
56 // A separate function to trigger size & position changes while | |
57 // *not* in willDraw(). | |
58 void RefreshSizeAndPosition(LayerImpl*); | |
59 bool ShouldDisplayPinchZoomScrollbars(); | |
60 | |
61 int track_width() const { | |
62 return kTrackWidth; | |
63 } | |
64 | |
65 private: | |
66 static const int kTrackWidth = 10; | |
67 PinchZoomViewport* owner_; | |
68 | |
69 WebKit::WebScrollbar::Orientation orientation_; | |
70 | |
71 scoped_ptr<ScopedResource> thumb_texture_; | |
72 gfx::Rect thumb_rect_; | |
73 float thumb_position_; | |
74 int track_length_; | |
75 int maximum_position_; | |
76 }; | |
77 | |
78 class CC_EXPORT PinchZoomScrollbarLayerImpl : public ScrollbarLayerImplBase { | |
79 public: | |
80 static scoped_ptr<PinchZoomScrollbarLayerImpl> create( | |
81 LayerTreeImpl* treeImpl, int id, PinchZoomScrollbarState* state); | |
82 virtual ~PinchZoomScrollbarLayerImpl(); | |
83 | |
84 // ScrollbarLayerImplBase overrides. | |
85 virtual float currentPos() const OVERRIDE; | |
86 virtual int totalSize() const OVERRIDE; | |
87 virtual int maximum() const OVERRIDE; | |
88 | |
89 virtual WebKit::WebScrollbar::Orientation orientation() const OVERRIDE; | |
90 | |
91 // LayerImpl overrides. | |
92 virtual void appendQuads(QuadSink&, AppendQuadsData&) OVERRIDE; | |
93 virtual void didLoseOutputSurface() OVERRIDE; | |
94 virtual void willDraw(ResourceProvider*) OVERRIDE; | |
95 // The pinch-zoom scrollbars should never have an implTransform applied to the m. | |
96 virtual void setImplTransform(const gfx::Transform& transform) OVERRIDE { } | |
97 | |
98 // Class-specific functions. | |
99 | |
100 private: | |
101 PinchZoomScrollbarLayerImpl( | |
102 LayerTreeImpl* treeImpl, int id, PinchZoomScrollbarState* state); | |
103 | |
104 PinchZoomScrollbarState* state_; | |
105 | |
106 }; | |
107 | |
108 } // namespace cc | |
109 #endif // PINCH_ZOOM_SCROLLBAR_LAYER_IMPL_H_ | |
OLD | NEW |