| 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_HANDLER_H_ | 5 #ifndef CC_INPUT_HANDLER_H_ |
| 6 #define CC_INPUT_HANDLER_H_ | 6 #define CC_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/cc_export.h" | 10 #include "cc/cc_export.h" |
| 11 | 11 |
| 12 namespace gfx { | 12 namespace gfx { |
| 13 class Point; | 13 class Point; |
| 14 class PointF; | 14 class PointF; |
| 15 class Vector2d; | 15 class Vector2d; |
| 16 class Vector2dF; | 16 class Vector2dF; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace cc { | 19 namespace cc { |
| 20 | 20 |
| 21 // The InputHandler is a way for the embedders to interact with | 21 // The InputHandler is a way for the embedders to interact with |
| 22 // the impl thread side of the compositor implementation. | 22 // the impl thread side of the compositor implementation. |
| 23 // | 23 // |
| 24 // There is one InputHandler for every LayerTreeHost. It is | 24 // There is one InputHandler for every LayerTreeHost. It is |
| 25 // created on the main thread and used only on the impl thread. | 25 // created on the main thread and used only on the impl thread. |
| 26 // | 26 // |
| 27 // The InputHandler is constructed with a InputHandlerClient, which is the | 27 // The InputHandler is constructed with a InputHandlerClient, which is the |
| 28 // interface by which the handler can manipulate the LayerTree. | 28 // interface by which the handler can manipulate the LayerTree. |
| 29 class CC_EXPORT InputHandlerClient { | 29 class CC_EXPORT InputHandlerClient { |
| 30 public: | 30 public: |
| 31 enum ScrollStatus { ScrollOnMainThread, ScrollStarted, ScrollIgnored }; | 31 enum ScrollStatus { ScrollOnMainThread, ScrollStarted, ScrollIgnored }; |
| 32 enum ScrollInputType { Gesture, Wheel, NonBubblingGesture }; | 32 enum ScrollInputType { Gesture, Wheel, NonBubblingGesture }; |
| 33 | 33 |
| 34 // Selects a layer to be scrolled at a given point in viewport (logical | 34 // Selects a layer to be scrolled at a given point in viewport (logical |
| 35 // pixel) coordinates. Returns ScrollStarted if the layer at the coordinates | 35 // pixel) coordinates. Returns ScrollStarted if the layer at the coordinates |
| 36 // can be scrolled, ScrollOnMainThread if the scroll event should instead be | 36 // can be scrolled, ScrollOnMainThread if the scroll event should instead be |
| 37 // delegated to the main thread, or ScrollIgnored if there is nothing to be | 37 // delegated to the main thread, or ScrollIgnored if there is nothing to be |
| 38 // scrolled at the given coordinates. | 38 // scrolled at the given coordinates. |
| 39 virtual ScrollStatus scrollBegin(gfx::Point, ScrollInputType) = 0; | 39 virtual ScrollStatus ScrollBegin(gfx::Point viewport_point, |
| 40 ScrollInputType type) = 0; |
| 40 | 41 |
| 41 // Scroll the selected layer starting at the given position. If the scroll | 42 // Scroll the selected layer starting at the given position. If the scroll |
| 42 // type given to scrollBegin was a gesture, then the scroll point and delta | 43 // type given to scrollBegin was a gesture, then the scroll point and delta |
| 43 // should be in viewport (logical pixel) coordinates. Otherwise they are in | 44 // should be in viewport (logical pixel) coordinates. Otherwise they are in |
| 44 // scrolling layer's (logical pixel) space. If there is no room to move the | 45 // scrolling layer's (logical pixel) space. If there is no room to move the |
| 45 // layer in the requested direction, its first ancestor layer that can be | 46 // layer in the requested direction, its first ancestor layer that can be |
| 46 // scrolled will be moved instead. If no layer can be moved in the requested | 47 // scrolled will be moved instead. If no layer can be moved in the requested |
| 47 // direction at all, then false is returned. If any layer is moved, then | 48 // direction at all, then false is returned. If any layer is moved, then |
| 48 // true is returned. | 49 // true is returned. |
| 49 // Should only be called if scrollBegin() returned ScrollStarted. | 50 // Should only be called if ScrollBegin() returned ScrollStarted. |
| 50 virtual bool scrollBy(const gfx::Point&, const gfx::Vector2dF&) = 0; | 51 virtual bool ScrollBy(gfx::Point viewport_point, |
| 52 gfx::Vector2dF scroll_delta) = 0; |
| 51 | 53 |
| 52 // Stop scrolling the selected layer. Should only be called if scrollBegin() | 54 // Stop scrolling the selected layer. Should only be called if ScrollBegin() |
| 53 // returned ScrollStarted. | 55 // returned ScrollStarted. |
| 54 virtual void scrollEnd() = 0; | 56 virtual void ScrollEnd() = 0; |
| 55 | 57 |
| 56 virtual void pinchGestureBegin() = 0; | 58 virtual void PinchGestureBegin() = 0; |
| 57 virtual void pinchGestureUpdate(float magnifyDelta, gfx::Point anchor) = 0; | 59 virtual void PinchGestureUpdate(float magnify_delta, gfx::Point anchor) = 0; |
| 58 virtual void pinchGestureEnd() = 0; | 60 virtual void PinchGestureEnd() = 0; |
| 59 | 61 |
| 60 virtual void startPageScaleAnimation(gfx::Vector2d targetOffset, | 62 virtual void StartPageScaleAnimation(gfx::Vector2d target_offset, |
| 61 bool anchorPoint, | 63 bool anchor_point, |
| 62 float pageScale, | 64 float page_scale, |
| 63 base::TimeTicks startTime, | 65 base::TimeTicks start_time, |
| 64 base::TimeDelta duration) = 0; | 66 base::TimeDelta duration) = 0; |
| 65 | 67 |
| 66 // Request another callback to InputHandler::animate(). | 68 // Request another callback to InputHandler::Animate(). |
| 67 virtual void scheduleAnimation() = 0; | 69 virtual void ScheduleAnimation() = 0; |
| 68 | 70 |
| 69 virtual bool haveTouchEventHandlersAt(const gfx::Point&) = 0; | 71 virtual bool HaveTouchEventHandlersAt(gfx::Point viewport_point) = 0; |
| 70 | 72 |
| 71 protected: | 73 protected: |
| 72 InputHandlerClient() { } | 74 InputHandlerClient() {} |
| 73 virtual ~InputHandlerClient() { } | 75 virtual ~InputHandlerClient() {} |
| 74 | 76 |
| 75 private: | 77 private: |
| 76 DISALLOW_COPY_AND_ASSIGN(InputHandlerClient); | 78 DISALLOW_COPY_AND_ASSIGN(InputHandlerClient); |
| 77 }; | 79 }; |
| 78 | 80 |
| 79 class CC_EXPORT InputHandler { | 81 class CC_EXPORT InputHandler { |
| 80 public: | 82 public: |
| 81 virtual ~InputHandler() { } | 83 virtual ~InputHandler() {} |
| 82 | 84 |
| 83 virtual void bindToClient(InputHandlerClient*) = 0; | 85 virtual void BindToClient(InputHandlerClient* client) = 0; |
| 84 virtual void animate(base::TimeTicks time) = 0; | 86 virtual void Animate(base::TimeTicks time) = 0; |
| 85 virtual void mainThreadHasStoppedFlinging() = 0; | 87 virtual void MainThreadHasStoppedFlinging() = 0; |
| 86 | 88 |
| 87 protected: | 89 protected: |
| 88 InputHandler() { } | 90 InputHandler() {} |
| 89 | 91 |
| 90 private: | 92 private: |
| 91 DISALLOW_COPY_AND_ASSIGN(InputHandler); | 93 DISALLOW_COPY_AND_ASSIGN(InputHandler); |
| 92 }; | 94 }; |
| 93 | 95 |
| 94 } | 96 } // namespace cc |
| 95 | 97 |
| 96 #endif // CC_INPUT_HANDLER_H_ | 98 #endif // CC_INPUT_HANDLER_H_ |
| OLD | NEW |