| 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 b4aadc1821371c8c2cb537cb04af6c68f50f3049..06b478e21fbecc87d5b89f56d0d49ce76f995c17 100644
|
| --- a/content/renderer/gpu/gpu_benchmarking_extension.cc
|
| +++ b/content/renderer/gpu/gpu_benchmarking_extension.cc
|
| @@ -20,6 +20,8 @@
|
| #include "content/common/child_process_messages.h"
|
| #include "content/common/input/synthetic_gesture_params.h"
|
| #include "content/common/input/synthetic_pinch_gesture_params.h"
|
| +#include "content/common/input/synthetic_pointer_action_list_params.h"
|
| +#include "content/common/input/synthetic_pointer_action_params.h"
|
| #include "content/common/input/synthetic_smooth_drag_gesture_params.h"
|
| #include "content/common/input/synthetic_smooth_scroll_gesture_params.h"
|
| #include "content/common/input/synthetic_tap_gesture_params.h"
|
| @@ -27,6 +29,7 @@
|
| #include "content/public/common/content_switches.h"
|
| #include "content/public/renderer/chrome_object_extensions_utils.h"
|
| #include "content/public/renderer/render_thread.h"
|
| +#include "content/renderer/gpu/actions_runner.h"
|
| #include "content/renderer/gpu/render_widget_compositor.h"
|
| #include "content/renderer/render_thread_impl.h"
|
| #include "content/renderer/render_view_impl.h"
|
| @@ -543,8 +546,7 @@ gin::ObjectTemplateBuilder GpuBenchmarking::GetObjectTemplateBuilder(
|
| .SetMethod("printToSkPicture", &GpuBenchmarking::PrintToSkPicture)
|
| .SetMethod("printPagesToSkPictures",
|
| &GpuBenchmarking::PrintPagesToSkPictures)
|
| - .SetMethod("printPagesToXPS",
|
| - &GpuBenchmarking::PrintPagesToXPS)
|
| + .SetMethod("printPagesToXPS", &GpuBenchmarking::PrintPagesToXPS)
|
| .SetValue("DEFAULT_INPUT", 0)
|
| .SetValue("TOUCH_INPUT", 1)
|
| .SetValue("MOUSE_INPUT", 2)
|
| @@ -568,7 +570,9 @@ gin::ObjectTemplateBuilder GpuBenchmarking::GetObjectTemplateBuilder(
|
| .SetMethod("hasGpuChannel", &GpuBenchmarking::HasGpuChannel)
|
| .SetMethod("hasGpuProcess", &GpuBenchmarking::HasGpuProcess)
|
| .SetMethod("getGpuDriverBugWorkarounds",
|
| - &GpuBenchmarking::GetGpuDriverBugWorkarounds);
|
| + &GpuBenchmarking::GetGpuDriverBugWorkarounds)
|
| + .SetMethod("pointerActionSequence",
|
| + &GpuBenchmarking::PointerActionSequence);
|
| }
|
|
|
| void GpuBenchmarking::SetNeedsDisplayOnAllLayers() {
|
| @@ -1048,4 +1052,50 @@ void GpuBenchmarking::GetGpuDriverBugWorkarounds(gin::Arguments* args) {
|
| args->Return(result);
|
| }
|
|
|
| +bool GpuBenchmarking::PointerActionSequence(gin::Arguments* args) {
|
| + GpuBenchmarkingContext context;
|
| + if (!context.Init(false))
|
| + return false;
|
| +
|
| + v8::Local<v8::Function> callback;
|
| +
|
| + v8::Local<v8::Object> obj;
|
| + if (!args->GetNext(&obj)) {
|
| + args->ThrowError();
|
| + return false;
|
| + }
|
| +
|
| + std::unique_ptr<V8ValueConverter> converter =
|
| + base::WrapUnique(V8ValueConverter::create());
|
| + v8::Local<v8::Context> v8_context =
|
| + context.web_frame()->mainWorldScriptContext();
|
| + std::unique_ptr<base::Value> value = converter->FromV8Value(obj, v8_context);
|
| +
|
| + // Get all the pointer actions from the user input and wrap them into a
|
| + // SyntheticPointerActionListParams object.
|
| + ActionsRunner actions_runner(value.get());
|
| + if (!actions_runner.ParseSources())
|
| + return false;
|
| +
|
| + std::unique_ptr<SyntheticPointerActionListParams> gesture_params =
|
| + actions_runner.gesture_params();
|
| +
|
| + if (!GetOptionalArg(args, &callback)) {
|
| + return false;
|
| + }
|
| +
|
| + // At the end, we will send a 'FINISH' action and need a callback.
|
| + scoped_refptr<CallbackAndContext> callback_and_context =
|
| + new CallbackAndContext(args->isolate(), callback,
|
| + context.web_frame()->mainWorldScriptContext());
|
| + // TODO(nduca): 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,
|
| + // somehow.
|
| + context.render_view_impl()->GetWidget()->QueueSyntheticGesture(
|
| + std::move(gesture_params),
|
| + base::Bind(&OnSyntheticGestureCompleted,
|
| + base::RetainedRef(callback_and_context)));
|
| + return true;
|
| +}
|
| +
|
| } // namespace content
|
|
|