| OLD | NEW |
| 1 // Copyright (c) 2011 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_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "gpu/command_buffer/service/gl_utils.h" | 14 #include "gpu/command_buffer/service/gl_utils.h" |
| 15 #include "gpu/command_buffer/service/shader_translator.h" | 15 #include "gpu/command_buffer/service/shader_translator.h" |
| 16 #include "gpu/gpu_export.h" |
| 16 | 17 |
| 17 namespace gpu { | 18 namespace gpu { |
| 18 namespace gles2 { | 19 namespace gles2 { |
| 19 | 20 |
| 20 // Tracks the Shaders. | 21 // Tracks the Shaders. |
| 21 // | 22 // |
| 22 // NOTE: To support shared resources an instance of this class will | 23 // NOTE: To support shared resources an instance of this class will |
| 23 // need to be shared by multiple GLES2Decoders. | 24 // need to be shared by multiple GLES2Decoders. |
| 24 class ShaderManager { | 25 class GPU_EXPORT ShaderManager { |
| 25 public: | 26 public: |
| 26 // This is used to keep the source code for a shader. This is because in order | 27 // This is used to keep the source code for a shader. This is because in order |
| 27 // to emluate GLES2 the shaders will have to be re-written before passed to | 28 // to emluate GLES2 the shaders will have to be re-written before passed to |
| 28 // the underlying OpenGL. But, when the user calls glGetShaderSource they | 29 // the underlying OpenGL. But, when the user calls glGetShaderSource they |
| 29 // should get the source they passed in, not the re-written source. | 30 // should get the source they passed in, not the re-written source. |
| 30 class ShaderInfo : public base::RefCounted<ShaderInfo> { | 31 class GPU_EXPORT ShaderInfo : public base::RefCounted<ShaderInfo> { |
| 31 public: | 32 public: |
| 32 typedef scoped_refptr<ShaderInfo> Ref; | 33 typedef scoped_refptr<ShaderInfo> Ref; |
| 33 typedef ShaderTranslator::VariableInfo VariableInfo; | 34 typedef ShaderTranslator::VariableInfo VariableInfo; |
| 34 | 35 |
| 35 void UpdateSource(const char* source) { | 36 void UpdateSource(const char* source) { |
| 36 source_.reset(source ? new std::string(source) : NULL); | 37 source_.reset(source ? new std::string(source) : NULL); |
| 37 translated_source_.reset(NULL); | 38 translated_source_.reset(NULL); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void UpdateTranslatedSource(const char* translated_source) { | 41 void UpdateTranslatedSource(const char* translated_source) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 void RemoveShaderInfoIfUnused(ShaderInfo* info); | 159 void RemoveShaderInfoIfUnused(ShaderInfo* info); |
| 159 | 160 |
| 160 DISALLOW_COPY_AND_ASSIGN(ShaderManager); | 161 DISALLOW_COPY_AND_ASSIGN(ShaderManager); |
| 161 }; | 162 }; |
| 162 | 163 |
| 163 } // namespace gles2 | 164 } // namespace gles2 |
| 164 } // namespace gpu | 165 } // namespace gpu |
| 165 | 166 |
| 166 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ | 167 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ |
| 167 | 168 |
| OLD | NEW |