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

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

Issue 988693005: Chromium roll (https://codereview.chromium.org/976353002) (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: fixed bad android build patch Created 5 years, 9 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/gles2_cmd_utils.cc ('k') | gpu/command_buffer/common/id_allocator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/common/id_allocator.h
diff --git a/gpu/command_buffer/common/id_allocator.h b/gpu/command_buffer/common/id_allocator.h
index b877083008ad724f515799283d66173215d03344..118424f3c9d6025ba8109bb94440297806aa7116 100644
--- a/gpu/command_buffer/common/id_allocator.h
+++ b/gpu/command_buffer/common/id_allocator.h
@@ -9,7 +9,7 @@
#include <stdint.h>
-#include <set>
+#include <map>
#include <utility>
#include "base/compiler_specific.h"
@@ -36,27 +36,28 @@ class GPU_EXPORT IdAllocator {
// Note: may wrap if it starts near limit.
ResourceId AllocateIDAtOrAbove(ResourceId desired_id);
+ // Allocates |range| amount of contiguous ids.
+ // Returns the first id to |first_id| or |kInvalidResource| if
+ // allocation failed.
+ ResourceId AllocateIDRange(uint32_t range);
+
// Marks an id as used. Returns false if id was already used.
bool MarkAsUsed(ResourceId id);
// Frees a resource ID.
void FreeID(ResourceId id);
+ // Frees a |range| amount of contiguous ids, starting from |first_id|.
+ void FreeIDRange(ResourceId first_id, uint32_t range);
+
// Checks whether or not a resource ID is in use.
bool InUse(ResourceId id) const;
private:
- // TODO(gman): This would work much better with ranges or a hash table.
- typedef std::set<ResourceId> ResourceIdSet;
-
- // The highest ID on the used list.
- ResourceId LastUsedId() const;
-
- // Lowest ID that isn't on the used list. This is slow, use as a last resort.
- ResourceId FindFirstUnusedId() const;
+ // first_id -> last_id mapping.
+ typedef std::map<ResourceId, ResourceId> ResourceIdRangeMap;
- ResourceIdSet used_ids_;
- ResourceIdSet free_ids_;
+ ResourceIdRangeMap used_ids_;
DISALLOW_COPY_AND_ASSIGN(IdAllocator);
};
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils.cc ('k') | gpu/command_buffer/common/id_allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698