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_VERTEX_ARRAY_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_VERTEX_ARRAY_MANAGER_H_
8 #include "base/basictypes.h"
9 #include "base/containers/hash_tables.h"
10 #include "base/logging.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "gpu/command_buffer/service/gl_utils.h"
14 #include "gpu/gpu_export.h"
19 class VertexAttribManager
;
21 // This class keeps track of the vertex arrays and their sizes so we can do
23 class GPU_EXPORT VertexArrayManager
{
26 ~VertexArrayManager();
28 // Must call before destruction.
29 void Destroy(bool have_context
);
31 // Creates a VertexAttribManager and if client_visible,
32 // maps it to the client_id.
33 scoped_refptr
<VertexAttribManager
> CreateVertexAttribManager(
36 uint32 num_vertex_attribs
,
39 // Gets the vertex attrib manager for the given vertex array.
40 VertexAttribManager
* GetVertexAttribManager(GLuint client_id
);
42 // Removes the vertex attrib manager for the given vertex array.
43 void RemoveVertexAttribManager(GLuint client_id
);
45 // Gets a client id for a given service id.
46 bool GetClientId(GLuint service_id
, GLuint
* client_id
) const;
49 friend class VertexAttribManager
;
51 void StartTracking(VertexAttribManager
* vertex_attrib_manager
);
52 void StopTracking(VertexAttribManager
* vertex_attrib_manager
);
54 // Info for each vertex array in the system.
55 typedef base::hash_map
<GLuint
, scoped_refptr
<VertexAttribManager
> >
56 VertexAttribManagerMap
;
57 VertexAttribManagerMap vertex_attrib_managers_
;
59 // Counts the number of VertexArrayInfo allocated with 'this' as its manager.
60 // Allows to check no VertexArrayInfo will outlive this.
61 unsigned int vertex_attrib_manager_count_
;
65 DISALLOW_COPY_AND_ASSIGN(VertexArrayManager
);
71 #endif // GPU_COMMAND_BUFFER_SERVICE_VERTEX_ARRAY_MANAGER_H_