| 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 #include "gpu/command_buffer/service/shader_translator.h" | 5 #include "gpu/command_buffer/service/shader_translator.h" |
| 6 | 6 |
| 7 #include <GLES2/gl2.h> | 7 #include <GLES2/gl2.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 case SH_WEBGL2_SPEC: | 198 case SH_WEBGL2_SPEC: |
| 199 compile_options_ |= SH_INIT_OUTPUT_VARIABLES; | 199 compile_options_ |= SH_INIT_OUTPUT_VARIABLES; |
| 200 break; | 200 break; |
| 201 default: | 201 default: |
| 202 break; | 202 break; |
| 203 } | 203 } |
| 204 | 204 |
| 205 return compiler_ != NULL; | 205 return compiler_ != NULL; |
| 206 } | 206 } |
| 207 | 207 |
| 208 int ShaderTranslator::GetCompileOptions() const { | 208 ShCompileOptions ShaderTranslator::GetCompileOptions() const { |
| 209 return compile_options_; | 209 return compile_options_; |
| 210 } | 210 } |
| 211 | 211 |
| 212 bool ShaderTranslator::Translate(const std::string& shader_source, | 212 bool ShaderTranslator::Translate(const std::string& shader_source, |
| 213 std::string* info_log, | 213 std::string* info_log, |
| 214 std::string* translated_source, | 214 std::string* translated_source, |
| 215 int* shader_version, | 215 int* shader_version, |
| 216 AttributeMap* attrib_map, | 216 AttributeMap* attrib_map, |
| 217 UniformMap* uniform_map, | 217 UniformMap* uniform_map, |
| 218 VaryingMap* varying_map, | 218 VaryingMap* varying_map, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 // We don't need results in the compiler anymore. | 254 // We don't need results in the compiler anymore. |
| 255 ShClearResults(compiler_); | 255 ShClearResults(compiler_); |
| 256 | 256 |
| 257 return success; | 257 return success; |
| 258 } | 258 } |
| 259 | 259 |
| 260 std::string ShaderTranslator::GetStringForOptionsThatWouldAffectCompilation() | 260 std::string ShaderTranslator::GetStringForOptionsThatWouldAffectCompilation() |
| 261 const { | 261 const { |
| 262 DCHECK(compiler_ != NULL); | 262 DCHECK(compiler_ != NULL); |
| 263 return std::string(":CompileOptions:" + | 263 return std::string(":CompileOptions:" + |
| 264 base::IntToString(GetCompileOptions())) + | 264 base::Uint64ToString(GetCompileOptions())) + |
| 265 ShGetBuiltInResourcesString(compiler_); | 265 ShGetBuiltInResourcesString(compiler_); |
| 266 } | 266 } |
| 267 | 267 |
| 268 void ShaderTranslator::AddDestructionObserver( | 268 void ShaderTranslator::AddDestructionObserver( |
| 269 DestructionObserver* observer) { | 269 DestructionObserver* observer) { |
| 270 destruction_observers_.AddObserver(observer); | 270 destruction_observers_.AddObserver(observer); |
| 271 } | 271 } |
| 272 | 272 |
| 273 void ShaderTranslator::RemoveDestructionObserver( | 273 void ShaderTranslator::RemoveDestructionObserver( |
| 274 DestructionObserver* observer) { | 274 DestructionObserver* observer) { |
| 275 destruction_observers_.RemoveObserver(observer); | 275 destruction_observers_.RemoveObserver(observer); |
| 276 } | 276 } |
| 277 | 277 |
| 278 ShaderTranslator::~ShaderTranslator() { | 278 ShaderTranslator::~ShaderTranslator() { |
| 279 FOR_EACH_OBSERVER(DestructionObserver, | 279 FOR_EACH_OBSERVER(DestructionObserver, |
| 280 destruction_observers_, | 280 destruction_observers_, |
| 281 OnDestruct(this)); | 281 OnDestruct(this)); |
| 282 | 282 |
| 283 if (compiler_ != NULL) | 283 if (compiler_ != NULL) |
| 284 ShDestruct(compiler_); | 284 ShDestruct(compiler_); |
| 285 } | 285 } |
| 286 | 286 |
| 287 } // namespace gles2 | 287 } // namespace gles2 |
| 288 } // namespace gpu | 288 } // namespace gpu |
| 289 | 289 |
| OLD | NEW |