| Index: gpu/command_buffer/service/vertex_attrib_manager.h
|
| diff --git a/gpu/command_buffer/service/vertex_attrib_manager.h b/gpu/command_buffer/service/vertex_attrib_manager.h
|
| index 9e87ee66d59f0da17a7919e231dbcdf1e9631c34..6ddfc4daf9b79077fdf980f861fa04d23461d597 100644
|
| --- a/gpu/command_buffer/service/vertex_attrib_manager.h
|
| +++ b/gpu/command_buffer/service/vertex_attrib_manager.h
|
| @@ -19,158 +19,156 @@ namespace gles2 {
|
|
|
| class VertexArrayManager;
|
|
|
| -// Manages vertex attributes.
|
| -// This class also acts as the service-side representation of a
|
| -// vertex array object and it's contained state.
|
| -class GPU_EXPORT VertexAttribManager :
|
| - public base::RefCounted<VertexAttribManager> {
|
| +// Info about a Vertex Attribute. This is used to track what the user currently
|
| +// has bound on each Vertex Attribute so that checking can be done at
|
| +// glDrawXXX time.
|
| +class GPU_EXPORT VertexAttrib {
|
| public:
|
| - typedef scoped_refptr<VertexAttribManager> Ref;
|
| -
|
| - // Info about Vertex Attributes. This is used to track what the user currently
|
| - // has bound on each Vertex Attribute so that checking can be done at
|
| - // glDrawXXX time.
|
| - class GPU_EXPORT VertexAttribInfo {
|
| - public:
|
| - typedef std::list<VertexAttribInfo*> VertexAttribInfoList;
|
| -
|
| - VertexAttribInfo();
|
| - ~VertexAttribInfo();
|
| + typedef std::list<VertexAttrib*> VertexAttribInfoList;
|
|
|
| - // Returns true if this VertexAttrib can access index.
|
| - bool CanAccess(GLuint index) const;
|
| + VertexAttrib();
|
| + ~VertexAttrib();
|
|
|
| - BufferManager::BufferInfo* buffer() const {
|
| - return buffer_;
|
| - }
|
| + // Returns true if this VertexAttrib can access index.
|
| + bool CanAccess(GLuint index) const;
|
|
|
| - GLsizei offset() const {
|
| - return offset_;
|
| - }
|
| + BufferManager::Buffer* buffer() const {
|
| + return buffer_;
|
| + }
|
|
|
| - GLuint index() const {
|
| - return index_;
|
| - }
|
| + GLsizei offset() const {
|
| + return offset_;
|
| + }
|
|
|
| - GLint size() const {
|
| - return size_;
|
| - }
|
| + GLuint index() const {
|
| + return index_;
|
| + }
|
|
|
| - GLenum type() const {
|
| - return type_;
|
| - }
|
| + GLint size() const {
|
| + return size_;
|
| + }
|
|
|
| - GLboolean normalized() const {
|
| - return normalized_;
|
| - }
|
| + GLenum type() const {
|
| + return type_;
|
| + }
|
|
|
| - GLsizei gl_stride() const {
|
| - return gl_stride_;
|
| - }
|
| + GLboolean normalized() const {
|
| + return normalized_;
|
| + }
|
|
|
| - GLuint divisor() const {
|
| - return divisor_;
|
| - }
|
| + GLsizei gl_stride() const {
|
| + return gl_stride_;
|
| + }
|
|
|
| - bool enabled() const {
|
| - return enabled_;
|
| - }
|
| + GLuint divisor() const {
|
| + return divisor_;
|
| + }
|
|
|
| - // Find the maximum vertex accessed, accounting for instancing.
|
| - GLuint MaxVertexAccessed(GLsizei primcount,
|
| - GLuint max_vertex_accessed) const {
|
| - return (primcount && divisor_) ? ((primcount - 1) / divisor_) :
|
| - max_vertex_accessed;
|
| - }
|
| + bool enabled() const {
|
| + return enabled_;
|
| + }
|
|
|
| - private:
|
| - friend class VertexAttribManager;
|
| + // Find the maximum vertex accessed, accounting for instancing.
|
| + GLuint MaxVertexAccessed(GLsizei primcount,
|
| + GLuint max_vertex_accessed) const {
|
| + return (primcount && divisor_) ? ((primcount - 1) / divisor_) :
|
| + max_vertex_accessed;
|
| + }
|
|
|
| - void set_enabled(bool enabled) {
|
| - enabled_ = enabled;
|
| - }
|
| + private:
|
| + friend class VertexAttribManager;
|
|
|
| - void set_index(GLuint index) {
|
| - index_ = index;
|
| - }
|
| + void set_enabled(bool enabled) {
|
| + enabled_ = enabled;
|
| + }
|
|
|
| - void SetList(VertexAttribInfoList* new_list) {
|
| - DCHECK(new_list);
|
| + void set_index(GLuint index) {
|
| + index_ = index;
|
| + }
|
|
|
| - if (list_) {
|
| - list_->erase(it_);
|
| - }
|
| + void SetList(VertexAttribInfoList* new_list) {
|
| + DCHECK(new_list);
|
|
|
| - it_ = new_list->insert(new_list->end(), this);
|
| - list_ = new_list;
|
| + if (list_) {
|
| + list_->erase(it_);
|
| }
|
|
|
| - void SetInfo(
|
| - BufferManager::BufferInfo* buffer,
|
| - GLint size,
|
| - GLenum type,
|
| - GLboolean normalized,
|
| - GLsizei gl_stride,
|
| - GLsizei real_stride,
|
| - GLsizei offset) {
|
| - DCHECK_GT(real_stride, 0);
|
| - buffer_ = buffer;
|
| - size_ = size;
|
| - type_ = type;
|
| - normalized_ = normalized;
|
| - gl_stride_ = gl_stride;
|
| - real_stride_ = real_stride;
|
| - offset_ = offset;
|
| - }
|
| + it_ = new_list->insert(new_list->end(), this);
|
| + list_ = new_list;
|
| + }
|
|
|
| - void SetDivisor(GLsizei divisor) {
|
| - divisor_ = divisor;
|
| - }
|
| + void SetInfo(
|
| + BufferManager::Buffer* buffer,
|
| + GLint size,
|
| + GLenum type,
|
| + GLboolean normalized,
|
| + GLsizei gl_stride,
|
| + GLsizei real_stride,
|
| + GLsizei offset) {
|
| + DCHECK_GT(real_stride, 0);
|
| + buffer_ = buffer;
|
| + size_ = size;
|
| + type_ = type;
|
| + normalized_ = normalized;
|
| + gl_stride_ = gl_stride;
|
| + real_stride_ = real_stride;
|
| + offset_ = offset;
|
| + }
|
|
|
| - void Unbind(BufferManager::BufferInfo* buffer) {
|
| - if (buffer_ == buffer) {
|
| - buffer_ = NULL;
|
| - }
|
| + void SetDivisor(GLsizei divisor) {
|
| + divisor_ = divisor;
|
| + }
|
| +
|
| + void Unbind(BufferManager::Buffer* buffer) {
|
| + if (buffer_ == buffer) {
|
| + buffer_ = NULL;
|
| }
|
| + }
|
|
|
| - // The index of this attrib.
|
| - GLuint index_;
|
| + // The index of this attrib.
|
| + GLuint index_;
|
|
|
| - // Whether or not this attribute is enabled.
|
| - bool enabled_;
|
| + // Whether or not this attribute is enabled.
|
| + bool enabled_;
|
|
|
| - // number of components (1, 2, 3, 4)
|
| - GLint size_;
|
| + // number of components (1, 2, 3, 4)
|
| + GLint size_;
|
|
|
| - // GL_BYTE, GL_FLOAT, etc. See glVertexAttribPointer.
|
| - GLenum type_;
|
| + // GL_BYTE, GL_FLOAT, etc. See glVertexAttribPointer.
|
| + GLenum type_;
|
|
|
| - // The offset into the buffer.
|
| - GLsizei offset_;
|
| + // The offset into the buffer.
|
| + GLsizei offset_;
|
|
|
| - GLboolean normalized_;
|
| + GLboolean normalized_;
|
|
|
| - // The stride passed to glVertexAttribPointer.
|
| - GLsizei gl_stride_;
|
| + // The stride passed to glVertexAttribPointer.
|
| + GLsizei gl_stride_;
|
|
|
| - // The stride that will be used to access the buffer. This is the actual
|
| - // stide, NOT the GL bogus stride. In other words there is never a stride
|
| - // of 0.
|
| - GLsizei real_stride_;
|
| + // The stride that will be used to access the buffer. This is the actual
|
| + // stide, NOT the GL bogus stride. In other words there is never a stride
|
| + // of 0.
|
| + GLsizei real_stride_;
|
|
|
| - GLsizei divisor_;
|
| + GLsizei divisor_;
|
|
|
| - // The buffer bound to this attribute.
|
| - BufferManager::BufferInfo::Ref buffer_;
|
| + // The buffer bound to this attribute.
|
| + scoped_refptr<BufferManager::Buffer> buffer_;
|
|
|
| - // List this info is on.
|
| - VertexAttribInfoList* list_;
|
| + // List this info is on.
|
| + VertexAttribInfoList* list_;
|
|
|
| - // Iterator for list this info is on. Enabled/Disabled
|
| - VertexAttribInfoList::iterator it_;
|
| - };
|
| + // Iterator for list this info is on. Enabled/Disabled
|
| + VertexAttribInfoList::iterator it_;
|
| +};
|
|
|
| - typedef std::list<VertexAttribInfo*> VertexAttribInfoList;
|
| +// Manages vertex attributes.
|
| +// This class also acts as the service-side representation of a
|
| +// vertex array object and it's contained state.
|
| +class GPU_EXPORT VertexAttribManager :
|
| + public base::RefCounted<VertexAttribManager> {
|
| + public:
|
| + typedef std::list<VertexAttrib*> VertexAttribInfoList;
|
|
|
| VertexAttribManager();
|
|
|
| @@ -186,7 +184,7 @@ class GPU_EXPORT VertexAttribManager :
|
| return enabled_vertex_attribs_;
|
| }
|
|
|
| - VertexAttribInfo* GetVertexAttribInfo(GLuint index) {
|
| + VertexAttrib* GetVertexAttrib(GLuint index) {
|
| if (index < vertex_attrib_infos_.size()) {
|
| return &vertex_attrib_infos_[index];
|
| }
|
| @@ -195,14 +193,14 @@ class GPU_EXPORT VertexAttribManager :
|
|
|
| void SetAttribInfo(
|
| GLuint index,
|
| - BufferManager::BufferInfo* buffer,
|
| + BufferManager::Buffer* buffer,
|
| GLint size,
|
| GLenum type,
|
| GLboolean normalized,
|
| GLsizei gl_stride,
|
| GLsizei real_stride,
|
| GLsizei offset) {
|
| - VertexAttribInfo* info = GetVertexAttribInfo(index);
|
| + VertexAttrib* info = GetVertexAttrib(index);
|
| if (info) {
|
| if (info->type() == GL_FIXED) {
|
| --num_fixed_attribs_;
|
| @@ -216,17 +214,17 @@ class GPU_EXPORT VertexAttribManager :
|
| }
|
|
|
| void SetDivisor(GLuint index, GLuint divisor) {
|
| - VertexAttribInfo* info = GetVertexAttribInfo(index);
|
| + VertexAttrib* info = GetVertexAttrib(index);
|
| if (info) {
|
| info->SetDivisor(divisor);
|
| }
|
| }
|
|
|
| - void SetElementArrayBuffer(BufferManager::BufferInfo* buffer) {
|
| + void SetElementArrayBuffer(BufferManager::Buffer* buffer) {
|
| element_array_buffer_ = buffer;
|
| }
|
|
|
| - BufferManager::BufferInfo* element_array_buffer() const {
|
| + BufferManager::Buffer* element_array_buffer() const {
|
| return element_array_buffer_;
|
| }
|
|
|
| @@ -234,7 +232,7 @@ class GPU_EXPORT VertexAttribManager :
|
| return service_id_;
|
| }
|
|
|
| - void Unbind(BufferManager::BufferInfo* buffer);
|
| + void Unbind(BufferManager::Buffer* buffer);
|
|
|
| bool IsDeleted() const {
|
| return deleted_;
|
| @@ -268,11 +266,11 @@ class GPU_EXPORT VertexAttribManager :
|
|
|
| // Info for each vertex attribute saved so we can check at glDrawXXX time
|
| // if it is safe to draw.
|
| - std::vector<VertexAttribInfo> vertex_attrib_infos_;
|
| + std::vector<VertexAttrib> vertex_attrib_infos_;
|
|
|
| // The currently bound element array buffer. If this is 0 it is illegal
|
| // to call glDrawElements.
|
| - BufferManager::BufferInfo::Ref element_array_buffer_;
|
| + scoped_refptr<BufferManager::Buffer> element_array_buffer_;
|
|
|
| // Lists for which vertex attribs are enabled, disabled.
|
| VertexAttribInfoList enabled_vertex_attribs_;
|
|
|