| 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" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 buffer_ = buffer; | 55 buffer_ = buffer; |
| 56 size_ = size; | 56 size_ = size; |
| 57 type_ = type; | 57 type_ = type; |
| 58 normalized_ = normalized; | 58 normalized_ = normalized; |
| 59 gl_stride_ = gl_stride; | 59 gl_stride_ = gl_stride; |
| 60 real_stride_ = real_stride; | 60 real_stride_ = real_stride; |
| 61 offset_ = offset; | 61 offset_ = offset; |
| 62 } | 62 } |
| 63 | 63 |
| 64 void VertexAttrib::Unbind(Buffer* buffer) { | 64 void VertexAttrib::Unbind(Buffer* buffer) { |
| 65 if (buffer_ == buffer) { | 65 if (buffer_.get() == buffer) { |
| 66 buffer_ = NULL; | 66 buffer_ = NULL; |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 | 69 |
| 70 bool VertexAttrib::CanAccess(GLuint index) const { | 70 bool VertexAttrib::CanAccess(GLuint index) const { |
| 71 if (!enabled_) { | 71 if (!enabled_) { |
| 72 return true; | 72 return true; |
| 73 } | 73 } |
| 74 | 74 |
| 75 if (!buffer_ || buffer_->IsDeleted()) { | 75 if (!buffer_.get() || buffer_->IsDeleted()) { |
| 76 return false; | 76 return false; |
| 77 } | 77 } |
| 78 | 78 |
| 79 // The number of elements that can be accessed. | 79 // The number of elements that can be accessed. |
| 80 GLsizeiptr buffer_size = buffer_->size(); | 80 GLsizeiptr buffer_size = buffer_->size(); |
| 81 if (offset_ > buffer_size || real_stride_ == 0) { | 81 if (offset_ > buffer_size || real_stride_ == 0) { |
| 82 return false; | 82 return false; |
| 83 } | 83 } |
| 84 | 84 |
| 85 uint32 usable_size = buffer_size - offset_; | 85 uint32 usable_size = buffer_size - offset_; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } | 145 } |
| 146 VertexAttrib& info = vertex_attribs_[index]; | 146 VertexAttrib& info = vertex_attribs_[index]; |
| 147 if (info.enabled() != enable) { | 147 if (info.enabled() != enable) { |
| 148 info.set_enabled(enable); | 148 info.set_enabled(enable); |
| 149 info.SetList(enable ? &enabled_vertex_attribs_ : &disabled_vertex_attribs_); | 149 info.SetList(enable ? &enabled_vertex_attribs_ : &disabled_vertex_attribs_); |
| 150 } | 150 } |
| 151 return true; | 151 return true; |
| 152 } | 152 } |
| 153 | 153 |
| 154 void VertexAttribManager::Unbind(Buffer* buffer) { | 154 void VertexAttribManager::Unbind(Buffer* buffer) { |
| 155 if (element_array_buffer_ == buffer) { | 155 if (element_array_buffer_.get() == buffer) { |
| 156 element_array_buffer_ = NULL; | 156 element_array_buffer_ = NULL; |
| 157 } | 157 } |
| 158 for (uint32 vv = 0; vv < vertex_attribs_.size(); ++vv) { | 158 for (uint32 vv = 0; vv < vertex_attribs_.size(); ++vv) { |
| 159 vertex_attribs_[vv].Unbind(buffer); | 159 vertex_attribs_[vv].Unbind(buffer); |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 | 162 |
| 163 bool VertexAttribManager::ValidateBindings( | 163 bool VertexAttribManager::ValidateBindings( |
| 164 const char* function_name, | 164 const char* function_name, |
| 165 GLES2Decoder* decoder, | 165 GLES2Decoder* decoder, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 if (current_buffer_id != kInitialBufferId) { | 265 if (current_buffer_id != kInitialBufferId) { |
| 266 // Restore the buffer binding. | 266 // Restore the buffer binding. |
| 267 decoder->RestoreBufferBindings(); | 267 decoder->RestoreBufferBindings(); |
| 268 } | 268 } |
| 269 | 269 |
| 270 return true; | 270 return true; |
| 271 } | 271 } |
| 272 | 272 |
| 273 } // namespace gles2 | 273 } // namespace gles2 |
| 274 } // namespace gpu | 274 } // namespace gpu |
| OLD | NEW |