diff options
-rw-r--r-- | content/browser/renderer_host/render_process_host_impl.cc | 1 | ||||
-rw-r--r-- | content/content_renderer.gypi | 2 | ||||
-rw-r--r-- | content/public/common/content_switches.cc | 3 | ||||
-rw-r--r-- | content/public/common/content_switches.h | 1 | ||||
-rw-r--r-- | content/renderer/gpu/gpu_benchmarking_extension.cc | 34 | ||||
-rw-r--r-- | content/renderer/gpu/gpu_benchmarking_extension.h | 23 | ||||
-rw-r--r-- | content/renderer/render_thread_impl.cc | 6 |
7 files changed, 69 insertions, 1 deletions
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index c8716d7..e5d80c3 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -678,6 +678,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( switches::kEnableGamepad, switches::kEnableGPUServiceLogging, switches::kEnableGPUClientLogging, + switches::kEnableGpuBenchmarking, switches::kEnableLogging, switches::kEnableMediaSource, switches::kEnablePartialSwap, diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi index 26d5ec7..241db2f 100644 --- a/content/content_renderer.gypi +++ b/content/content_renderer.gypi @@ -77,6 +77,8 @@ 'renderer/gpu/compositor_thread.h', 'renderer/gpu/input_event_filter.cc', 'renderer/gpu/input_event_filter.h', + 'renderer/gpu/gpu_benchmarking_extension.cc', + 'renderer/gpu/gpu_benchmarking_extension.h', 'renderer/idle_user_detector.cc', 'renderer/idle_user_detector.h', 'renderer/input_tag_speech_dispatcher.cc', diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc index d7186e4..8c25d81 100644 --- a/content/public/common/content_switches.cc +++ b/content/public/common/content_switches.cc @@ -278,6 +278,9 @@ const char kEnablePointerLock[] = "enable-pointer-lock"; // Enable the Gamepad API const char kEnableGamepad[] = "enable-gamepad"; +// Enables the GPU benchmarking extension +const char kEnableGpuBenchmarking[] = "enable-gpu-benchmarking"; + // Force logging to be enabled. Logging is disabled by default in release // builds. const char kEnableLogging[] = "enable-logging"; diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h index 6a58f4b..674ebf7 100644 --- a/content/public/common/content_switches.h +++ b/content/public/common/content_switches.h @@ -95,6 +95,7 @@ CONTENT_EXPORT extern const char kEnableFixedLayout[]; CONTENT_EXPORT extern const char kDisableFullScreen[]; extern const char kEnablePointerLock[]; extern const char kEnableGamepad[]; +extern const char kEnableGpuBenchmarking[]; CONTENT_EXPORT extern const char kEnableLogging[]; extern const char kEnableMediaSource[]; extern const char kEnablePeerConnection[]; diff --git a/content/renderer/gpu/gpu_benchmarking_extension.cc b/content/renderer/gpu/gpu_benchmarking_extension.cc new file mode 100644 index 0000000..06bf193 --- /dev/null +++ b/content/renderer/gpu/gpu_benchmarking_extension.cc @@ -0,0 +1,34 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "content/renderer/gpu/gpu_benchmarking_extension.h" + +#include "v8/include/v8.h" + +const char kGpuBenchmarkingExtensionName[] = "v8/GpuBenchmarking"; + +namespace content { + +class GpuBenchmarkingWrapper : public v8::Extension { + public: + GpuBenchmarkingWrapper() : + v8::Extension(kGpuBenchmarkingExtensionName, + "if (typeof(chrome) == 'undefined') {" + " chrome = {};" + "};" + "if (typeof(chrome.gpuBenchmarking) == 'undefined') {" + " chrome.gpuBenchmarking = {};" + "};") {} + + virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( + v8::Handle<v8::String> name) { + return v8::Handle<v8::FunctionTemplate>(); + } +}; + +v8::Extension* GpuBenchmarkingExtension::Get() { + return new GpuBenchmarkingWrapper(); +} + +} // namespace content diff --git a/content/renderer/gpu/gpu_benchmarking_extension.h b/content/renderer/gpu/gpu_benchmarking_extension.h new file mode 100644 index 0000000..60f126d --- /dev/null +++ b/content/renderer/gpu/gpu_benchmarking_extension.h @@ -0,0 +1,23 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_RENDERER_GPU_GPU_BENCHMARKING_EXTENSION_H_ +#define CONTENT_RENDERER_GPU_GPU_BENCHMARKING_EXTENSION_H_ +#pragma once + +namespace v8 { +class Extension; +} + +namespace content { + +// V8 extension for gpu benchmarking +class GpuBenchmarkingExtension { + public: + static v8::Extension* Get(); +}; + +} // namespace content + +#endif // CONTENT_RENDERER_GPU_GPU_BENCHMARKING_EXTENSION_H_ diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc index a22e6d2..d3729aa 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc @@ -53,6 +53,7 @@ #include "content/renderer/dom_storage/webstoragearea_impl.h" #include "content/renderer/dom_storage/webstoragenamespace_impl.h" #include "content/renderer/gpu/compositor_thread.h" +#include "content/renderer/gpu/gpu_benchmarking_extension.h" #include "content/renderer/media/audio_input_message_filter.h" #include "content/renderer/media/audio_message_filter.h" #include "content/renderer/media/media_stream_center.h" @@ -241,8 +242,11 @@ void RenderThreadImpl::Init() { content::GetContentClient()->renderer()->RenderThreadStarted(); -#if defined(WEBCOMPOSITOR_OWNS_SETTINGS) const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + if (command_line.HasSwitch(switches::kEnableGpuBenchmarking)) + RegisterExtension(content::GpuBenchmarkingExtension::Get()); + +#if defined(WEBCOMPOSITOR_OWNS_SETTINGS) WebKit::WebCompositor::setAcceleratedAnimationEnabled( !command_line.HasSwitch(switches::kDisableThreadedAnimation)); WebKit::WebCompositor::setPerTilePaintingEnabled( |