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 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/base64.h" | 11 #include "base/base64.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "cc/layers/layer.h" | 16 #include "cc/layers/layer.h" |
| 17 #include "content/common/gpu/gpu_messages.h" |
17 #include "content/common/input/synthetic_gesture_params.h" | 18 #include "content/common/input/synthetic_gesture_params.h" |
18 #include "content/common/input/synthetic_pinch_gesture_params.h" | 19 #include "content/common/input/synthetic_pinch_gesture_params.h" |
19 #include "content/common/input/synthetic_smooth_drag_gesture_params.h" | 20 #include "content/common/input/synthetic_smooth_drag_gesture_params.h" |
20 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" | 21 #include "content/common/input/synthetic_smooth_scroll_gesture_params.h" |
21 #include "content/common/input/synthetic_tap_gesture_params.h" | 22 #include "content/common/input/synthetic_tap_gesture_params.h" |
22 #include "content/public/child/v8_value_converter.h" | 23 #include "content/public/child/v8_value_converter.h" |
23 #include "content/public/renderer/chrome_object_extensions_utils.h" | 24 #include "content/public/renderer/chrome_object_extensions_utils.h" |
24 #include "content/public/renderer/render_thread.h" | 25 #include "content/public/renderer/render_thread.h" |
25 #include "content/renderer/gpu/render_widget_compositor.h" | 26 #include "content/renderer/gpu/render_widget_compositor.h" |
26 #include "content/renderer/render_thread_impl.h" | 27 #include "content/renderer/render_thread_impl.h" |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 // stable. | 461 // stable. |
461 .SetValue("newPinchInterface", true) | 462 .SetValue("newPinchInterface", true) |
462 .SetMethod("pinchBy", &GpuBenchmarking::PinchBy) | 463 .SetMethod("pinchBy", &GpuBenchmarking::PinchBy) |
463 .SetMethod("visualViewportHeight", &GpuBenchmarking::VisualViewportHeight) | 464 .SetMethod("visualViewportHeight", &GpuBenchmarking::VisualViewportHeight) |
464 .SetMethod("visualViewportWidth", &GpuBenchmarking::VisualViewportWidth) | 465 .SetMethod("visualViewportWidth", &GpuBenchmarking::VisualViewportWidth) |
465 .SetMethod("tap", &GpuBenchmarking::Tap) | 466 .SetMethod("tap", &GpuBenchmarking::Tap) |
466 .SetMethod("clearImageCache", &GpuBenchmarking::ClearImageCache) | 467 .SetMethod("clearImageCache", &GpuBenchmarking::ClearImageCache) |
467 .SetMethod("runMicroBenchmark", &GpuBenchmarking::RunMicroBenchmark) | 468 .SetMethod("runMicroBenchmark", &GpuBenchmarking::RunMicroBenchmark) |
468 .SetMethod("sendMessageToMicroBenchmark", | 469 .SetMethod("sendMessageToMicroBenchmark", |
469 &GpuBenchmarking::SendMessageToMicroBenchmark) | 470 &GpuBenchmarking::SendMessageToMicroBenchmark) |
| 471 .SetMethod("hasGpuChannel", &GpuBenchmarking::HasGpuChannel) |
470 .SetMethod("hasGpuProcess", &GpuBenchmarking::HasGpuProcess); | 472 .SetMethod("hasGpuProcess", &GpuBenchmarking::HasGpuProcess); |
471 } | 473 } |
472 | 474 |
473 void GpuBenchmarking::SetNeedsDisplayOnAllLayers() { | 475 void GpuBenchmarking::SetNeedsDisplayOnAllLayers() { |
474 GpuBenchmarkingContext context; | 476 GpuBenchmarkingContext context; |
475 if (!context.Init(true)) | 477 if (!context.Init(true)) |
476 return; | 478 return; |
477 | 479 |
478 context.compositor()->SetNeedsDisplayOnAllLayers(); | 480 context.compositor()->SetNeedsDisplayOnAllLayers(); |
479 } | 481 } |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
861 make_scoped_ptr(V8ValueConverter::create()); | 863 make_scoped_ptr(V8ValueConverter::create()); |
862 v8::Local<v8::Context> v8_context = | 864 v8::Local<v8::Context> v8_context = |
863 context.web_frame()->mainWorldScriptContext(); | 865 context.web_frame()->mainWorldScriptContext(); |
864 scoped_ptr<base::Value> value = | 866 scoped_ptr<base::Value> value = |
865 make_scoped_ptr(converter->FromV8Value(message, v8_context)); | 867 make_scoped_ptr(converter->FromV8Value(message, v8_context)); |
866 | 868 |
867 return context.compositor()->SendMessageToMicroBenchmark(id, | 869 return context.compositor()->SendMessageToMicroBenchmark(id, |
868 std::move(value)); | 870 std::move(value)); |
869 } | 871 } |
870 | 872 |
| 873 bool GpuBenchmarking::HasGpuChannel() { |
| 874 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); |
| 875 return !!gpu_channel; |
| 876 } |
| 877 |
871 bool GpuBenchmarking::HasGpuProcess() { | 878 bool GpuBenchmarking::HasGpuProcess() { |
872 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); | 879 bool has_gpu_process = false; |
873 return !!gpu_channel; | 880 if (!RenderThreadImpl::current()->Send( |
| 881 new GpuHostMsg_HasGpuProcess(&has_gpu_process))) |
| 882 return false; |
| 883 |
| 884 return has_gpu_process; |
874 } | 885 } |
875 | 886 |
876 } // namespace content | 887 } // namespace content |
OLD | NEW |