| 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 <string.h> | 7 #include <string.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 | 9 |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 case SH_ACTIVE_ATTRIBUTES: | 40 case SH_ACTIVE_ATTRIBUTES: |
| 41 ShGetInfo(compiler, SH_ACTIVE_ATTRIBUTE_MAX_LENGTH, &name_len); | 41 ShGetInfo(compiler, SH_ACTIVE_ATTRIBUTE_MAX_LENGTH, &name_len); |
| 42 break; | 42 break; |
| 43 case SH_ACTIVE_UNIFORMS: | 43 case SH_ACTIVE_UNIFORMS: |
| 44 ShGetInfo(compiler, SH_ACTIVE_UNIFORM_MAX_LENGTH, &name_len); | 44 ShGetInfo(compiler, SH_ACTIVE_UNIFORM_MAX_LENGTH, &name_len); |
| 45 break; | 45 break; |
| 46 default: NOTREACHED(); | 46 default: NOTREACHED(); |
| 47 } | 47 } |
| 48 ShGetInfo(compiler, SH_MAPPED_NAME_MAX_LENGTH, &mapped_name_len); | 48 ShGetInfo(compiler, SH_MAPPED_NAME_MAX_LENGTH, &mapped_name_len); |
| 49 if (name_len <= 1 || mapped_name_len <= 1) return; | 49 if (name_len <= 1 || mapped_name_len <= 1) return; |
| 50 scoped_array<char> name(new char[name_len]); | 50 scoped_ptr<char[]> name(new char[name_len]); |
| 51 scoped_array<char> mapped_name(new char[mapped_name_len]); | 51 scoped_ptr<char[]> mapped_name(new char[mapped_name_len]); |
| 52 | 52 |
| 53 ANGLEGetInfoType num_vars = 0; | 53 ANGLEGetInfoType num_vars = 0; |
| 54 ShGetInfo(compiler, var_type, &num_vars); | 54 ShGetInfo(compiler, var_type, &num_vars); |
| 55 for (ANGLEGetInfoType i = 0; i < num_vars; ++i) { | 55 for (ANGLEGetInfoType i = 0; i < num_vars; ++i) { |
| 56 ANGLEGetInfoType len = 0; | 56 ANGLEGetInfoType len = 0; |
| 57 int size = 0; | 57 int size = 0; |
| 58 ShDataType type = SH_NONE; | 58 ShDataType type = SH_NONE; |
| 59 | 59 |
| 60 switch (var_type) { | 60 switch (var_type) { |
| 61 case SH_ACTIVE_ATTRIBUTES: | 61 case SH_ACTIVE_ATTRIBUTES: |
| (...skipping 23 matching lines...) Expand all Loading... |
| 85 ShHandle compiler, ShaderTranslator::NameMap* name_map) { | 85 ShHandle compiler, ShaderTranslator::NameMap* name_map) { |
| 86 ANGLEGetInfoType hashed_names_count = 0; | 86 ANGLEGetInfoType hashed_names_count = 0; |
| 87 ShGetInfo(compiler, SH_HASHED_NAMES_COUNT, &hashed_names_count); | 87 ShGetInfo(compiler, SH_HASHED_NAMES_COUNT, &hashed_names_count); |
| 88 if (hashed_names_count == 0) | 88 if (hashed_names_count == 0) |
| 89 return; | 89 return; |
| 90 | 90 |
| 91 ANGLEGetInfoType name_max_len = 0, hashed_name_max_len = 0; | 91 ANGLEGetInfoType name_max_len = 0, hashed_name_max_len = 0; |
| 92 ShGetInfo(compiler, SH_NAME_MAX_LENGTH, &name_max_len); | 92 ShGetInfo(compiler, SH_NAME_MAX_LENGTH, &name_max_len); |
| 93 ShGetInfo(compiler, SH_HASHED_NAME_MAX_LENGTH, &hashed_name_max_len); | 93 ShGetInfo(compiler, SH_HASHED_NAME_MAX_LENGTH, &hashed_name_max_len); |
| 94 | 94 |
| 95 scoped_array<char> name(new char[name_max_len]); | 95 scoped_ptr<char[]> name(new char[name_max_len]); |
| 96 scoped_array<char> hashed_name(new char[hashed_name_max_len]); | 96 scoped_ptr<char[]> hashed_name(new char[hashed_name_max_len]); |
| 97 | 97 |
| 98 for (ANGLEGetInfoType i = 0; i < hashed_names_count; ++i) { | 98 for (ANGLEGetInfoType i = 0; i < hashed_names_count; ++i) { |
| 99 ShGetNameHashingEntry(compiler, i, name.get(), hashed_name.get()); | 99 ShGetNameHashingEntry(compiler, i, name.get(), hashed_name.get()); |
| 100 (*name_map)[hashed_name.get()] = name.get(); | 100 (*name_map)[hashed_name.get()] = name.get(); |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 | 103 |
| 104 } // namespace | 104 } // namespace |
| 105 | 105 |
| 106 namespace gpu { | 106 namespace gpu { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 translated_shader_.reset(); | 235 translated_shader_.reset(); |
| 236 info_log_.reset(); | 236 info_log_.reset(); |
| 237 attrib_map_.clear(); | 237 attrib_map_.clear(); |
| 238 uniform_map_.clear(); | 238 uniform_map_.clear(); |
| 239 name_map_.clear(); | 239 name_map_.clear(); |
| 240 } | 240 } |
| 241 | 241 |
| 242 } // namespace gles2 | 242 } // namespace gles2 |
| 243 } // namespace gpu | 243 } // namespace gpu |
| 244 | 244 |
| OLD | NEW |