Make GL bindings conditional
[chromium-blink-merge.git] / gpu / command_buffer / service / id_manager.h
blob0bc0674190422ecd92ca102edb32e7b094ebd511
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_ID_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_ID_MANAGER_H_
8 #include "base/basictypes.h"
9 #include "base/containers/hash_tables.h"
10 #include "gpu/command_buffer/service/gl_utils.h"
11 #include "gpu/gpu_export.h"
13 namespace gpu {
14 namespace gles2 {
16 // This class maps one set of ids to another.
18 // NOTE: To support shared resources an instance of this class will
19 // need to be shared by multiple GLES2Decoders.
20 class GPU_EXPORT IdManager {
21 public:
22 IdManager();
23 ~IdManager();
25 // Maps a client_id to a service_id. Return false if the client_id or
26 // service_id are already mapped to something else.
27 bool AddMapping(GLuint client_id, GLuint service_id);
29 // Unmaps a pair of ids. Returns false if the pair were not previously mapped.
30 bool RemoveMapping(GLuint client_id, GLuint service_id);
32 // Gets the corresponding service_id for the given client_id.
33 // Returns false if there is no corresponding service_id.
34 bool GetServiceId(GLuint client_id, GLuint* service_id);
36 // Gets the corresponding client_id for the given service_id.
37 // Returns false if there is no corresponding client_id.
38 bool GetClientId(GLuint service_id, GLuint* client_id);
40 private:
41 typedef base::hash_map<GLuint, GLuint> MapType;
42 MapType id_map_;
44 DISALLOW_COPY_AND_ASSIGN(IdManager);
47 } // namespace gles2
48 } // namespace gpu
50 #endif // GPU_COMMAND_BUFFER_SERVICE_ID_MANAGER_H_