Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1140)

Side by Side Diff: gpu/command_buffer/client/vertex_array_object_manager.cc

Issue 1542513002: Switch to standard integer types in gpu/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/client/vertex_array_object_manager.h" 5 #include "gpu/command_buffer/client/vertex_array_object_manager.h"
6 6
7 #include <stddef.h>
8 #include <stdint.h>
9
7 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/macros.h"
8 #include "gpu/command_buffer/client/gles2_cmd_helper.h" 12 #include "gpu/command_buffer/client/gles2_cmd_helper.h"
9 #include "gpu/command_buffer/client/gles2_implementation.h" 13 #include "gpu/command_buffer/client/gles2_implementation.h"
10 14
11 namespace gpu { 15 namespace gpu {
12 namespace gles2 { 16 namespace gles2 {
13 17
14 static GLsizei RoundUpToMultipleOf4(GLsizei size) { 18 static GLsizei RoundUpToMultipleOf4(GLsizei size) {
15 return (size + 3) & ~3; 19 return (size + 3) & ~3;
16 } 20 }
17 21
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 163
160 bool HaveEnabledClientSideBuffers() const; 164 bool HaveEnabledClientSideBuffers() const;
161 165
162 void SetAttribEnable(GLuint index, bool enabled); 166 void SetAttribEnable(GLuint index, bool enabled);
163 167
164 void SetAttribPointer( 168 void SetAttribPointer(
165 GLuint buffer_id, 169 GLuint buffer_id,
166 GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, 170 GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride,
167 const void* ptr, GLboolean integer); 171 const void* ptr, GLboolean integer);
168 172
169 bool GetVertexAttrib( 173 bool GetVertexAttrib(GLuint index, GLenum pname, uint32_t* param) const;
170 GLuint index, GLenum pname, uint32* param) const;
171 174
172 void SetAttribDivisor(GLuint index, GLuint divisor); 175 void SetAttribDivisor(GLuint index, GLuint divisor);
173 176
174 bool GetAttribPointer(GLuint index, GLenum pname, void** ptr) const; 177 bool GetAttribPointer(GLuint index, GLenum pname, void** ptr) const;
175 178
176 const VertexAttribs& vertex_attribs() const { 179 const VertexAttribs& vertex_attribs() const {
177 return vertex_attribs_; 180 return vertex_attribs_;
178 } 181 }
179 182
180 GLuint bound_element_array_buffer() const { 183 GLuint bound_element_array_buffer() const {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } 262 }
260 263
261 attrib.SetInfo(buffer_id, size, type, normalized, stride, ptr, integer); 264 attrib.SetInfo(buffer_id, size, type, normalized, stride, ptr, integer);
262 265
263 if (attrib.IsClientSide() && attrib.enabled()) { 266 if (attrib.IsClientSide() && attrib.enabled()) {
264 ++num_client_side_pointers_enabled_; 267 ++num_client_side_pointers_enabled_;
265 } 268 }
266 } 269 }
267 } 270 }
268 271
269 bool VertexArrayObject::GetVertexAttrib( 272 bool VertexArrayObject::GetVertexAttrib(GLuint index,
270 GLuint index, GLenum pname, uint32* param) const { 273 GLenum pname,
274 uint32_t* param) const {
271 const VertexAttrib* attrib = GetAttrib(index); 275 const VertexAttrib* attrib = GetAttrib(index);
272 if (!attrib) { 276 if (!attrib) {
273 return false; 277 return false;
274 } 278 }
275 279
276 switch (pname) { 280 switch (pname) {
277 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: 281 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
278 *param = attrib->buffer_id(); 282 *param = attrib->buffer_id();
279 break; 283 break;
280 case GL_VERTEX_ATTRIB_ARRAY_ENABLED: 284 case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 } 421 }
418 422
419 bool VertexArrayObjectManager::HaveEnabledClientSideBuffers() const { 423 bool VertexArrayObjectManager::HaveEnabledClientSideBuffers() const {
420 return bound_vertex_array_object_->HaveEnabledClientSideBuffers(); 424 return bound_vertex_array_object_->HaveEnabledClientSideBuffers();
421 } 425 }
422 426
423 void VertexArrayObjectManager::SetAttribEnable(GLuint index, bool enabled) { 427 void VertexArrayObjectManager::SetAttribEnable(GLuint index, bool enabled) {
424 bound_vertex_array_object_->SetAttribEnable(index, enabled); 428 bound_vertex_array_object_->SetAttribEnable(index, enabled);
425 } 429 }
426 430
427 bool VertexArrayObjectManager::GetVertexAttrib( 431 bool VertexArrayObjectManager::GetVertexAttrib(GLuint index,
428 GLuint index, GLenum pname, uint32* param) { 432 GLenum pname,
433 uint32_t* param) {
429 return bound_vertex_array_object_->GetVertexAttrib(index, pname, param); 434 return bound_vertex_array_object_->GetVertexAttrib(index, pname, param);
430 } 435 }
431 436
432 bool VertexArrayObjectManager::GetAttribPointer( 437 bool VertexArrayObjectManager::GetAttribPointer(
433 GLuint index, GLenum pname, void** ptr) const { 438 GLuint index, GLenum pname, void** ptr) const {
434 return bound_vertex_array_object_->GetAttribPointer(index, pname, ptr); 439 return bound_vertex_array_object_->GetAttribPointer(index, pname, ptr);
435 } 440 }
436 441
437 bool VertexArrayObjectManager::SetAttribPointer( 442 bool VertexArrayObjectManager::SetAttribPointer(
438 GLuint buffer_id, 443 GLuint buffer_id,
(...skipping 19 matching lines...) Expand all
458 463
459 // Collects the data into the collection buffer and returns the number of 464 // Collects the data into the collection buffer and returns the number of
460 // bytes collected. 465 // bytes collected.
461 GLsizei VertexArrayObjectManager::CollectData( 466 GLsizei VertexArrayObjectManager::CollectData(
462 const void* data, 467 const void* data,
463 GLsizei bytes_per_element, 468 GLsizei bytes_per_element,
464 GLsizei real_stride, 469 GLsizei real_stride,
465 GLsizei num_elements) { 470 GLsizei num_elements) {
466 GLsizei bytes_needed = bytes_per_element * num_elements; 471 GLsizei bytes_needed = bytes_per_element * num_elements;
467 if (collection_buffer_size_ < bytes_needed) { 472 if (collection_buffer_size_ < bytes_needed) {
468 collection_buffer_.reset(new int8[bytes_needed]); 473 collection_buffer_.reset(new int8_t[bytes_needed]);
469 collection_buffer_size_ = bytes_needed; 474 collection_buffer_size_ = bytes_needed;
470 } 475 }
471 const int8* src = static_cast<const int8*>(data); 476 const int8_t* src = static_cast<const int8_t*>(data);
472 int8* dst = collection_buffer_.get(); 477 int8_t* dst = collection_buffer_.get();
473 int8* end = dst + bytes_per_element * num_elements; 478 int8_t* end = dst + bytes_per_element * num_elements;
474 for (; dst < end; src += real_stride, dst += bytes_per_element) { 479 for (; dst < end; src += real_stride, dst += bytes_per_element) {
475 memcpy(dst, src, bytes_per_element); 480 memcpy(dst, src, bytes_per_element);
476 } 481 }
477 return bytes_needed; 482 return bytes_needed;
478 } 483 }
479 484
480 bool VertexArrayObjectManager::IsDefaultVAOBound() const { 485 bool VertexArrayObjectManager::IsDefaultVAOBound() const {
481 return bound_vertex_array_object_ == default_vertex_array_object_; 486 return bound_vertex_array_object_ == default_vertex_array_object_;
482 } 487 }
483 488
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 *offset = ToGLuint(indices); 568 *offset = ToGLuint(indices);
564 if (!support_client_side_arrays_) 569 if (!support_client_side_arrays_)
565 return true; 570 return true;
566 GLsizei num_elements = 0; 571 GLsizei num_elements = 0;
567 if (bound_vertex_array_object_->bound_element_array_buffer() == 0) { 572 if (bound_vertex_array_object_->bound_element_array_buffer() == 0) {
568 *simulated = true; 573 *simulated = true;
569 *offset = 0; 574 *offset = 0;
570 GLsizei max_index = -1; 575 GLsizei max_index = -1;
571 switch (type) { 576 switch (type) {
572 case GL_UNSIGNED_BYTE: { 577 case GL_UNSIGNED_BYTE: {
573 const uint8* src = static_cast<const uint8*>(indices); 578 const uint8_t* src = static_cast<const uint8_t*>(indices);
574 for (GLsizei ii = 0; ii < count; ++ii) { 579 for (GLsizei ii = 0; ii < count; ++ii) {
575 if (src[ii] > max_index) { 580 if (src[ii] > max_index) {
576 max_index = src[ii]; 581 max_index = src[ii];
577 } 582 }
578 } 583 }
579 break; 584 break;
580 } 585 }
581 case GL_UNSIGNED_SHORT: { 586 case GL_UNSIGNED_SHORT: {
582 const uint16* src = static_cast<const uint16*>(indices); 587 const uint16_t* src = static_cast<const uint16_t*>(indices);
583 for (GLsizei ii = 0; ii < count; ++ii) { 588 for (GLsizei ii = 0; ii < count; ++ii) {
584 if (src[ii] > max_index) { 589 if (src[ii] > max_index) {
585 max_index = src[ii]; 590 max_index = src[ii];
586 } 591 }
587 } 592 }
588 break; 593 break;
589 } 594 }
590 case GL_UNSIGNED_INT: { 595 case GL_UNSIGNED_INT: {
591 uint32 max_glsizei = static_cast<uint32>( 596 uint32_t max_glsizei =
592 std::numeric_limits<GLsizei>::max()); 597 static_cast<uint32_t>(std::numeric_limits<GLsizei>::max());
593 const uint32* src = static_cast<const uint32*>(indices); 598 const uint32_t* src = static_cast<const uint32_t*>(indices);
594 for (GLsizei ii = 0; ii < count; ++ii) { 599 for (GLsizei ii = 0; ii < count; ++ii) {
595 // Other parts of the API use GLsizei (signed) to store limits. 600 // Other parts of the API use GLsizei (signed) to store limits.
596 // As such, if we encounter a index that cannot be represented with 601 // As such, if we encounter a index that cannot be represented with
597 // an unsigned int we need to flag it as an error here. 602 // an unsigned int we need to flag it as an error here.
598 if(src[ii] > max_glsizei) { 603 if(src[ii] > max_glsizei) {
599 gl->SetGLError( 604 gl->SetGLError(
600 GL_INVALID_OPERATION, function_name, "index too large."); 605 GL_INVALID_OPERATION, function_name, "index too large.");
601 return false; 606 return false;
602 } 607 }
603 GLsizei signed_index = static_cast<GLsizei>(src[ii]); 608 GLsizei signed_index = static_cast<GLsizei>(src[ii]);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 function_name, gl, gl_helper, num_elements, primcount, 643 function_name, gl, gl_helper, num_elements, primcount,
639 &simulated_client_side_buffers); 644 &simulated_client_side_buffers);
640 *simulated = *simulated || simulated_client_side_buffers; 645 *simulated = *simulated || simulated_client_side_buffers;
641 return true; 646 return true;
642 } 647 }
643 648
644 } // namespace gles2 649 } // namespace gles2
645 } // namespace gpu 650 } // namespace gpu
646 651
647 652
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698