Commit 4583ba5d authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Fix scrolling perf regression

pixels per mouse_scroll_wheel_tick was being set wrong (should have
been wheel_scroll_factor but was the value divided by dip_scale
was set), hence decreased the scroll rate and caused the regression.
This CL fixes the issue. Now WindowAndroid stores wheel_scroll_factor
(instead of tick multiplier) which is accessed much more often, for
efficiency's sake.

Bug: 821101
Change-Id: I99e81fdfc21ec101a99092c50555be4f429d7a20
Reviewed-on: https://chromium-review.googlesource.com/961503Reviewed-by: default avatarBo <boliu@chromium.org>
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#543013}
parent 67c36e7a
......@@ -444,7 +444,7 @@ int RenderWidgetHostViewAndroid::GetMouseWheelMinimumGranularity() const {
// many pixels each tick scrolls. This multiplier is specified by device
// metrics (See WindowAndroid.getMouseWheelScrollFactor) so the minimum
// granularity will be the size of this tick multiplier.
return window->mouse_wheel_tick_multiplier();
return window->mouse_wheel_scroll_factor() / view_.GetDipScale();
}
void RenderWidgetHostViewAndroid::UpdateCursor(const WebCursor& cursor) {
......
......@@ -143,8 +143,9 @@ void EventForwarder::OnMouseWheelEvent(JNIEnv* env,
0, x, y, 0.0f /* touch_major */, 0.0f /* touch_minor */, 0.0f, 0.0f, 0);
auto* window = view_->GetWindowAndroid();
float pixels_per_tick = window ? window->mouse_wheel_tick_multiplier()
: kDefaultMouseWheelTickMultiplier;
float pixels_per_tick =
window ? window->mouse_wheel_scroll_factor()
: kDefaultMouseWheelTickMultiplier * view_->GetDipScale();
ui::MotionEventAndroid event(
env, nullptr, 1.f / view_->GetDipScale(), ticks_x, ticks_y,
pixels_per_tick, time_ms, 0 /* action */, 1 /* pointer_count */,
......
......@@ -136,9 +136,9 @@ WindowAndroid::WindowAndroid(JNIEnv* env,
begin_frame_source_(new WindowBeginFrameSource(this)),
needs_begin_frames_(false) {
java_window_.Reset(env, obj);
mouse_wheel_tick_multiplier_ = scroll_factor > 0
? scroll_factor / GetDipScale()
: kDefaultMouseWheelTickMultiplier;
mouse_wheel_scroll_factor_ =
scroll_factor > 0 ? scroll_factor
: kDefaultMouseWheelTickMultiplier * GetDipScale();
}
void WindowAndroid::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) {
......
......@@ -88,9 +88,7 @@ class UI_ANDROID_EXPORT WindowAndroid : public ViewAndroid {
// Return whether the specified Android permission can be requested by Chrome.
bool CanRequestPermission(const std::string& permission);
float mouse_wheel_tick_multiplier() const {
return mouse_wheel_tick_multiplier_;
}
float mouse_wheel_scroll_factor() const { return mouse_wheel_scroll_factor_; }
static WindowAndroid* CreateForTesting();
......@@ -120,7 +118,7 @@ class UI_ANDROID_EXPORT WindowAndroid : public ViewAndroid {
std::unique_ptr<WindowBeginFrameSource> begin_frame_source_;
bool needs_begin_frames_;
std::list<base::Closure> vsync_complete_callbacks_;
float mouse_wheel_tick_multiplier_;
float mouse_wheel_scroll_factor_;
DISALLOW_COPY_AND_ASSIGN(WindowAndroid);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment