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_manager.h" | 5 #include "gpu/command_buffer/service/shader_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 void Shader::IncUseCount() { | 127 void Shader::IncUseCount() { |
128 ++use_count_; | 128 ++use_count_; |
129 } | 129 } |
130 | 130 |
131 void Shader::DecUseCount() { | 131 void Shader::DecUseCount() { |
132 --use_count_; | 132 --use_count_; |
133 DCHECK_GE(use_count_, 0); | 133 DCHECK_GE(use_count_, 0); |
134 } | 134 } |
135 | 135 |
136 void Shader::MarkAsDeleted() { | 136 void Shader::MarkAsDeleted() { |
| 137 if (use_count_ > 0) { |
| 138 // If attached, compile the shader before we delete it. |
| 139 DoCompile(); |
| 140 } |
137 DCHECK_NE(service_id_, 0u); | 141 DCHECK_NE(service_id_, 0u); |
138 service_id_ = 0; | 142 service_id_ = 0; |
139 } | 143 } |
140 | 144 |
141 const sh::Attribute* Shader::GetAttribInfo(const std::string& name) const { | 145 const sh::Attribute* Shader::GetAttribInfo(const std::string& name) const { |
142 // Vertex attributes can't be arrays or structs (GLSL ES 3.00.4, section | 146 // Vertex attributes can't be arrays or structs (GLSL ES 3.00.4, section |
143 // 4.3.4, "Input Variables"), so |name| is the top level name used as | 147 // 4.3.4, "Input Variables"), so |name| is the top level name used as |
144 // the AttributeMap key. | 148 // the AttributeMap key. |
145 AttributeMap::const_iterator it = attrib_map_.find(name); | 149 AttributeMap::const_iterator it = attrib_map_.find(name); |
146 return it != attrib_map_.end() ? &it->second : NULL; | 150 return it != attrib_map_.end() ? &it->second : NULL; |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 DCHECK(shader); | 268 DCHECK(shader); |
265 DCHECK(IsOwned(shader)); | 269 DCHECK(IsOwned(shader)); |
266 shader->DecUseCount(); | 270 shader->DecUseCount(); |
267 RemoveShader(shader); | 271 RemoveShader(shader); |
268 } | 272 } |
269 | 273 |
270 } // namespace gles2 | 274 } // namespace gles2 |
271 } // namespace gpu | 275 } // namespace gpu |
272 | 276 |
273 | 277 |
OLD | NEW |