| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/vertex_attrib_manager.h" | 5 #include "gpu/command_buffer/service/vertex_attrib_manager.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #define GLES2_GPU_SERVICE 1 | 13 #define GLES2_GPU_SERVICE 1 |
| 14 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 14 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
| 15 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 15 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 16 #include "gpu/command_buffer/service/gl_utils.h" | 16 #include "gpu/command_buffer/service/gl_utils.h" |
| 17 #include "gpu/command_buffer/service/gpu_switches.h" | 17 #include "gpu/command_buffer/service/gpu_switches.h" |
| 18 #include "gpu/command_buffer/service/vertex_array_manager.h" | 18 #include "gpu/command_buffer/service/vertex_array_manager.h" |
| 19 | 19 |
| 20 namespace gpu { | 20 namespace gpu { |
| 21 namespace gles2 { | 21 namespace gles2 { |
| 22 | 22 |
| 23 VertexAttribManager::VertexAttribInfo::VertexAttribInfo() | 23 VertexAttrib::VertexAttrib() |
| 24 : index_(0), | 24 : index_(0), |
| 25 enabled_(false), | 25 enabled_(false), |
| 26 size_(4), | 26 size_(4), |
| 27 type_(GL_FLOAT), | 27 type_(GL_FLOAT), |
| 28 offset_(0), | 28 offset_(0), |
| 29 normalized_(GL_FALSE), | 29 normalized_(GL_FALSE), |
| 30 gl_stride_(0), | 30 gl_stride_(0), |
| 31 real_stride_(16), | 31 real_stride_(16), |
| 32 divisor_(0), | 32 divisor_(0), |
| 33 list_(NULL) { | 33 list_(NULL) { |
| 34 } | 34 } |
| 35 | 35 |
| 36 VertexAttribManager::VertexAttribInfo::~VertexAttribInfo() { | 36 VertexAttrib::~VertexAttrib() { |
| 37 } | 37 } |
| 38 | 38 |
| 39 bool VertexAttribManager::VertexAttribInfo::CanAccess(GLuint index) const { | 39 bool VertexAttrib::CanAccess(GLuint index) const { |
| 40 if (!enabled_) { | 40 if (!enabled_) { |
| 41 return true; | 41 return true; |
| 42 } | 42 } |
| 43 | 43 |
| 44 if (!buffer_ || buffer_->IsDeleted()) { | 44 if (!buffer_ || buffer_->IsDeleted()) { |
| 45 return false; | 45 return false; |
| 46 } | 46 } |
| 47 | 47 |
| 48 // The number of elements that can be accessed. | 48 // The number of elements that can be accessed. |
| 49 GLsizeiptr buffer_size = buffer_->size(); | 49 GLsizeiptr buffer_size = buffer_->size(); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 if (!disable_workarounds && init_attribs) { | 101 if (!disable_workarounds && init_attribs) { |
| 102 glVertexAttrib4f(vv, 0.0f, 0.0f, 0.0f, 1.0f); | 102 glVertexAttrib4f(vv, 0.0f, 0.0f, 0.0f, 1.0f); |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 | 106 |
| 107 bool VertexAttribManager::Enable(GLuint index, bool enable) { | 107 bool VertexAttribManager::Enable(GLuint index, bool enable) { |
| 108 if (index >= vertex_attrib_infos_.size()) { | 108 if (index >= vertex_attrib_infos_.size()) { |
| 109 return false; | 109 return false; |
| 110 } | 110 } |
| 111 VertexAttribInfo& info = vertex_attrib_infos_[index]; | 111 VertexAttrib& info = vertex_attrib_infos_[index]; |
| 112 if (info.enabled() != enable) { | 112 if (info.enabled() != enable) { |
| 113 info.set_enabled(enable); | 113 info.set_enabled(enable); |
| 114 info.SetList(enable ? &enabled_vertex_attribs_ : &disabled_vertex_attribs_); | 114 info.SetList(enable ? &enabled_vertex_attribs_ : &disabled_vertex_attribs_); |
| 115 } | 115 } |
| 116 return true; | 116 return true; |
| 117 } | 117 } |
| 118 | 118 |
| 119 void VertexAttribManager::Unbind(BufferManager::BufferInfo* buffer) { | 119 void VertexAttribManager::Unbind(BufferManager::Buffer* buffer) { |
| 120 if (element_array_buffer_ == buffer) { | 120 if (element_array_buffer_ == buffer) { |
| 121 element_array_buffer_ = NULL; | 121 element_array_buffer_ = NULL; |
| 122 } | 122 } |
| 123 for (uint32 vv = 0; vv < vertex_attrib_infos_.size(); ++vv) { | 123 for (uint32 vv = 0; vv < vertex_attrib_infos_.size(); ++vv) { |
| 124 vertex_attrib_infos_[vv].Unbind(buffer); | 124 vertex_attrib_infos_[vv].Unbind(buffer); |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 | 127 |
| 128 } // namespace gles2 | 128 } // namespace gles2 |
| 129 } // namespace gpu | 129 } // namespace gpu |
| OLD | NEW |