| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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/indexed_buffer_binding_host.h" | 5 #include "gpu/command_buffer/service/indexed_buffer_binding_host.h" |
| 6 | 6 |
| 7 #include "gpu/command_buffer/service/buffer_manager.h" | 7 #include "gpu/command_buffer/service/buffer_manager.h" |
| 8 | 8 |
| 9 namespace gpu { | 9 namespace gpu { |
| 10 namespace gles2 { | 10 namespace gles2 { |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 Buffer* IndexedBufferBindingHost::GetBufferBinding(GLuint index) const { | 188 Buffer* IndexedBufferBindingHost::GetBufferBinding(GLuint index) const { |
| 189 DCHECK_LT(index, buffer_bindings_.size()); | 189 DCHECK_LT(index, buffer_bindings_.size()); |
| 190 return buffer_bindings_[index].buffer.get(); | 190 return buffer_bindings_[index].buffer.get(); |
| 191 } | 191 } |
| 192 | 192 |
| 193 GLsizeiptr IndexedBufferBindingHost::GetBufferSize(GLuint index) const { | 193 GLsizeiptr IndexedBufferBindingHost::GetBufferSize(GLuint index) const { |
| 194 DCHECK_LT(index, buffer_bindings_.size()); | 194 DCHECK_LT(index, buffer_bindings_.size()); |
| 195 return buffer_bindings_[index].size; | 195 return buffer_bindings_[index].size; |
| 196 } | 196 } |
| 197 | 197 |
| 198 GLsizeiptr IndexedBufferBindingHost::GetEffectiveBufferSize( |
| 199 GLuint index) const { |
| 200 DCHECK_LT(index, buffer_bindings_.size()); |
| 201 const IndexedBufferBinding& binding = buffer_bindings_[index]; |
| 202 if (!binding.buffer.get()) |
| 203 return 0; |
| 204 GLsizeiptr full_buffer_size = binding.buffer->size(); |
| 205 switch (binding.type) { |
| 206 case kBindBufferBase: |
| 207 return full_buffer_size; |
| 208 case kBindBufferRange: |
| 209 if (binding.offset + binding.size > full_buffer_size) |
| 210 return full_buffer_size - binding.offset; |
| 211 return binding.size; |
| 212 case kBindBufferNone: |
| 213 return 0; |
| 214 } |
| 215 return buffer_bindings_[index].size; |
| 216 } |
| 217 |
| 198 GLintptr IndexedBufferBindingHost::GetBufferStart(GLuint index) const { | 218 GLintptr IndexedBufferBindingHost::GetBufferStart(GLuint index) const { |
| 199 DCHECK_LT(index, buffer_bindings_.size()); | 219 DCHECK_LT(index, buffer_bindings_.size()); |
| 200 return buffer_bindings_[index].offset; | 220 return buffer_bindings_[index].offset; |
| 201 } | 221 } |
| 202 | 222 |
| 203 void IndexedBufferBindingHost::RestoreBindings( | 223 void IndexedBufferBindingHost::RestoreBindings( |
| 204 IndexedBufferBindingHost* prev) { | 224 IndexedBufferBindingHost* prev) { |
| 205 size_t limit = max_non_null_binding_index_plus_one_; | 225 size_t limit = max_non_null_binding_index_plus_one_; |
| 206 if (prev && prev->max_non_null_binding_index_plus_one_ > limit) { | 226 if (prev && prev->max_non_null_binding_index_plus_one_ > limit) { |
| 207 limit = prev->max_non_null_binding_index_plus_one_; | 227 limit = prev->max_non_null_binding_index_plus_one_; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 max_non_null_binding_index_plus_one_ = ii; | 259 max_non_null_binding_index_plus_one_ = ii; |
| 240 break; | 260 break; |
| 241 } | 261 } |
| 242 } | 262 } |
| 243 } | 263 } |
| 244 } | 264 } |
| 245 } | 265 } |
| 246 | 266 |
| 247 } // namespace gles2 | 267 } // namespace gles2 |
| 248 } // namespace gpu | 268 } // namespace gpu |
| OLD | NEW |