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

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

Issue 2177513002: gpu: Avoid integer overflow when setting up client side buffers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months 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> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 for (; dst < end; src += real_stride, dst += bytes_per_element) { 479 for (; dst < end; src += real_stride, dst += bytes_per_element) {
480 memcpy(dst, src, bytes_per_element); 480 memcpy(dst, src, bytes_per_element);
481 } 481 }
482 return bytes_needed; 482 return bytes_needed;
483 } 483 }
484 484
485 bool VertexArrayObjectManager::IsDefaultVAOBound() const { 485 bool VertexArrayObjectManager::IsDefaultVAOBound() const {
486 return bound_vertex_array_object_ == default_vertex_array_object_; 486 return bound_vertex_array_object_ == default_vertex_array_object_;
487 } 487 }
488 488
489 bool VertexArrayObjectManager::SupportsClientSideBuffers() {
490 return support_client_side_arrays_ &&
491 bound_vertex_array_object_->HaveEnabledClientSideBuffers();
492 }
493
489 // Returns true if buffers were setup. 494 // Returns true if buffers were setup.
490 bool VertexArrayObjectManager::SetupSimulatedClientSideBuffers( 495 bool VertexArrayObjectManager::SetupSimulatedClientSideBuffers(
491 const char* function_name, 496 const char* function_name,
492 GLES2Implementation* gl, 497 GLES2Implementation* gl,
493 GLES2CmdHelper* gl_helper, 498 GLES2CmdHelper* gl_helper,
494 GLsizei num_elements, 499 GLsizei num_elements,
495 GLsizei primcount, 500 GLsizei primcount,
496 bool* simulated) { 501 bool* simulated) {
497 *simulated = false; 502 *simulated = false;
498 if (!support_client_side_arrays_) 503 if (!SupportsClientSideBuffers())
499 return true; 504 return false;
500 if (!bound_vertex_array_object_->HaveEnabledClientSideBuffers()) { 505
501 return true;
502 }
503 if (!IsDefaultVAOBound()) { 506 if (!IsDefaultVAOBound()) {
504 gl->SetGLError( 507 gl->SetGLError(
505 GL_INVALID_OPERATION, function_name, 508 GL_INVALID_OPERATION, function_name,
506 "client side arrays not allowed with vertex array object"); 509 "client side arrays not allowed with vertex array object");
507 return false; 510 return false;
508 } 511 }
509 *simulated = true; 512 *simulated = true;
510 GLsizei total_size = 0; 513 GLsizei total_size = 0;
511 // Compute the size of the buffer we need. 514 // Compute the size of the buffer we need.
512 const VertexArrayObject::VertexAttribs& vertex_attribs = 515 const VertexArrayObject::VertexAttribs& vertex_attribs =
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 function_name, gl, gl_helper, num_elements, primcount, 643 function_name, gl, gl_helper, num_elements, primcount,
641 &simulated_client_side_buffers); 644 &simulated_client_side_buffers);
642 *simulated = *simulated || simulated_client_side_buffers; 645 *simulated = *simulated || simulated_client_side_buffers;
643 return true; 646 return true;
644 } 647 }
645 648
646 } // namespace gles2 649 } // namespace gles2
647 } // namespace gpu 650 } // namespace gpu
648 651
649 652
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698