OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef GPU_COMMAND_BUFFER_SERVICE_ID_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_ID_MANAGER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_ID_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_ID_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "gpu/command_buffer/service/gl_utils.h" | 10 #include "gpu/command_buffer/service/gl_utils.h" |
11 | 11 |
12 namespace gpu { | 12 namespace gpu { |
13 namespace gles2 { | 13 namespace gles2 { |
14 | 14 |
15 // This class maps one set of ids to another. | 15 // This class maps one set of ids to another. |
16 // | 16 // |
17 // NOTE: To support shared resources an instance of this class will | 17 // NOTE: To support shared resources an instance of this class will |
18 // need to be shared by multiple GLES2Decoders. | 18 // need to be shared by multiple GLES2Decoders. |
19 class IdManager { | 19 class IdManager { |
20 public: | 20 public: |
21 IdManager() { } | 21 IdManager(); |
| 22 ~IdManager(); |
22 | 23 |
23 // Maps a client_id to a service_id. Return false if the client_id or | 24 // Maps a client_id to a service_id. Return false if the client_id or |
24 // service_id are already mapped to something else. | 25 // service_id are already mapped to something else. |
25 bool AddMapping(GLuint client_id, GLuint service_id); | 26 bool AddMapping(GLuint client_id, GLuint service_id); |
26 | 27 |
27 // Unmaps a pair of ids. Returns false if the pair were not previously mapped. | 28 // Unmaps a pair of ids. Returns false if the pair were not previously mapped. |
28 bool RemoveMapping(GLuint client_id, GLuint service_id); | 29 bool RemoveMapping(GLuint client_id, GLuint service_id); |
29 | 30 |
30 // Gets the corresponding service_id for the given client_id. | 31 // Gets the corresponding service_id for the given client_id. |
31 // Returns false if there is no corresponding service_id. | 32 // Returns false if there is no corresponding service_id. |
32 bool GetServiceId(GLuint client_id, GLuint* service_id); | 33 bool GetServiceId(GLuint client_id, GLuint* service_id); |
33 | 34 |
34 // Gets the corresponding client_id for the given service_id. | 35 // Gets the corresponding client_id for the given service_id. |
35 // Returns false if there is no corresponding client_id. | 36 // Returns false if there is no corresponding client_id. |
36 bool GetClientId(GLuint service_id, GLuint* client_id); | 37 bool GetClientId(GLuint service_id, GLuint* client_id); |
37 | 38 |
38 private: | 39 private: |
39 // TODO(gman): Replace with faster implementation. | 40 // TODO(gman): Replace with faster implementation. |
40 typedef std::map<GLuint, GLuint> MapType; | 41 typedef std::map<GLuint, GLuint> MapType; |
41 MapType id_map_; | 42 MapType id_map_; |
42 | 43 |
43 DISALLOW_COPY_AND_ASSIGN(IdManager); | 44 DISALLOW_COPY_AND_ASSIGN(IdManager); |
44 }; | 45 }; |
45 | 46 |
46 } // namespace gles2 | 47 } // namespace gles2 |
47 } // namespace gpu | 48 } // namespace gpu |
48 | 49 |
49 #endif // GPU_COMMAND_BUFFER_SERVICE_ID_MANAGER_H_ | 50 #endif // GPU_COMMAND_BUFFER_SERVICE_ID_MANAGER_H_ |
50 | 51 |
OLD | NEW |