OLD | NEW |
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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 8 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
9 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
10 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h" | 10 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 cmd.Init(kClientPathId, GL_COUNT_UP_CHROMIUM, 1, GL_BOUNDING_BOX_CHROMIUM); | 119 cmd.Init(kClientPathId, GL_COUNT_UP_CHROMIUM, 1, GL_BOUNDING_BOX_CHROMIUM); |
120 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 120 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
121 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 121 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
122 } | 122 } |
123 { | 123 { |
124 cmds::StencilThenCoverStrokePathCHROMIUM cmd; | 124 cmds::StencilThenCoverStrokePathCHROMIUM cmd; |
125 cmd.Init(kClientPathId, 1, 2, GL_BOUNDING_BOX_CHROMIUM); | 125 cmd.Init(kClientPathId, 1, 2, GL_BOUNDING_BOX_CHROMIUM); |
126 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 126 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
127 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 127 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
128 } | 128 } |
| 129 { |
| 130 cmds::StencilFillPathInstancedCHROMIUM cmd; |
| 131 GLuint* paths = GetSharedMemoryAs<GLuint*>(); |
| 132 paths[0] = kClientPathId; |
| 133 cmd.Init(1, GL_UNSIGNED_INT, shared_memory_id_, shared_memory_offset_, 0, |
| 134 GL_COUNT_UP_CHROMIUM, 1, GL_NONE, 0, 0); |
| 135 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 136 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 137 } |
| 138 { |
| 139 cmds::StencilStrokePathInstancedCHROMIUM cmd; |
| 140 GLuint* paths = GetSharedMemoryAs<GLuint*>(); |
| 141 paths[0] = kClientPathId; |
| 142 cmd.Init(1, GL_UNSIGNED_INT, shared_memory_id_, shared_memory_offset_, 0, |
| 143 0x80, 0x80, GL_NONE, 0, 0); |
| 144 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 145 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 146 } |
| 147 { |
| 148 cmds::CoverFillPathInstancedCHROMIUM cmd; |
| 149 GLuint* paths = GetSharedMemoryAs<GLuint*>(); |
| 150 paths[0] = kClientPathId; |
| 151 cmd.Init(1, GL_UNSIGNED_INT, shared_memory_id_, shared_memory_offset_, 0, |
| 152 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, GL_NONE, 0, 0); |
| 153 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 154 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 155 } |
| 156 { |
| 157 cmds::CoverStrokePathInstancedCHROMIUM cmd; |
| 158 GLuint* paths = GetSharedMemoryAs<GLuint*>(); |
| 159 paths[0] = kClientPathId; |
| 160 cmd.Init(1, GL_UNSIGNED_INT, shared_memory_id_, shared_memory_offset_, 0, |
| 161 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, GL_NONE, 0, 0); |
| 162 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 163 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 164 } |
| 165 { |
| 166 cmds::StencilThenCoverFillPathInstancedCHROMIUM cmd; |
| 167 GLuint* paths = GetSharedMemoryAs<GLuint*>(); |
| 168 paths[0] = kClientPathId; |
| 169 cmd.Init(1, GL_UNSIGNED_INT, shared_memory_id_, shared_memory_offset_, 0, |
| 170 GL_COUNT_UP_CHROMIUM, 1, |
| 171 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, GL_NONE, 0, 0); |
| 172 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 173 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 174 } |
| 175 { |
| 176 cmds::StencilThenCoverStrokePathInstancedCHROMIUM cmd; |
| 177 GLuint* paths = GetSharedMemoryAs<GLuint*>(); |
| 178 paths[0] = kClientPathId; |
| 179 cmd.Init(1, GL_UNSIGNED_INT, shared_memory_id_, shared_memory_offset_, 0, |
| 180 0x80, 0x80, GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, GL_NONE, 0, |
| 181 0); |
| 182 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 183 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 184 } |
129 } | 185 } |
130 | 186 |
131 class GLES2DecoderTestWithCHROMIUMPathRendering : public GLES2DecoderTest { | 187 class GLES2DecoderTestWithCHROMIUMPathRendering : public GLES2DecoderTest { |
132 public: | 188 public: |
133 GLES2DecoderTestWithCHROMIUMPathRendering() : client_path_id_(125) {} | 189 GLES2DecoderTestWithCHROMIUMPathRendering() : client_path_id_(125) {} |
134 | 190 |
135 void SetUp() override { | 191 void SetUp() override { |
136 InitState init; | 192 InitState init; |
137 init.gl_version = "opengl es 3.1"; | 193 init.gl_version = "opengl es 3.1"; |
138 init.has_alpha = true; | 194 init.has_alpha = true; |
139 init.has_depth = true; | 195 init.has_depth = true; |
140 init.request_alpha = true; | 196 init.request_alpha = true; |
141 init.request_depth = true; | 197 init.request_depth = true; |
142 init.bind_generates_resource = true; | 198 init.bind_generates_resource = true; |
143 init.extensions = "GL_NV_path_rendering"; | 199 init.extensions = "GL_NV_path_rendering"; |
144 base::CommandLine command_line(0, NULL); | 200 base::CommandLine command_line(0, NULL); |
145 command_line.AppendSwitch(switches::kEnableGLPathRendering); | 201 command_line.AppendSwitch(switches::kEnableGLPathRendering); |
146 InitDecoderWithCommandLine(init, &command_line); | 202 InitDecoderWithCommandLine(init, &command_line); |
147 | 203 |
148 EXPECT_CALL(*gl_, GenPathsNV(1)) | 204 EXPECT_CALL(*gl_, GenPathsNV(1)) |
149 .WillOnce(Return(kServicePathId)) | 205 .WillOnce(Return(kServicePathId)) |
150 .RetiresOnSaturation(); | 206 .RetiresOnSaturation(); |
151 cmds::GenPathsCHROMIUM cmd; | 207 cmds::GenPathsCHROMIUM cmd; |
152 cmd.Init(client_path_id_, 1); | 208 cmd.Init(client_path_id_, 1); |
153 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 209 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 210 |
| 211 // The tests use client_path_id_ to test all sorts of drawing. The NVPR API |
| 212 // behaves differently with a path name that is "used" but not which does |
| 213 // not "allocate path object state" and a path name that is a name of a real |
| 214 // path object. The drawing with former causes GL error while latter works |
| 215 // ok, even if there is nothing in the actual path object. To remain |
| 216 // compatible with the API, we allocate path object state even when using |
| 217 // the mock API. |
| 218 EXPECT_CALL(*gl_, |
| 219 PathCommandsNV(kServicePathId, 0, NULL, 0, GL_FLOAT, NULL)) |
| 220 .RetiresOnSaturation(); |
| 221 cmds::PathCommandsCHROMIUM pcmd; |
| 222 pcmd.Init(client_path_id_, 0, 0, 0, 0, GL_FLOAT, 0, 0); |
| 223 EXPECT_EQ(error::kNoError, ExecuteCmd(pcmd)); |
154 } | 224 } |
155 | 225 |
156 protected: | 226 protected: |
157 template <typename TypeParam> | 227 template <typename TypeParam> |
158 void TestPathCommandsCHROMIUMCoordTypes(); | 228 void TestPathCommandsCHROMIUMCoordTypes(); |
159 | 229 |
| 230 struct InstancedTestcase { |
| 231 GLsizei num_paths; |
| 232 const GLuint* paths; |
| 233 GLuint path_base; |
| 234 GLenum fill_mode; |
| 235 GLuint reference; |
| 236 GLuint mask; |
| 237 GLenum transform_type; |
| 238 const GLfloat* transform_values; |
| 239 size_t sizeof_paths; // Used for copying to shm buffer. |
| 240 size_t sizeof_transform_values; // Used for copying to shm buffer. |
| 241 error::Error expected_error; |
| 242 GLint expected_gl_error; |
| 243 bool expect_gl_call; |
| 244 }; |
| 245 |
| 246 void CallAllInstancedCommands(const InstancedTestcase& testcase) { |
| 247 // Note: for testcases that expect a call, We do not compare the 'paths' |
| 248 // array during EXPECT_CALL due to it being void*. Instead, we rely on the |
| 249 // fact that if the path base was not added correctly, the paths wouldn't |
| 250 // exists and the call wouldn't come through. |
| 251 |
| 252 bool copy_paths = false; // Paths are copied for each call that has paths, |
| 253 // since the implementation modifies the memory |
| 254 // area. |
| 255 GLuint* paths = NULL; |
| 256 uint32 paths_shm_id = 0; |
| 257 uint32 paths_shm_offset = 0; |
| 258 GLfloat* transforms = NULL; |
| 259 uint32 transforms_shm_id = 0; |
| 260 uint32 transforms_shm_offset = 0; |
| 261 |
| 262 if (testcase.transform_values) { |
| 263 transforms = GetSharedMemoryAs<GLfloat*>(); |
| 264 transforms_shm_id = shared_memory_id_; |
| 265 transforms_shm_offset = shared_memory_offset_; |
| 266 memcpy(transforms, testcase.transform_values, |
| 267 testcase.sizeof_transform_values); |
| 268 } else { |
| 269 DCHECK(testcase.sizeof_transform_values == 0); |
| 270 } |
| 271 if (testcase.paths) { |
| 272 paths = GetSharedMemoryAsWithOffset<GLuint*>( |
| 273 testcase.sizeof_transform_values); |
| 274 paths_shm_id = shared_memory_id_; |
| 275 paths_shm_offset = |
| 276 shared_memory_offset_ + testcase.sizeof_transform_values; |
| 277 copy_paths = true; |
| 278 } else { |
| 279 DCHECK(testcase.sizeof_paths == 0); |
| 280 } |
| 281 |
| 282 if (testcase.expect_gl_call) { |
| 283 EXPECT_CALL(*gl_, StencilFillPathInstancedNV( |
| 284 testcase.num_paths, GL_UNSIGNED_INT, paths, 0, |
| 285 testcase.fill_mode, testcase.mask, |
| 286 testcase.transform_type, transforms)) |
| 287 .RetiresOnSaturation(); |
| 288 } |
| 289 if (copy_paths) { |
| 290 memcpy(paths, testcase.paths, testcase.sizeof_paths); |
| 291 } |
| 292 { |
| 293 cmds::StencilFillPathInstancedCHROMIUM sfi_cmd; |
| 294 sfi_cmd.Init(testcase.num_paths, GL_UNSIGNED_INT, paths_shm_id, |
| 295 paths_shm_offset, testcase.path_base, testcase.fill_mode, |
| 296 testcase.mask, testcase.transform_type, transforms_shm_id, |
| 297 transforms_shm_offset); |
| 298 EXPECT_EQ(testcase.expected_error, ExecuteCmd(sfi_cmd)); |
| 299 EXPECT_EQ(testcase.expected_gl_error, GetGLError()); |
| 300 } |
| 301 |
| 302 if (testcase.expect_gl_call) { |
| 303 EXPECT_CALL(*gl_, StencilStrokePathInstancedNV( |
| 304 testcase.num_paths, GL_UNSIGNED_INT, paths, 0, |
| 305 testcase.reference, testcase.mask, |
| 306 testcase.transform_type, transforms)) |
| 307 .RetiresOnSaturation(); |
| 308 } |
| 309 if (copy_paths) { |
| 310 memcpy(paths, testcase.paths, testcase.sizeof_paths); |
| 311 } |
| 312 { |
| 313 cmds::StencilStrokePathInstancedCHROMIUM ssi_cmd; |
| 314 ssi_cmd.Init(testcase.num_paths, GL_UNSIGNED_INT, paths_shm_id, |
| 315 paths_shm_offset, testcase.path_base, testcase.reference, |
| 316 testcase.mask, testcase.transform_type, transforms_shm_id, |
| 317 transforms_shm_offset); |
| 318 EXPECT_EQ(testcase.expected_error, ExecuteCmd(ssi_cmd)); |
| 319 EXPECT_EQ(testcase.expected_gl_error, GetGLError()); |
| 320 } |
| 321 |
| 322 if (testcase.expect_gl_call) { |
| 323 EXPECT_CALL(*gl_, CoverFillPathInstancedNV( |
| 324 testcase.num_paths, GL_UNSIGNED_INT, paths, 0, |
| 325 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV, |
| 326 testcase.transform_type, transforms)) |
| 327 .RetiresOnSaturation(); |
| 328 } |
| 329 if (copy_paths) { |
| 330 memcpy(paths, testcase.paths, testcase.sizeof_paths); |
| 331 } |
| 332 { |
| 333 cmds::CoverFillPathInstancedCHROMIUM cfi_cmd; |
| 334 cfi_cmd.Init( |
| 335 testcase.num_paths, GL_UNSIGNED_INT, paths_shm_id, paths_shm_offset, |
| 336 testcase.path_base, GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, |
| 337 testcase.transform_type, transforms_shm_id, transforms_shm_offset); |
| 338 EXPECT_EQ(testcase.expected_error, ExecuteCmd(cfi_cmd)); |
| 339 EXPECT_EQ(testcase.expected_gl_error, GetGLError()); |
| 340 } |
| 341 if (testcase.expect_gl_call) { |
| 342 EXPECT_CALL(*gl_, CoverStrokePathInstancedNV( |
| 343 testcase.num_paths, GL_UNSIGNED_INT, paths, 0, |
| 344 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV, |
| 345 testcase.transform_type, transforms)) |
| 346 .RetiresOnSaturation(); |
| 347 } |
| 348 if (copy_paths) { |
| 349 memcpy(paths, testcase.paths, testcase.sizeof_paths); |
| 350 } |
| 351 |
| 352 { |
| 353 cmds::CoverStrokePathInstancedCHROMIUM csi_cmd; |
| 354 csi_cmd.Init( |
| 355 testcase.num_paths, GL_UNSIGNED_INT, paths_shm_id, paths_shm_offset, |
| 356 testcase.path_base, GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, |
| 357 testcase.transform_type, transforms_shm_id, transforms_shm_offset); |
| 358 EXPECT_EQ(testcase.expected_error, ExecuteCmd(csi_cmd)); |
| 359 EXPECT_EQ(testcase.expected_gl_error, GetGLError()); |
| 360 } |
| 361 |
| 362 if (testcase.expect_gl_call) { |
| 363 EXPECT_CALL(*gl_, StencilThenCoverFillPathInstancedNV( |
| 364 testcase.num_paths, GL_UNSIGNED_INT, paths, 0, |
| 365 testcase.fill_mode, testcase.mask, |
| 366 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV, |
| 367 testcase.transform_type, transforms)) |
| 368 .RetiresOnSaturation(); |
| 369 } |
| 370 if (copy_paths) { |
| 371 memcpy(paths, testcase.paths, testcase.sizeof_paths); |
| 372 } |
| 373 { |
| 374 cmds::StencilThenCoverFillPathInstancedCHROMIUM stcfi_cmd; |
| 375 stcfi_cmd.Init(testcase.num_paths, GL_UNSIGNED_INT, paths_shm_id, |
| 376 paths_shm_offset, testcase.path_base, testcase.fill_mode, |
| 377 testcase.mask, GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, |
| 378 testcase.transform_type, transforms_shm_id, |
| 379 transforms_shm_offset); |
| 380 EXPECT_EQ(testcase.expected_error, ExecuteCmd(stcfi_cmd)); |
| 381 EXPECT_EQ(testcase.expected_gl_error, GetGLError()); |
| 382 } |
| 383 |
| 384 if (testcase.expect_gl_call) { |
| 385 EXPECT_CALL(*gl_, StencilThenCoverStrokePathInstancedNV( |
| 386 testcase.num_paths, GL_UNSIGNED_INT, paths, 0, |
| 387 testcase.reference, testcase.mask, |
| 388 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV, |
| 389 testcase.transform_type, transforms)) |
| 390 .RetiresOnSaturation(); |
| 391 } |
| 392 if (copy_paths) { |
| 393 memcpy(paths, testcase.paths, testcase.sizeof_paths); |
| 394 } |
| 395 { |
| 396 cmds::StencilThenCoverStrokePathInstancedCHROMIUM stcsi_cmd; |
| 397 stcsi_cmd.Init(testcase.num_paths, GL_UNSIGNED_INT, paths_shm_id, |
| 398 paths_shm_offset, testcase.path_base, testcase.reference, |
| 399 testcase.mask, GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, |
| 400 testcase.transform_type, transforms_shm_id, |
| 401 transforms_shm_offset); |
| 402 EXPECT_EQ(testcase.expected_error, ExecuteCmd(stcsi_cmd)); |
| 403 EXPECT_EQ(testcase.expected_gl_error, GetGLError()); |
| 404 } |
| 405 } |
| 406 |
| 407 void CallAllInstancedCommandsWithInvalidSHM(GLsizei num_paths, |
| 408 const GLuint* paths, |
| 409 GLuint* paths_shm, |
| 410 uint32 paths_shm_id, |
| 411 uint32 paths_shm_offset, |
| 412 uint32 transforms_shm_id, |
| 413 uint32 transforms_shm_offset) { |
| 414 const GLuint kPathBase = 0; |
| 415 const GLenum kFillMode = GL_INVERT; |
| 416 const GLuint kMask = 0x80; |
| 417 const GLuint kReference = 0xFF; |
| 418 const GLuint kTransformType = GL_AFFINE_3D_CHROMIUM; |
| 419 memcpy(paths_shm, paths, sizeof(GLuint) * num_paths); |
| 420 { |
| 421 cmds::StencilFillPathInstancedCHROMIUM sfi_cmd; |
| 422 sfi_cmd.Init(num_paths, GL_UNSIGNED_INT, paths_shm_id, paths_shm_offset, |
| 423 kPathBase, kFillMode, kMask, kTransformType, |
| 424 transforms_shm_id, transforms_shm_offset); |
| 425 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(sfi_cmd)); |
| 426 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 427 } |
| 428 memcpy(paths_shm, paths, sizeof(GLuint) * num_paths); |
| 429 { |
| 430 cmds::StencilStrokePathInstancedCHROMIUM ssi_cmd; |
| 431 ssi_cmd.Init(num_paths, GL_UNSIGNED_INT, paths_shm_id, paths_shm_offset, |
| 432 kPathBase, kReference, kMask, kTransformType, |
| 433 transforms_shm_id, transforms_shm_offset); |
| 434 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(ssi_cmd)); |
| 435 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 436 } |
| 437 memcpy(paths_shm, paths, sizeof(GLuint) * num_paths); |
| 438 { |
| 439 cmds::CoverFillPathInstancedCHROMIUM cfi_cmd; |
| 440 cfi_cmd.Init(num_paths, GL_UNSIGNED_INT, paths_shm_id, paths_shm_offset, |
| 441 kPathBase, GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, |
| 442 kTransformType, transforms_shm_id, transforms_shm_offset); |
| 443 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cfi_cmd)); |
| 444 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 445 } |
| 446 memcpy(paths_shm, paths, sizeof(GLuint) * num_paths); |
| 447 { |
| 448 cmds::CoverStrokePathInstancedCHROMIUM csi_cmd; |
| 449 csi_cmd.Init(num_paths, GL_UNSIGNED_INT, paths_shm_id, paths_shm_offset, |
| 450 kPathBase, GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, |
| 451 kTransformType, transforms_shm_id, transforms_shm_offset); |
| 452 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(csi_cmd)); |
| 453 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 454 } |
| 455 memcpy(paths_shm, paths, sizeof(GLuint) * num_paths); |
| 456 { |
| 457 cmds::StencilThenCoverFillPathInstancedCHROMIUM stcfi_cmd; |
| 458 stcfi_cmd.Init(num_paths, GL_UNSIGNED_INT, paths_shm_id, paths_shm_offset, |
| 459 kPathBase, kFillMode, kMask, |
| 460 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, kTransformType, |
| 461 transforms_shm_id, transforms_shm_offset); |
| 462 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(stcfi_cmd)); |
| 463 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 464 } |
| 465 memcpy(paths_shm, paths, sizeof(GLuint) * num_paths); |
| 466 { |
| 467 cmds::StencilThenCoverStrokePathInstancedCHROMIUM stcsi_cmd; |
| 468 stcsi_cmd.Init(num_paths, GL_UNSIGNED_INT, paths_shm_id, paths_shm_offset, |
| 469 kPathBase, kReference, kMask, |
| 470 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, kTransformType, |
| 471 transforms_shm_id, transforms_shm_offset); |
| 472 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(stcsi_cmd)); |
| 473 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 474 } |
| 475 } |
| 476 |
160 GLuint client_path_id_; | 477 GLuint client_path_id_; |
161 static const GLuint kServicePathId = 311; | 478 static const GLuint kServicePathId = 311; |
162 }; | 479 }; |
163 | 480 |
164 INSTANTIATE_TEST_CASE_P(Service, | 481 INSTANTIATE_TEST_CASE_P(Service, |
165 GLES2DecoderTestWithCHROMIUMPathRendering, | 482 GLES2DecoderTestWithCHROMIUMPathRendering, |
166 ::testing::Bool()); | 483 ::testing::Bool()); |
167 | 484 |
168 class GLES2DecoderTestWithBlendEquationAdvanced : public GLES2DecoderTest { | 485 class GLES2DecoderTestWithBlendEquationAdvanced : public GLES2DecoderTest { |
169 public: | 486 public: |
(...skipping 25 matching lines...) Expand all Loading... |
195 gen_cmd.Init(kFirstClientID, 0); | 512 gen_cmd.Init(kFirstClientID, 0); |
196 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); | 513 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); |
197 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 514 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
198 | 515 |
199 // DeletePaths range 0 causes no calls. | 516 // DeletePaths range 0 causes no calls. |
200 cmds::DeletePathsCHROMIUM delete_cmd; | 517 cmds::DeletePathsCHROMIUM delete_cmd; |
201 delete_cmd.Init(kFirstClientID, 0); | 518 delete_cmd.Init(kFirstClientID, 0); |
202 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); | 519 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); |
203 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 520 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
204 | 521 |
205 // DeletePaths client 0 causes no calls and no errors. | 522 // DeletePaths client id 0 causes no calls and no errors. |
206 delete_cmd.Init(0, 1); | 523 delete_cmd.Init(0, 1); |
207 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); | 524 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); |
208 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 525 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
209 | 526 |
210 // DeletePaths with a big range should not cause any deletes. | 527 // DeletePaths with a big range should not cause any deletes. |
211 delete_cmd.Init(client_path_id_ + 1, | 528 delete_cmd.Init(client_path_id_ + 1, |
212 std::numeric_limits<GLsizei>::max() - client_path_id_ - 1); | 529 std::numeric_limits<GLsizei>::max() - client_path_id_ - 1); |
213 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); | 530 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); |
214 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 531 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
215 | 532 |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 PathCommandsCHROMIUMCoordTypes) { | 1303 PathCommandsCHROMIUMCoordTypes) { |
987 // Not using a typed test case, because the base class is already parametrized | 1304 // Not using a typed test case, because the base class is already parametrized |
988 // test case and uses GetParam. | 1305 // test case and uses GetParam. |
989 TestPathCommandsCHROMIUMCoordTypes<GLbyte>(); | 1306 TestPathCommandsCHROMIUMCoordTypes<GLbyte>(); |
990 TestPathCommandsCHROMIUMCoordTypes<GLubyte>(); | 1307 TestPathCommandsCHROMIUMCoordTypes<GLubyte>(); |
991 TestPathCommandsCHROMIUMCoordTypes<GLshort>(); | 1308 TestPathCommandsCHROMIUMCoordTypes<GLshort>(); |
992 TestPathCommandsCHROMIUMCoordTypes<GLushort>(); | 1309 TestPathCommandsCHROMIUMCoordTypes<GLushort>(); |
993 TestPathCommandsCHROMIUMCoordTypes<GLfloat>(); | 1310 TestPathCommandsCHROMIUMCoordTypes<GLfloat>(); |
994 } | 1311 } |
995 | 1312 |
| 1313 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, |
| 1314 StencilXFillPathInstancedCHROMIUMInvalidArgs) { |
| 1315 cmds::StencilFillPathInstancedCHROMIUM sfi_cmd; |
| 1316 cmds::StencilThenCoverFillPathInstancedCHROMIUM stcfi_cmd; |
| 1317 |
| 1318 const GLuint kPaths[] = {client_path_id_, client_path_id_ + 5, |
| 1319 client_path_id_, client_path_id_ + 18}; |
| 1320 const GLsizei kPathCount = arraysize(kPaths); |
| 1321 |
| 1322 struct { |
| 1323 GLenum fill_mode; |
| 1324 GLuint mask; |
| 1325 GLint expected_error; |
| 1326 } testcases[] = { |
| 1327 // Using invalid fill mode produces invalid enum. |
| 1328 {GL_COUNT_UP_CHROMIUM - 1, 0x7F, GL_INVALID_ENUM}, |
| 1329 {GL_COUNT_DOWN_CHROMIUM + 1, 0x7F, GL_INVALID_ENUM}, |
| 1330 // Using /mask/+1 which is not power of two produces invalid value. |
| 1331 {GL_COUNT_UP_CHROMIUM, 0x80, GL_INVALID_VALUE}, |
| 1332 {GL_COUNT_DOWN_CHROMIUM, 4, GL_INVALID_VALUE}}; |
| 1333 |
| 1334 GLuint* paths = GetSharedMemoryAs<GLuint*>(); |
| 1335 |
| 1336 for (size_t i = 0; i < arraysize(testcases); ++i) { |
| 1337 memcpy(paths, kPaths, sizeof(kPaths)); |
| 1338 sfi_cmd.Init(kPathCount, GL_UNSIGNED_INT, shared_memory_id_, |
| 1339 shared_memory_offset_, 0, testcases[i].fill_mode, |
| 1340 testcases[i].mask, GL_NONE, 0, 0); |
| 1341 EXPECT_EQ(error::kNoError, ExecuteCmd(sfi_cmd)); |
| 1342 EXPECT_EQ(testcases[i].expected_error, GetGLError()); |
| 1343 |
| 1344 memcpy(paths, kPaths, sizeof(kPaths)); |
| 1345 stcfi_cmd.Init(kPathCount, GL_UNSIGNED_INT, shared_memory_id_, |
| 1346 shared_memory_offset_, 0, testcases[i].fill_mode, |
| 1347 testcases[i].mask, |
| 1348 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, GL_NONE, 0, 0); |
| 1349 EXPECT_EQ(error::kNoError, ExecuteCmd(stcfi_cmd)); |
| 1350 EXPECT_EQ(testcases[i].expected_error, GetGLError()); |
| 1351 } |
| 1352 } |
| 1353 |
| 1354 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, |
| 1355 StencilXFillPathInstancedCHROMIUMFillMode) { |
| 1356 SetupExpectationsForApplyingDefaultDirtyState(); |
| 1357 |
| 1358 // Test different fill modes. |
| 1359 cmds::StencilFillPathInstancedCHROMIUM sfi_cmd; |
| 1360 cmds::StencilThenCoverFillPathInstancedCHROMIUM stcfi_cmd; |
| 1361 |
| 1362 const GLuint kPaths[] = {client_path_id_, client_path_id_ + 5, |
| 1363 client_path_id_, client_path_id_ + 18}; |
| 1364 const GLsizei kPathCount = arraysize(kPaths); |
| 1365 |
| 1366 static const GLenum kFillModes[] = {GL_INVERT, GL_COUNT_UP_CHROMIUM, |
| 1367 GL_COUNT_DOWN_CHROMIUM}; |
| 1368 const GLuint kMask = 0x7F; |
| 1369 |
| 1370 GLuint* paths = GetSharedMemoryAs<GLuint*>(); |
| 1371 |
| 1372 for (size_t i = 0; i < arraysize(kFillModes); ++i) { |
| 1373 memcpy(paths, kPaths, sizeof(kPaths)); |
| 1374 EXPECT_CALL( |
| 1375 *gl_, StencilFillPathInstancedNV(kPathCount, GL_UNSIGNED_INT, paths, 0, |
| 1376 kFillModes[i], kMask, GL_NONE, NULL)) |
| 1377 .RetiresOnSaturation(); |
| 1378 sfi_cmd.Init(kPathCount, GL_UNSIGNED_INT, shared_memory_id_, |
| 1379 shared_memory_offset_, 0, kFillModes[i], kMask, GL_NONE, 0, 0); |
| 1380 EXPECT_EQ(error::kNoError, ExecuteCmd(sfi_cmd)); |
| 1381 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1382 |
| 1383 memcpy(paths, kPaths, sizeof(kPaths)); |
| 1384 EXPECT_CALL(*gl_, |
| 1385 StencilThenCoverFillPathInstancedNV( |
| 1386 kPathCount, GL_UNSIGNED_INT, paths, 0, kFillModes[i], kMask, |
| 1387 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV, GL_NONE, NULL)) |
| 1388 .RetiresOnSaturation(); |
| 1389 stcfi_cmd.Init(kPathCount, GL_UNSIGNED_INT, shared_memory_id_, |
| 1390 shared_memory_offset_, 0, kFillModes[i], kMask, |
| 1391 GL_BOUNDING_BOX_OF_BOUNDING_BOXES_CHROMIUM, GL_NONE, 0, 0); |
| 1392 EXPECT_EQ(error::kNoError, ExecuteCmd(stcfi_cmd)); |
| 1393 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 1394 } |
| 1395 } |
| 1396 |
| 1397 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, InstancedCalls) { |
| 1398 SetupExpectationsForApplyingDefaultDirtyState(); |
| 1399 |
| 1400 const GLuint kPaths[] = {0, client_path_id_, 15, client_path_id_}; |
| 1401 const GLsizei kPathCount = arraysize(kPaths); |
| 1402 |
| 1403 // The path base will be client_path_id_, and so 0 is a |
| 1404 // valid path. |
| 1405 const GLuint kPathBase = client_path_id_; |
| 1406 const GLuint kPathsWithBase[] = {0, 5, 0, 18}; |
| 1407 |
| 1408 const GLenum kFillMode = GL_INVERT; |
| 1409 const GLuint kMask = 0x80; |
| 1410 const GLuint kReference = 0xFF; |
| 1411 |
| 1412 GLfloat transform_values[12 * kPathCount]; |
| 1413 for (GLsizei i = 0; i < kPathCount; ++i) { |
| 1414 for (int j = 0; j < 12; ++j) { |
| 1415 transform_values[i * 12 + j] = 0.1f * j + i; |
| 1416 } |
| 1417 } |
| 1418 |
| 1419 InstancedTestcase testcases[] = { |
| 1420 // Test a normal call. |
| 1421 {kPathCount, kPaths, 0, kFillMode, kReference, kMask, GL_NONE, NULL, |
| 1422 sizeof(kPaths), 0, error::kNoError, GL_NO_ERROR, true}, |
| 1423 // Test that the path base is applied correctly for each instanced call. |
| 1424 {kPathCount, kPathsWithBase, kPathBase, kFillMode, kReference, kMask, |
| 1425 GL_NONE, NULL, sizeof(kPaths), 0, error::kNoError, GL_NO_ERROR, true}, |
| 1426 {kPathCount, kPathsWithBase, kPathBase, kFillMode, kReference, kMask, |
| 1427 |
| 1428 // Test all possible transform types. The float array is big enough for |
| 1429 // all the variants. The contents of the array in call is not checked, |
| 1430 // though. |
| 1431 GL_TRANSLATE_X_CHROMIUM, transform_values, sizeof(kPaths), |
| 1432 sizeof(transform_values), error::kNoError, GL_NO_ERROR, true}, |
| 1433 {kPathCount, kPathsWithBase, kPathBase, kFillMode, kReference, kMask, |
| 1434 GL_TRANSLATE_Y_CHROMIUM, transform_values, sizeof(kPaths), |
| 1435 sizeof(transform_values), error::kNoError, GL_NO_ERROR, true}, |
| 1436 {kPathCount, kPathsWithBase, kPathBase, kFillMode, kReference, kMask, |
| 1437 GL_TRANSLATE_2D_CHROMIUM, transform_values, sizeof(kPaths), |
| 1438 sizeof(transform_values), error::kNoError, GL_NO_ERROR, true}, |
| 1439 {kPathCount, kPathsWithBase, kPathBase, kFillMode, kReference, kMask, |
| 1440 GL_TRANSLATE_3D_CHROMIUM, transform_values, sizeof(kPaths), |
| 1441 sizeof(transform_values), error::kNoError, GL_NO_ERROR, true}, |
| 1442 {kPathCount, kPathsWithBase, kPathBase, kFillMode, kReference, kMask, |
| 1443 GL_AFFINE_2D_CHROMIUM, transform_values, sizeof(kPaths), |
| 1444 sizeof(transform_values), error::kNoError, GL_NO_ERROR, true}, |
| 1445 {kPathCount, kPathsWithBase, kPathBase, kFillMode, kReference, kMask, |
| 1446 GL_AFFINE_3D_CHROMIUM, transform_values, sizeof(kPaths), |
| 1447 sizeof(transform_values), error::kNoError, GL_NO_ERROR, true}, |
| 1448 {kPathCount, kPathsWithBase, kPathBase, kFillMode, kReference, kMask, |
| 1449 GL_TRANSPOSE_AFFINE_2D_CHROMIUM, transform_values, sizeof(kPaths), |
| 1450 sizeof(transform_values), error::kNoError, GL_NO_ERROR, true}, |
| 1451 {kPathCount, kPathsWithBase, kPathBase, kFillMode, kReference, kMask, |
| 1452 GL_TRANSPOSE_AFFINE_3D_CHROMIUM, transform_values, sizeof(kPaths), |
| 1453 sizeof(transform_values), error::kNoError, GL_NO_ERROR, true}}; |
| 1454 |
| 1455 for (size_t i = 0; i < arraysize(testcases); ++i) { |
| 1456 SCOPED_TRACE(testing::Message() << "InstancedCalls testcase " << i); |
| 1457 CallAllInstancedCommands(testcases[i]); |
| 1458 } |
| 1459 } |
| 1460 |
| 1461 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, InstancedNoCalls) { |
| 1462 const GLuint kPaths[] = {1, client_path_id_, 5, client_path_id_}; |
| 1463 const GLsizei kPathCount = arraysize(kPaths); |
| 1464 |
| 1465 const GLenum kFillMode = GL_INVERT; |
| 1466 const GLuint kMask = 0x80; |
| 1467 const GLuint kReference = 0xFF; |
| 1468 GLfloat transform_values[12 * kPathCount]; |
| 1469 for (GLsizei i = 0; i < kPathCount; ++i) { |
| 1470 for (int j = 0; j < 12; ++j) { |
| 1471 transform_values[i * 12 + j] = 0.1f * j + i; |
| 1472 } |
| 1473 } |
| 1474 |
| 1475 // The path base will be client_path_id_, and so 0 is a valid path and others |
| 1476 // should be invalid. |
| 1477 const GLuint kInvalidPathBase = client_path_id_; |
| 1478 const GLuint kInvalidPathsWithBase[] = {1, client_path_id_, 5, 18}; |
| 1479 |
| 1480 const GLuint kBigInvalidPathBase = std::numeric_limits<GLuint>::max() - 5; |
| 1481 |
| 1482 InstancedTestcase testcases[] = { |
| 1483 // Zero path count produces no error, no call. |
| 1484 {0, NULL, 0, kFillMode, kReference, kMask, GL_NONE, NULL, 0, 0, |
| 1485 error::kNoError, GL_NO_ERROR, false}, |
| 1486 |
| 1487 // Zero path count, even with path data, produces no error, no call. |
| 1488 {0, kPaths, 0, kFillMode, kReference, kMask, GL_TRANSLATE_X_CHROMIUM, |
| 1489 transform_values, sizeof(kPaths), sizeof(transform_values), |
| 1490 error::kNoError, GL_NO_ERROR, false}, |
| 1491 |
| 1492 // Negative path count produces error. |
| 1493 {-1, kPaths, 0, kFillMode, kReference, kMask, GL_TRANSLATE_X_CHROMIUM, |
| 1494 transform_values, sizeof(kPaths), sizeof(transform_values), |
| 1495 error::kNoError, GL_INVALID_VALUE, false}, |
| 1496 |
| 1497 // Passing paths count but not having the shm data is a connection error. |
| 1498 {kPathCount, NULL, 0, kFillMode, kReference, kMask, |
| 1499 GL_TRANSLATE_X_CHROMIUM, transform_values, 0, sizeof(transform_values), |
| 1500 error::kOutOfBounds, GL_NO_ERROR, false}, |
| 1501 |
| 1502 // Huge path count would cause huge transfer buffer, it does not go |
| 1503 // through. |
| 1504 {std::numeric_limits<GLsizei>::max() - 3, kPaths, 0, kFillMode, |
| 1505 kReference, kMask, GL_TRANSLATE_X_CHROMIUM, transform_values, |
| 1506 sizeof(kPaths), sizeof(transform_values), error::kOutOfBounds, |
| 1507 GL_NO_ERROR, false}, |
| 1508 |
| 1509 // Test that the path base is applied correctly for each instanced call. |
| 1510 // In this case no path is marked as used, and so no GL function should be |
| 1511 // called and no error should be generated. |
| 1512 {kPathCount, kInvalidPathsWithBase, kInvalidPathBase, kFillMode, |
| 1513 kReference, kMask, GL_TRANSLATE_X_CHROMIUM, transform_values, |
| 1514 sizeof(kInvalidPathsWithBase), sizeof(transform_values), error::kNoError, |
| 1515 GL_NO_ERROR, false}, |
| 1516 |
| 1517 // Test that if using path base causes path id to overflow, we get out of |
| 1518 // bounds error. |
| 1519 {kPathCount, kInvalidPathsWithBase, kBigInvalidPathBase, kFillMode, |
| 1520 kReference, kMask, GL_TRANSLATE_X_CHROMIUM, transform_values, |
| 1521 sizeof(kInvalidPathsWithBase), sizeof(transform_values), |
| 1522 error::kOutOfBounds, GL_NO_ERROR, false}, |
| 1523 |
| 1524 // Test that using correct paths but invalid transform type produces |
| 1525 // invalid enum. |
| 1526 {kPathCount, kPaths, 0, kFillMode, kReference, kMask, |
| 1527 GL_TRANSLATE_X_CHROMIUM - 1, transform_values, sizeof(kPaths), |
| 1528 sizeof(transform_values), error::kNoError, GL_INVALID_ENUM, false}, |
| 1529 |
| 1530 // Test that if we have transform, not having the shm data is a connection |
| 1531 // error. |
| 1532 {kPathCount, kPaths, 0, kFillMode, kReference, kMask, |
| 1533 GL_TRANSLATE_X_CHROMIUM, NULL, sizeof(kPaths), 0, error::kOutOfBounds, |
| 1534 GL_NO_ERROR, false}}; |
| 1535 for (size_t i = 0; i < arraysize(testcases); ++i) { |
| 1536 SCOPED_TRACE(testing::Message() << "InstancedNoCalls testcase " << i); |
| 1537 CallAllInstancedCommands(testcases[i]); |
| 1538 } |
| 1539 } |
| 1540 |
| 1541 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, InstancedInvalidSHMValues) { |
| 1542 const GLuint kPaths[] = {1, client_path_id_, 5, client_path_id_}; |
| 1543 const GLsizei kPathCount = arraysize(kPaths); |
| 1544 GLfloat transform_values[12 * kPathCount]; |
| 1545 for (GLsizei i = 0; i < kPathCount; ++i) { |
| 1546 for (int j = 0; j < 12; ++j) { |
| 1547 transform_values[i * 12 + j] = 0.1f * j + i; |
| 1548 } |
| 1549 } |
| 1550 enum { |
| 1551 kPathsSHMIdInvalid = 1, |
| 1552 kPathsSHMOffsetInvalid = 1 << 1, |
| 1553 kTransformsHMIdInvalid = 1 << 2, |
| 1554 kTransformsHMOffsetInvalid = 1 << 3, |
| 1555 kFirstTestcase = kPathsSHMIdInvalid, |
| 1556 kLastTestcase = kTransformsHMOffsetInvalid |
| 1557 }; |
| 1558 |
| 1559 for (int testcase = kFirstTestcase; testcase <= kLastTestcase; ++testcase) { |
| 1560 GLfloat* transforms = GetSharedMemoryAs<GLfloat*>(); |
| 1561 uint32 transforms_shm_id = shared_memory_id_; |
| 1562 uint32 transforms_shm_offset = shared_memory_offset_; |
| 1563 memcpy(transforms, transform_values, sizeof(transform_values)); |
| 1564 |
| 1565 GLuint* paths = |
| 1566 GetSharedMemoryAsWithOffset<GLuint*>(sizeof(transform_values)); |
| 1567 uint32 paths_shm_id = shared_memory_id_; |
| 1568 uint32 paths_shm_offset = shared_memory_offset_ + sizeof(transform_values); |
| 1569 |
| 1570 if (testcase & kPathsSHMIdInvalid) { |
| 1571 paths_shm_id = kInvalidSharedMemoryId; |
| 1572 } |
| 1573 if (testcase & kPathsSHMOffsetInvalid) { |
| 1574 paths_shm_offset = kInvalidSharedMemoryOffset; |
| 1575 } |
| 1576 if (testcase & kTransformsHMIdInvalid) { |
| 1577 transforms_shm_id = kInvalidSharedMemoryId; |
| 1578 } |
| 1579 if (testcase & kTransformsHMOffsetInvalid) { |
| 1580 transforms_shm_offset = kInvalidSharedMemoryOffset; |
| 1581 } |
| 1582 SCOPED_TRACE(testing::Message() << "InstancedInvalidSHMValues testcase " |
| 1583 << testcase); |
| 1584 CallAllInstancedCommandsWithInvalidSHM( |
| 1585 kPathCount, kPaths, paths, paths_shm_id, paths_shm_offset, |
| 1586 transforms_shm_id, transforms_shm_offset); |
| 1587 } |
| 1588 } |
| 1589 |
996 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_extensions_autog
en.h" | 1590 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_extensions_autog
en.h" |
997 | 1591 |
998 } // namespace gles2 | 1592 } // namespace gles2 |
999 } // namespace gpu | 1593 } // namespace gpu |
1000 | 1594 |
OLD | NEW |