Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "content/common/child_process_messages.h" | 20 #include "content/common/child_process_messages.h" |
| 21 #include "content/common/input/synthetic_gesture_params.h" | 21 #include "content/common/input/synthetic_gesture_params.h" |
| 22 #include "content/common/input/synthetic_pinch_gesture_params.h" | 22 #include "content/common/input/synthetic_pinch_gesture_params.h" |
| 23 #include "content/common/input/synthetic_pointer_action_list_params.h" | |
| 24 #include "content/common/input/synthetic_pointer_action_params.h" | |
| 23 #include "content/common/input/synthetic_smooth_drag_gesture_params.h" | 25 #include "content/common/input/synthetic_smooth_drag_gesture_params.h" |
| 24 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" | 26 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" |
| 25 #include "content/common/input/synthetic_tap_gesture_params.h" | 27 #include "content/common/input/synthetic_tap_gesture_params.h" |
| 26 #include "content/public/child/v8_value_converter.h" | 28 #include "content/public/child/v8_value_converter.h" |
| 27 #include "content/public/common/content_switches.h" | 29 #include "content/public/common/content_switches.h" |
| 28 #include "content/public/renderer/chrome_object_extensions_utils.h" | 30 #include "content/public/renderer/chrome_object_extensions_utils.h" |
| 29 #include "content/public/renderer/render_thread.h" | 31 #include "content/public/renderer/render_thread.h" |
| 30 #include "content/renderer/gpu/render_widget_compositor.h" | 32 #include "content/renderer/gpu/render_widget_compositor.h" |
| 31 #include "content/renderer/render_thread_impl.h" | 33 #include "content/renderer/render_thread_impl.h" |
| 32 #include "content/renderer/render_view_impl.h" | 34 #include "content/renderer/render_view_impl.h" |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 .SetMethod("smoothDrag", &GpuBenchmarking::SmoothDrag) | 504 .SetMethod("smoothDrag", &GpuBenchmarking::SmoothDrag) |
| 503 .SetMethod("swipe", &GpuBenchmarking::Swipe) | 505 .SetMethod("swipe", &GpuBenchmarking::Swipe) |
| 504 .SetMethod("scrollBounce", &GpuBenchmarking::ScrollBounce) | 506 .SetMethod("scrollBounce", &GpuBenchmarking::ScrollBounce) |
| 505 .SetMethod("pinchBy", &GpuBenchmarking::PinchBy) | 507 .SetMethod("pinchBy", &GpuBenchmarking::PinchBy) |
| 506 .SetMethod("pageScaleFactor", &GpuBenchmarking::PageScaleFactor) | 508 .SetMethod("pageScaleFactor", &GpuBenchmarking::PageScaleFactor) |
| 507 .SetMethod("visualViewportX", &GpuBenchmarking::VisualViewportX) | 509 .SetMethod("visualViewportX", &GpuBenchmarking::VisualViewportX) |
| 508 .SetMethod("visualViewportY", &GpuBenchmarking::VisualViewportY) | 510 .SetMethod("visualViewportY", &GpuBenchmarking::VisualViewportY) |
| 509 .SetMethod("visualViewportHeight", &GpuBenchmarking::VisualViewportHeight) | 511 .SetMethod("visualViewportHeight", &GpuBenchmarking::VisualViewportHeight) |
| 510 .SetMethod("visualViewportWidth", &GpuBenchmarking::VisualViewportWidth) | 512 .SetMethod("visualViewportWidth", &GpuBenchmarking::VisualViewportWidth) |
| 511 .SetMethod("tap", &GpuBenchmarking::Tap) | 513 .SetMethod("tap", &GpuBenchmarking::Tap) |
| 514 .SetMethod("touchActionSequence", &GpuBenchmarking::TouchActionSequence) | |
| 512 .SetMethod("clearImageCache", &GpuBenchmarking::ClearImageCache) | 515 .SetMethod("clearImageCache", &GpuBenchmarking::ClearImageCache) |
| 513 .SetMethod("runMicroBenchmark", &GpuBenchmarking::RunMicroBenchmark) | 516 .SetMethod("runMicroBenchmark", &GpuBenchmarking::RunMicroBenchmark) |
| 514 .SetMethod("sendMessageToMicroBenchmark", | 517 .SetMethod("sendMessageToMicroBenchmark", |
| 515 &GpuBenchmarking::SendMessageToMicroBenchmark) | 518 &GpuBenchmarking::SendMessageToMicroBenchmark) |
| 516 .SetMethod("hasGpuChannel", &GpuBenchmarking::HasGpuChannel) | 519 .SetMethod("hasGpuChannel", &GpuBenchmarking::HasGpuChannel) |
| 517 .SetMethod("hasGpuProcess", &GpuBenchmarking::HasGpuProcess) | 520 .SetMethod("hasGpuProcess", &GpuBenchmarking::HasGpuProcess) |
| 518 .SetMethod("getGpuDriverBugWorkarounds", | 521 .SetMethod("getGpuDriverBugWorkarounds", |
| 519 &GpuBenchmarking::GetGpuDriverBugWorkarounds); | 522 &GpuBenchmarking::GetGpuDriverBugWorkarounds); |
| 520 } | 523 } |
| 521 | 524 |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 922 // progress, we will leak the callback and context. This needs to be fixed, | 925 // progress, we will leak the callback and context. This needs to be fixed, |
| 923 // somehow. | 926 // somehow. |
| 924 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( | 927 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( |
| 925 std::move(gesture_params), | 928 std::move(gesture_params), |
| 926 base::Bind(&OnSyntheticGestureCompleted, | 929 base::Bind(&OnSyntheticGestureCompleted, |
| 927 base::RetainedRef(callback_and_context))); | 930 base::RetainedRef(callback_and_context))); |
| 928 | 931 |
| 929 return true; | 932 return true; |
| 930 } | 933 } |
| 931 | 934 |
| 935 bool GpuBenchmarking::TouchActionSequence(gin::Arguments* args) { | |
| 936 GpuBenchmarkingContext context; | |
| 937 if (!context.Init(false)) | |
| 938 return false; | |
| 939 | |
| 940 v8::Local<v8::Function> callback; | |
| 941 // pass a two-dimensional list of actions. | |
| 942 int pointer_action_type_int; | |
| 943 int index; | |
| 944 float position_x; | |
| 945 float position_y; | |
| 946 int gesture_source_type = SyntheticGestureParams::DEFAULT_INPUT; | |
| 947 SyntheticPointerActionParams::PointerActionType pointer_action_type; | |
| 948 if (!GetArg(args, &pointer_action_type_int)) { | |
|
lanwei
2016/09/15 20:26:50
This is a simple version of getting just one actio
samuong
2016/09/23 12:53:40
Since this is just sample code, maybe this should
| |
| 949 return false; | |
| 950 } | |
| 951 pointer_action_type = | |
| 952 static_cast<SyntheticPointerActionParams::PointerActionType>( | |
| 953 pointer_action_type_int); | |
| 954 SyntheticPointerActionParams gesture_params(pointer_action_type); | |
| 955 | |
| 956 if (pointer_action_type != | |
| 957 SyntheticPointerActionParams::PointerActionType::PROCESS && | |
| 958 pointer_action_type != | |
| 959 SyntheticPointerActionParams::PointerActionType::FINISH) { | |
| 960 if (!GetArg(args, &index)) { | |
| 961 return false; | |
| 962 } | |
| 963 gesture_params.set_index(index); | |
| 964 if (pointer_action_type == | |
| 965 SyntheticPointerActionParams::PointerActionType::PRESS || | |
| 966 pointer_action_type == | |
| 967 SyntheticPointerActionParams::PointerActionType::MOVE) { | |
| 968 if (!GetArg(args, &position_x) || !GetArg(args, &position_y)) { | |
| 969 return false; | |
| 970 } | |
| 971 gesture_params.set_position(gfx::PointF(position_x, position_y)); | |
| 972 } | |
| 973 } | |
| 974 | |
| 975 if (!GetOptionalArg(args, &gesture_source_type)) { | |
| 976 return false; | |
| 977 } | |
| 978 | |
| 979 std::unique_ptr<SyntheticPointerActionListParams> gesture_params_list( | |
| 980 new SyntheticPointerActionListParams(gesture_params)); | |
| 981 | |
| 982 // At the end, we will send a 'FINISH' action and need a callback. | |
| 983 scoped_refptr<CallbackAndContext> callback_and_context = | |
| 984 new CallbackAndContext(args->isolate(), callback, | |
| 985 context.web_frame()->mainWorldScriptContext()); | |
| 986 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in | |
| 987 // progress, we will leak the callback and context. This needs to be fixed, | |
| 988 // somehow. | |
| 989 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( | |
| 990 std::move(gesture_params_list), | |
| 991 base::Bind(&OnSyntheticGestureCompleted, | |
| 992 base::RetainedRef(callback_and_context))); | |
| 993 return true; | |
| 994 } | |
| 995 | |
| 932 void GpuBenchmarking::ClearImageCache() { | 996 void GpuBenchmarking::ClearImageCache() { |
| 933 WebImageCache::clear(); | 997 WebImageCache::clear(); |
| 934 } | 998 } |
| 935 | 999 |
| 936 int GpuBenchmarking::RunMicroBenchmark(gin::Arguments* args) { | 1000 int GpuBenchmarking::RunMicroBenchmark(gin::Arguments* args) { |
| 937 GpuBenchmarkingContext context; | 1001 GpuBenchmarkingContext context; |
| 938 if (!context.Init(true)) | 1002 if (!context.Init(true)) |
| 939 return 0; | 1003 return 0; |
| 940 | 1004 |
| 941 std::string name; | 1005 std::string name; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1006 &gpu_driver_bug_workarounds))) { | 1070 &gpu_driver_bug_workarounds))) { |
| 1007 return; | 1071 return; |
| 1008 } | 1072 } |
| 1009 | 1073 |
| 1010 v8::Local<v8::Value> result; | 1074 v8::Local<v8::Value> result; |
| 1011 if (gin::TryConvertToV8(args->isolate(), gpu_driver_bug_workarounds, &result)) | 1075 if (gin::TryConvertToV8(args->isolate(), gpu_driver_bug_workarounds, &result)) |
| 1012 args->Return(result); | 1076 args->Return(result); |
| 1013 } | 1077 } |
| 1014 | 1078 |
| 1015 } // namespace content | 1079 } // namespace content |
| OLD | NEW |