Chromium Code Reviews| 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/query_manager.h" | 5 #include "gpu/command_buffer/service/query_manager.h" |
| 6 | 6 |
| 7 #include "base/atomicops.h" | 7 #include "base/atomicops.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 this, target, shm_id, shm_offset, service_id); | 505 this, target, shm_id, shm_offset, service_id); |
| 506 break; | 506 break; |
| 507 } | 507 } |
| 508 } | 508 } |
| 509 std::pair<QueryMap::iterator, bool> result = | 509 std::pair<QueryMap::iterator, bool> result = |
| 510 queries_.insert(std::make_pair(client_id, query)); | 510 queries_.insert(std::make_pair(client_id, query)); |
| 511 DCHECK(result.second); | 511 DCHECK(result.second); |
| 512 return query.get(); | 512 return query.get(); |
| 513 } | 513 } |
| 514 | 514 |
| 515 void QueryManager::GenQueries(GLsizei n, const GLuint* queries) { | |
| 516 DCHECK_GE(n, 0); | |
| 517 for (GLsizei i = 0; i < n; ++i) { | |
| 518 generated_query_ids_.insert(queries[i]); | |
| 519 } | |
| 520 } | |
| 521 | |
| 522 bool QueryManager::IsValidQuery(GLuint id) { | |
| 523 GeneratedQueryIds::iterator it = generated_query_ids_.find(id); | |
| 524 return it != generated_query_ids_.end() ? true : false; | |
|
piman
2014/04/22 00:37:31
'? true : false' doesn't add anything. Just return
| |
| 525 } | |
| 526 | |
| 515 QueryManager::Query* QueryManager::GetQuery( | 527 QueryManager::Query* QueryManager::GetQuery( |
| 516 GLuint client_id) { | 528 GLuint client_id) { |
| 517 QueryMap::iterator it = queries_.find(client_id); | 529 QueryMap::iterator it = queries_.find(client_id); |
| 518 return it != queries_.end() ? it->second.get() : NULL; | 530 return it != queries_.end() ? it->second.get() : NULL; |
| 519 } | 531 } |
| 520 | 532 |
| 521 void QueryManager::RemoveQuery(GLuint client_id) { | 533 void QueryManager::RemoveQuery(GLuint client_id) { |
| 522 QueryMap::iterator it = queries_.find(client_id); | 534 QueryMap::iterator it = queries_.find(client_id); |
| 523 if (it != queries_.end()) { | 535 if (it != queries_.end()) { |
| 524 Query* query = it->second.get(); | 536 Query* query = it->second.get(); |
| 537 generated_query_ids_.erase(client_id); | |
|
piman
2014/04/22 00:37:31
According to spec, this must be removed in DeleteQ
rptr
2014/04/22 05:43:18
Done.
| |
| 525 RemovePendingQuery(query); | 538 RemovePendingQuery(query); |
| 526 query->MarkAsDeleted(); | 539 query->MarkAsDeleted(); |
| 527 queries_.erase(it); | 540 queries_.erase(it); |
| 528 } | 541 } |
| 529 } | 542 } |
| 530 | 543 |
| 531 void QueryManager::StartTracking(QueryManager::Query* /* query */) { | 544 void QueryManager::StartTracking(QueryManager::Query* /* query */) { |
| 532 ++query_count_; | 545 ++query_count_; |
| 533 } | 546 } |
| 534 | 547 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 725 bool QueryManager::EndQuery(Query* query, base::subtle::Atomic32 submit_count) { | 738 bool QueryManager::EndQuery(Query* query, base::subtle::Atomic32 submit_count) { |
| 726 DCHECK(query); | 739 DCHECK(query); |
| 727 if (!RemovePendingQuery(query)) { | 740 if (!RemovePendingQuery(query)) { |
| 728 return false; | 741 return false; |
| 729 } | 742 } |
| 730 return query->End(submit_count); | 743 return query->End(submit_count); |
| 731 } | 744 } |
| 732 | 745 |
| 733 } // namespace gles2 | 746 } // namespace gles2 |
| 734 } // namespace gpu | 747 } // namespace gpu |
| OLD | NEW |