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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest_drawing.cc

Issue 2349613002: Fix int overflow in GLES2DecoderImpl::DoDrawArrays (Closed)
Patch Set: Created 4 years, 3 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 | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 DrawArraysMissingAttributesZeroCountSucceeds) { 796 DrawArraysMissingAttributesZeroCountSucceeds) {
797 DoEnableVertexAttribArray(1); 797 DoEnableVertexAttribArray(1);
798 798
799 EXPECT_CALL(*gl_, DrawArrays(_, _, _)).Times(0); 799 EXPECT_CALL(*gl_, DrawArrays(_, _, _)).Times(0);
800 DrawArrays cmd; 800 DrawArrays cmd;
801 cmd.Init(GL_TRIANGLES, 0, 0); 801 cmd.Init(GL_TRIANGLES, 0, 0);
802 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 802 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
803 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 803 EXPECT_EQ(GL_NO_ERROR, GetGLError());
804 } 804 }
805 805
806 TEST_P(GLES2DecoderWithShaderTest, DrawArraysIntOverflow) {
807 DoEnableVertexAttribArray(1);
808
809 GLint large = std::numeric_limits<GLint>::max();
810
811 EXPECT_CALL(*gl_, DrawArrays(_, _, _)).Times(0);
812 DrawArrays cmd;
813 cmd.Init(GL_TRIANGLES, large, large);
814 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
815 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
816 }
817
806 TEST_P(GLES2DecoderWithShaderTest, DrawArraysValidAttributesSucceeds) { 818 TEST_P(GLES2DecoderWithShaderTest, DrawArraysValidAttributesSucceeds) {
807 SetupTexture(); 819 SetupTexture();
808 SetupVertexBuffer(); 820 SetupVertexBuffer();
809 DoEnableVertexAttribArray(1); 821 DoEnableVertexAttribArray(1);
810 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0); 822 DoVertexAttribPointer(1, 2, GL_FLOAT, 0, 0);
811 AddExpectationsForSimulatedAttrib0(kNumVertices, kServiceBufferId); 823 AddExpectationsForSimulatedAttrib0(kNumVertices, kServiceBufferId);
812 SetupExpectationsForApplyingDefaultDirtyState(); 824 SetupExpectationsForApplyingDefaultDirtyState();
813 825
814 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) 826 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices))
815 .Times(1) 827 .Times(1)
(...skipping 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after
2322 .Times(1) 2334 .Times(1)
2323 .RetiresOnSaturation(); 2335 .RetiresOnSaturation();
2324 DrawArrays cmd; 2336 DrawArrays cmd;
2325 cmd.Init(GL_TRIANGLES, 0, kNumVertices); 2337 cmd.Init(GL_TRIANGLES, 0, kNumVertices);
2326 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 2338 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
2327 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 2339 EXPECT_EQ(GL_NO_ERROR, GetGLError());
2328 } 2340 }
2329 2341
2330 } // namespace gles2 2342 } // namespace gles2
2331 } // namespace gpu 2343 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698