summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/common/id_allocator.cc
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-13 17:44:15 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-13 17:44:15 +0000
commitbbf94a3e7f3c4372c4ff918a6811a505d8fd69b9 (patch)
treec5d2614d92182544af89d3908be118149fae185a /gpu/command_buffer/common/id_allocator.cc
parent372c8e90fba9881bdf52298587f336cc083e3b17 (diff)
downloadchromium_src-bbf94a3e7f3c4372c4ff918a6811a505d8fd69b9.zip
chromium_src-bbf94a3e7f3c4372c4ff918a6811a505d8fd69b9.tar.gz
chromium_src-bbf94a3e7f3c4372c4ff918a6811a505d8fd69b9.tar.bz2
FBTF: Fix more ctor/dtors found by clang plugin.
(1.2 megs off of Debug Linux .a files) BUG=none TEST=compiles everywhere Review URL: http://codereview.chromium.org/3743001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62420 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/common/id_allocator.cc')
-rw-r--r--gpu/command_buffer/common/id_allocator.cc38
1 files changed, 29 insertions, 9 deletions
diff --git a/gpu/command_buffer/common/id_allocator.cc b/gpu/command_buffer/common/id_allocator.cc
index 6b2c0e4..68f7972 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