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