Index: webkit/child/fling_animator_impl_android.cc |
diff --git a/webkit/child/fling_animator_impl_android.cc b/webkit/child/fling_animator_impl_android.cc |
index 668076ba235cfa9decadaa14c13743552ecfba42..c5e5d3d796cb363cccd02d5a602b86f6851130c7 100644 |
--- a/webkit/child/fling_animator_impl_android.cc |
+++ b/webkit/child/fling_animator_impl_android.cc |
@@ -20,7 +20,9 @@ static const float kEpsilon = 1e-4; |
} |
FlingAnimatorImpl::FlingAnimatorImpl() |
- : is_active_(false) { |
+ : is_active_(false), |
+ last_time_(0), |
+ dpi_scale_(1) { |
// hold the global reference of the Java objects. |
JNIEnv* env = base::android::AttachCurrentThread(); |
java_scroller_.Reset(JNI_OverScroller::Java_OverScroller_ConstructorAWOS_ACC( |
@@ -50,13 +52,17 @@ void FlingAnimatorImpl::StartFling(const gfx::PointF& velocity) |
is_active_ = true; |
last_time_ = 0; |
last_velocity_ = velocity; |
+ dpi_scale_ = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay() |
jamesr
2014/02/18 22:40:46
let's not do this. if you want to add a cache for
jdduke (slow)
2014/02/18 22:51:29
Done.
|
+ .device_scale_factor(); |
JNIEnv* env = base::android::AttachCurrentThread(); |
+ // The OverScroller deceleration constants work in pixel space. DIP scaling |
+ // will be performed in |apply()| on the generated fling updates. |
JNI_OverScroller::Java_OverScroller_flingV_I_I_I_I_I_I_I_I( |
env, java_scroller_.obj(), 0, 0, |
- static_cast<int>(velocity.x()), |
- static_cast<int>(velocity.y()), |
+ static_cast<int>(velocity.x() * dpi_scale_), |
+ static_cast<int>(velocity.y() * dpi_scale_), |
INT_MIN, INT_MAX, INT_MIN, INT_MAX); |
} |
@@ -105,10 +111,8 @@ bool FlingAnimatorImpl::apply(double time, |
gfx::Point current_position = GetCurrentPosition(); |
gfx::Vector2d diff(current_position - last_position_); |
last_position_ = current_position; |
- float dpi_scale = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay() |
- .device_scale_factor(); |
- blink::WebFloatSize scroll_amount(diff.x() / dpi_scale, |
- diff.y() / dpi_scale); |
+ blink::WebFloatSize scroll_amount(diff.x() / dpi_scale_, |
+ diff.y() / dpi_scale_); |
jamesr
2014/02/18 22:40:46
bad alignment
jdduke (slow)
2014/02/18 22:51:29
Done.
|
float delta_time = time - last_time_; |
last_time_ = time; |
@@ -127,8 +131,8 @@ bool FlingAnimatorImpl::apply(double time, |
} |
} |
last_velocity_ = current_velocity; |
- blink::WebFloatSize fling_velocity(current_velocity.x() / dpi_scale, |
- current_velocity.y() / dpi_scale); |
+ blink::WebFloatSize fling_velocity(current_velocity.x() / dpi_scale_, |
+ current_velocity.y() / dpi_scale_); |
jamesr
2014/02/18 22:40:46
bad alignment
jdduke (slow)
2014/02/18 22:51:29
Done.
|
target->notifyCurrentFlingVelocity(fling_velocity); |
// scrollBy() could delete this curve if the animation is over, so don't touch |