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

Side by Side Diff: gpu/command_buffer/client/gles2_implementation.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
« no previous file with comments | « no previous file | gpu/command_buffer/client/vertex_array_object_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // A class to emulate GLES2 over command buffers. 5 // A class to emulate GLES2 over command buffers.
6 6
7 #include "gpu/command_buffer/client/gles2_implementation.h" 7 #include "gpu/command_buffer/client/gles2_implementation.h"
8 8
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #include <GLES2/gl2ext.h> 10 #include <GLES2/gl2ext.h>
(...skipping 4545 matching lines...) Expand 10 before | Expand all | Expand 10 after
4556 void GLES2Implementation::DrawArrays(GLenum mode, GLint first, GLsizei count) { 4556 void GLES2Implementation::DrawArrays(GLenum mode, GLint first, GLsizei count) {
4557 GPU_CLIENT_SINGLE_THREAD_CHECK(); 4557 GPU_CLIENT_SINGLE_THREAD_CHECK();
4558 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDrawArrays(" 4558 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glDrawArrays("
4559 << GLES2Util::GetStringDrawMode(mode) << ", " 4559 << GLES2Util::GetStringDrawMode(mode) << ", "
4560 << first << ", " << count << ")"); 4560 << first << ", " << count << ")");
4561 if (count < 0) { 4561 if (count < 0) {
4562 SetGLError(GL_INVALID_VALUE, "glDrawArrays", "count < 0"); 4562 SetGLError(GL_INVALID_VALUE, "glDrawArrays", "count < 0");
4563 return; 4563 return;
4564 } 4564 }
4565 bool simulated = false; 4565 bool simulated = false;
4566 if (!vertex_array_object_manager_->SetupSimulatedClientSideBuffers( 4566 if (vertex_array_object_manager_->SupportsClientSideBuffers()) {
4567 "glDrawArrays", this, helper_, first + count, 0, &simulated)) { 4567 GLsizei num_elements;
4568 return; 4568 SafeAddInt32(first, count, &num_elements);
Zhenyao Mo 2016/08/04 17:40:14 We should generate INVALID_VALUE if SafeAddInt32 r
4569 if (!vertex_array_object_manager_->SetupSimulatedClientSideBuffers(
4570 "glDrawArrays", this, helper_, num_elements, 0, &simulated)) {
4571 return;
4572 }
4569 } 4573 }
4570 helper_->DrawArrays(mode, first, count); 4574 helper_->DrawArrays(mode, first, count);
4571 RestoreArrayBuffer(simulated); 4575 RestoreArrayBuffer(simulated);
4572 CheckGLError(); 4576 CheckGLError();
4573 } 4577 }
4574 4578
4575 void GLES2Implementation::GetVertexAttribfv( 4579 void GLES2Implementation::GetVertexAttribfv(
4576 GLuint index, GLenum pname, GLfloat* params) { 4580 GLuint index, GLenum pname, GLfloat* params) {
4577 GPU_CLIENT_SINGLE_THREAD_CHECK(); 4581 GPU_CLIENT_SINGLE_THREAD_CHECK();
4578 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetVertexAttribfv(" 4582 GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGetVertexAttribfv("
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
5569 return; 5573 return;
5570 } 5574 }
5571 if (primcount < 0) { 5575 if (primcount < 0) {
5572 SetGLError(GL_INVALID_VALUE, "glDrawArraysInstancedANGLE", "primcount < 0"); 5576 SetGLError(GL_INVALID_VALUE, "glDrawArraysInstancedANGLE", "primcount < 0");
5573 return; 5577 return;
5574 } 5578 }
5575 if (primcount == 0) { 5579 if (primcount == 0) {
5576 return; 5580 return;
5577 } 5581 }
5578 bool simulated = false; 5582 bool simulated = false;
5579 if (!vertex_array_object_manager_->SetupSimulatedClientSideBuffers( 5583 if (vertex_array_object_manager_->SupportsClientSideBuffers()) {
5580 "glDrawArraysInstancedANGLE", this, helper_, first + count, primcount, 5584 GLsizei num_elements;
5581 &simulated)) { 5585 SafeAddInt32(first, count, &num_elements);
Zhenyao Mo 2016/08/04 17:40:14 Same here.
5582 return; 5586 if (!vertex_array_object_manager_->SetupSimulatedClientSideBuffers(
5587 "glDrawArraysInstancedANGLE", this, helper_, num_elements,
5588 primcount, &simulated)) {
5589 return;
5590 }
5583 } 5591 }
5584 helper_->DrawArraysInstancedANGLE(mode, first, count, primcount); 5592 helper_->DrawArraysInstancedANGLE(mode, first, count, primcount);
5585 RestoreArrayBuffer(simulated); 5593 RestoreArrayBuffer(simulated);
5586 CheckGLError(); 5594 CheckGLError();
5587 } 5595 }
5588 5596
5589 void GLES2Implementation::DrawElementsInstancedANGLE( 5597 void GLES2Implementation::DrawElementsInstancedANGLE(
5590 GLenum mode, GLsizei count, GLenum type, const void* indices, 5598 GLenum mode, GLsizei count, GLenum type, const void* indices,
5591 GLsizei primcount) { 5599 GLsizei primcount) {
5592 GPU_CLIENT_SINGLE_THREAD_CHECK(); 5600 GPU_CLIENT_SINGLE_THREAD_CHECK();
(...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after
6874 cached_extensions_.clear(); 6882 cached_extensions_.clear();
6875 } 6883 }
6876 6884
6877 // Include the auto-generated part of this file. We split this because it means 6885 // Include the auto-generated part of this file. We split this because it means
6878 // we can easily edit the non-auto generated parts right here in this file 6886 // we can easily edit the non-auto generated parts right here in this file
6879 // instead of having to edit some template or the code generator. 6887 // instead of having to edit some template or the code generator.
6880 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h" 6888 #include "gpu/command_buffer/client/gles2_implementation_impl_autogen.h"
6881 6889
6882 } // namespace gles2 6890 } // namespace gles2
6883 } // namespace gpu 6891 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/client/vertex_array_object_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698