| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_CACHE_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_CACHE_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_CACHE_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_CACHE_H_ |
| 7 | 7 |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 // ShaderTranslator::DestructionObserver implementation | 30 // ShaderTranslator::DestructionObserver implementation |
| 31 virtual void OnDestruct(ShaderTranslator* translator) OVERRIDE; | 31 virtual void OnDestruct(ShaderTranslator* translator) OVERRIDE; |
| 32 | 32 |
| 33 scoped_refptr<ShaderTranslator> GetTranslator( | 33 scoped_refptr<ShaderTranslator> GetTranslator( |
| 34 ShShaderType shader_type, | 34 ShShaderType shader_type, |
| 35 ShShaderSpec shader_spec, | 35 ShShaderSpec shader_spec, |
| 36 const ShBuiltInResources* resources, | 36 const ShBuiltInResources* resources, |
| 37 ShaderTranslatorInterface::GlslImplementationType | 37 ShaderTranslatorInterface::GlslImplementationType |
| 38 glsl_implementation_type, | 38 glsl_implementation_type, |
| 39 ShaderTranslatorInterface::GlslBuiltInFunctionBehavior | 39 int driver_bug_workarounds); |
| 40 glsl_built_in_function_behavior); | |
| 41 | 40 |
| 42 private: | 41 private: |
| 43 ShaderTranslatorCache(); | 42 ShaderTranslatorCache(); |
| 44 virtual ~ShaderTranslatorCache(); | 43 virtual ~ShaderTranslatorCache(); |
| 45 | 44 |
| 46 friend struct DefaultSingletonTraits<ShaderTranslatorCache>; | 45 friend struct DefaultSingletonTraits<ShaderTranslatorCache>; |
| 47 | 46 |
| 48 // Parameters passed into ShaderTranslator::Init | 47 // Parameters passed into ShaderTranslator::Init |
| 49 struct ShaderTranslatorInitParams { | 48 struct ShaderTranslatorInitParams { |
| 50 ShShaderType shader_type; | 49 ShShaderType shader_type; |
| 51 ShShaderSpec shader_spec; | 50 ShShaderSpec shader_spec; |
| 52 ShBuiltInResources resources; | 51 ShBuiltInResources resources; |
| 53 ShaderTranslatorInterface::GlslImplementationType | 52 ShaderTranslatorInterface::GlslImplementationType |
| 54 glsl_implementation_type; | 53 glsl_implementation_type; |
| 55 ShaderTranslatorInterface::GlslBuiltInFunctionBehavior | 54 int driver_bug_workarounds; |
| 56 glsl_built_in_function_behavior; | |
| 57 | 55 |
| 58 ShaderTranslatorInitParams( | 56 ShaderTranslatorInitParams( |
| 59 ShShaderType shader_type, | 57 ShShaderType shader_type, |
| 60 ShShaderSpec shader_spec, | 58 ShShaderSpec shader_spec, |
| 61 const ShBuiltInResources& resources, | 59 const ShBuiltInResources& resources, |
| 62 ShaderTranslatorInterface::GlslImplementationType | 60 ShaderTranslatorInterface::GlslImplementationType |
| 63 glsl_implementation_type, | 61 glsl_implementation_type, |
| 64 ShaderTranslatorInterface::GlslBuiltInFunctionBehavior | 62 int driver_bug_workarounds) |
| 65 glsl_built_in_function_behavior) | |
| 66 : shader_type(shader_type), | 63 : shader_type(shader_type), |
| 67 shader_spec(shader_spec), | 64 shader_spec(shader_spec), |
| 68 resources(resources), | 65 resources(resources), |
| 69 glsl_implementation_type(glsl_implementation_type), | 66 glsl_implementation_type(glsl_implementation_type), |
| 70 glsl_built_in_function_behavior(glsl_built_in_function_behavior) { | 67 driver_bug_workarounds(driver_bug_workarounds) { |
| 71 } | 68 } |
| 72 | 69 |
| 73 ShaderTranslatorInitParams(const ShaderTranslatorInitParams& params) { | 70 ShaderTranslatorInitParams(const ShaderTranslatorInitParams& params) { |
| 74 memcpy(this, ¶ms, sizeof(*this)); | 71 memcpy(this, ¶ms, sizeof(*this)); |
| 75 } | 72 } |
| 76 | 73 |
| 77 bool operator== (const ShaderTranslatorInitParams& params) const { | 74 bool operator== (const ShaderTranslatorInitParams& params) const { |
| 78 return memcmp(¶ms, this, sizeof(*this)) == 0; | 75 return memcmp(¶ms, this, sizeof(*this)) == 0; |
| 79 } | 76 } |
| 80 | 77 |
| 81 bool operator< (const ShaderTranslatorInitParams& params) const { | 78 bool operator< (const ShaderTranslatorInitParams& params) const { |
| 82 return memcmp(¶ms, this, sizeof(*this)) < 0; | 79 return memcmp(¶ms, this, sizeof(*this)) < 0; |
| 83 } | 80 } |
| 84 }; | 81 }; |
| 85 | 82 |
| 86 typedef std::map<ShaderTranslatorInitParams, ShaderTranslator* > Cache; | 83 typedef std::map<ShaderTranslatorInitParams, ShaderTranslator* > Cache; |
| 87 Cache cache_; | 84 Cache cache_; |
| 88 | 85 |
| 89 DISALLOW_COPY_AND_ASSIGN(ShaderTranslatorCache); | 86 DISALLOW_COPY_AND_ASSIGN(ShaderTranslatorCache); |
| 90 }; | 87 }; |
| 91 | 88 |
| 92 } // namespace gles2 | 89 } // namespace gles2 |
| 93 } // namespace gpu | 90 } // namespace gpu |
| 94 | 91 |
| 95 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_CACHE_H_ | 92 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_CACHE_H_ |
| OLD | NEW |