Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(688)

Unified Diff: webkit/child/fling_animator_impl_android.cc

Issue 170993003: [Android] Use DIP coordinates for GestureFlingStart events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/child/fling_animator_impl_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « webkit/child/fling_animator_impl_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698