Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Unified Diff: gpu/command_buffer/common/id_allocator.cc

Issue 3743001: FBTF: Fix more ctor/dtors found by clang plugin. (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: Rebase to pick up mac fix on ToT Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gpu/command_buffer/common/id_allocator.h ('k') | gpu/command_buffer/service/buffer_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/common/id_allocator.cc
diff --git a/gpu/command_buffer/common/id_allocator.cc b/gpu/command_buffer/common/id_allocator.cc
index 6b2c0e4bc5cab7cb9945ad8ddc1d2d825161fd1e..68f79720b1de2000718b9c7d90fc21c0dca624a5 100644
--- a/gpu/command_buffer/common/id_allocator.cc
+++ b/gpu/command_buffer/common/id_allocator.cc
@@ -9,7 +9,35 @@
namespace gpu {
-IdAllocator::IdAllocator() {
+IdAllocator::IdAllocator() {}
+
+IdAllocator::~IdAllocator() {}
+
+ResourceId IdAllocator::AllocateID() {
+ ResourceId id = FindFirstFree();
+ MarkAsUsed(id);
+ return id;
+}
+
+ResourceId IdAllocator::AllocateIDAtOrAbove(ResourceId desired_id) {
+ GPU_DCHECK_LT(static_cast<ResourceId>(used_ids_.size()),
+ static_cast<ResourceId>(-1));
+ for (; InUse(desired_id); ++desired_id) {}
+ MarkAsUsed(desired_id);
+ return desired_id;
+}
+
+bool IdAllocator::MarkAsUsed(ResourceId id) {
+ std::pair<ResourceIdSet::iterator, bool> result = used_ids_.insert(id);
+ return result.second;
+}
+
+void IdAllocator::FreeID(ResourceId id) {
+ used_ids_.erase(id);
+}
+
+bool IdAllocator::InUse(ResourceId id) const {
+ return id == kInvalidResource || used_ids_.find(id) != used_ids_.end();
}
ResourceId IdAllocator::FindFirstFree() const {
@@ -24,12 +52,4 @@ ResourceId IdAllocator::FindFirstFree() const {
return id;
}
-ResourceId IdAllocator::AllocateIDAtOrAbove(ResourceId desired_id) {
- GPU_DCHECK_LT(static_cast<ResourceId>(used_ids_.size()),
- static_cast<ResourceId>(-1));
- for (; InUse(desired_id); ++desired_id) {}
- MarkAsUsed(desired_id);
- return desired_id;
-}
-
} // namespace gpu
« no previous file with comments | « gpu/command_buffer/common/id_allocator.h ('k') | gpu/command_buffer/service/buffer_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698