Index: android_webview/browser/deferred_gpu_command_service.cc |
diff --git a/android_webview/browser/deferred_gpu_command_service.cc b/android_webview/browser/deferred_gpu_command_service.cc |
index a9fd6a2c19d95e463a4bb3dc4a1036122ea0d477..cc9e0a14a2460f49aea0265964ff0fb7fca04b16 100644 |
--- a/android_webview/browser/deferred_gpu_command_service.cc |
+++ b/android_webview/browser/deferred_gpu_command_service.cc |
@@ -6,19 +6,34 @@ |
#include "android_webview/browser/gl_view_renderer_manager.h" |
#include "android_webview/browser/shared_renderer_state.h" |
+#include "base/command_line.h" |
#include "base/lazy_instance.h" |
+#include "base/strings/string_number_conversions.h" |
#include "base/synchronization/lock.h" |
#include "base/trace_event/trace_event.h" |
#include "content/public/browser/android/synchronous_compositor.h" |
#include "gpu/command_buffer/service/framebuffer_completeness_cache.h" |
+#include "gpu/command_buffer/service/gpu_switches.h" |
#include "gpu/command_buffer/service/shader_translator_cache.h" |
#include "gpu/command_buffer/service/sync_point_manager.h" |
+#include "gpu/config/gpu_switches.h" |
+#include "ui/gl/gl_switches.h" |
namespace android_webview { |
namespace { |
base::LazyInstance<scoped_refptr<DeferredGpuCommandService> > |
g_service = LAZY_INSTANCE_INITIALIZER; |
+ |
+bool GetSizeTFromSwitch(const base::CommandLine* command_line, |
+ const base::StringPiece& switch_string, |
+ size_t* value) { |
+ if (!command_line->HasSwitch(switch_string)) |
+ return false; |
+ std::string switch_value(command_line->GetSwitchValueASCII(switch_string)); |
+ return base::StringToSizeT(switch_value, value); |
+} |
+ |
} // namespace |
base::LazyInstance<base::ThreadLocalBoolean> ScopedAllowGL::allow_gl; |
@@ -63,7 +78,10 @@ DeferredGpuCommandService* DeferredGpuCommandService::GetInstance() { |
} |
DeferredGpuCommandService::DeferredGpuCommandService() |
- : sync_point_manager_(new gpu::SyncPointManager(true)) {} |
+ : gpu::InProcessCommandBuffer::Service(gpu_preferences_), |
piman
2016/02/25 21:56:05
Oh, this is confusing/dangerous (and probably unde
Peng
2016/02/25 22:29:08
Done.
|
+ sync_point_manager_(new gpu::SyncPointManager(true)) { |
+ InitGpuPreferences(); |
+} |
DeferredGpuCommandService::~DeferredGpuCommandService() { |
base::AutoLock lock(tasks_lock_); |
@@ -95,6 +113,58 @@ void DeferredGpuCommandService::ScheduleTask(const base::Closure& task) { |
} |
} |
+void DeferredGpuCommandService::InitGpuPreferences() { |
+ DCHECK(base::CommandLine::InitializedForCurrentProcess()); |
+ const base::CommandLine* command_line = |
+ base::CommandLine::ForCurrentProcess(); |
+ gpu_preferences_.single_process = true; |
+ gpu_preferences_.in_process_gpu = true; |
+ // TODO(penghuang): share below code with content/gpu/gpu_child_thread.cc |
+ gpu_preferences_.compile_shader_always_succeeds = |
+ command_line->HasSwitch(switches::kCompileShaderAlwaysSucceeds); |
+ gpu_preferences_.disable_gl_error_limit = |
+ command_line->HasSwitch(switches::kDisableGLErrorLimit); |
+ gpu_preferences_.disable_glsl_translator = |
+ command_line->HasSwitch(switches::kDisableGLSLTranslator); |
+ gpu_preferences_.disable_gpu_driver_bug_workarounds = |
+ command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds); |
+ gpu_preferences_.disable_shader_name_hashing = |
+ command_line->HasSwitch(switches::kDisableShaderNameHashing); |
+ gpu_preferences_.enable_gpu_command_logging = |
+ command_line->HasSwitch(switches::kEnableGPUCommandLogging); |
+ gpu_preferences_.enable_gpu_debugging = |
+ command_line->HasSwitch(switches::kEnableGPUDebugging); |
+ gpu_preferences_.enable_gpu_service_logging_gpu = |
+ command_line->HasSwitch(switches::kEnableGPUServiceLoggingGPU); |
+ gpu_preferences_.disable_gpu_program_cache = |
+ command_line->HasSwitch(switches::kDisableGpuProgramCache); |
+ gpu_preferences_.enforce_gl_minimums = |
+ command_line->HasSwitch(switches::kEnforceGLMinimums); |
+ if (GetSizeTFromSwitch(command_line, switches::kForceGpuMemAvailableMb, |
+ &gpu_preferences_.force_gpu_mem_available)) { |
+ gpu_preferences_.force_gpu_mem_available *= 1024 * 1024; |
+ } |
+ if (GetSizeTFromSwitch(command_line, switches::kGpuProgramCacheSizeKb, |
+ &gpu_preferences_.gpu_program_cache_size)) { |
+ gpu_preferences_.gpu_program_cache_size *= 1024; |
+ } |
+ gpu_preferences_.enable_share_group_async_texture_upload = |
+ command_line->HasSwitch(switches::kEnableShareGroupAsyncTextureUpload); |
+ gpu_preferences_.enable_subscribe_uniform_extension = |
+ command_line->HasSwitch(switches::kEnableSubscribeUniformExtension); |
+ gpu_preferences_.enable_threaded_texture_mailboxes = |
+ command_line->HasSwitch(switches::kEnableThreadedTextureMailboxes); |
+ gpu_preferences_.gl_shader_interm_output = |
+ command_line->HasSwitch(switches::kGLShaderIntermOutput); |
+ gpu_preferences_.emulate_shader_precision = |
+ command_line->HasSwitch(switches::kEmulateShaderPrecision); |
+ gpu_preferences_.enable_gl_path_rendering = |
+ command_line->HasSwitch(switches::kEnableGLPathRendering); |
+ gpu_preferences_.enable_gpu_service_logging = |
+ command_line->HasSwitch(switches::kEnableGPUServiceLogging); |
+ gpu_preferences_.enable_gpu_service_tracing = |
+} |
+ |
size_t DeferredGpuCommandService::IdleQueueSize() { |
base::AutoLock lock(tasks_lock_); |
return idle_tasks_.size(); |
@@ -149,8 +219,10 @@ bool DeferredGpuCommandService::UseVirtualizedGLContexts() { return true; } |
scoped_refptr<gpu::gles2::ShaderTranslatorCache> |
DeferredGpuCommandService::shader_translator_cache() { |
- if (!shader_translator_cache_.get()) |
- shader_translator_cache_ = new gpu::gles2::ShaderTranslatorCache; |
+ if (!shader_translator_cache_.get()) { |
+ shader_translator_cache_ = |
+ new gpu::gles2::ShaderTranslatorCache(gpu_preferences()); |
+ } |
return shader_translator_cache_; |
} |