Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Unified Diff: gpu/command_buffer/service/shader_translator_cache.h

Issue 217813004: Make ShaderTranslatorCache thread safe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: protect ShFinalize Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/shader_translator_cache.h
diff --git a/gpu/command_buffer/service/shader_translator_cache.h b/gpu/command_buffer/service/shader_translator_cache.h
index 8439d5339871bd455b39091cc42a3e66740f72f2..880995f1992bb200fb2c0ce95b501eea0b00ab24 100644
--- a/gpu/command_buffer/service/shader_translator_cache.h
+++ b/gpu/command_buffer/service/shader_translator_cache.h
@@ -10,22 +10,23 @@
#include <map>
#include "base/memory/ref_counted.h"
-#include "base/memory/singleton.h"
#include "gpu/command_buffer/service/shader_translator.h"
#include "third_party/angle/include/GLSLANG/ShaderLang.h"
namespace gpu {
namespace gles2 {
-// This singleton and the cache that it implements is NOT thread safe.
-// We're relying on the fact that the all GLES2DecoderImpl's are used
-// on one thread.
+// This class can is not thread safe and can only be created and destroyed
no sievers 2014/04/02 18:30:19 nit: 'can is' -> 'is'
+// on a single thread. But it is safe to use two indepdent instances on two
no sievers 2014/04/02 18:30:19 nit: typo 'indepdent'
+// threads without synchronization.
//
// TODO(backer): Investigate using glReleaseShaderCompiler as an alternative to
// to this cache.
-class ShaderTranslatorCache : public ShaderTranslator::DestructionObserver {
+class GPU_EXPORT ShaderTranslatorCache
+ : public base::RefCounted<ShaderTranslatorCache>,
+ public ShaderTranslator::DestructionObserver {
public:
- static ShaderTranslatorCache* GetInstance();
+ ShaderTranslatorCache();
// ShaderTranslator::DestructionObserver implementation
virtual void OnDestruct(ShaderTranslator* translator) OVERRIDE;
@@ -39,11 +40,9 @@ class ShaderTranslatorCache : public ShaderTranslator::DestructionObserver {
ShCompileOptions driver_bug_workarounds);
private:
- ShaderTranslatorCache();
+ friend class base::RefCounted<ShaderTranslatorCache>;
virtual ~ShaderTranslatorCache();
- friend struct DefaultSingletonTraits<ShaderTranslatorCache>;
-
// Parameters passed into ShaderTranslator::Init
struct ShaderTranslatorInitParams {
ShShaderType shader_type;

Powered by Google App Engine
This is Rietveld 408576698