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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest_extensions.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 4 years, 12 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 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 <stddef.h>
8 #include <stdint.h>
9
7 #include "base/command_line.h" 10 #include "base/command_line.h"
8 #include "gpu/command_buffer/common/gles2_cmd_format.h" 11 #include "gpu/command_buffer/common/gles2_cmd_format.h"
9 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 12 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
10 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h" 13 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h"
11 #include "gpu/command_buffer/service/gpu_switches.h" 14 #include "gpu/command_buffer/service/gpu_switches.h"
12 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/gl/gl_mock.h" 16 #include "ui/gl/gl_mock.h"
14 17
15 using ::gfx::MockGLInterface; 18 using ::gfx::MockGLInterface;
16 using ::testing::_; 19 using ::testing::_;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 cmds::StencilThenCoverStrokePathInstancedCHROMIUM cmd; 159 cmds::StencilThenCoverStrokePathInstancedCHROMIUM cmd;
157 GLuint* paths = GetSharedMemoryAs<GLuint*>(); 160 GLuint* paths = GetSharedMemoryAs<GLuint*>();
158 paths[0] = kClientPathId; 161 paths[0] = kClientPathId;
159 cmd.Init(1, GL_UNSIGNED_INT, shared_memory_id_, shared_memory_offset_, 0, 162 cmd.Init(1, GL_UNSIGNED_INT, shared_memory_id_, shared_memory_offset_, 0,
160 0x80, 0x80, GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, GL_NONE, 0, 163 0x80, 0x80, GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, GL_NONE, 0,
161 0); 164 0);
162 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); 165 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
163 } 166 }
164 { 167 {
165 cmds::BindFragmentInputLocationCHROMIUMBucket cmd; 168 cmds::BindFragmentInputLocationCHROMIUMBucket cmd;
166 const uint32 kBucketId = 123; 169 const uint32_t kBucketId = 123;
167 const GLint kLocation = 2; 170 const GLint kLocation = 2;
168 const char* kName = "testing"; 171 const char* kName = "testing";
169 SetBucketAsCString(kBucketId, kName); 172 SetBucketAsCString(kBucketId, kName);
170 cmd.Init(client_program_id_, kLocation, kBucketId); 173 cmd.Init(client_program_id_, kLocation, kBucketId);
171 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd)); 174 EXPECT_EQ(error::kUnknownCommand, ExecuteCmd(cmd));
172 } 175 }
173 { 176 {
174 cmds::ProgramPathFragmentInputGenCHROMIUM cmd; 177 cmds::ProgramPathFragmentInputGenCHROMIUM cmd;
175 const GLint kLocation = 2; 178 const GLint kLocation = 2;
176 cmd.Init(client_program_id_, kLocation, 0, GL_NONE, 0, 0); 179 cmd.Init(client_program_id_, kLocation, 0, GL_NONE, 0, 0);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 void CallAllInstancedCommands(const InstancedTestcase& testcase) { 244 void CallAllInstancedCommands(const InstancedTestcase& testcase) {
242 // Note: for testcases that expect a call, We do not compare the 'paths' 245 // Note: for testcases that expect a call, We do not compare the 'paths'
243 // array during EXPECT_CALL due to it being void*. Instead, we rely on the 246 // array during EXPECT_CALL due to it being void*. Instead, we rely on the
244 // fact that if the path base was not added correctly, the paths wouldn't 247 // fact that if the path base was not added correctly, the paths wouldn't
245 // exists and the call wouldn't come through. 248 // exists and the call wouldn't come through.
246 249
247 bool copy_paths = false; // Paths are copied for each call that has paths, 250 bool copy_paths = false; // Paths are copied for each call that has paths,
248 // since the implementation modifies the memory 251 // since the implementation modifies the memory
249 // area. 252 // area.
250 void* paths = NULL; 253 void* paths = NULL;
251 uint32 paths_shm_id = 0; 254 uint32_t paths_shm_id = 0;
252 uint32 paths_shm_offset = 0; 255 uint32_t paths_shm_offset = 0;
253 GLfloat* transforms = NULL; 256 GLfloat* transforms = NULL;
254 uint32 transforms_shm_id = 0; 257 uint32_t transforms_shm_id = 0;
255 uint32 transforms_shm_offset = 0; 258 uint32_t transforms_shm_offset = 0;
256 259
257 if (testcase.transform_values) { 260 if (testcase.transform_values) {
258 transforms = GetSharedMemoryAs<GLfloat*>(); 261 transforms = GetSharedMemoryAs<GLfloat*>();
259 transforms_shm_id = shared_memory_id_; 262 transforms_shm_id = shared_memory_id_;
260 transforms_shm_offset = shared_memory_offset_; 263 transforms_shm_offset = shared_memory_offset_;
261 memcpy(transforms, testcase.transform_values, 264 memcpy(transforms, testcase.transform_values,
262 testcase.sizeof_transform_values); 265 testcase.sizeof_transform_values);
263 } else { 266 } else {
264 DCHECK(testcase.sizeof_transform_values == 0); 267 DCHECK(testcase.sizeof_transform_values == 0);
265 } 268 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 testcase.transform_type, transforms_shm_id, 400 testcase.transform_type, transforms_shm_id,
398 transforms_shm_offset); 401 transforms_shm_offset);
399 EXPECT_EQ(testcase.expected_error, ExecuteCmd(stcsi_cmd)); 402 EXPECT_EQ(testcase.expected_error, ExecuteCmd(stcsi_cmd));
400 EXPECT_EQ(testcase.expected_gl_error, GetGLError()); 403 EXPECT_EQ(testcase.expected_gl_error, GetGLError());
401 } 404 }
402 } 405 }
403 406
404 void CallAllInstancedCommandsWithInvalidSHM(GLsizei num_paths, 407 void CallAllInstancedCommandsWithInvalidSHM(GLsizei num_paths,
405 const GLuint* paths, 408 const GLuint* paths,
406 GLuint* paths_shm, 409 GLuint* paths_shm,
407 uint32 paths_shm_id, 410 uint32_t paths_shm_id,
408 uint32 paths_shm_offset, 411 uint32_t paths_shm_offset,
409 uint32 transforms_shm_id, 412 uint32_t transforms_shm_id,
410 uint32 transforms_shm_offset) { 413 uint32_t transforms_shm_offset) {
411 const GLuint kPathBase = 0; 414 const GLuint kPathBase = 0;
412 const GLenum kFillMode = GL_INVERT; 415 const GLenum kFillMode = GL_INVERT;
413 const GLuint kMask = 0x80; 416 const GLuint kMask = 0x80;
414 const GLuint kReference = 0xFF; 417 const GLuint kReference = 0xFF;
415 const GLuint kTransformType = GL_AFFINE_3D_CHROMIUM; 418 const GLuint kTransformType = GL_AFFINE_3D_CHROMIUM;
416 memcpy(paths_shm, paths, sizeof(GLuint) * num_paths); 419 memcpy(paths_shm, paths, sizeof(GLuint) * num_paths);
417 { 420 {
418 cmds::StencilFillPathInstancedCHROMIUM sfi_cmd; 421 cmds::StencilFillPathInstancedCHROMIUM sfi_cmd;
419 sfi_cmd.Init(num_paths, GL_UNSIGNED_INT, paths_shm_id, paths_shm_offset, 422 sfi_cmd.Init(num_paths, GL_UNSIGNED_INT, paths_shm_id, paths_shm_offset,
420 kPathBase, kFillMode, kMask, kTransformType, 423 kPathBase, kFillMode, kMask, kTransformType,
(...skipping 1210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 kPathsSHMIdInvalid = 1, 1634 kPathsSHMIdInvalid = 1,
1632 kPathsSHMOffsetInvalid = 1 << 1, 1635 kPathsSHMOffsetInvalid = 1 << 1,
1633 kTransformsHMIdInvalid = 1 << 2, 1636 kTransformsHMIdInvalid = 1 << 2,
1634 kTransformsHMOffsetInvalid = 1 << 3, 1637 kTransformsHMOffsetInvalid = 1 << 3,
1635 kFirstTestcase = kPathsSHMIdInvalid, 1638 kFirstTestcase = kPathsSHMIdInvalid,
1636 kLastTestcase = kTransformsHMOffsetInvalid 1639 kLastTestcase = kTransformsHMOffsetInvalid
1637 }; 1640 };
1638 1641
1639 for (int testcase = kFirstTestcase; testcase <= kLastTestcase; ++testcase) { 1642 for (int testcase = kFirstTestcase; testcase <= kLastTestcase; ++testcase) {
1640 GLfloat* transforms = GetSharedMemoryAs<GLfloat*>(); 1643 GLfloat* transforms = GetSharedMemoryAs<GLfloat*>();
1641 uint32 transforms_shm_id = shared_memory_id_; 1644 uint32_t transforms_shm_id = shared_memory_id_;
1642 uint32 transforms_shm_offset = shared_memory_offset_; 1645 uint32_t transforms_shm_offset = shared_memory_offset_;
1643 memcpy(transforms, transform_values, sizeof(transform_values)); 1646 memcpy(transforms, transform_values, sizeof(transform_values));
1644 1647
1645 GLuint* paths = 1648 GLuint* paths =
1646 GetSharedMemoryAsWithOffset<GLuint*>(sizeof(transform_values)); 1649 GetSharedMemoryAsWithOffset<GLuint*>(sizeof(transform_values));
1647 uint32 paths_shm_id = shared_memory_id_; 1650 uint32_t paths_shm_id = shared_memory_id_;
1648 uint32 paths_shm_offset = shared_memory_offset_ + sizeof(transform_values); 1651 uint32_t paths_shm_offset =
1652 shared_memory_offset_ + sizeof(transform_values);
1649 1653
1650 if (testcase & kPathsSHMIdInvalid) { 1654 if (testcase & kPathsSHMIdInvalid) {
1651 paths_shm_id = kInvalidSharedMemoryId; 1655 paths_shm_id = kInvalidSharedMemoryId;
1652 } 1656 }
1653 if (testcase & kPathsSHMOffsetInvalid) { 1657 if (testcase & kPathsSHMOffsetInvalid) {
1654 paths_shm_offset = kInvalidSharedMemoryOffset; 1658 paths_shm_offset = kInvalidSharedMemoryOffset;
1655 } 1659 }
1656 if (testcase & kTransformsHMIdInvalid) { 1660 if (testcase & kTransformsHMIdInvalid) {
1657 transforms_shm_id = kInvalidSharedMemoryId; 1661 transforms_shm_id = kInvalidSharedMemoryId;
1658 } 1662 }
1659 if (testcase & kTransformsHMOffsetInvalid) { 1663 if (testcase & kTransformsHMOffsetInvalid) {
1660 transforms_shm_offset = kInvalidSharedMemoryOffset; 1664 transforms_shm_offset = kInvalidSharedMemoryOffset;
1661 } 1665 }
1662 SCOPED_TRACE(testing::Message() << "InstancedInvalidSHMValues testcase " 1666 SCOPED_TRACE(testing::Message() << "InstancedInvalidSHMValues testcase "
1663 << testcase); 1667 << testcase);
1664 CallAllInstancedCommandsWithInvalidSHM( 1668 CallAllInstancedCommandsWithInvalidSHM(
1665 kPathCount, kPaths, paths, paths_shm_id, paths_shm_offset, 1669 kPathCount, kPaths, paths, paths_shm_id, paths_shm_offset,
1666 transforms_shm_id, transforms_shm_offset); 1670 transforms_shm_id, transforms_shm_offset);
1667 } 1671 }
1668 } 1672 }
1669 1673
1670 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, 1674 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering,
1671 BindFragmentInputLocationCHROMIUM) { 1675 BindFragmentInputLocationCHROMIUM) {
1672 const uint32 kBucketId = 123; 1676 const uint32_t kBucketId = 123;
1673 const GLint kLocation = 2; 1677 const GLint kLocation = 2;
1674 const char* kName = "testing"; 1678 const char* kName = "testing";
1675 const char* kBadName1 = "gl_testing"; 1679 const char* kBadName1 = "gl_testing";
1676 1680
1677 SetBucketAsCString(kBucketId, kName); 1681 SetBucketAsCString(kBucketId, kName);
1678 cmds::BindFragmentInputLocationCHROMIUMBucket cmd; 1682 cmds::BindFragmentInputLocationCHROMIUMBucket cmd;
1679 cmd.Init(client_program_id_, kLocation, kBucketId); 1683 cmd.Init(client_program_id_, kLocation, kBucketId);
1680 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1684 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1681 EXPECT_EQ(GL_NO_ERROR, GetGLError()); 1685 EXPECT_EQ(GL_NO_ERROR, GetGLError());
1682 // Check negative location. 1686 // Check negative location.
(...skipping 16 matching lines...) Expand all
1699 SetBucketAsCString(kBucketId, kBadName1); 1703 SetBucketAsCString(kBucketId, kBadName1);
1700 cmd.Init(client_program_id_, kLocation, kBucketId); 1704 cmd.Init(client_program_id_, kLocation, kBucketId);
1701 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); 1705 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
1702 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); 1706 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
1703 } 1707 }
1704 1708
1705 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_extensions_autog en.h" 1709 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_extensions_autog en.h"
1706 1710
1707 } // namespace gles2 1711 } // namespace gles2
1708 } // namespace gpu 1712 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698