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

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

Issue 2742473002: gpu benchmarking swipe for touchpad
Patch Set: gpu benchmarking swipe for touchpad Created 3 years, 9 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
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 1cabf083f5f5f9ef6763f6b639c883950ee1dfe1..d0e729ff083496d618a7e6a2aaab6873ab11f6a7 100644
--- a/content/renderer/gpu/gpu_benchmarking_extension.cc
+++ b/content/renderer/gpu/gpu_benchmarking_extension.cc
@@ -337,7 +337,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;
@@ -383,31 +385,56 @@ 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;
+
+ DCHECK(!set_velocity || velocity_x || velocity_y);
+ if (set_velocity && !velocity_x && !velocity_y)
bokan 2017/03/10 14:41:57 Ditto here for the DCHECK and |if|
sahel 2017/03/10 21:51:41 Done.
+ return false;
+
+ gfx::Vector2dF velocity;
gfx::Vector2dF distance;
- if (direction == "down")
+
+ if (direction == "down") {
bokan 2017/03/10 14:41:57 Question: do we really need this direction paramet
sahel 2017/03/10 21:51:41 I am not sure why we have it here, but one reason
distance.set_y(-distance_length);
- else if (direction == "up")
+ velocity.set_y(set_velocity ? -velocity_y : 0);
+ } else if (direction == "up") {
distance.set_y(distance_length);
- else if (direction == "right")
+ velocity.set_y(set_velocity ? velocity_y : 0);
+ } else if (direction == "right") {
distance.set_x(-distance_length);
- else if (direction == "left")
+ velocity.set_x(set_velocity ? -velocity_x : 0);
+ } else if (direction == "left") {
distance.set_x(distance_length);
- else if (direction == "upleft") {
+ velocity.set_x(set_velocity ? velocity_x : 0);
+ } else if (direction == "upleft") {
distance.set_y(distance_length);
distance.set_x(distance_length);
+ velocity.set_y(set_velocity ? velocity_y : 0);
+ velocity.set_x(set_velocity ? velocity_x : 0);
} else if (direction == "upright") {
distance.set_y(distance_length);
distance.set_x(-distance_length);
+ velocity.set_y(set_velocity ? velocity_y : 0);
+ velocity.set_x(set_velocity ? -velocity_x : 0);
} else if (direction == "downleft") {
distance.set_y(-distance_length);
distance.set_x(distance_length);
+ velocity.set_y(set_velocity ? -velocity_y : 0);
+ velocity.set_x(set_velocity ? velocity_x : 0);
} else if (direction == "downright") {
distance.set_y(-distance_length);
distance.set_x(-distance_length);
+ velocity.set_y(set_velocity ? -velocity_y : 0);
+ velocity.set_x(set_velocity ? -velocity_x : 0);
} 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,
@@ -722,12 +749,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) ||
@@ -738,15 +768,22 @@ bool GpuBenchmarking::Swipe(gin::Arguments* args) {
return false;
}
+ // 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;
+ }
+
+ float direction_adjustment = SyntheticGestureParams::TOUCH_INPUT ? 1 : -1;
return BeginSmoothScroll(args->isolate(),
- -pixels_to_scroll,
- callback,
- 1, // TOUCH_INPUT
- direction,
- speed_in_pixels_s,
- false,
- start_x,
- start_y);
+ direction_adjustment * 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) {

Powered by Google App Engine
This is Rietveld 408576698