diff options
Diffstat (limited to 'gpu/command_buffer/common/id_allocator.h')
-rw-r--r-- | gpu/command_buffer/common/id_allocator.h | 52 |
1 files changed, 9 insertions, 43 deletions
diff --git a/gpu/command_buffer/common/id_allocator.h b/gpu/command_buffer/common/id_allocator.h index 3f2dc4a..b8770830 100644 --- a/gpu/command_buffer/common/id_allocator.h +++ b/gpu/command_buffer/common/id_allocator.h @@ -23,39 +23,27 @@ typedef uint32_t ResourceId; // Invalid resource ID. static const ResourceId kInvalidResource = 0u; -class GPU_EXPORT IdAllocatorInterface { +// A class to manage the allocation of resource IDs. +class GPU_EXPORT IdAllocator { public: - virtual ~IdAllocatorInterface(); + IdAllocator(); + ~IdAllocator(); // Allocates a new resource ID. - virtual ResourceId AllocateID() = 0; + ResourceId AllocateID(); // Allocates an Id starting at or above desired_id. // Note: may wrap if it starts near limit. - virtual ResourceId AllocateIDAtOrAbove(ResourceId desired_id) = 0; + ResourceId AllocateIDAtOrAbove(ResourceId desired_id); // Marks an id as used. Returns false if id was already used. - virtual bool MarkAsUsed(ResourceId id) = 0; + bool MarkAsUsed(ResourceId id); // Frees a resource ID. - virtual void FreeID(ResourceId id) = 0; + void FreeID(ResourceId id); // Checks whether or not a resource ID is in use. - virtual bool InUse(ResourceId id) const = 0; -}; - -// A class to manage the allocation of resource IDs. -class GPU_EXPORT IdAllocator : public IdAllocatorInterface { - public: - IdAllocator(); - virtual ~IdAllocator(); - - // Implement IdAllocatorInterface. - virtual ResourceId AllocateID() OVERRIDE; - virtual ResourceId AllocateIDAtOrAbove(ResourceId desired_id) OVERRIDE; - virtual bool MarkAsUsed(ResourceId id) OVERRIDE; - virtual void FreeID(ResourceId id) OVERRIDE; - virtual bool InUse(ResourceId id) const OVERRIDE; + bool InUse(ResourceId id) const; private: // TODO(gman): This would work much better with ranges or a hash table. @@ -73,28 +61,6 @@ class GPU_EXPORT IdAllocator : public IdAllocatorInterface { DISALLOW_COPY_AND_ASSIGN(IdAllocator); }; -// A class to manage the allocation of resource IDs that are never reused. This -// implementation does not track which IDs are currently used. It is useful for -// shared and programs which cannot be implicitly created by binding a -// previously unused ID. -class NonReusedIdAllocator : public IdAllocatorInterface { - public: - NonReusedIdAllocator(); - virtual ~NonReusedIdAllocator(); - - // Implement IdAllocatorInterface. - virtual ResourceId AllocateID() OVERRIDE; - virtual ResourceId AllocateIDAtOrAbove(ResourceId desired_id) OVERRIDE; - virtual bool MarkAsUsed(ResourceId id) OVERRIDE; - virtual void FreeID(ResourceId id) OVERRIDE; - virtual bool InUse(ResourceId id) const OVERRIDE; - - private: - ResourceId last_id_; - - DISALLOW_COPY_AND_ASSIGN(NonReusedIdAllocator); -}; - } // namespace gpu #endif // GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_ |