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

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

Issue 7554015: Implemented support for GL constext share groups in the renderer process. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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
Index: gpu/command_buffer/common/id_allocator.h
===================================================================
--- gpu/command_buffer/common/id_allocator.h (revision 95161)
+++ gpu/command_buffer/common/id_allocator.h (working copy)
@@ -11,6 +11,10 @@
#include <utility>
#include "../common/types.h"
+// TODO(apatrick): Having regular GL flush semantics on the client side, it
+// probably isn't necessary to round trip to the service to allocate IDs.
+// Retire this code.
+
namespace gpu {
// A resource ID, key to the resource maps.
@@ -18,28 +22,40 @@
// Invalid resource ID.
static const ResourceId kInvalidResource = 0u;
-// A class to manage the allocation of resource IDs.
-class IdAllocator {
+class IdAllocatorInterface {
public:
- IdAllocator();
- ~IdAllocator();
+ virtual ~IdAllocatorInterface();
// Allocates a new resource ID.
- ResourceId AllocateID();
+ virtual ResourceId AllocateID() = 0;
// Allocates an Id starting at or above desired_id.
// Note: may wrap if it starts near limit.
- ResourceId AllocateIDAtOrAbove(ResourceId desired_id);
+ virtual ResourceId AllocateIDAtOrAbove(ResourceId desired_id) = 0;
// Marks an id as used. Returns false if id was already used.
- bool MarkAsUsed(ResourceId id);
+ virtual bool MarkAsUsed(ResourceId id) = 0;
// Frees a resource ID.
- void FreeID(ResourceId id);
+ virtual void FreeID(ResourceId id) = 0;
// Checks whether or not a resource ID is in use.
- bool InUse(ResourceId id) const;
+ virtual bool InUse(ResourceId id) const = 0;
+};
+// A class to manage the allocation of resource IDs.
+class IdAllocator : public IdAllocatorInterface {
+ public:
+ IdAllocator();
+ virtual ~IdAllocator();
+
+ // Implement IdAllocatorInterface.
+ virtual ResourceId AllocateID();
+ virtual ResourceId AllocateIDAtOrAbove(ResourceId desired_id);
+ virtual bool MarkAsUsed(ResourceId id);
+ virtual void FreeID(ResourceId id);
+ virtual bool InUse(ResourceId id) const;
+
private:
// TODO(gman): This would work much better with ranges or a hash table.
typedef std::set<ResourceId> ResourceIdSet;
@@ -56,6 +72,28 @@
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 usedul for
jamesr 2011/08/03 21:51:20 typo: usedul -> useful
+// 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();
+ virtual ResourceId AllocateIDAtOrAbove(ResourceId desired_id);
+ virtual bool MarkAsUsed(ResourceId id);
+ virtual void FreeID(ResourceId id);
+ virtual bool InUse(ResourceId id) const;
+
+ private:
+ ResourceId last_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(NonReusedIdAllocator);
+};
+
} // namespace gpu
#endif // GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_

Powered by Google App Engine
This is Rietveld 408576698