OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/program_manager.h" | 5 #include "gpu/command_buffer/service/program_manager.h" |
6 #include "base/basictypes.h" | 6 #include "base/basictypes.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 | 300 |
301 bool ProgramManager::ProgramInfo::CanLink() const { | 301 bool ProgramManager::ProgramInfo::CanLink() const { |
302 for (int ii = 0; ii < kMaxAttachedShaders; ++ii) { | 302 for (int ii = 0; ii < kMaxAttachedShaders; ++ii) { |
303 if (!attached_shaders_[ii] || !attached_shaders_[ii]->IsValid()) { | 303 if (!attached_shaders_[ii] || !attached_shaders_[ii]->IsValid()) { |
304 return false; | 304 return false; |
305 } | 305 } |
306 } | 306 } |
307 return true; | 307 return true; |
308 } | 308 } |
309 | 309 |
| 310 ProgramManager::~ProgramManager() { |
| 311 DCHECK(program_infos_.empty()); |
| 312 } |
| 313 |
| 314 void ProgramManager::Destroy(bool have_context) { |
| 315 while (!program_infos_.empty()) { |
| 316 if (have_context) { |
| 317 ProgramInfo* info = program_infos_.begin()->second; |
| 318 if (!info->IsDeleted()) { |
| 319 glDeleteProgram(info->service_id()); |
| 320 info->MarkAsDeleted(); |
| 321 } |
| 322 } |
| 323 program_infos_.erase(program_infos_.begin()); |
| 324 } |
| 325 } |
| 326 |
310 void ProgramManager::CreateProgramInfo(GLuint client_id, GLuint service_id) { | 327 void ProgramManager::CreateProgramInfo(GLuint client_id, GLuint service_id) { |
311 std::pair<ProgramInfoMap::iterator, bool> result = | 328 std::pair<ProgramInfoMap::iterator, bool> result = |
312 program_infos_.insert( | 329 program_infos_.insert( |
313 std::make_pair(client_id, | 330 std::make_pair(client_id, |
314 ProgramInfo::Ref(new ProgramInfo(service_id)))); | 331 ProgramInfo::Ref(new ProgramInfo(service_id)))); |
315 DCHECK(result.second); | 332 DCHECK(result.second); |
316 } | 333 } |
317 | 334 |
318 ProgramManager::ProgramInfo* ProgramManager::GetProgramInfo(GLuint client_id) { | 335 ProgramManager::ProgramInfo* ProgramManager::GetProgramInfo(GLuint client_id) { |
319 ProgramInfoMap::iterator it = program_infos_.find(client_id); | 336 ProgramInfoMap::iterator it = program_infos_.find(client_id); |
(...skipping 17 matching lines...) Expand all Loading... |
337 return true; | 354 return true; |
338 } | 355 } |
339 } | 356 } |
340 return false; | 357 return false; |
341 } | 358 } |
342 | 359 |
343 } // namespace gles2 | 360 } // namespace gles2 |
344 } // namespace gpu | 361 } // namespace gpu |
345 | 362 |
346 | 363 |
OLD | NEW |