diff options
author | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-03 15:58:14 +0000 |
---|---|---|
committer | boliu@chromium.org <boliu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-03 15:58:14 +0000 |
commit | 03cef9bf3062048da19b0d31645d3e6956a50a0a (patch) | |
tree | f31381d34a9c4ea6fe9a69b964e7fff4e8d8f63a /android_webview/browser | |
parent | 8f9541bc63b99cb8438853fec12ec5b0b6130b19 (diff) | |
download | chromium_src-03cef9bf3062048da19b0d31645d3e6956a50a0a.zip chromium_src-03cef9bf3062048da19b0d31645d3e6956a50a0a.tar.gz chromium_src-03cef9bf3062048da19b0d31645d3e6956a50a0a.tar.bz2 |
Make ShaderTranslatorCache per thread refcounted
After crbug.com/332146 is fixed, in Android WebView, GLES2Decoder can be
used on two threads. Make sure a ShaderTranslatorCache instance is only
used on a single thread by refcounting an instance between all decoders.
Also protect ShInitialize by using the thread safety guarantees of
LazyInstance.
For tests, a new instance of ShaderTranslatorCache is passed for each
ContextGroup.
BUG=
Review URL: https://codereview.chromium.org/217813004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261427 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview/browser')
-rw-r--r-- | android_webview/browser/hardware_renderer.cc | 8 | ||||
-rw-r--r-- | android_webview/browser/hardware_renderer.h | 4 |
2 files changed, 12 insertions, 0 deletions
diff --git a/android_webview/browser/hardware_renderer.cc b/android_webview/browser/hardware_renderer.cc index 8042d9d..59356db 100644 --- a/android_webview/browser/hardware_renderer.cc +++ b/android_webview/browser/hardware_renderer.cc @@ -14,6 +14,7 @@ #include "base/strings/string_number_conversions.h" #include "content/public/browser/browser_thread.h" #include "content/public/common/content_switches.h" +#include "gpu/command_buffer/service/shader_translator_cache.h" #include "ui/gfx/transform.h" using content::BrowserThread; @@ -252,6 +253,13 @@ void DeferredGpuCommandService::ScheduleIdleWork( 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; + return shader_translator_cache_; +} + void DeferredGpuCommandService::RunTasks() { bool has_more_tasks; { diff --git a/android_webview/browser/hardware_renderer.h b/android_webview/browser/hardware_renderer.h index 13800e4..4f226d2 100644 --- a/android_webview/browser/hardware_renderer.h +++ b/android_webview/browser/hardware_renderer.h @@ -76,6 +76,8 @@ class DeferredGpuCommandService virtual void ScheduleTask(const base::Closure& task) OVERRIDE; virtual void ScheduleIdleWork(const base::Closure& task) OVERRIDE; virtual bool UseVirtualizedGLContexts() OVERRIDE; + virtual scoped_refptr<gpu::gles2::ShaderTranslatorCache> + shader_translator_cache() OVERRIDE; void RunTasks(); @@ -91,6 +93,8 @@ class DeferredGpuCommandService base::Lock tasks_lock_; std::queue<base::Closure> tasks_; + + scoped_refptr<gpu::gles2::ShaderTranslatorCache> shader_translator_cache_; DISALLOW_COPY_AND_ASSIGN(DeferredGpuCommandService); }; |