cc: Added inline to Tile::IsReadyToDraw
[chromium-blink-merge.git] / gpu / command_buffer / client / vertex_array_object_manager.h
blob254b15da055731bcab91c9b389f6318241533f03
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_
8 #include <GLES2/gl2.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"
14 namespace gpu {
15 namespace gles2 {
17 class GLES2Implementation;
18 class GLES2CmdHelper;
19 class VertexArrayObject;
21 // VertexArrayObjectManager manages vertex array objects on the client side
22 // of the command buffer.
23 class GLES2_IMPL_EXPORT VertexArrayObjectManager {
24 public:
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);
37 // Unbind buffer.
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,
57 GLsizei num_elements,
58 GLsizei primcount,
59 bool* simulated);
61 // Returns true if buffers were setup.
62 bool SetupSimulatedIndexAndClientSideBuffers(
63 const char* function_name,
64 GLES2Implementation* gl,
65 GLES2CmdHelper* gl_helper,
66 GLsizei count,
67 GLenum type,
68 GLsizei primcount,
69 const void* indices,
70 GLuint* offset,
71 bool* simulated);
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(
83 GLuint buffer_id,
84 GLuint index,
85 GLint size,
86 GLenum type,
87 GLboolean normalized,
88 GLsizei stride,
89 const void* ptr);
91 void SetAttribDivisor(GLuint index, GLuint divisor);
93 GLuint bound_element_array_buffer() const;
95 private:
96 typedef gpu::hash_map<GLuint, VertexArrayObject*> VertexArrayObjectMap;
98 bool IsDefaultVAOBound() const;
100 GLsizei CollectData(const void* data,
101 GLsizei bytes_per_element,
102 GLsizei real_stride,
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);
121 } // namespace gles2
122 } // namespace gpu
124 #endif // GPU_COMMAND_BUFFER_CLIENT_VERTEX_ARRAY_OBJECT_MANAGER_H_