| 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 <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 }; | 304 }; |
| 305 | 305 |
| 306 void OnMicroBenchmarkCompleted(CallbackAndContext* callback_and_context, | 306 void OnMicroBenchmarkCompleted(CallbackAndContext* callback_and_context, |
| 307 std::unique_ptr<base::Value> result) { | 307 std::unique_ptr<base::Value> result) { |
| 308 v8::Isolate* isolate = callback_and_context->isolate(); | 308 v8::Isolate* isolate = callback_and_context->isolate(); |
| 309 v8::HandleScope scope(isolate); | 309 v8::HandleScope scope(isolate); |
| 310 v8::Local<v8::Context> context = callback_and_context->GetContext(); | 310 v8::Local<v8::Context> context = callback_and_context->GetContext(); |
| 311 v8::Context::Scope context_scope(context); | 311 v8::Context::Scope context_scope(context); |
| 312 WebLocalFrame* frame = WebLocalFrame::FrameForContext(context); | 312 WebLocalFrame* frame = WebLocalFrame::FrameForContext(context); |
| 313 if (frame) { | 313 if (frame) { |
| 314 std::unique_ptr<V8ValueConverter> converter = | 314 v8::Local<v8::Value> value = |
| 315 base::WrapUnique(V8ValueConverter::create()); | 315 V8ValueConverter::Create()->ToV8Value(result.get(), context); |
| 316 v8::Local<v8::Value> value = converter->ToV8Value(result.get(), context); | |
| 317 v8::Local<v8::Value> argv[] = { value }; | 316 v8::Local<v8::Value> argv[] = { value }; |
| 318 | 317 |
| 319 frame->CallFunctionEvenIfScriptDisabled(callback_and_context->GetCallback(), | 318 frame->CallFunctionEvenIfScriptDisabled(callback_and_context->GetCallback(), |
| 320 v8::Object::New(isolate), 1, argv); | 319 v8::Object::New(isolate), 1, argv); |
| 321 } | 320 } |
| 322 } | 321 } |
| 323 | 322 |
| 324 void OnSyntheticGestureCompleted(CallbackAndContext* callback_and_context) { | 323 void OnSyntheticGestureCompleted(CallbackAndContext* callback_and_context) { |
| 325 v8::Isolate* isolate = callback_and_context->isolate(); | 324 v8::Isolate* isolate = callback_and_context->isolate(); |
| 326 v8::HandleScope scope(isolate); | 325 v8::HandleScope scope(isolate); |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 return false; | 1017 return false; |
| 1019 | 1018 |
| 1020 v8::Local<v8::Function> callback; | 1019 v8::Local<v8::Function> callback; |
| 1021 | 1020 |
| 1022 v8::Local<v8::Object> obj; | 1021 v8::Local<v8::Object> obj; |
| 1023 if (!args->GetNext(&obj)) { | 1022 if (!args->GetNext(&obj)) { |
| 1024 args->ThrowError(); | 1023 args->ThrowError(); |
| 1025 return false; | 1024 return false; |
| 1026 } | 1025 } |
| 1027 | 1026 |
| 1028 std::unique_ptr<V8ValueConverter> converter = | |
| 1029 base::WrapUnique(V8ValueConverter::create()); | |
| 1030 v8::Local<v8::Context> v8_context = | 1027 v8::Local<v8::Context> v8_context = |
| 1031 context.web_frame()->MainWorldScriptContext(); | 1028 context.web_frame()->MainWorldScriptContext(); |
| 1032 std::unique_ptr<base::Value> value = converter->FromV8Value(obj, v8_context); | 1029 std::unique_ptr<base::Value> value = |
| 1030 V8ValueConverter::Create()->FromV8Value(obj, v8_context); |
| 1033 | 1031 |
| 1034 // Get all the pointer actions from the user input and wrap them into a | 1032 // Get all the pointer actions from the user input and wrap them into a |
| 1035 // SyntheticPointerActionListParams object. | 1033 // SyntheticPointerActionListParams object. |
| 1036 ActionsParser actions_parser(value.get()); | 1034 ActionsParser actions_parser(value.get()); |
| 1037 if (!actions_parser.ParsePointerActionSequence()) | 1035 if (!actions_parser.ParsePointerActionSequence()) |
| 1038 return false; | 1036 return false; |
| 1039 | 1037 |
| 1040 std::unique_ptr<SyntheticPointerActionListParams> gesture_params = | 1038 std::unique_ptr<SyntheticPointerActionListParams> gesture_params = |
| 1041 actions_parser.gesture_params(); | 1039 actions_parser.gesture_params(); |
| 1042 | 1040 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 | 1072 |
| 1075 if (!GetArg(args, &name) || !GetArg(args, &callback) || | 1073 if (!GetArg(args, &name) || !GetArg(args, &callback) || |
| 1076 !GetOptionalArg(args, &arguments)) { | 1074 !GetOptionalArg(args, &arguments)) { |
| 1077 return 0; | 1075 return 0; |
| 1078 } | 1076 } |
| 1079 | 1077 |
| 1080 scoped_refptr<CallbackAndContext> callback_and_context = | 1078 scoped_refptr<CallbackAndContext> callback_and_context = |
| 1081 new CallbackAndContext(args->isolate(), callback, | 1079 new CallbackAndContext(args->isolate(), callback, |
| 1082 context.web_frame()->MainWorldScriptContext()); | 1080 context.web_frame()->MainWorldScriptContext()); |
| 1083 | 1081 |
| 1084 std::unique_ptr<V8ValueConverter> converter = | |
| 1085 base::WrapUnique(V8ValueConverter::create()); | |
| 1086 v8::Local<v8::Context> v8_context = callback_and_context->GetContext(); | 1082 v8::Local<v8::Context> v8_context = callback_and_context->GetContext(); |
| 1087 std::unique_ptr<base::Value> value = | 1083 std::unique_ptr<base::Value> value = |
| 1088 converter->FromV8Value(arguments, v8_context); | 1084 V8ValueConverter::Create()->FromV8Value(arguments, v8_context); |
| 1089 | 1085 |
| 1090 return context.compositor()->ScheduleMicroBenchmark( | 1086 return context.compositor()->ScheduleMicroBenchmark( |
| 1091 name, std::move(value), | 1087 name, std::move(value), |
| 1092 base::Bind(&OnMicroBenchmarkCompleted, | 1088 base::Bind(&OnMicroBenchmarkCompleted, |
| 1093 base::RetainedRef(callback_and_context))); | 1089 base::RetainedRef(callback_and_context))); |
| 1094 } | 1090 } |
| 1095 | 1091 |
| 1096 bool GpuBenchmarking::SendMessageToMicroBenchmark( | 1092 bool GpuBenchmarking::SendMessageToMicroBenchmark( |
| 1097 int id, | 1093 int id, |
| 1098 v8::Local<v8::Object> message) { | 1094 v8::Local<v8::Object> message) { |
| 1099 GpuBenchmarkingContext context; | 1095 GpuBenchmarkingContext context; |
| 1100 if (!context.Init(true)) | 1096 if (!context.Init(true)) |
| 1101 return false; | 1097 return false; |
| 1102 | 1098 |
| 1103 std::unique_ptr<V8ValueConverter> converter = | |
| 1104 base::WrapUnique(V8ValueConverter::create()); | |
| 1105 v8::Local<v8::Context> v8_context = | 1099 v8::Local<v8::Context> v8_context = |
| 1106 context.web_frame()->MainWorldScriptContext(); | 1100 context.web_frame()->MainWorldScriptContext(); |
| 1107 std::unique_ptr<base::Value> value = | 1101 std::unique_ptr<base::Value> value = |
| 1108 converter->FromV8Value(message, v8_context); | 1102 V8ValueConverter::Create()->FromV8Value(message, v8_context); |
| 1109 | 1103 |
| 1110 return context.compositor()->SendMessageToMicroBenchmark(id, | 1104 return context.compositor()->SendMessageToMicroBenchmark(id, |
| 1111 std::move(value)); | 1105 std::move(value)); |
| 1112 } | 1106 } |
| 1113 | 1107 |
| 1114 bool GpuBenchmarking::HasGpuChannel() { | 1108 bool GpuBenchmarking::HasGpuChannel() { |
| 1115 gpu::GpuChannelHost* gpu_channel = | 1109 gpu::GpuChannelHost* gpu_channel = |
| 1116 RenderThreadImpl::current()->GetGpuChannel(); | 1110 RenderThreadImpl::current()->GetGpuChannel(); |
| 1117 return !!gpu_channel; | 1111 return !!gpu_channel; |
| 1118 } | 1112 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1135 &gpu_driver_bug_workarounds))) { | 1129 &gpu_driver_bug_workarounds))) { |
| 1136 return; | 1130 return; |
| 1137 } | 1131 } |
| 1138 | 1132 |
| 1139 v8::Local<v8::Value> result; | 1133 v8::Local<v8::Value> result; |
| 1140 if (gin::TryConvertToV8(args->isolate(), gpu_driver_bug_workarounds, &result)) | 1134 if (gin::TryConvertToV8(args->isolate(), gpu_driver_bug_workarounds, &result)) |
| 1141 args->Return(result); | 1135 args->Return(result); |
| 1142 } | 1136 } |
| 1143 | 1137 |
| 1144 } // namespace content | 1138 } // namespace content |
| OLD | NEW |