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_CLIENT_VERTEX_ARRAY_OBJECT_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_CLIENT_VERTEX_ARRAY_OBJECT_MANAGER_H_
9 #include "base/memory/scoped_ptr.h"
10 #include "gles2_impl_export.h"
11 #include "gpu/command_buffer/client/hash_tables.h"
12 #include "gpu/command_buffer/common/types.h"
17 class GLES2Implementation
;
19 class VertexArrayObject
;
21 // VertexArrayObjectManager manages vertex array objects on the client side
22 // of the command buffer.
23 class GLES2_IMPL_EXPORT VertexArrayObjectManager
{
25 VertexArrayObjectManager(
26 GLuint max_vertex_attribs
,
27 GLuint array_buffer_id
,
28 GLuint element_array_buffer_id
);
29 ~VertexArrayObjectManager();
31 bool IsReservedId(GLuint id
) const;
33 // Binds an element array.
34 // Returns true if service should be called.
35 bool BindElementArray(GLuint id
);
38 void UnbindBuffer(GLuint id
);
40 // Geneates array objects for the given ids.
41 void GenVertexArrays(GLsizei n
, const GLuint
* arrays
);
43 // Deletes array objects for the given ids.
44 void DeleteVertexArrays(GLsizei n
, const GLuint
* arrays
);
46 // Binds a vertex array.
47 // changed will be set to true if the service should be called.
48 // Returns false if array is an unknown id.
49 bool BindVertexArray(GLuint array
, bool* changed
);
51 // simulated will be set to true if buffers were simulated.
52 // Returns true service should be called.
53 bool SetupSimulatedClientSideBuffers(
54 const char* function_name
,
55 GLES2Implementation
* gl
,
56 GLES2CmdHelper
* gl_helper
,
61 // Returns true if buffers were setup.
62 bool SetupSimulatedIndexAndClientSideBuffers(
63 const char* function_name
,
64 GLES2Implementation
* gl
,
65 GLES2CmdHelper
* gl_helper
,
73 bool HaveEnabledClientSideBuffers() const;
75 void SetAttribEnable(GLuint index
, bool enabled
);
77 bool GetVertexAttrib(GLuint index
, GLenum pname
, uint32
* param
);
79 bool GetAttribPointer(GLuint index
, GLenum pname
, void** ptr
) const;
81 // Returns false if error.
82 bool SetAttribPointer(
91 void SetAttribDivisor(GLuint index
, GLuint divisor
);
93 GLuint
bound_element_array_buffer() const;
96 typedef gpu::hash_map
<GLuint
, VertexArrayObject
*> VertexArrayObjectMap
;
98 bool IsDefaultVAOBound() const;
100 GLsizei
CollectData(const void* data
,
101 GLsizei bytes_per_element
,
103 GLsizei num_elements
);
105 GLuint max_vertex_attribs_
;
106 GLuint array_buffer_id_
;
107 GLsizei array_buffer_size_
;
108 GLsizei array_buffer_offset_
;
109 GLuint element_array_buffer_id_
;
110 GLsizei element_array_buffer_size_
;
111 GLsizei collection_buffer_size_
;
112 scoped_ptr
<int8
[]> collection_buffer_
;
114 VertexArrayObject
* default_vertex_array_object_
;
115 VertexArrayObject
* bound_vertex_array_object_
;
116 VertexArrayObjectMap vertex_array_objects_
;
118 DISALLOW_COPY_AND_ASSIGN(VertexArrayObjectManager
);
124 #endif // GPU_COMMAND_BUFFER_CLIENT_VERTEX_ARRAY_OBJECT_MANAGER_H_