Commit c7b76cc1 authored by Lan Wei's avatar Lan Wei Committed by Commit Bot

Add wheel scroll options to GpuBenchmarking

In GpuBenchmarking, for mouse wheel and touchpad scroll, we want to add
"has_precise_scrolling_deltas" scroll option to
GpuBenchmarking::SmoothScrollBy.


Bug: 871970
Change-Id: I456db492e2a7fdab35263efe931d089b400a9e3d
Reviewed-on: https://chromium-review.googlesource.com/1166165Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Reviewed-by: default avatarSahel Sharify <sahel@chromium.org>
Reviewed-by: default avatarTimothy Dresser <tdresser@chromium.org>
Commit-Queue: Lan Wei <lanwei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583249}
parent b1e1c51b
...@@ -188,7 +188,8 @@ class MockSyntheticGestureTarget : public SyntheticGestureTarget { ...@@ -188,7 +188,8 @@ class MockSyntheticGestureTarget : public SyntheticGestureTarget {
class MockMoveGestureTarget : public MockSyntheticGestureTarget { class MockMoveGestureTarget : public MockSyntheticGestureTarget {
public: public:
MockMoveGestureTarget() : total_abs_move_distance_length_(0) {} MockMoveGestureTarget()
: total_abs_move_distance_length_(0), precise_scrolling_deltas_(false) {}
~MockMoveGestureTarget() override {} ~MockMoveGestureTarget() override {}
gfx::Vector2dF start_to_end_distance() const { gfx::Vector2dF start_to_end_distance() const {
...@@ -197,10 +198,12 @@ class MockMoveGestureTarget : public MockSyntheticGestureTarget { ...@@ -197,10 +198,12 @@ class MockMoveGestureTarget : public MockSyntheticGestureTarget {
float total_abs_move_distance_length() const { float total_abs_move_distance_length() const {
return total_abs_move_distance_length_; return total_abs_move_distance_length_;
} }
bool precise_scrolling_deltas() const { return precise_scrolling_deltas_; }
protected: protected:
gfx::Vector2dF start_to_end_distance_; gfx::Vector2dF start_to_end_distance_;
float total_abs_move_distance_length_; float total_abs_move_distance_length_;
bool precise_scrolling_deltas_;
}; };
class MockScrollMouseTarget : public MockMoveGestureTarget { class MockScrollMouseTarget : public MockMoveGestureTarget {
...@@ -215,6 +218,7 @@ class MockScrollMouseTarget : public MockMoveGestureTarget { ...@@ -215,6 +218,7 @@ class MockScrollMouseTarget : public MockMoveGestureTarget {
gfx::Vector2dF delta(mouse_wheel_event.delta_x, mouse_wheel_event.delta_y); gfx::Vector2dF delta(mouse_wheel_event.delta_x, mouse_wheel_event.delta_y);
start_to_end_distance_ += delta; start_to_end_distance_ += delta;
total_abs_move_distance_length_ += delta.Length(); total_abs_move_distance_length_ += delta.Length();
precise_scrolling_deltas_ = mouse_wheel_event.has_precise_scrolling_deltas;
} }
}; };
...@@ -1186,6 +1190,28 @@ TEST_F(SyntheticGestureControllerTest, MultiScrollGestureMouseHorizontal) { ...@@ -1186,6 +1190,28 @@ TEST_F(SyntheticGestureControllerTest, MultiScrollGestureMouseHorizontal) {
scroll_target->start_to_end_distance().x()); scroll_target->start_to_end_distance().x());
} }
TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMousePreciseScroll) {
CreateControllerAndTarget<MockScrollMouseTarget>();
SyntheticSmoothMoveGestureParams params;
params.input_type = SyntheticSmoothMoveGestureParams::MOUSE_WHEEL_INPUT;
params.start_point.SetPoint(39, 86);
params.distances.push_back(gfx::Vector2d(0, -132));
params.precise_scrolling_deltas = true;
std::unique_ptr<SyntheticSmoothMoveGesture> gesture(
new SyntheticSmoothMoveGesture(params));
QueueSyntheticGesture(std::move(gesture));
FlushInputUntilComplete();
MockMoveGestureTarget* scroll_target =
static_cast<MockMoveGestureTarget*>(target_);
EXPECT_EQ(1, num_success_);
EXPECT_EQ(0, num_failure_);
EXPECT_EQ(params.precise_scrolling_deltas,
scroll_target->precise_scrolling_deltas());
}
void CheckIsWithinRangeMulti(float scroll_distance, void CheckIsWithinRangeMulti(float scroll_distance,
int target_distance, int target_distance,
SyntheticGestureTarget* target) { SyntheticGestureTarget* target) {
......
...@@ -81,9 +81,12 @@ void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform( ...@@ -81,9 +81,12 @@ void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform(
return; return;
} }
base::TimeTicks timestamp = web_wheel.TimeStamp(); base::TimeTicks timestamp = web_wheel.TimeStamp();
int modifiers = web_wheel.has_precise_scrolling_deltas
? ui::EF_PRECISION_SCROLLING_DELTA
: ui::EF_NONE;
ui::MouseWheelEvent wheel_event( ui::MouseWheelEvent wheel_event(
gfx::Vector2d(web_wheel.delta_x, web_wheel.delta_y), gfx::Point(), gfx::Vector2d(web_wheel.delta_x, web_wheel.delta_y), gfx::Point(),
gfx::Point(), timestamp, ui::EF_NONE, ui::EF_NONE); gfx::Point(), timestamp, modifiers, ui::EF_NONE);
gfx::PointF location(web_wheel.PositionInWidget().x * device_scale_factor_, gfx::PointF location(web_wheel.PositionInWidget().x * device_scale_factor_,
web_wheel.PositionInWidget().y * device_scale_factor_); web_wheel.PositionInWidget().y * device_scale_factor_);
wheel_event.set_location_f(location); wheel_event.set_location_f(location);
......
...@@ -30,7 +30,8 @@ const int kDefaultSpeedInPixelsPerSec = 800; ...@@ -30,7 +30,8 @@ const int kDefaultSpeedInPixelsPerSec = 800;
SyntheticSmoothMoveGestureParams::SyntheticSmoothMoveGestureParams() SyntheticSmoothMoveGestureParams::SyntheticSmoothMoveGestureParams()
: speed_in_pixels_s(kDefaultSpeedInPixelsPerSec), : speed_in_pixels_s(kDefaultSpeedInPixelsPerSec),
prevent_fling(true), prevent_fling(true),
add_slop(true) {} add_slop(true),
precise_scrolling_deltas(false) {}
SyntheticSmoothMoveGestureParams::SyntheticSmoothMoveGestureParams( SyntheticSmoothMoveGestureParams::SyntheticSmoothMoveGestureParams(
const SyntheticSmoothMoveGestureParams& other) = default; const SyntheticSmoothMoveGestureParams& other) = default;
...@@ -258,8 +259,8 @@ void SyntheticSmoothMoveGesture::ForwardMouseWheelEvent( ...@@ -258,8 +259,8 @@ void SyntheticSmoothMoveGesture::ForwardMouseWheelEvent(
const blink::WebMouseWheelEvent::Phase phase, const blink::WebMouseWheelEvent::Phase phase,
const base::TimeTicks& timestamp) const { const base::TimeTicks& timestamp) const {
blink::WebMouseWheelEvent mouse_wheel_event = blink::WebMouseWheelEvent mouse_wheel_event =
SyntheticWebMouseWheelEventBuilder::Build(0, 0, delta.x(), delta.y(), 0, SyntheticWebMouseWheelEventBuilder::Build(
false); 0, 0, delta.x(), delta.y(), 0, params_.precise_scrolling_deltas);
mouse_wheel_event.SetPositionInWidget( mouse_wheel_event.SetPositionInWidget(
current_move_segment_start_position_.x(), current_move_segment_start_position_.x(),
......
...@@ -36,6 +36,7 @@ class CONTENT_EXPORT SyntheticSmoothMoveGestureParams { ...@@ -36,6 +36,7 @@ class CONTENT_EXPORT SyntheticSmoothMoveGestureParams {
int speed_in_pixels_s; int speed_in_pixels_s;
bool prevent_fling; bool prevent_fling;
bool add_slop; bool add_slop;
bool precise_scrolling_deltas;
}; };
// This class is used as helper class for simulation of scroll and drag. // This class is used as helper class for simulation of scroll and drag.
......
...@@ -48,6 +48,7 @@ bool SyntheticSmoothScrollGesture::InitializeMoveGesture( ...@@ -48,6 +48,7 @@ bool SyntheticSmoothScrollGesture::InitializeMoveGesture(
move_params.prevent_fling = params_.prevent_fling; move_params.prevent_fling = params_.prevent_fling;
move_params.input_type = GetInputSourceType(gesture_type); move_params.input_type = GetInputSourceType(gesture_type);
move_params.add_slop = true; move_params.add_slop = true;
move_params.precise_scrolling_deltas = params_.precise_scrolling_deltas;
move_gesture_.reset(new SyntheticSmoothMoveGesture(move_params)); move_gesture_.reset(new SyntheticSmoothMoveGesture(move_params));
return true; return true;
} }
......
...@@ -14,15 +14,18 @@ const float kDefaultSpeedInPixelsS = 800; ...@@ -14,15 +14,18 @@ const float kDefaultSpeedInPixelsS = 800;
} // namespace } // namespace
SyntheticSmoothScrollGestureParams::SyntheticSmoothScrollGestureParams() SyntheticSmoothScrollGestureParams::SyntheticSmoothScrollGestureParams()
: prevent_fling(true), speed_in_pixels_s(kDefaultSpeedInPixelsS) {} : prevent_fling(true),
speed_in_pixels_s(kDefaultSpeedInPixelsS),
precise_scrolling_deltas(false) {}
SyntheticSmoothScrollGestureParams::SyntheticSmoothScrollGestureParams( SyntheticSmoothScrollGestureParams::SyntheticSmoothScrollGestureParams(
const SyntheticSmoothScrollGestureParams& other) const SyntheticSmoothScrollGestureParams& other)
: SyntheticGestureParams(other), : SyntheticGestureParams(other),
anchor(other.anchor), anchor(other.anchor),
distances(other.distances), distances(other.distances),
prevent_fling(other.prevent_fling), prevent_fling(other.prevent_fling),
speed_in_pixels_s(other.speed_in_pixels_s) {} speed_in_pixels_s(other.speed_in_pixels_s),
precise_scrolling_deltas(other.precise_scrolling_deltas) {}
SyntheticSmoothScrollGestureParams::~SyntheticSmoothScrollGestureParams() {} SyntheticSmoothScrollGestureParams::~SyntheticSmoothScrollGestureParams() {}
......
...@@ -28,6 +28,7 @@ struct CONTENT_EXPORT SyntheticSmoothScrollGestureParams ...@@ -28,6 +28,7 @@ struct CONTENT_EXPORT SyntheticSmoothScrollGestureParams
std::vector<gfx::Vector2dF> distances; // Positive X/Y to scroll left/up. std::vector<gfx::Vector2dF> distances; // Positive X/Y to scroll left/up.
bool prevent_fling; // Defaults to true. bool prevent_fling; // Defaults to true.
float speed_in_pixels_s; float speed_in_pixels_s;
bool precise_scrolling_deltas;
static const SyntheticSmoothScrollGestureParams* Cast( static const SyntheticSmoothScrollGestureParams* Cast(
const SyntheticGestureParams* gesture_params); const SyntheticGestureParams* gesture_params);
......
...@@ -287,7 +287,8 @@ bool BeginSmoothScroll(GpuBenchmarkingContext* context, ...@@ -287,7 +287,8 @@ bool BeginSmoothScroll(GpuBenchmarkingContext* context,
float speed_in_pixels_s, float speed_in_pixels_s,
bool prevent_fling, bool prevent_fling,
float start_x, float start_x,
float start_y) { float start_y,
bool precise_scrolling_deltas) {
gfx::Rect rect = context->render_view_impl()->GetWidget()->ViewRect(); gfx::Rect rect = context->render_view_impl()->GetWidget()->ViewRect();
rect -= rect.OffsetFromOrigin(); rect -= rect.OffsetFromOrigin();
if (!rect.Contains(start_x, start_y)) { if (!rect.Contains(start_x, start_y)) {
...@@ -324,6 +325,7 @@ bool BeginSmoothScroll(GpuBenchmarkingContext* context, ...@@ -324,6 +325,7 @@ bool BeginSmoothScroll(GpuBenchmarkingContext* context,
gesture_params.speed_in_pixels_s = speed_in_pixels_s; gesture_params.speed_in_pixels_s = speed_in_pixels_s;
gesture_params.prevent_fling = prevent_fling; gesture_params.prevent_fling = prevent_fling;
gesture_params.precise_scrolling_deltas = precise_scrolling_deltas;
gesture_params.anchor.SetPoint(start_x, start_y); gesture_params.anchor.SetPoint(start_x, start_y);
...@@ -641,21 +643,25 @@ bool GpuBenchmarking::SmoothScrollBy(gin::Arguments* args) { ...@@ -641,21 +643,25 @@ bool GpuBenchmarking::SmoothScrollBy(gin::Arguments* args) {
int gesture_source_type = SyntheticGestureParams::DEFAULT_INPUT; int gesture_source_type = SyntheticGestureParams::DEFAULT_INPUT;
std::string direction = "down"; std::string direction = "down";
float speed_in_pixels_s = 800; float speed_in_pixels_s = 800;
bool precise_scrolling_deltas = true;
if (!GetOptionalArg(args, &pixels_to_scroll) || if (!GetOptionalArg(args, &pixels_to_scroll) ||
!GetOptionalArg(args, &callback) || !GetOptionalArg(args, &callback) || !GetOptionalArg(args, &start_x) ||
!GetOptionalArg(args, &start_x) ||
!GetOptionalArg(args, &start_y) || !GetOptionalArg(args, &start_y) ||
!GetOptionalArg(args, &gesture_source_type) || !GetOptionalArg(args, &gesture_source_type) ||
!GetOptionalArg(args, &direction) || !GetOptionalArg(args, &direction) ||
!GetOptionalArg(args, &speed_in_pixels_s)) { !GetOptionalArg(args, &speed_in_pixels_s) ||
!GetOptionalArg(args, &precise_scrolling_deltas)) {
return false; return false;
} }
DCHECK(gesture_source_type != SyntheticGestureParams::TOUCH_INPUT ||
precise_scrolling_deltas);
EnsureRemoteInterface(); EnsureRemoteInterface();
return BeginSmoothScroll(&context, args, input_injector_, pixels_to_scroll, return BeginSmoothScroll(&context, args, input_injector_, pixels_to_scroll,
callback, gesture_source_type, direction, callback, gesture_source_type, direction,
speed_in_pixels_s, true, start_x, start_y); speed_in_pixels_s, true, start_x, start_y,
precise_scrolling_deltas);
} }
bool GpuBenchmarking::SmoothDrag(gin::Arguments* args) { bool GpuBenchmarking::SmoothDrag(gin::Arguments* args) {
...@@ -714,7 +720,7 @@ bool GpuBenchmarking::Swipe(gin::Arguments* args) { ...@@ -714,7 +720,7 @@ bool GpuBenchmarking::Swipe(gin::Arguments* args) {
return BeginSmoothScroll( return BeginSmoothScroll(
&context, args, input_injector_, -pixels_to_scroll, callback, &context, args, input_injector_, -pixels_to_scroll, callback,
1, // TOUCH_INPUT 1, // TOUCH_INPUT
direction, speed_in_pixels_s, false, start_x, start_y); direction, speed_in_pixels_s, false, start_x, start_y, true);
} }
bool GpuBenchmarking::ScrollBounce(gin::Arguments* args) { bool GpuBenchmarking::ScrollBounce(gin::Arguments* args) {
......
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