OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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_INPUT_INPUT_HANDLER_H_ | 5 #ifndef CC_INPUT_INPUT_HANDLER_H_ |
6 #define CC_INPUT_INPUT_HANDLER_H_ | 6 #define CC_INPUT_INPUT_HANDLER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" |
9 #include "base/time/time.h" | 10 #include "base/time/time.h" |
10 #include "cc/base/cc_export.h" | 11 #include "cc/base/cc_export.h" |
11 #include "cc/base/swap_promise_monitor.h" | 12 #include "cc/base/swap_promise_monitor.h" |
12 #include "cc/input/scrollbar.h" | 13 #include "cc/input/scrollbar.h" |
13 | 14 |
14 namespace gfx { | 15 namespace gfx { |
15 class Point; | 16 class Point; |
16 class PointF; | 17 class PointF; |
17 class Vector2d; | 18 class Vector2d; |
18 class Vector2dF; | 19 class Vector2dF; |
19 } | 20 } |
20 | 21 |
21 namespace ui { struct LatencyInfo; } | 22 namespace ui { struct LatencyInfo; } |
22 | 23 |
23 namespace cc { | 24 namespace cc { |
24 | 25 |
25 class LayerScrollOffsetDelegate; | 26 class LayerScrollOffsetDelegate; |
| 27 class ScrollElasticityHelper; |
| 28 |
| 29 struct CC_EXPORT InputHandlerScrollResult { |
| 30 InputHandlerScrollResult(); |
| 31 // Did any layer scroll as a result this ScrollBy call? |
| 32 bool did_scroll; |
| 33 // Was any of the scroll delta argument to this ScrollBy call not used? |
| 34 bool did_overscroll_root; |
| 35 // The total overscroll that has been accumulated by all ScrollBy calls that |
| 36 // have had overscroll since the last ScrollBegin call. This resets upon a |
| 37 // ScrollBy with no overscroll. |
| 38 gfx::Vector2dF accumulated_root_overscroll; |
| 39 // The amount of the scroll delta argument to this ScrollBy call that was not |
| 40 // used for scrolling. |
| 41 gfx::Vector2dF unused_scroll_delta; |
| 42 }; |
26 | 43 |
27 class CC_EXPORT InputHandlerClient { | 44 class CC_EXPORT InputHandlerClient { |
28 public: | 45 public: |
29 virtual ~InputHandlerClient() {} | 46 virtual ~InputHandlerClient() {} |
30 | 47 |
31 virtual void WillShutdown() = 0; | 48 virtual void WillShutdown() = 0; |
32 virtual void Animate(base::TimeTicks time) = 0; | 49 virtual void Animate(base::TimeTicks time) = 0; |
33 virtual void MainThreadHasStoppedFlinging() = 0; | 50 virtual void MainThreadHasStoppedFlinging() = 0; |
34 | 51 |
35 // Called when scroll deltas reaching the root scrolling layer go unused. | |
36 // The accumulated overscroll is scoped by the most recent call to | |
37 // InputHandler::ScrollBegin. | |
38 virtual void DidOverscroll(const gfx::PointF& causal_event_viewport_point, | |
39 const gfx::Vector2dF& accumulated_overscroll, | |
40 const gfx::Vector2dF& latest_overscroll_delta) = 0; | |
41 | |
42 protected: | 52 protected: |
43 InputHandlerClient() {} | 53 InputHandlerClient() {} |
44 | 54 |
45 private: | 55 private: |
46 DISALLOW_COPY_AND_ASSIGN(InputHandlerClient); | 56 DISALLOW_COPY_AND_ASSIGN(InputHandlerClient); |
47 }; | 57 }; |
48 | 58 |
49 // The InputHandler is a way for the embedders to interact with the impl thread | 59 // The InputHandler is a way for the embedders to interact with the impl thread |
50 // side of the compositor implementation. There is one InputHandler per | 60 // side of the compositor implementation. There is one InputHandler per |
51 // LayerTreeHost. To use the input handler, implement the InputHanderClient | 61 // LayerTreeHost. To use the input handler, implement the InputHanderClient |
(...skipping 26 matching lines...) Expand all Loading... |
78 ScrollInputType type) = 0; | 88 ScrollInputType type) = 0; |
79 | 89 |
80 virtual ScrollStatus ScrollAnimated(const gfx::Point& viewport_point, | 90 virtual ScrollStatus ScrollAnimated(const gfx::Point& viewport_point, |
81 const gfx::Vector2dF& scroll_delta) = 0; | 91 const gfx::Vector2dF& scroll_delta) = 0; |
82 | 92 |
83 // Scroll the selected layer starting at the given position. If the scroll | 93 // Scroll the selected layer starting at the given position. If the scroll |
84 // type given to ScrollBegin was a gesture, then the scroll point and delta | 94 // type given to ScrollBegin was a gesture, then the scroll point and delta |
85 // should be in viewport (logical pixel) coordinates. Otherwise they are in | 95 // should be in viewport (logical pixel) coordinates. Otherwise they are in |
86 // scrolling layer's (logical pixel) space. If there is no room to move the | 96 // scrolling layer's (logical pixel) space. If there is no room to move the |
87 // layer in the requested direction, its first ancestor layer that can be | 97 // layer in the requested direction, its first ancestor layer that can be |
88 // scrolled will be moved instead. If no layer can be moved in the requested | 98 // scrolled will be moved instead. The return value's |did_scroll| field is |
89 // direction at all, then false is returned. If any layer is moved, then | 99 // set to false if no layer can be moved in the requested direction at all, |
90 // true is returned. | 100 // and set to true if any layer is moved. |
91 // If the scroll delta hits the root layer, and the layer can no longer move, | 101 // If the scroll delta hits the root layer, and the layer can no longer move, |
92 // the root overscroll accumulated within this ScrollBegin() scope is reported | 102 // the root overscroll accumulated within this ScrollBegin() scope is reported |
93 // to the client. | 103 // in the return value's |accumulated_overscroll| field. |
94 // Should only be called if ScrollBegin() returned ScrollStarted. | 104 // Should only be called if ScrollBegin() returned ScrollStarted. |
95 virtual bool ScrollBy(const gfx::Point& viewport_point, | 105 virtual InputHandlerScrollResult ScrollBy( |
96 const gfx::Vector2dF& scroll_delta) = 0; | 106 const gfx::Point& viewport_point, |
| 107 const gfx::Vector2dF& scroll_delta) = 0; |
97 | 108 |
98 virtual bool ScrollVerticallyByPage(const gfx::Point& viewport_point, | 109 virtual bool ScrollVerticallyByPage(const gfx::Point& viewport_point, |
99 ScrollDirection direction) = 0; | 110 ScrollDirection direction) = 0; |
100 | 111 |
101 // Returns ScrollStarted if a layer was being actively being scrolled, | 112 // Returns ScrollStarted if a layer was being actively being scrolled, |
102 // ScrollIgnored if not. | 113 // ScrollIgnored if not. |
103 virtual ScrollStatus FlingScrollBegin() = 0; | 114 virtual ScrollStatus FlingScrollBegin() = 0; |
104 | 115 |
105 virtual void MouseMoveAt(const gfx::Point& mouse_position) = 0; | 116 virtual void MouseMoveAt(const gfx::Point& mouse_position) = 0; |
106 | 117 |
(...skipping 26 matching lines...) Expand all Loading... |
133 virtual bool HaveTouchEventHandlersAt(const gfx::Point& viewport_point) = 0; | 144 virtual bool HaveTouchEventHandlersAt(const gfx::Point& viewport_point) = 0; |
134 | 145 |
135 // Calling CreateLatencyInfoSwapPromiseMonitor() to get a scoped | 146 // Calling CreateLatencyInfoSwapPromiseMonitor() to get a scoped |
136 // LatencyInfoSwapPromiseMonitor. During the life time of the | 147 // LatencyInfoSwapPromiseMonitor. During the life time of the |
137 // LatencyInfoSwapPromiseMonitor, if SetNeedsRedraw() or SetNeedsRedrawRect() | 148 // LatencyInfoSwapPromiseMonitor, if SetNeedsRedraw() or SetNeedsRedrawRect() |
138 // is called on LayerTreeHostImpl, the original latency info will be turned | 149 // is called on LayerTreeHostImpl, the original latency info will be turned |
139 // into a LatencyInfoSwapPromise. | 150 // into a LatencyInfoSwapPromise. |
140 virtual scoped_ptr<SwapPromiseMonitor> CreateLatencyInfoSwapPromiseMonitor( | 151 virtual scoped_ptr<SwapPromiseMonitor> CreateLatencyInfoSwapPromiseMonitor( |
141 ui::LatencyInfo* latency) = 0; | 152 ui::LatencyInfo* latency) = 0; |
142 | 153 |
| 154 virtual ScrollElasticityHelper* CreateScrollElasticityHelper() = 0; |
| 155 |
143 protected: | 156 protected: |
144 InputHandler() {} | 157 InputHandler() {} |
145 virtual ~InputHandler() {} | 158 virtual ~InputHandler() {} |
146 | 159 |
147 private: | 160 private: |
148 DISALLOW_COPY_AND_ASSIGN(InputHandler); | 161 DISALLOW_COPY_AND_ASSIGN(InputHandler); |
149 }; | 162 }; |
150 | 163 |
151 } // namespace cc | 164 } // namespace cc |
152 | 165 |
153 #endif // CC_INPUT_INPUT_HANDLER_H_ | 166 #endif // CC_INPUT_INPUT_HANDLER_H_ |
OLD | NEW |