Index: content/renderer/gpu/gpu_benchmarking_extension.cc |
diff --git a/content/renderer/gpu/gpu_benchmarking_extension.cc b/content/renderer/gpu/gpu_benchmarking_extension.cc |
index 431636ebcbb69fec0688c43f60a0297a3d96cfa0..3373a41941bf54150ee24ccafa3aa90ae067419d 100644 |
--- a/content/renderer/gpu/gpu_benchmarking_extension.cc |
+++ b/content/renderer/gpu/gpu_benchmarking_extension.cc |
@@ -341,7 +341,9 @@ bool BeginSmoothScroll(v8::Isolate* isolate, |
float speed_in_pixels_s, |
bool prevent_fling, |
float start_x, |
- float start_y) { |
+ float start_y, |
+ float velocity_x = 0, |
+ float velocity_y = 0) { |
GpuBenchmarkingContext context; |
if (!context.Init(false)) |
return false; |
@@ -388,31 +390,55 @@ bool BeginSmoothScroll(v8::Isolate* isolate, |
start_y * page_scale_factor); |
float distance_length = pixels_to_scroll * page_scale_factor; |
+ |
+ bool set_velocity = |
+ gesture_source_type == SyntheticGestureParams::MOUSE_INPUT && |
+ !prevent_fling; |
+ |
+ if (set_velocity && !velocity_x && !velocity_y) |
+ return false; |
+ |
+ gfx::Vector2dF velocity(0, 0); |
gfx::Vector2dF distance; |
- if (direction == "down") |
+ |
+ if (direction == "down") { |
distance.set_y(-distance_length); |
- else if (direction == "up") |
+ velocity.set_y(-velocity_y); |
+ } else if (direction == "up") { |
distance.set_y(distance_length); |
- else if (direction == "right") |
+ velocity.set_y(velocity_y); |
+ } else if (direction == "right") { |
distance.set_x(-distance_length); |
- else if (direction == "left") |
+ velocity.set_x(-velocity_x); |
+ } else if (direction == "left") { |
distance.set_x(distance_length); |
- else if (direction == "upleft") { |
+ velocity.set_x(velocity_x); |
+ } else if (direction == "upleft") { |
distance.set_y(distance_length); |
distance.set_x(distance_length); |
+ velocity.set_y(velocity_y); |
+ velocity.set_x(velocity_x); |
} else if (direction == "upright") { |
distance.set_y(distance_length); |
distance.set_x(-distance_length); |
+ velocity.set_y(velocity_y); |
+ velocity.set_x(-velocity_x); |
} else if (direction == "downleft") { |
distance.set_y(-distance_length); |
distance.set_x(distance_length); |
+ velocity.set_y(-velocity_y); |
+ velocity.set_x(velocity_x); |
} else if (direction == "downright") { |
distance.set_y(-distance_length); |
distance.set_x(-distance_length); |
+ velocity.set_y(-velocity_y); |
+ velocity.set_x(-velocity_x); |
} else { |
return false; |
} |
+ |
gesture_params->distances.push_back(distance); |
+ gesture_params->velocity = velocity; |
// TODO(678879): If the render_view_impl is destroyed while the gesture is in |
// progress, we will leak the callback and context. This needs to be fixed, |
@@ -757,12 +783,15 @@ bool GpuBenchmarking::Swipe(gin::Arguments* args) { |
float page_scale_factor = context.web_view()->PageScaleFactor(); |
blink::WebRect rect = context.render_view_impl()->GetWidget()->ViewRect(); |
- std::string direction = "up"; |
+ std::string direction = "down"; |
float pixels_to_scroll = 0; |
v8::Local<v8::Function> callback; |
float start_x = rect.width / (page_scale_factor * 2); |
float start_y = rect.height / (page_scale_factor * 2); |
float speed_in_pixels_s = 800; |
+ int gesture_source_type = SyntheticGestureParams::DEFAULT_INPUT; |
+ float velocity_x = 0; |
+ float velocity_y = 0; |
if (!GetOptionalArg(args, &direction) || |
!GetOptionalArg(args, &pixels_to_scroll) || |
@@ -773,15 +802,19 @@ bool GpuBenchmarking::Swipe(gin::Arguments* args) { |
return false; |
} |
- return BeginSmoothScroll(args->isolate(), |
- -pixels_to_scroll, |
- callback, |
- 1, // TOUCH_INPUT |
- direction, |
- speed_in_pixels_s, |
- false, |
- start_x, |
- start_y); |
+ // If no gesture source type is provided, do a touch swipe by default. |
+ if (!GetOptionalArg(args, &gesture_source_type)) |
+ gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; |
+ |
+ if (gesture_source_type == SyntheticGestureParams::MOUSE_INPUT && |
+ (!GetOptionalArg(args, &velocity_x) || |
+ !GetOptionalArg(args, &velocity_y))) { |
+ return false; |
+ } |
+ |
+ return BeginSmoothScroll(args->isolate(), pixels_to_scroll, callback, |
+ gesture_source_type, direction, speed_in_pixels_s, |
+ false, start_x, start_y, velocity_x, velocity_y); |
} |
bool GpuBenchmarking::ScrollBounce(gin::Arguments* args) { |