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

Side by Side Diff: content/renderer/gpu/gpu_benchmarking_extension.cc

Issue 1884883005: Prepare SyntheticPointerAction to handle touch actions for multiple fingers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move logic to controller Created 4 years, 7 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>
11 11
12 #include "base/base64.h" 12 #include "base/base64.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ptr_util.h" 17 #include "base/memory/ptr_util.h"
18 #include "base/strings/string_number_conversions.h" 18 #include "base/strings/string_number_conversions.h"
19 #include "cc/layers/layer.h" 19 #include "cc/layers/layer.h"
20 #include "cc/trees/layer_tree_host.h" 20 #include "cc/trees/layer_tree_host.h"
21 #include "content/common/child_process_messages.h" 21 #include "content/common/child_process_messages.h"
22 #include "content/common/input/synthetic_gesture_params.h" 22 #include "content/common/input/synthetic_gesture_params.h"
23 #include "content/common/input/synthetic_pinch_gesture_params.h" 23 #include "content/common/input/synthetic_pinch_gesture_params.h"
24 #include "content/common/input/synthetic_pointer_action_params.h"
24 #include "content/common/input/synthetic_smooth_drag_gesture_params.h" 25 #include "content/common/input/synthetic_smooth_drag_gesture_params.h"
25 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" 26 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h"
26 #include "content/common/input/synthetic_tap_gesture_params.h" 27 #include "content/common/input/synthetic_tap_gesture_params.h"
27 #include "content/public/child/v8_value_converter.h" 28 #include "content/public/child/v8_value_converter.h"
28 #include "content/public/common/content_switches.h" 29 #include "content/public/common/content_switches.h"
29 #include "content/public/renderer/chrome_object_extensions_utils.h" 30 #include "content/public/renderer/chrome_object_extensions_utils.h"
30 #include "content/public/renderer/render_thread.h" 31 #include "content/public/renderer/render_thread.h"
31 #include "content/renderer/gpu/render_widget_compositor.h" 32 #include "content/renderer/gpu/render_widget_compositor.h"
32 #include "content/renderer/render_thread_impl.h" 33 #include "content/renderer/render_thread_impl.h"
33 #include "content/renderer/render_view_impl.h" 34 #include "content/renderer/render_view_impl.h"
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 .SetMethod("smoothDrag", &GpuBenchmarking::SmoothDrag) 496 .SetMethod("smoothDrag", &GpuBenchmarking::SmoothDrag)
496 .SetMethod("swipe", &GpuBenchmarking::Swipe) 497 .SetMethod("swipe", &GpuBenchmarking::Swipe)
497 .SetMethod("scrollBounce", &GpuBenchmarking::ScrollBounce) 498 .SetMethod("scrollBounce", &GpuBenchmarking::ScrollBounce)
498 .SetMethod("pinchBy", &GpuBenchmarking::PinchBy) 499 .SetMethod("pinchBy", &GpuBenchmarking::PinchBy)
499 .SetMethod("pageScaleFactor", &GpuBenchmarking::PageScaleFactor) 500 .SetMethod("pageScaleFactor", &GpuBenchmarking::PageScaleFactor)
500 .SetMethod("visualViewportX", &GpuBenchmarking::VisualViewportX) 501 .SetMethod("visualViewportX", &GpuBenchmarking::VisualViewportX)
501 .SetMethod("visualViewportY", &GpuBenchmarking::VisualViewportY) 502 .SetMethod("visualViewportY", &GpuBenchmarking::VisualViewportY)
502 .SetMethod("visualViewportHeight", &GpuBenchmarking::VisualViewportHeight) 503 .SetMethod("visualViewportHeight", &GpuBenchmarking::VisualViewportHeight)
503 .SetMethod("visualViewportWidth", &GpuBenchmarking::VisualViewportWidth) 504 .SetMethod("visualViewportWidth", &GpuBenchmarking::VisualViewportWidth)
504 .SetMethod("tap", &GpuBenchmarking::Tap) 505 .SetMethod("tap", &GpuBenchmarking::Tap)
506 .SetMethod("touchActionSequence", &GpuBenchmarking::TouchActionSequence)
505 .SetMethod("clearImageCache", &GpuBenchmarking::ClearImageCache) 507 .SetMethod("clearImageCache", &GpuBenchmarking::ClearImageCache)
506 .SetMethod("runMicroBenchmark", &GpuBenchmarking::RunMicroBenchmark) 508 .SetMethod("runMicroBenchmark", &GpuBenchmarking::RunMicroBenchmark)
507 .SetMethod("sendMessageToMicroBenchmark", 509 .SetMethod("sendMessageToMicroBenchmark",
508 &GpuBenchmarking::SendMessageToMicroBenchmark) 510 &GpuBenchmarking::SendMessageToMicroBenchmark)
509 .SetMethod("hasGpuChannel", &GpuBenchmarking::HasGpuChannel) 511 .SetMethod("hasGpuChannel", &GpuBenchmarking::HasGpuChannel)
510 .SetMethod("hasGpuProcess", &GpuBenchmarking::HasGpuProcess) 512 .SetMethod("hasGpuProcess", &GpuBenchmarking::HasGpuProcess)
511 .SetMethod("getGpuDriverBugWorkarounds", 513 .SetMethod("getGpuDriverBugWorkarounds",
512 &GpuBenchmarking::GetGpuDriverBugWorkarounds); 514 &GpuBenchmarking::GetGpuDriverBugWorkarounds);
513 } 515 }
514 516
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 // progress, we will leak the callback and context. This needs to be fixed, 878 // progress, we will leak the callback and context. This needs to be fixed,
877 // somehow. 879 // somehow.
878 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( 880 context.render_view_impl()->GetWidget()->QueueSyntheticGesture(
879 std::move(gesture_params), 881 std::move(gesture_params),
880 base::Bind(&OnSyntheticGestureCompleted, 882 base::Bind(&OnSyntheticGestureCompleted,
881 base::RetainedRef(callback_and_context))); 883 base::RetainedRef(callback_and_context)));
882 884
883 return true; 885 return true;
884 } 886 }
885 887
888 bool GpuBenchmarking::TouchActionSequence(gin::Arguments* args) {
tdresser 2016/05/13 13:58:04 This patch is getting a little big - maybe we coul
lanwei 2016/05/19 16:04:13 Sure. I will remove this file from this patch.
889 GpuBenchmarkingContext context;
890 if (!context.Init(false))
891 return false;
892
893 v8::Local<v8::Function> callback;
894
895 // pass a two-dimensional list of actions.
896
897 int pointer_action_type_int;
898 int index;
899 float position_x;
900 float position_y;
901 int gesture_source_type = SyntheticGestureParams::DEFAULT_INPUT;
902 SyntheticPointerActionParams::PointerActionType pointer_action_type;
903 if (!GetArg(args, &pointer_action_type_int)) {
904 return false;
905 }
906 pointer_action_type =
907 static_cast<SyntheticPointerActionParams::PointerActionType>(
908 pointer_action_type_int);
909 std::unique_ptr<SyntheticPointerActionParams> gesture_params(
910 new SyntheticPointerActionParams(pointer_action_type));
911
912 if (pointer_action_type !=
913 SyntheticPointerActionParams::PointerActionType::PROCESS &&
914 pointer_action_type !=
915 SyntheticPointerActionParams::PointerActionType::FINISH) {
916 if (!GetArg(args, &index)) {
917 return false;
918 }
919 gesture_params->set_index(index);
920 if (pointer_action_type ==
921 SyntheticPointerActionParams::PointerActionType::PRESS ||
922 pointer_action_type ==
923 SyntheticPointerActionParams::PointerActionType::MOVE) {
924 if (!GetArg(args, &position_x) || !GetArg(args, &position_y)) {
925 return false;
926 }
927 gesture_params->set_position(gfx::PointF(position_x, position_y));
928 }
929 }
930
931 if (!GetOptionalArg(args, &gesture_source_type)) {
932 return false;
933 }
934
935 if (pointer_action_type !=
936 SyntheticPointerActionParams::PointerActionType::FINISH) {
937 context.render_view_impl()->GetWidget()->QueueSyntheticGesture(
938 std::move(gesture_params));
939 return true;
940 }
941
942 // At the end, we will send a 'FINISH' action and need a callback.
943 scoped_refptr<CallbackAndContext> callback_and_context =
944 new CallbackAndContext(args->isolate(), callback,
945 context.web_frame()->mainWorldScriptContext());
946 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in
947 // progress, we will leak the callback and context. This needs to be fixed,
948 // somehow.
949 context.render_view_impl()->GetWidget()->QueueSyntheticGesture(
950 std::move(gesture_params),
951 base::Bind(&OnSyntheticGestureCompleted,
952 base::RetainedRef(callback_and_context)));
953 return true;
954 }
955
886 void GpuBenchmarking::ClearImageCache() { 956 void GpuBenchmarking::ClearImageCache() {
887 WebImageCache::clear(); 957 WebImageCache::clear();
888 } 958 }
889 959
890 int GpuBenchmarking::RunMicroBenchmark(gin::Arguments* args) { 960 int GpuBenchmarking::RunMicroBenchmark(gin::Arguments* args) {
891 GpuBenchmarkingContext context; 961 GpuBenchmarkingContext context;
892 if (!context.Init(true)) 962 if (!context.Init(true))
893 return 0; 963 return 0;
894 964
895 std::string name; 965 std::string name;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 &gpu_driver_bug_workarounds))) { 1029 &gpu_driver_bug_workarounds))) {
960 return; 1030 return;
961 } 1031 }
962 1032
963 v8::Local<v8::Value> result; 1033 v8::Local<v8::Value> result;
964 if (gin::TryConvertToV8(args->isolate(), gpu_driver_bug_workarounds, &result)) 1034 if (gin::TryConvertToV8(args->isolate(), gpu_driver_bug_workarounds, &result))
965 args->Return(result); 1035 args->Return(result);
966 } 1036 }
967 1037
968 } // namespace content 1038 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698