OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This file contains the implementation of IdAllocator. | 5 // This file contains the implementation of IdAllocator. |
6 | 6 |
7 #include "../common/id_allocator.h" | 7 #include "../common/id_allocator.h" |
8 #include "../common/logging.h" | 8 #include "../common/logging.h" |
9 | 9 |
10 namespace gpu { | 10 namespace gpu { |
11 | 11 |
| 12 IdAllocatorInterface::~IdAllocatorInterface() { |
| 13 } |
| 14 |
12 IdAllocator::IdAllocator() {} | 15 IdAllocator::IdAllocator() {} |
13 | 16 |
14 IdAllocator::~IdAllocator() {} | 17 IdAllocator::~IdAllocator() {} |
15 | 18 |
16 ResourceId IdAllocator::AllocateID() { | 19 ResourceId IdAllocator::AllocateID() { |
17 ResourceId id; | 20 ResourceId id; |
18 ResourceIdSet::iterator iter = free_ids_.begin(); | 21 ResourceIdSet::iterator iter = free_ids_.begin(); |
19 if (iter != free_ids_.end()) { | 22 if (iter != free_ids_.end()) { |
20 id = *iter; | 23 id = *iter; |
21 } else { | 24 } else { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 for (ResourceIdSet::const_iterator it = used_ids_.begin(); | 81 for (ResourceIdSet::const_iterator it = used_ids_.begin(); |
79 it != used_ids_.end(); ++it) { | 82 it != used_ids_.end(); ++it) { |
80 if ((*it) != id) { | 83 if ((*it) != id) { |
81 return id; | 84 return id; |
82 } | 85 } |
83 ++id; | 86 ++id; |
84 } | 87 } |
85 return id; | 88 return id; |
86 } | 89 } |
87 | 90 |
| 91 NonReusedIdAllocator::NonReusedIdAllocator() : last_id_(0) { |
| 92 } |
| 93 |
| 94 NonReusedIdAllocator::~NonReusedIdAllocator() { |
| 95 } |
| 96 |
| 97 ResourceId NonReusedIdAllocator::AllocateID() { |
| 98 return ++last_id_; |
| 99 } |
| 100 |
| 101 ResourceId NonReusedIdAllocator::AllocateIDAtOrAbove(ResourceId desired_id) { |
| 102 if (desired_id > last_id_) |
| 103 last_id_ = desired_id; |
| 104 |
| 105 return ++last_id_; |
| 106 } |
| 107 |
| 108 bool NonReusedIdAllocator::MarkAsUsed(ResourceId id) { |
| 109 GPU_NOTREACHED(); |
| 110 return false; |
| 111 } |
| 112 |
| 113 void NonReusedIdAllocator::FreeID(ResourceId id) { |
| 114 } |
| 115 |
| 116 bool NonReusedIdAllocator::InUse(ResourceId id) const { |
| 117 GPU_NOTREACHED(); |
| 118 return false; |
| 119 } |
| 120 |
88 } // namespace gpu | 121 } // namespace gpu |
OLD | NEW |