diff options
author | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-11 00:07:54 +0000 |
---|---|---|
committer | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-11 00:07:54 +0000 |
commit | 95bbcc75d1e793d85cda714e640c1ddb36dd4c59 (patch) | |
tree | d9799984bf532e9fef8384c87c4005990ee1cf95 /gpu | |
parent | 2fdf74420b8ac9905319fcd572101ccfa2681bc4 (diff) | |
download | chromium_src-95bbcc75d1e793d85cda714e640c1ddb36dd4c59.zip chromium_src-95bbcc75d1e793d85cda714e640c1ddb36dd4c59.tar.gz chromium_src-95bbcc75d1e793d85cda714e640c1ddb36dd4c59.tar.bz2 |
RefCounted types should not have public destructors
BUG=123295
TEST=existing unittests
Review URL: https://chromiumcodereview.appspot.com/10694111
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146001 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/command_buffer/service/shader_translator.cc | 23 | ||||
-rw-r--r-- | gpu/command_buffer/service/shader_translator.h | 45 |
2 files changed, 38 insertions, 30 deletions
diff --git a/gpu/command_buffer/service/shader_translator.cc b/gpu/command_buffer/service/shader_translator.cc index 6839736..c58d198 100644 --- a/gpu/command_buffer/service/shader_translator.cc +++ b/gpu/command_buffer/service/shader_translator.cc @@ -11,6 +11,9 @@ #include "base/logging.h" namespace { + +using gpu::gles2::ShaderTranslator; + void FinalizeShaderTranslator(void* /* dummy */) { ShFinalize(); } @@ -24,7 +27,6 @@ bool InitializeShaderTranslator() { return initialized; } -using gpu::gles2::ShaderTranslator; void GetVariableInfo(ShHandle compiler, ShShaderInfo var_type, ShaderTranslator::VariableMap* var_map) { int name_len = 0, mapped_name_len = 0; @@ -72,6 +74,7 @@ void GetVariableInfo(ShHandle compiler, ShShaderInfo var_type, (*var_map)[mapped_name.get()] = info; } } + } // namespace namespace gpu { @@ -89,15 +92,6 @@ ShaderTranslator::ShaderTranslator() needs_built_in_function_emulation_(false) { } -ShaderTranslator::~ShaderTranslator() { - FOR_EACH_OBSERVER(DestructionObserver, - destruction_observers_, - OnDestruct(this)); - - if (compiler_ != NULL) - ShDestruct(compiler_); -} - bool ShaderTranslator::Init( ShShaderType shader_type, ShShaderSpec shader_spec, @@ -191,6 +185,15 @@ void ShaderTranslator::RemoveDestructionObserver( destruction_observers_.RemoveObserver(observer); } +ShaderTranslator::~ShaderTranslator() { + FOR_EACH_OBSERVER(DestructionObserver, + destruction_observers_, + OnDestruct(this)); + + if (compiler_ != NULL) + ShDestruct(compiler_); +} + void ShaderTranslator::ClearResults() { translated_shader_.reset(); info_log_.reset(); diff --git a/gpu/command_buffer/service/shader_translator.h b/gpu/command_buffer/service/shader_translator.h index 9173740..f82343e 100644 --- a/gpu/command_buffer/service/shader_translator.h +++ b/gpu/command_buffer/service/shader_translator.h @@ -32,7 +32,25 @@ class ShaderTranslatorInterface { kGlslBuiltInFunctionEmulated }; - virtual ~ShaderTranslatorInterface() { } + struct VariableInfo { + VariableInfo() + : type(0), + size(0) { + } + + VariableInfo(int _type, int _size, std::string _name) + : type(_type), + size(_size), + name(_name) { + } + + int type; + int size; + std::string name; // name in the original shader source. + }; + + // Mapping between variable name and info. + typedef base::hash_map<std::string, VariableInfo> VariableMap; // Initializes the translator. // Must be called once before using the translator object. @@ -54,24 +72,11 @@ class ShaderTranslatorInterface { virtual const char* translated_shader() const = 0; virtual const char* info_log() const = 0; - struct VariableInfo { - VariableInfo() - : type(0), - size(0) { - } - VariableInfo(int _type, int _size, std::string _name) - : type(_type), - size(_size), - name(_name) { - } - int type; - int size; - std::string name; // name in the original shader source. - }; - // Mapping between variable name and info. - typedef base::hash_map<std::string, VariableInfo> VariableMap; virtual const VariableMap& attrib_map() const = 0; virtual const VariableMap& uniform_map() const = 0; + + protected: + virtual ~ShaderTranslatorInterface() {} }; // Implementation of ShaderTranslatorInterface @@ -85,6 +90,7 @@ class GPU_EXPORT ShaderTranslator virtual ~DestructionObserver(); virtual void OnDestruct(ShaderTranslator* translator) = 0; + private: DISALLOW_COPY_AND_ASSIGN(DestructionObserver); }; @@ -114,8 +120,9 @@ class GPU_EXPORT ShaderTranslator void RemoveDestructionObserver(DestructionObserver* observer); private: - virtual ~ShaderTranslator(); + friend class base::RefCounted<ShaderTranslator>; + virtual ~ShaderTranslator(); void ClearResults(); ShHandle compiler_; @@ -127,8 +134,6 @@ class GPU_EXPORT ShaderTranslator bool needs_built_in_function_emulation_; ObserverList<DestructionObserver> destruction_observers_; - friend class base::RefCounted<ShaderTranslator>; - DISALLOW_COPY_AND_ASSIGN(ShaderTranslator); }; |