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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/gpu/gpu_benchmarking_extension.h" 5 #include "content/renderer/gpu/gpu_benchmarking_extension.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 } 334 }
335 335
336 bool BeginSmoothScroll(v8::Isolate* isolate, 336 bool BeginSmoothScroll(v8::Isolate* isolate,
337 float pixels_to_scroll, 337 float pixels_to_scroll,
338 v8::Local<v8::Function> callback, 338 v8::Local<v8::Function> callback,
339 int gesture_source_type, 339 int gesture_source_type,
340 const std::string& direction, 340 const std::string& direction,
341 float speed_in_pixels_s, 341 float speed_in_pixels_s,
342 bool prevent_fling, 342 bool prevent_fling,
343 float start_x, 343 float start_x,
344 float start_y) { 344 float start_y,
345 float velocity_x = 0,
346 float velocity_y = 0) {
345 GpuBenchmarkingContext context; 347 GpuBenchmarkingContext context;
346 if (!context.Init(false)) 348 if (!context.Init(false))
347 return false; 349 return false;
348 350
349 // Convert coordinates from CSS pixels to density independent pixels (DIPs). 351 // Convert coordinates from CSS pixels to density independent pixels (DIPs).
350 float page_scale_factor = context.web_view()->PageScaleFactor(); 352 float page_scale_factor = context.web_view()->PageScaleFactor();
351 353
352 if (gesture_source_type == SyntheticGestureParams::MOUSE_INPUT) { 354 if (gesture_source_type == SyntheticGestureParams::MOUSE_INPUT) {
353 // Ensure the mouse is centered and visible, in case it will 355 // Ensure the mouse is centered and visible, in case it will
354 // trigger any hover or mousemove effects. 356 // trigger any hover or mousemove effects.
(...skipping 26 matching lines...) Expand all
381 static_cast<SyntheticGestureParams::GestureSourceType>( 383 static_cast<SyntheticGestureParams::GestureSourceType>(
382 gesture_source_type); 384 gesture_source_type);
383 385
384 gesture_params->speed_in_pixels_s = speed_in_pixels_s; 386 gesture_params->speed_in_pixels_s = speed_in_pixels_s;
385 gesture_params->prevent_fling = prevent_fling; 387 gesture_params->prevent_fling = prevent_fling;
386 388
387 gesture_params->anchor.SetPoint(start_x * page_scale_factor, 389 gesture_params->anchor.SetPoint(start_x * page_scale_factor,
388 start_y * page_scale_factor); 390 start_y * page_scale_factor);
389 391
390 float distance_length = pixels_to_scroll * page_scale_factor; 392 float distance_length = pixels_to_scroll * page_scale_factor;
393
394 bool set_velocity =
395 gesture_source_type == SyntheticGestureParams::MOUSE_INPUT &&
396 !prevent_fling;
397
398 if (set_velocity && !velocity_x && !velocity_y)
399 return false;
400
401 gfx::Vector2dF velocity(0, 0);
391 gfx::Vector2dF distance; 402 gfx::Vector2dF distance;
392 if (direction == "down") 403
404 if (direction == "down") {
393 distance.set_y(-distance_length); 405 distance.set_y(-distance_length);
394 else if (direction == "up") 406 velocity.set_y(-velocity_y);
407 } else if (direction == "up") {
395 distance.set_y(distance_length); 408 distance.set_y(distance_length);
396 else if (direction == "right") 409 velocity.set_y(velocity_y);
410 } else if (direction == "right") {
397 distance.set_x(-distance_length); 411 distance.set_x(-distance_length);
398 else if (direction == "left") 412 velocity.set_x(-velocity_x);
413 } else if (direction == "left") {
399 distance.set_x(distance_length); 414 distance.set_x(distance_length);
400 else if (direction == "upleft") { 415 velocity.set_x(velocity_x);
416 } else if (direction == "upleft") {
401 distance.set_y(distance_length); 417 distance.set_y(distance_length);
402 distance.set_x(distance_length); 418 distance.set_x(distance_length);
419 velocity.set_y(velocity_y);
420 velocity.set_x(velocity_x);
403 } else if (direction == "upright") { 421 } else if (direction == "upright") {
404 distance.set_y(distance_length); 422 distance.set_y(distance_length);
405 distance.set_x(-distance_length); 423 distance.set_x(-distance_length);
424 velocity.set_y(velocity_y);
425 velocity.set_x(-velocity_x);
406 } else if (direction == "downleft") { 426 } else if (direction == "downleft") {
407 distance.set_y(-distance_length); 427 distance.set_y(-distance_length);
408 distance.set_x(distance_length); 428 distance.set_x(distance_length);
429 velocity.set_y(-velocity_y);
430 velocity.set_x(velocity_x);
409 } else if (direction == "downright") { 431 } else if (direction == "downright") {
410 distance.set_y(-distance_length); 432 distance.set_y(-distance_length);
411 distance.set_x(-distance_length); 433 distance.set_x(-distance_length);
434 velocity.set_y(-velocity_y);
435 velocity.set_x(-velocity_x);
412 } else { 436 } else {
413 return false; 437 return false;
414 } 438 }
439
415 gesture_params->distances.push_back(distance); 440 gesture_params->distances.push_back(distance);
441 gesture_params->velocity = velocity;
416 442
417 // TODO(678879): If the render_view_impl is destroyed while the gesture is in 443 // TODO(678879): If the render_view_impl is destroyed while the gesture is in
418 // progress, we will leak the callback and context. This needs to be fixed, 444 // progress, we will leak the callback and context. This needs to be fixed,
419 // somehow, see https://crbug.com/678879. 445 // somehow, see https://crbug.com/678879.
420 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( 446 context.render_view_impl()->GetWidget()->QueueSyntheticGesture(
421 std::move(gesture_params), 447 std::move(gesture_params),
422 base::Bind(&OnSyntheticGestureCompleted, 448 base::Bind(&OnSyntheticGestureCompleted,
423 base::RetainedRef(callback_and_context))); 449 base::RetainedRef(callback_and_context)));
424 450
425 return true; 451 return true;
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 } 776 }
751 777
752 bool GpuBenchmarking::Swipe(gin::Arguments* args) { 778 bool GpuBenchmarking::Swipe(gin::Arguments* args) {
753 GpuBenchmarkingContext context; 779 GpuBenchmarkingContext context;
754 if (!context.Init(true)) 780 if (!context.Init(true))
755 return false; 781 return false;
756 782
757 float page_scale_factor = context.web_view()->PageScaleFactor(); 783 float page_scale_factor = context.web_view()->PageScaleFactor();
758 blink::WebRect rect = context.render_view_impl()->GetWidget()->ViewRect(); 784 blink::WebRect rect = context.render_view_impl()->GetWidget()->ViewRect();
759 785
760 std::string direction = "up"; 786 std::string direction = "down";
761 float pixels_to_scroll = 0; 787 float pixels_to_scroll = 0;
762 v8::Local<v8::Function> callback; 788 v8::Local<v8::Function> callback;
763 float start_x = rect.width / (page_scale_factor * 2); 789 float start_x = rect.width / (page_scale_factor * 2);
764 float start_y = rect.height / (page_scale_factor * 2); 790 float start_y = rect.height / (page_scale_factor * 2);
765 float speed_in_pixels_s = 800; 791 float speed_in_pixels_s = 800;
792 int gesture_source_type = SyntheticGestureParams::DEFAULT_INPUT;
793 float velocity_x = 0;
794 float velocity_y = 0;
766 795
767 if (!GetOptionalArg(args, &direction) || 796 if (!GetOptionalArg(args, &direction) ||
768 !GetOptionalArg(args, &pixels_to_scroll) || 797 !GetOptionalArg(args, &pixels_to_scroll) ||
769 !GetOptionalArg(args, &callback) || 798 !GetOptionalArg(args, &callback) ||
770 !GetOptionalArg(args, &start_x) || 799 !GetOptionalArg(args, &start_x) ||
771 !GetOptionalArg(args, &start_y) || 800 !GetOptionalArg(args, &start_y) ||
772 !GetOptionalArg(args, &speed_in_pixels_s)) { 801 !GetOptionalArg(args, &speed_in_pixels_s)) {
773 return false; 802 return false;
774 } 803 }
775 804
776 return BeginSmoothScroll(args->isolate(), 805 // If no gesture source type is provided, do a touch swipe by default.
777 -pixels_to_scroll, 806 if (!GetOptionalArg(args, &gesture_source_type))
778 callback, 807 gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
779 1, // TOUCH_INPUT 808
780 direction, 809 if (gesture_source_type == SyntheticGestureParams::MOUSE_INPUT &&
781 speed_in_pixels_s, 810 (!GetOptionalArg(args, &velocity_x) ||
782 false, 811 !GetOptionalArg(args, &velocity_y))) {
783 start_x, 812 return false;
784 start_y); 813 }
814
815 return BeginSmoothScroll(args->isolate(), pixels_to_scroll, callback,
816 gesture_source_type, direction, speed_in_pixels_s,
817 false, start_x, start_y, velocity_x, velocity_y);
785 } 818 }
786 819
787 bool GpuBenchmarking::ScrollBounce(gin::Arguments* args) { 820 bool GpuBenchmarking::ScrollBounce(gin::Arguments* args) {
788 GpuBenchmarkingContext context; 821 GpuBenchmarkingContext context;
789 if (!context.Init(false)) 822 if (!context.Init(false))
790 return false; 823 return false;
791 824
792 float page_scale_factor = context.web_view()->PageScaleFactor(); 825 float page_scale_factor = context.web_view()->PageScaleFactor();
793 blink::WebRect rect = context.render_view_impl()->GetWidget()->ViewRect(); 826 blink::WebRect rect = context.render_view_impl()->GetWidget()->ViewRect();
794 827
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 &gpu_driver_bug_workarounds))) { 1163 &gpu_driver_bug_workarounds))) {
1131 return; 1164 return;
1132 } 1165 }
1133 1166
1134 v8::Local<v8::Value> result; 1167 v8::Local<v8::Value> result;
1135 if (gin::TryConvertToV8(args->isolate(), gpu_driver_bug_workarounds, &result)) 1168 if (gin::TryConvertToV8(args->isolate(), gpu_driver_bug_workarounds, &result))
1136 args->Return(result); 1169 args->Return(result);
1137 } 1170 }
1138 1171
1139 } // namespace content 1172 } // namespace content
OLDNEW
« 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