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

Unified Diff: content/renderer/gpu/gpu_benchmarking_extension.cc

Issue 2742473002: gpu benchmarking swipe for touchpad
Patch Set: Update direction in tests that use swipeElement/Page to maintain the same behavior. Created 3 years, 8 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 | « content/renderer/gpu/gpu_benchmarking_extension.h ('k') | tools/perf/page_sets/key_silk_cases.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « content/renderer/gpu/gpu_benchmarking_extension.h ('k') | tools/perf/page_sets/key_silk_cases.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698