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" |
| 32 #include "content/renderer/gpu/actions_runner.h" |
30 #include "content/renderer/gpu/render_widget_compositor.h" | 33 #include "content/renderer/gpu/render_widget_compositor.h" |
31 #include "content/renderer/render_thread_impl.h" | 34 #include "content/renderer/render_thread_impl.h" |
32 #include "content/renderer/render_view_impl.h" | 35 #include "content/renderer/render_view_impl.h" |
33 #include "content/renderer/skia_benchmarking_extension.h" | 36 #include "content/renderer/skia_benchmarking_extension.h" |
34 #include "gin/arguments.h" | 37 #include "gin/arguments.h" |
35 #include "gin/handle.h" | 38 #include "gin/handle.h" |
36 #include "gin/object_template_builder.h" | 39 #include "gin/object_template_builder.h" |
37 #include "gpu/ipc/common/gpu_messages.h" | 40 #include "gpu/ipc/common/gpu_messages.h" |
38 #include "third_party/WebKit/public/web/WebImageCache.h" | 41 #include "third_party/WebKit/public/web/WebImageCache.h" |
39 #include "third_party/WebKit/public/web/WebKit.h" | 42 #include "third_party/WebKit/public/web/WebKit.h" |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 gin::ObjectTemplateBuilder GpuBenchmarking::GetObjectTemplateBuilder( | 539 gin::ObjectTemplateBuilder GpuBenchmarking::GetObjectTemplateBuilder( |
537 v8::Isolate* isolate) { | 540 v8::Isolate* isolate) { |
538 return gin::Wrappable<GpuBenchmarking>::GetObjectTemplateBuilder(isolate) | 541 return gin::Wrappable<GpuBenchmarking>::GetObjectTemplateBuilder(isolate) |
539 .SetMethod("setNeedsDisplayOnAllLayers", | 542 .SetMethod("setNeedsDisplayOnAllLayers", |
540 &GpuBenchmarking::SetNeedsDisplayOnAllLayers) | 543 &GpuBenchmarking::SetNeedsDisplayOnAllLayers) |
541 .SetMethod("setRasterizeOnlyVisibleContent", | 544 .SetMethod("setRasterizeOnlyVisibleContent", |
542 &GpuBenchmarking::SetRasterizeOnlyVisibleContent) | 545 &GpuBenchmarking::SetRasterizeOnlyVisibleContent) |
543 .SetMethod("printToSkPicture", &GpuBenchmarking::PrintToSkPicture) | 546 .SetMethod("printToSkPicture", &GpuBenchmarking::PrintToSkPicture) |
544 .SetMethod("printPagesToSkPictures", | 547 .SetMethod("printPagesToSkPictures", |
545 &GpuBenchmarking::PrintPagesToSkPictures) | 548 &GpuBenchmarking::PrintPagesToSkPictures) |
546 .SetMethod("printPagesToXPS", | 549 .SetMethod("printPagesToXPS", &GpuBenchmarking::PrintPagesToXPS) |
547 &GpuBenchmarking::PrintPagesToXPS) | |
548 .SetValue("DEFAULT_INPUT", 0) | 550 .SetValue("DEFAULT_INPUT", 0) |
549 .SetValue("TOUCH_INPUT", 1) | 551 .SetValue("TOUCH_INPUT", 1) |
550 .SetValue("MOUSE_INPUT", 2) | 552 .SetValue("MOUSE_INPUT", 2) |
551 .SetMethod("gestureSourceTypeSupported", | 553 .SetMethod("gestureSourceTypeSupported", |
552 &GpuBenchmarking::GestureSourceTypeSupported) | 554 &GpuBenchmarking::GestureSourceTypeSupported) |
553 .SetMethod("smoothScrollBy", &GpuBenchmarking::SmoothScrollBy) | 555 .SetMethod("smoothScrollBy", &GpuBenchmarking::SmoothScrollBy) |
554 .SetMethod("smoothDrag", &GpuBenchmarking::SmoothDrag) | 556 .SetMethod("smoothDrag", &GpuBenchmarking::SmoothDrag) |
555 .SetMethod("swipe", &GpuBenchmarking::Swipe) | 557 .SetMethod("swipe", &GpuBenchmarking::Swipe) |
556 .SetMethod("scrollBounce", &GpuBenchmarking::ScrollBounce) | 558 .SetMethod("scrollBounce", &GpuBenchmarking::ScrollBounce) |
557 .SetMethod("pinchBy", &GpuBenchmarking::PinchBy) | 559 .SetMethod("pinchBy", &GpuBenchmarking::PinchBy) |
558 .SetMethod("pageScaleFactor", &GpuBenchmarking::PageScaleFactor) | 560 .SetMethod("pageScaleFactor", &GpuBenchmarking::PageScaleFactor) |
559 .SetMethod("visualViewportX", &GpuBenchmarking::VisualViewportX) | 561 .SetMethod("visualViewportX", &GpuBenchmarking::VisualViewportX) |
560 .SetMethod("visualViewportY", &GpuBenchmarking::VisualViewportY) | 562 .SetMethod("visualViewportY", &GpuBenchmarking::VisualViewportY) |
561 .SetMethod("visualViewportHeight", &GpuBenchmarking::VisualViewportHeight) | 563 .SetMethod("visualViewportHeight", &GpuBenchmarking::VisualViewportHeight) |
562 .SetMethod("visualViewportWidth", &GpuBenchmarking::VisualViewportWidth) | 564 .SetMethod("visualViewportWidth", &GpuBenchmarking::VisualViewportWidth) |
563 .SetMethod("tap", &GpuBenchmarking::Tap) | 565 .SetMethod("tap", &GpuBenchmarking::Tap) |
564 .SetMethod("clearImageCache", &GpuBenchmarking::ClearImageCache) | 566 .SetMethod("clearImageCache", &GpuBenchmarking::ClearImageCache) |
565 .SetMethod("runMicroBenchmark", &GpuBenchmarking::RunMicroBenchmark) | 567 .SetMethod("runMicroBenchmark", &GpuBenchmarking::RunMicroBenchmark) |
566 .SetMethod("sendMessageToMicroBenchmark", | 568 .SetMethod("sendMessageToMicroBenchmark", |
567 &GpuBenchmarking::SendMessageToMicroBenchmark) | 569 &GpuBenchmarking::SendMessageToMicroBenchmark) |
568 .SetMethod("hasGpuChannel", &GpuBenchmarking::HasGpuChannel) | 570 .SetMethod("hasGpuChannel", &GpuBenchmarking::HasGpuChannel) |
569 .SetMethod("hasGpuProcess", &GpuBenchmarking::HasGpuProcess) | 571 .SetMethod("hasGpuProcess", &GpuBenchmarking::HasGpuProcess) |
570 .SetMethod("getGpuDriverBugWorkarounds", | 572 .SetMethod("getGpuDriverBugWorkarounds", |
571 &GpuBenchmarking::GetGpuDriverBugWorkarounds); | 573 &GpuBenchmarking::GetGpuDriverBugWorkarounds) |
| 574 .SetMethod("pointerActionSequence", |
| 575 &GpuBenchmarking::PointerActionSequence); |
572 } | 576 } |
573 | 577 |
574 void GpuBenchmarking::SetNeedsDisplayOnAllLayers() { | 578 void GpuBenchmarking::SetNeedsDisplayOnAllLayers() { |
575 GpuBenchmarkingContext context; | 579 GpuBenchmarkingContext context; |
576 if (!context.Init(true)) | 580 if (!context.Init(true)) |
577 return; | 581 return; |
578 | 582 |
579 context.compositor()->SetNeedsDisplayOnAllLayers(); | 583 context.compositor()->SetNeedsDisplayOnAllLayers(); |
580 } | 584 } |
581 | 585 |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 !gpu_channel->Send(new GpuChannelMsg_GetDriverBugWorkArounds( | 1045 !gpu_channel->Send(new GpuChannelMsg_GetDriverBugWorkArounds( |
1042 &gpu_driver_bug_workarounds))) { | 1046 &gpu_driver_bug_workarounds))) { |
1043 return; | 1047 return; |
1044 } | 1048 } |
1045 | 1049 |
1046 v8::Local<v8::Value> result; | 1050 v8::Local<v8::Value> result; |
1047 if (gin::TryConvertToV8(args->isolate(), gpu_driver_bug_workarounds, &result)) | 1051 if (gin::TryConvertToV8(args->isolate(), gpu_driver_bug_workarounds, &result)) |
1048 args->Return(result); | 1052 args->Return(result); |
1049 } | 1053 } |
1050 | 1054 |
| 1055 bool GpuBenchmarking::PointerActionSequence(gin::Arguments* args) { |
| 1056 GpuBenchmarkingContext context; |
| 1057 if (!context.Init(false)) |
| 1058 return false; |
| 1059 |
| 1060 v8::Local<v8::Function> callback; |
| 1061 |
| 1062 v8::Local<v8::Object> obj; |
| 1063 if (!args->GetNext(&obj)) { |
| 1064 args->ThrowError(); |
| 1065 return false; |
| 1066 } |
| 1067 |
| 1068 std::unique_ptr<V8ValueConverter> converter = |
| 1069 base::WrapUnique(V8ValueConverter::create()); |
| 1070 v8::Local<v8::Context> v8_context = |
| 1071 context.web_frame()->mainWorldScriptContext(); |
| 1072 std::unique_ptr<base::Value> value = converter->FromV8Value(obj, v8_context); |
| 1073 |
| 1074 // Get all the pointer actions from the user input and wrap them into a |
| 1075 // SyntheticPointerActionListParams object. |
| 1076 ActionsRunner actions_runner(value.get()); |
| 1077 if (!actions_runner.ParseSources()) |
| 1078 return false; |
| 1079 |
| 1080 std::unique_ptr<SyntheticPointerActionListParams> gesture_params = |
| 1081 actions_runner.gesture_params(); |
| 1082 |
| 1083 if (!GetOptionalArg(args, &callback)) { |
| 1084 return false; |
| 1085 } |
| 1086 |
| 1087 // At the end, we will send a 'FINISH' action and need a callback. |
| 1088 scoped_refptr<CallbackAndContext> callback_and_context = |
| 1089 new CallbackAndContext(args->isolate(), callback, |
| 1090 context.web_frame()->mainWorldScriptContext()); |
| 1091 // TODO(nduca): If the render_view_impl is destroyed while the gesture is in |
| 1092 // progress, we will leak the callback and context. This needs to be fixed, |
| 1093 // somehow. |
| 1094 context.render_view_impl()->GetWidget()->QueueSyntheticGesture( |
| 1095 std::move(gesture_params), |
| 1096 base::Bind(&OnSyntheticGestureCompleted, |
| 1097 base::RetainedRef(callback_and_context))); |
| 1098 return true; |
| 1099 } |
| 1100 |
1051 } // namespace content | 1101 } // namespace content |
OLD | NEW |