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

Side by Side Diff: gpu/command_buffer/client/id_allocator.h

Issue 367002: Added Pepper 3D render context that instantiates the GPU plugin.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 12 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 definition of the IdAllocator class. 5 // This file contains the definition of the IdAllocator class.
6 6
7 #ifndef GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_ 7 #ifndef GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_
8 #define GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_ 8 #define GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_
9 9
10 #include <vector> 10 #include <vector>
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "gpu/command_buffer/common/types.h" 12 #include "gpu/command_buffer/common/types.h"
13 #include "gpu/command_buffer/common/resource.h" 13 #include "gpu/command_buffer/common/resource.h"
14 14
15 namespace gpu { 15 namespace gpu {
16 16
17 // A class to manage the allocation of resource IDs. It uses a bitfield stored 17 // A class to manage the allocation of resource IDs. It uses a bitfield stored
18 // into a vector of unsigned ints. 18 // into a vector of unsigned ints.
19 class IdAllocator { 19 class IdAllocator {
20 public: 20 public:
21 IdAllocator(); 21 IdAllocator();
22 22
23 // Allocates a new resource ID. 23 // Allocates a new resource ID.
24 gpu::ResourceId AllocateID() { 24 ResourceId AllocateID() {
25 unsigned int bit = FindFirstFree(); 25 unsigned int bit = FindFirstFree();
26 SetBit(bit, true); 26 SetBit(bit, true);
27 return bit; 27 return bit;
28 } 28 }
29 29
30 // Frees a resource ID. 30 // Frees a resource ID.
31 void FreeID(gpu::ResourceId id) { 31 void FreeID(ResourceId id) {
32 SetBit(id, false); 32 SetBit(id, false);
33 } 33 }
34 34
35 // Checks whether or not a resource ID is in use. 35 // Checks whether or not a resource ID is in use.
36 bool InUse(gpu::ResourceId id) { 36 bool InUse(ResourceId id) {
37 return GetBit(id); 37 return GetBit(id);
38 } 38 }
39 private: 39 private:
40 void SetBit(unsigned int bit, bool value); 40 void SetBit(unsigned int bit, bool value);
41 bool GetBit(unsigned int bit) const; 41 bool GetBit(unsigned int bit) const;
42 unsigned int FindFirstFree() const; 42 unsigned int FindFirstFree() const;
43 43
44 std::vector<Uint32> bitmap_; 44 std::vector<Uint32> bitmap_;
45 DISALLOW_COPY_AND_ASSIGN(IdAllocator); 45 DISALLOW_COPY_AND_ASSIGN(IdAllocator);
46 }; 46 };
47 47
48 } // namespace gpu 48 } // namespace gpu
49 49
50 #endif // GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_ 50 #endif // GPU_COMMAND_BUFFER_CLIENT_ID_ALLOCATOR_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/gles2_implementation.h ('k') | gpu/command_buffer/client/id_allocator_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698