• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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 #include "content/child/fling_curve_configuration.h"
6 
7 #include "base/logging.h"
8 #include "content/child/touch_fling_gesture_curve.h"
9 #include "third_party/WebKit/public/platform/WebGestureCurve.h"
10 
11 namespace content {
12 
FlingCurveConfiguration()13 FlingCurveConfiguration::FlingCurveConfiguration() { }
14 
~FlingCurveConfiguration()15 FlingCurveConfiguration::~FlingCurveConfiguration() { }
16 
SetCurveParameters(const std::vector<float> & new_touchpad,const std::vector<float> & new_touchscreen)17 void FlingCurveConfiguration::SetCurveParameters(
18     const std::vector<float>& new_touchpad,
19     const std::vector<float>& new_touchscreen) {
20   DCHECK(new_touchpad.size() >= 3);
21   DCHECK(new_touchscreen.size() >= 3);
22   base::AutoLock scoped_lock(lock_);
23   touchpad_coefs_ = new_touchpad;
24   touchscreen_coefs_ = new_touchscreen;
25 }
26 
CreateCore(const std::vector<float> & coefs,const blink::WebFloatPoint & velocity,const blink::WebSize & cumulativeScroll)27 blink::WebGestureCurve* FlingCurveConfiguration::CreateCore(
28     const std::vector<float>& coefs,
29     const blink::WebFloatPoint& velocity,
30     const blink::WebSize& cumulativeScroll) {
31   float p0, p1, p2;
32 
33   {
34     base::AutoLock scoped_lock(lock_);
35     p0 = coefs[0];
36     p1 = coefs[1];
37     p2 = coefs[2];
38   }
39 
40   return TouchFlingGestureCurve::Create(velocity, p0, p1, p2,
41       cumulativeScroll);
42 }
43 
CreateForTouchPad(const blink::WebFloatPoint & velocity,const blink::WebSize & cumulativeScroll)44 blink::WebGestureCurve* FlingCurveConfiguration::CreateForTouchPad(
45     const blink::WebFloatPoint& velocity,
46     const blink::WebSize& cumulativeScroll) {
47   return CreateCore(touchpad_coefs_, velocity, cumulativeScroll);
48 }
49 
CreateForTouchScreen(const blink::WebFloatPoint & velocity,const blink::WebSize & cumulativeScroll)50 blink::WebGestureCurve* FlingCurveConfiguration::CreateForTouchScreen(
51     const blink::WebFloatPoint& velocity,
52     const blink::WebSize& cumulativeScroll) {
53   return CreateCore(touchscreen_coefs_, velocity, cumulativeScroll);
54 }
55 
56 } // namespace content
57