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/time.h" | 9 #include "base/time.h" |
10 #include "cc/base/cc_export.h" | 10 #include "cc/base/cc_export.h" |
11 #include "third_party/WebKit/Source/Platform/chromium/public/WebScrollbar.h" | 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebScrollbar.h" |
12 | 12 |
13 namespace gfx { | 13 namespace gfx { |
14 class Point; | 14 class Point; |
15 class PointF; | 15 class PointF; |
16 class Vector2d; | 16 class Vector2d; |
17 class Vector2dF; | 17 class Vector2dF; |
18 } | 18 } |
19 | 19 |
20 namespace cc { | 20 namespace cc { |
21 | 21 |
| 22 class CC_EXPORT InputHandlerClient { |
| 23 public: |
| 24 virtual ~InputHandlerClient() {} |
| 25 |
| 26 virtual void Animate(base::TimeTicks time) = 0; |
| 27 virtual void MainThreadHasStoppedFlinging() = 0; |
| 28 |
| 29 protected: |
| 30 InputHandlerClient() {} |
| 31 |
| 32 private: |
| 33 DISALLOW_COPY_AND_ASSIGN(InputHandlerClient); |
| 34 }; |
| 35 |
22 // The InputHandler is a way for the embedders to interact with the impl thread | 36 // The InputHandler is a way for the embedders to interact with the impl thread |
23 // side of the compositor implementation. There is one InputHandler per | 37 // side of the compositor implementation. There is one InputHandler per |
24 // LayerTreeHost. To use the input handler, implement the InputHanderClient | 38 // LayerTreeHost. To use the input handler, implement the InputHanderClient |
25 // interface and bind it to the handler on the compositor thread. | 39 // interface and bind it to the handler on the compositor thread. |
26 class CC_EXPORT InputHandler { | 40 class CC_EXPORT InputHandler { |
27 public: | 41 public: |
28 enum ScrollStatus { ScrollOnMainThread, ScrollStarted, ScrollIgnored }; | 42 enum ScrollStatus { ScrollOnMainThread, ScrollStarted, ScrollIgnored }; |
29 enum ScrollInputType { Gesture, Wheel, NonBubblingGesture }; | 43 enum ScrollInputType { Gesture, Wheel, NonBubblingGesture }; |
30 | 44 |
| 45 // Binds a client to this handler to receive notifications. Only one client |
| 46 // can be bound to an InputHandler. The client must outlive the InputHandler. |
| 47 virtual void BindToClient(InputHandlerClient* client) = 0; |
| 48 |
31 // Selects a layer to be scrolled at a given point in viewport (logical | 49 // Selects a layer to be scrolled at a given point in viewport (logical |
32 // pixel) coordinates. Returns ScrollStarted if the layer at the coordinates | 50 // pixel) coordinates. Returns ScrollStarted if the layer at the coordinates |
33 // can be scrolled, ScrollOnMainThread if the scroll event should instead be | 51 // can be scrolled, ScrollOnMainThread if the scroll event should instead be |
34 // delegated to the main thread, or ScrollIgnored if there is nothing to be | 52 // delegated to the main thread, or ScrollIgnored if there is nothing to be |
35 // scrolled at the given coordinates. | 53 // scrolled at the given coordinates. |
36 virtual ScrollStatus ScrollBegin(gfx::Point viewport_point, | 54 virtual ScrollStatus ScrollBegin(gfx::Point viewport_point, |
37 ScrollInputType type) = 0; | 55 ScrollInputType type) = 0; |
38 | 56 |
39 // Scroll the selected layer starting at the given position. If the scroll | 57 // Scroll the selected layer starting at the given position. If the scroll |
40 // type given to ScrollBegin was a gesture, then the scroll point and delta | 58 // type given to ScrollBegin was a gesture, then the scroll point and delta |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 base::TimeTicks frame_time) = 0; | 99 base::TimeTicks frame_time) = 0; |
82 | 100 |
83 protected: | 101 protected: |
84 InputHandler() {} | 102 InputHandler() {} |
85 virtual ~InputHandler() {} | 103 virtual ~InputHandler() {} |
86 | 104 |
87 private: | 105 private: |
88 DISALLOW_COPY_AND_ASSIGN(InputHandler); | 106 DISALLOW_COPY_AND_ASSIGN(InputHandler); |
89 }; | 107 }; |
90 | 108 |
91 class CC_EXPORT InputHandlerClient { | |
92 public: | |
93 virtual ~InputHandlerClient() {} | |
94 | |
95 virtual void BindToHandler(InputHandler* handler) = 0; | |
96 virtual void Animate(base::TimeTicks time) = 0; | |
97 virtual void MainThreadHasStoppedFlinging() = 0; | |
98 | |
99 protected: | |
100 InputHandlerClient() {} | |
101 | |
102 private: | |
103 DISALLOW_COPY_AND_ASSIGN(InputHandlerClient); | |
104 }; | |
105 | |
106 } // namespace cc | 109 } // namespace cc |
107 | 110 |
108 #endif // CC_INPUT_INPUT_HANDLER_H_ | 111 #endif // CC_INPUT_INPUT_HANDLER_H_ |
OLD | NEW |