Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / webkit / child / fling_curve_configuration.h
1 // Copyright (c) 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 WEBKIT_CHILD_FLING_CURVE_CONFIGURATION_H_
6 #define WEBKIT_CHILD_FLING_CURVE_CONFIGURATION_H_
7
8 #include <vector>
9
10 #include "base/synchronization/lock.h"
11 #include "third_party/WebKit/public/platform/WebFloatPoint.h"
12 #include "third_party/WebKit/public/platform/WebSize.h"
13 #include "webkit/child/webkit_child_export.h"
14
15 namespace blink {
16 class WebGestureCurve;
17 }
18
19 namespace webkit_glue {
20
21 // A class to manage dynamically adjustable parameters controlling the
22 // shape of the fling deacceleration function.
23 class WEBKIT_CHILD_EXPORT FlingCurveConfiguration {
24  public:
25   FlingCurveConfiguration();
26   virtual ~FlingCurveConfiguration();
27
28   // Create a touchpad fling curve using the current parameters.
29   blink::WebGestureCurve* CreateForTouchPad(
30       const blink::WebFloatPoint& velocity,
31       const blink::WebSize& cumulativeScroll);
32
33   // Create a touchscreen fling curve using the current parameters.
34   blink::WebGestureCurve* CreateForTouchScreen(
35       const blink::WebFloatPoint& velocity,
36       const blink::WebSize& cumulativeScroll);
37
38   // Set the curve parameters.
39   void SetCurveParameters(
40       const std::vector<float>& new_touchpad,
41       const std::vector<float>& new_touchscreen);
42
43  private:
44   blink::WebGestureCurve* CreateCore(
45     const std::vector<float>& coefs,
46     const blink::WebFloatPoint& velocity,
47     const blink::WebSize& cumulativeScroll);
48
49   // Protect access to touchpad_coefs_ and touchscreen_coefs_.
50   base::Lock lock_;
51   std::vector<float> touchpad_coefs_;
52   std::vector<float> touchscreen_coefs_;
53
54   DISALLOW_COPY_AND_ASSIGN(FlingCurveConfiguration);
55 };
56
57 } // namespace webkit_glue
58
59 #endif // WEBKIT_CHILD_FLING_CURVE_CONFIGURATION_H_