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 "gpu/command_buffer/common/gles2_cmd_format.h" | 7 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
9 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h" | 9 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/gl/gl_mock.h" | 11 #include "ui/gl/gl_mock.h" |
12 | 12 |
13 using ::gfx::MockGLInterface; | 13 using ::gfx::MockGLInterface; |
14 using ::testing::_; | 14 using ::testing::_; |
| 15 using ::testing::Return; |
15 | 16 |
16 namespace gpu { | 17 namespace gpu { |
17 namespace gles2 { | 18 namespace gles2 { |
18 | 19 |
| 20 // Class to use to test that functions which need feature flags or |
| 21 // extensions always return INVALID_OPERATION if the feature flags is not |
| 22 // enabled or extension is not present. |
| 23 class GLES2DecoderTestDisabledExtensions : public GLES2DecoderTest { |
| 24 public: |
| 25 GLES2DecoderTestDisabledExtensions() {} |
| 26 }; |
| 27 INSTANTIATE_TEST_CASE_P(Service, |
| 28 GLES2DecoderTestDisabledExtensions, |
| 29 ::testing::Bool()); |
| 30 |
| 31 TEST_P(GLES2DecoderTestDisabledExtensions, CHROMIUMPathRenderingDisabled) { |
| 32 const GLuint kClientPathId = 0; |
| 33 { |
| 34 cmds::MatrixLoadfCHROMIUMImmediate& cmd = |
| 35 *GetImmediateAs<cmds::MatrixLoadfCHROMIUMImmediate>(); |
| 36 GLfloat temp[16] = { |
| 37 0, |
| 38 }; |
| 39 cmd.Init(GL_PATH_MODELVIEW_CHROMIUM, temp); |
| 40 EXPECT_EQ(error::kNoError, ExecuteImmediateCmd(cmd, sizeof(temp))); |
| 41 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 42 } |
| 43 { |
| 44 cmds::MatrixLoadIdentityCHROMIUM cmd; |
| 45 cmd.Init(GL_PATH_PROJECTION_CHROMIUM); |
| 46 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 47 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 48 } |
| 49 { |
| 50 cmds::GenPathsCHROMIUM cmd; |
| 51 cmd.Init(0, 0); |
| 52 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 53 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 54 } |
| 55 { |
| 56 cmds::DeletePathsCHROMIUM cmd; |
| 57 cmd.Init(0, 0); |
| 58 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 59 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 60 } |
| 61 { |
| 62 cmds::IsPathCHROMIUM cmd; |
| 63 cmd.Init(kClientPathId, shared_memory_id_, shared_memory_offset_); |
| 64 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 65 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 66 } |
| 67 { |
| 68 cmds::PathCommandsCHROMIUM cmd; |
| 69 cmd.Init(kClientPathId, 0, 0, 0, 0, GL_FLOAT, 0, 0); |
| 70 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 71 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 72 } |
| 73 { |
| 74 cmds::PathParameterfCHROMIUM cmd; |
| 75 cmd.Init(kClientPathId, GL_PATH_STROKE_WIDTH_CHROMIUM, 1.0f); |
| 76 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 77 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 78 } |
| 79 { |
| 80 cmds::PathParameteriCHROMIUM cmd; |
| 81 cmd.Init(kClientPathId, GL_PATH_STROKE_WIDTH_CHROMIUM, 1); |
| 82 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 83 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 84 } |
| 85 { |
| 86 cmds::PathStencilFuncCHROMIUM cmd; |
| 87 cmd.Init(GL_NEVER, 2, 3); |
| 88 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 89 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 90 } |
| 91 { |
| 92 cmds::StencilFillPathCHROMIUM cmd; |
| 93 cmd.Init(kClientPathId, GL_COUNT_UP_CHROMIUM, 1); |
| 94 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 95 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 96 } |
| 97 { |
| 98 cmds::StencilStrokePathCHROMIUM cmd; |
| 99 cmd.Init(kClientPathId, 1, 2); |
| 100 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 101 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 102 } |
| 103 { |
| 104 cmds::CoverFillPathCHROMIUM cmd; |
| 105 cmd.Init(kClientPathId, GL_BOUNDING_BOX_CHROMIUM); |
| 106 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 107 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 108 } |
| 109 { |
| 110 cmds::CoverStrokePathCHROMIUM cmd; |
| 111 cmd.Init(kClientPathId, GL_BOUNDING_BOX_CHROMIUM); |
| 112 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 113 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 114 } |
| 115 { |
| 116 cmds::StencilThenCoverFillPathCHROMIUM cmd; |
| 117 cmd.Init(kClientPathId, GL_COUNT_UP_CHROMIUM, 1, GL_BOUNDING_BOX_CHROMIUM); |
| 118 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 119 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 120 } |
| 121 { |
| 122 cmds::StencilThenCoverStrokePathCHROMIUM cmd; |
| 123 cmd.Init(kClientPathId, 1, 2, GL_BOUNDING_BOX_CHROMIUM); |
| 124 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 125 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 126 } |
| 127 } |
| 128 |
19 class GLES2DecoderTestWithCHROMIUMPathRendering : public GLES2DecoderTest { | 129 class GLES2DecoderTestWithCHROMIUMPathRendering : public GLES2DecoderTest { |
20 public: | 130 public: |
21 GLES2DecoderTestWithCHROMIUMPathRendering() {} | 131 GLES2DecoderTestWithCHROMIUMPathRendering() : client_path_id_(125) {} |
| 132 |
22 void SetUp() override { | 133 void SetUp() override { |
23 InitState init; | 134 InitState init; |
24 init.gl_version = "opengl es 3.1"; | 135 init.gl_version = "opengl es 3.1"; |
25 init.has_alpha = true; | 136 init.has_alpha = true; |
26 init.has_depth = true; | 137 init.has_depth = true; |
27 init.request_alpha = true; | 138 init.request_alpha = true; |
28 init.request_depth = true; | 139 init.request_depth = true; |
29 init.bind_generates_resource = true; | 140 init.bind_generates_resource = true; |
30 init.extensions = "GL_NV_path_rendering"; | 141 init.extensions = "GL_NV_path_rendering"; |
31 InitDecoder(init); | 142 InitDecoder(init); |
| 143 |
| 144 EXPECT_CALL(*gl_, GenPathsNV(1)) |
| 145 .WillOnce(Return(kServicePathId)) |
| 146 .RetiresOnSaturation(); |
| 147 cmds::GenPathsCHROMIUM cmd; |
| 148 cmd.Init(client_path_id_, 1); |
| 149 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
32 } | 150 } |
| 151 |
| 152 protected: |
| 153 template <typename TypeParam> |
| 154 void TestPathCommandsCHROMIUMCoordTypes(); |
| 155 |
| 156 GLuint client_path_id_; |
| 157 static const GLuint kServicePathId = 311; |
33 }; | 158 }; |
34 | 159 |
35 INSTANTIATE_TEST_CASE_P(Service, | 160 INSTANTIATE_TEST_CASE_P(Service, |
36 GLES2DecoderTestWithCHROMIUMPathRendering, | 161 GLES2DecoderTestWithCHROMIUMPathRendering, |
37 ::testing::Bool()); | 162 ::testing::Bool()); |
38 | 163 |
39 class GLES2DecoderTestWithBlendEquationAdvanced : public GLES2DecoderTest { | 164 class GLES2DecoderTestWithBlendEquationAdvanced : public GLES2DecoderTest { |
40 public: | 165 public: |
41 GLES2DecoderTestWithBlendEquationAdvanced() {} | 166 GLES2DecoderTestWithBlendEquationAdvanced() {} |
42 void SetUp() override { | 167 void SetUp() override { |
43 InitState init; | 168 InitState init; |
44 init.gl_version = "opengl es 2.0"; | 169 init.gl_version = "opengl es 2.0"; |
45 init.has_alpha = true; | 170 init.has_alpha = true; |
46 init.has_depth = true; | 171 init.has_depth = true; |
47 init.request_alpha = true; | 172 init.request_alpha = true; |
48 init.request_depth = true; | 173 init.request_depth = true; |
49 init.bind_generates_resource = true; | 174 init.bind_generates_resource = true; |
50 init.extensions = "GL_KHR_blend_equation_advanced"; | 175 init.extensions = "GL_KHR_blend_equation_advanced"; |
51 InitDecoder(init); | 176 InitDecoder(init); |
52 } | 177 } |
53 }; | 178 }; |
54 | 179 |
55 INSTANTIATE_TEST_CASE_P(Service, | 180 INSTANTIATE_TEST_CASE_P(Service, |
56 GLES2DecoderTestWithBlendEquationAdvanced, | 181 GLES2DecoderTestWithBlendEquationAdvanced, |
57 ::testing::Bool()); | 182 ::testing::Bool()); |
58 | 183 |
| 184 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, GenDeletePaths) { |
| 185 static GLuint kFirstClientID = client_path_id_ + 88; |
| 186 static GLsizei kPathCount = 58; |
| 187 static GLuint kFirstCreatedServiceID = 8000; |
| 188 |
| 189 // GenPaths range 0 causes no calls. |
| 190 cmds::GenPathsCHROMIUM gen_cmd; |
| 191 gen_cmd.Init(kFirstClientID, 0); |
| 192 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); |
| 193 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 194 |
| 195 // DeletePaths range 0 causes no calls. |
| 196 cmds::DeletePathsCHROMIUM delete_cmd; |
| 197 delete_cmd.Init(kFirstClientID, 0); |
| 198 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); |
| 199 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 200 |
| 201 // DeletePaths client 0 causes no calls and no errors. |
| 202 delete_cmd.Init(0, 1); |
| 203 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); |
| 204 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 205 |
| 206 // DeletePaths with a big range should not cause any deletes. |
| 207 delete_cmd.Init(client_path_id_ + 1, |
| 208 std::numeric_limits<GLsizei>::max() - client_path_id_ - 1); |
| 209 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); |
| 210 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 211 |
| 212 delete_cmd.Init(std::numeric_limits<GLsizei>::max() + 1, |
| 213 std::numeric_limits<GLsizei>::max()); |
| 214 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); |
| 215 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 216 |
| 217 // Normal Gen and Delete should cause the normal calls. |
| 218 EXPECT_CALL(*gl_, GenPathsNV(kPathCount)) |
| 219 .WillOnce(Return(kFirstCreatedServiceID)) |
| 220 .RetiresOnSaturation(); |
| 221 |
| 222 gen_cmd.Init(kFirstClientID, kPathCount); |
| 223 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); |
| 224 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 225 |
| 226 EXPECT_CALL(*gl_, DeletePathsNV(kFirstCreatedServiceID, kPathCount)) |
| 227 .RetiresOnSaturation(); |
| 228 |
| 229 delete_cmd.Init(kFirstClientID, kPathCount); |
| 230 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); |
| 231 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 232 } |
| 233 |
| 234 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, GenDeleteRanges) { |
| 235 static GLuint kFirstClientID = client_path_id_ + 77; |
| 236 static GLsizei kPathCount = 5800; |
| 237 static GLuint kFirstCreatedServiceID = 8000; |
| 238 |
| 239 // Create a range of path names, delete one in middle and then |
| 240 // the rest. Expect 3 DeletePath calls. |
| 241 EXPECT_CALL(*gl_, GenPathsNV(kPathCount)) |
| 242 .WillOnce(Return(kFirstCreatedServiceID)) |
| 243 .RetiresOnSaturation(); |
| 244 cmds::GenPathsCHROMIUM gen_cmd; |
| 245 gen_cmd.Init(kFirstClientID, kPathCount); |
| 246 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); |
| 247 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 248 |
| 249 EXPECT_CALL(*gl_, DeletePathsNV(kFirstCreatedServiceID + (kPathCount / 2), 1)) |
| 250 .RetiresOnSaturation(); |
| 251 |
| 252 cmds::DeletePathsCHROMIUM delete_cmd; |
| 253 delete_cmd.Init(kFirstClientID + (kPathCount / 2), 1); |
| 254 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); |
| 255 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 256 |
| 257 EXPECT_CALL(*gl_, DeletePathsNV(kFirstCreatedServiceID, (kPathCount / 2))) |
| 258 .RetiresOnSaturation(); |
| 259 EXPECT_CALL(*gl_, DeletePathsNV(kFirstCreatedServiceID + (kPathCount / 2) + 1, |
| 260 (kPathCount / 2) - 1)).RetiresOnSaturation(); |
| 261 |
| 262 delete_cmd.Init(kFirstClientID, kPathCount); |
| 263 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); |
| 264 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 265 } |
| 266 |
| 267 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, GenDeleteManyPaths) { |
| 268 static GLuint kFirstClientID = client_path_id_ + 1; |
| 269 static GLsizei kPathCount = std::numeric_limits<GLsizei>::max(); |
| 270 static GLuint kFirstCreatedServiceID = 8000; |
| 271 |
| 272 EXPECT_CALL(*gl_, GenPathsNV(kPathCount)) |
| 273 .WillOnce(Return(kFirstCreatedServiceID)) |
| 274 .RetiresOnSaturation(); |
| 275 |
| 276 // GenPaths with big range. |
| 277 cmds::GenPathsCHROMIUM gen_cmd; |
| 278 gen_cmd.Init(kFirstClientID, kPathCount); |
| 279 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); |
| 280 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 281 |
| 282 // Path range wraps, so we get connection error. |
| 283 gen_cmd.Init(kFirstClientID + kPathCount, kPathCount); |
| 284 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(gen_cmd)); |
| 285 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 286 |
| 287 EXPECT_CALL(*gl_, DeletePathsNV(kFirstCreatedServiceID, kPathCount)) |
| 288 .RetiresOnSaturation(); |
| 289 |
| 290 cmds::DeletePathsCHROMIUM delete_cmd; |
| 291 delete_cmd.Init(kFirstClientID, kPathCount); |
| 292 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); |
| 293 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 294 |
| 295 // Delete every possible path. |
| 296 // We run into the one created for client_path_id_. |
| 297 EXPECT_CALL(*gl_, DeletePathsNV(kServicePathId, 1)).RetiresOnSaturation(); |
| 298 |
| 299 delete_cmd.Init(1u, kPathCount); |
| 300 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); |
| 301 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 302 |
| 303 delete_cmd.Init(static_cast<GLuint>(kPathCount) + 1u, kPathCount); |
| 304 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); |
| 305 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 306 |
| 307 // Allocate every possible path, delete few, allocate them back and |
| 308 // expect minimum amount of calls. |
| 309 EXPECT_CALL(*gl_, GenPathsNV(kPathCount)) |
| 310 .WillOnce(Return(static_cast<GLuint>(1u))) |
| 311 .WillOnce(Return(static_cast<GLuint>(kPathCount) + 1u)) |
| 312 .RetiresOnSaturation(); |
| 313 |
| 314 gen_cmd.Init(1u, kPathCount); |
| 315 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); |
| 316 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 317 |
| 318 gen_cmd.Init(static_cast<GLuint>(kPathCount) + 1u, kPathCount); |
| 319 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); |
| 320 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 321 |
| 322 gen_cmd.Init(static_cast<GLuint>(kPathCount) * 2u + 2u, kPathCount); |
| 323 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(gen_cmd)); |
| 324 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 325 |
| 326 EXPECT_CALL(*gl_, DeletePathsNV(kFirstClientID, 4)).RetiresOnSaturation(); |
| 327 |
| 328 delete_cmd.Init(kFirstClientID, 4); |
| 329 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); |
| 330 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 331 |
| 332 EXPECT_CALL(*gl_, DeletePathsNV(kFirstClientID * 3, 1)).RetiresOnSaturation(); |
| 333 |
| 334 delete_cmd.Init(kFirstClientID * 3, 1); |
| 335 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); |
| 336 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 337 |
| 338 EXPECT_CALL(*gl_, GenPathsNV(1)) |
| 339 .WillOnce(Return(kFirstClientID)) |
| 340 .WillOnce(Return(kFirstClientID + 1)) |
| 341 .WillOnce(Return(kFirstClientID + 2)) |
| 342 .WillOnce(Return(kFirstClientID + 3)) |
| 343 .RetiresOnSaturation(); |
| 344 |
| 345 for (int i = 0; i < 4; ++i) { |
| 346 gen_cmd.Init(kFirstClientID + i, 1); |
| 347 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); |
| 348 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 349 } |
| 350 |
| 351 EXPECT_CALL(*gl_, GenPathsNV(1)) |
| 352 .WillOnce(Return(kFirstClientID * 3)) |
| 353 .RetiresOnSaturation(); |
| 354 gen_cmd.Init(kFirstClientID * 3, 1); |
| 355 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); |
| 356 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 357 |
| 358 EXPECT_CALL(*gl_, DeletePathsNV(1u, kPathCount)).RetiresOnSaturation(); |
| 359 EXPECT_CALL(*gl_, DeletePathsNV(static_cast<GLuint>(kPathCount) + 1u, |
| 360 kPathCount)).RetiresOnSaturation(); |
| 361 |
| 362 delete_cmd.Init(1u, kPathCount); |
| 363 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); |
| 364 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 365 |
| 366 delete_cmd.Init(static_cast<GLuint>(kPathCount) + 1u, kPathCount); |
| 367 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); |
| 368 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 369 |
| 370 // Cleanup: return the client_path_id_ as a path. |
| 371 EXPECT_CALL(*gl_, GenPathsNV(1)) |
| 372 .WillOnce(Return(static_cast<GLuint>(kServicePathId))) |
| 373 .RetiresOnSaturation(); |
| 374 |
| 375 gen_cmd.Init(client_path_id_, 1); |
| 376 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); |
| 377 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 378 } |
| 379 |
| 380 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, |
| 381 GenPathsCHROMIUMInvalidCalls) { |
| 382 static GLuint kFirstClientID = client_path_id_ + 88; |
| 383 static GLsizei kPathCount = 5800; |
| 384 static GLuint kFirstCreatedServiceID = 8000; |
| 385 |
| 386 // Range < 0 is causes gl error. |
| 387 cmds::GenPathsCHROMIUM gen_cmd; |
| 388 gen_cmd.Init(kFirstClientID, -1); |
| 389 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); |
| 390 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 391 |
| 392 // Path 0 is invalid client id, connection error. |
| 393 gen_cmd.Init(0, kPathCount); |
| 394 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(gen_cmd)); |
| 395 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 396 |
| 397 // Too big range causes client id to wrap, connection error. |
| 398 gen_cmd.Init(std::numeric_limits<GLsizei>::max() + 3, |
| 399 std::numeric_limits<GLsizei>::max()); |
| 400 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(gen_cmd)); |
| 401 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 402 |
| 403 // Creating duplicate client_ids cause connection error. |
| 404 EXPECT_CALL(*gl_, GenPathsNV(kPathCount)) |
| 405 .WillOnce(Return(kFirstCreatedServiceID)) |
| 406 .RetiresOnSaturation(); |
| 407 |
| 408 gen_cmd.Init(kFirstClientID, kPathCount); |
| 409 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); |
| 410 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 411 |
| 412 // Create duplicate by executing the same cmd. |
| 413 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(gen_cmd)); |
| 414 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 415 |
| 416 // Create duplicate by creating a range that contains |
| 417 // an already existing client path id. |
| 418 gen_cmd.Init(kFirstClientID - 1, 2); |
| 419 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(gen_cmd)); |
| 420 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 421 |
| 422 // Cleanup. |
| 423 EXPECT_CALL(*gl_, DeletePathsNV(kFirstCreatedServiceID, kPathCount)) |
| 424 .RetiresOnSaturation(); |
| 425 cmds::DeletePathsCHROMIUM delete_cmd; |
| 426 delete_cmd.Init(kFirstClientID, kPathCount); |
| 427 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); |
| 428 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 429 } |
| 430 |
| 431 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, |
| 432 DeletePathsCHROMIUMInvalidCalls) { |
| 433 static GLuint kFirstClientID = client_path_id_ + 88; |
| 434 |
| 435 // Range < 0 is causes gl error. |
| 436 cmds::DeletePathsCHROMIUM delete_cmd; |
| 437 delete_cmd.Init(kFirstClientID, -1); |
| 438 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); |
| 439 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 440 |
| 441 // Too big range causes client id to wrap, connection error. |
| 442 delete_cmd.Init(std::numeric_limits<GLsizei>::max() + 3, |
| 443 std::numeric_limits<GLsizei>::max()); |
| 444 EXPECT_EQ(error::kInvalidArguments, ExecuteCmd(delete_cmd)); |
| 445 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 446 } |
| 447 |
| 448 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, |
| 449 PathCommandsCHROMIUMInvalidCalls) { |
| 450 static const GLsizei kCorrectCoordCount = 19; |
| 451 static const GLsizei kCorrectCommandCount = 6; |
| 452 static const GLenum kInvalidCoordType = GL_NONE; |
| 453 |
| 454 GLfloat* coords = GetSharedMemoryAs<GLfloat*>(); |
| 455 unsigned commands_offset = sizeof(GLfloat) * kCorrectCoordCount; |
| 456 GLubyte* commands = GetSharedMemoryAsWithOffset<GLubyte*>(commands_offset); |
| 457 for (int i = 0; i < kCorrectCoordCount; ++i) { |
| 458 coords[i] = 5.0f * i; |
| 459 } |
| 460 commands[0] = GL_MOVE_TO_CHROMIUM; |
| 461 commands[1] = GL_CLOSE_PATH_CHROMIUM; |
| 462 commands[2] = GL_LINE_TO_CHROMIUM; |
| 463 commands[3] = GL_QUADRATIC_CURVE_TO_CHROMIUM; |
| 464 commands[4] = GL_CUBIC_CURVE_TO_CHROMIUM; |
| 465 commands[5] = GL_CONIC_CURVE_TO_CHROMIUM; |
| 466 |
| 467 EXPECT_CALL(*gl_, PathCommandsNV(kServicePathId, kCorrectCommandCount, |
| 468 commands, kCorrectCoordCount, GL_FLOAT, |
| 469 coords)).RetiresOnSaturation(); |
| 470 |
| 471 cmds::PathCommandsCHROMIUM cmd; |
| 472 |
| 473 // Reference call -- this succeeds. |
| 474 cmd.Init(client_path_id_, kCorrectCommandCount, shared_memory_id_, |
| 475 shared_memory_offset_ + commands_offset, kCorrectCoordCount, |
| 476 GL_FLOAT, shared_memory_id_, shared_memory_offset_); |
| 477 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 478 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 479 |
| 480 EXPECT_CALL(*gl_, PathCommandsNV(_, _, _, _, _, _)).Times(0); |
| 481 |
| 482 // Invalid client id fails. |
| 483 cmd.Init(client_path_id_ - 1, kCorrectCommandCount, shared_memory_id_, |
| 484 shared_memory_offset_, kCorrectCoordCount, GL_FLOAT, |
| 485 shared_memory_id_, shared_memory_offset_); |
| 486 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 487 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 488 |
| 489 // The numCommands < 0. |
| 490 cmd.Init(client_path_id_, -1, shared_memory_id_, shared_memory_offset_, |
| 491 kCorrectCoordCount, GL_FLOAT, shared_memory_id_, |
| 492 shared_memory_offset_); |
| 493 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 494 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 495 |
| 496 // The numCoords < 0. |
| 497 cmd.Init(client_path_id_, kCorrectCommandCount, shared_memory_id_, |
| 498 shared_memory_offset_, -1, GL_FLOAT, shared_memory_id_, |
| 499 shared_memory_offset_); |
| 500 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 501 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 502 |
| 503 // Invalid coordType fails. |
| 504 cmd.Init(client_path_id_, kCorrectCommandCount, shared_memory_id_, |
| 505 shared_memory_offset_, kCorrectCoordCount, kInvalidCoordType, |
| 506 shared_memory_id_, shared_memory_offset_); |
| 507 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 508 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 509 |
| 510 // Big command counts. |
| 511 cmd.Init(client_path_id_, std::numeric_limits<GLsizei>::max(), |
| 512 shared_memory_id_, shared_memory_offset_ + commands_offset, |
| 513 kCorrectCoordCount, GL_FLOAT, shared_memory_id_, |
| 514 shared_memory_offset_); |
| 515 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); |
| 516 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 517 |
| 518 // Invalid SHM cases. |
| 519 cmd.Init(client_path_id_, kCorrectCommandCount, kInvalidSharedMemoryId, |
| 520 shared_memory_offset_ + commands_offset, kCorrectCoordCount, |
| 521 GL_FLOAT, shared_memory_id_, shared_memory_offset_); |
| 522 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); |
| 523 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 524 |
| 525 cmd.Init(client_path_id_, kCorrectCommandCount, shared_memory_id_, |
| 526 kInvalidSharedMemoryOffset, kCorrectCoordCount, GL_FLOAT, |
| 527 shared_memory_id_, shared_memory_offset_); |
| 528 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); |
| 529 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 530 |
| 531 cmd.Init(client_path_id_, kCorrectCommandCount, shared_memory_id_, |
| 532 shared_memory_offset_ + commands_offset, kCorrectCoordCount, |
| 533 GL_FLOAT, kInvalidSharedMemoryId, shared_memory_offset_); |
| 534 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); |
| 535 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 536 |
| 537 cmd.Init(client_path_id_, kCorrectCommandCount, shared_memory_id_, |
| 538 shared_memory_offset_ + commands_offset, kCorrectCoordCount, |
| 539 GL_FLOAT, shared_memory_id_, kInvalidSharedMemoryOffset); |
| 540 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd)); |
| 541 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 542 |
| 543 // NULL shm command id. Currently causes gl error, though client should not |
| 544 // let this through. |
| 545 cmd.Init(client_path_id_, kCorrectCommandCount, 0, 0, kCorrectCoordCount, |
| 546 GL_FLOAT, shared_memory_id_, shared_memory_offset_); |
| 547 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 548 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 549 |
| 550 // The coordCount not matching what is in commands. |
| 551 // Expects kCorrectCoordCount+2 coords. |
| 552 commands[1] = GL_MOVE_TO_CHROMIUM; |
| 553 cmd.Init(client_path_id_, kCorrectCommandCount, shared_memory_id_, |
| 554 shared_memory_offset_ + commands_offset, kCorrectCoordCount, |
| 555 GL_FLOAT, shared_memory_id_, shared_memory_offset_); |
| 556 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 557 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 558 |
| 559 // The coordCount not matching what is in commands. |
| 560 // Expects kCorrectCoordCount-2 coords. |
| 561 commands[0] = GL_CLOSE_PATH_CHROMIUM; |
| 562 commands[1] = GL_CLOSE_PATH_CHROMIUM; |
| 563 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 564 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 565 |
| 566 // NULL shm coord ids. Currently causes gl error, though client should not let |
| 567 // this through. |
| 568 cmd.Init(client_path_id_, kCorrectCommandCount, shared_memory_id_, |
| 569 shared_memory_offset_ + commands_offset, kCorrectCoordCount, |
| 570 GL_FLOAT, 0, 0); |
| 571 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 572 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 573 } |
| 574 |
| 575 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, |
| 576 PathCommandsCHROMIUMEmptyCommands) { |
| 577 EXPECT_CALL(*gl_, PathCommandsNV(kServicePathId, 0, NULL, 0, GL_FLOAT, NULL)) |
| 578 .RetiresOnSaturation(); |
| 579 cmds::PathCommandsCHROMIUM cmd; |
| 580 cmd.Init(client_path_id_, 0, 0, 0, 0, GL_FLOAT, 0, 0); |
| 581 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 582 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 583 } |
| 584 |
| 585 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, |
| 586 PathCommandsCHROMIUMInvalidCommands) { |
| 587 EXPECT_CALL(*gl_, PathCommandsNV(_, _, _, _, _, _)).Times(0); |
| 588 |
| 589 cmds::PathCommandsCHROMIUM cmd; |
| 590 |
| 591 { |
| 592 const GLsizei kCoordCount = 2; |
| 593 const GLsizei kCommandCount = 2; |
| 594 GLfloat* coords = GetSharedMemoryAs<GLfloat*>(); |
| 595 unsigned commands_offset = sizeof(GLfloat) * kCoordCount; |
| 596 GLubyte* commands = GetSharedMemoryAsWithOffset<GLubyte*>(commands_offset); |
| 597 |
| 598 coords[0] = 5.0f; |
| 599 coords[1] = 5.0f; |
| 600 commands[0] = 0x3; // Token MOVE_TO_RELATIVE in NV_path_rendering. |
| 601 commands[1] = GL_CLOSE_PATH_CHROMIUM; |
| 602 |
| 603 cmd.Init(client_path_id_ - 1, kCommandCount, shared_memory_id_, |
| 604 shared_memory_offset_, kCoordCount, GL_FLOAT, shared_memory_id_, |
| 605 shared_memory_offset_); |
| 606 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 607 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 608 } |
| 609 { |
| 610 const GLsizei kCoordCount = 8; |
| 611 const GLsizei kCommandCount = 4; |
| 612 GLfloat* coords = GetSharedMemoryAs<GLfloat*>(); |
| 613 unsigned commands_offset = sizeof(GLfloat) * kCoordCount; |
| 614 GLubyte* commands = GetSharedMemoryAsWithOffset<GLubyte*>(commands_offset); |
| 615 |
| 616 for (int i = 0; i < kCoordCount; ++i) { |
| 617 coords[i] = 5.0f * i; |
| 618 } |
| 619 commands[0] = GL_MOVE_TO_CHROMIUM; |
| 620 commands[1] = GL_MOVE_TO_CHROMIUM; |
| 621 commands[2] = 'M'; // Synonym to MOVE_TO in NV_path_rendering. |
| 622 commands[3] = GL_MOVE_TO_CHROMIUM; |
| 623 |
| 624 cmd.Init(client_path_id_ - 1, kCommandCount, shared_memory_id_, |
| 625 shared_memory_offset_, kCoordCount, GL_FLOAT, shared_memory_id_, |
| 626 shared_memory_offset_); |
| 627 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 628 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
| 629 } |
| 630 } |
| 631 |
| 632 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, PathParameterXCHROMIUM) { |
| 633 static GLuint kFirstClientID = client_path_id_ + 88; |
| 634 static GLsizei kPathCount = 2; |
| 635 static GLuint kFirstCreatedServiceID = 8000; |
| 636 |
| 637 // Create a paths so that we do not modify client_path_id_ |
| 638 EXPECT_CALL(*gl_, GenPathsNV(kPathCount)) |
| 639 .WillOnce(Return(kFirstCreatedServiceID)) |
| 640 .RetiresOnSaturation(); |
| 641 cmds::GenPathsCHROMIUM gen_cmd; |
| 642 gen_cmd.Init(kFirstClientID, kPathCount); |
| 643 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); |
| 644 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 645 |
| 646 cmds::PathParameterfCHROMIUM fcmd; |
| 647 cmds::PathParameteriCHROMIUM icmd; |
| 648 const struct { |
| 649 GLenum pname; |
| 650 GLfloat value; |
| 651 GLfloat expected_value; |
| 652 } kTestcases[] = { |
| 653 {GL_PATH_STROKE_WIDTH_CHROMIUM, 1.0f, 1.0f}, |
| 654 {GL_PATH_STROKE_WIDTH_CHROMIUM, 0.0f, 0.0f}, |
| 655 {GL_PATH_MITER_LIMIT_CHROMIUM, 500.0f, 500.0f}, |
| 656 {GL_PATH_STROKE_BOUND_CHROMIUM, .80f, .80f}, |
| 657 {GL_PATH_STROKE_BOUND_CHROMIUM, 1.80f, 1.0f}, |
| 658 {GL_PATH_STROKE_BOUND_CHROMIUM, -1.0f, 0.0f}, |
| 659 {GL_PATH_END_CAPS_CHROMIUM, GL_FLAT_CHROMIUM, GL_FLAT_CHROMIUM}, |
| 660 {GL_PATH_END_CAPS_CHROMIUM, GL_SQUARE_CHROMIUM, GL_SQUARE_CHROMIUM}, |
| 661 {GL_PATH_JOIN_STYLE_CHROMIUM, |
| 662 GL_MITER_REVERT_CHROMIUM, |
| 663 GL_MITER_REVERT_CHROMIUM}, |
| 664 }; |
| 665 |
| 666 for (auto& testcase : kTestcases) { |
| 667 EXPECT_CALL(*gl_, PathParameterfNV(kFirstCreatedServiceID, testcase.pname, |
| 668 testcase.expected_value)) |
| 669 .Times(1) |
| 670 .RetiresOnSaturation(); |
| 671 fcmd.Init(kFirstClientID, testcase.pname, testcase.value); |
| 672 EXPECT_EQ(error::kNoError, ExecuteCmd(fcmd)); |
| 673 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 674 |
| 675 EXPECT_CALL(*gl_, |
| 676 PathParameteriNV(kFirstCreatedServiceID + 1, testcase.pname, |
| 677 static_cast<GLint>(testcase.expected_value))) |
| 678 .Times(1) |
| 679 .RetiresOnSaturation(); |
| 680 icmd.Init(kFirstClientID + 1, testcase.pname, |
| 681 static_cast<GLint>(testcase.value)); |
| 682 EXPECT_EQ(error::kNoError, ExecuteCmd(icmd)); |
| 683 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 684 } |
| 685 |
| 686 // Cleanup. |
| 687 EXPECT_CALL(*gl_, DeletePathsNV(kFirstCreatedServiceID, kPathCount)) |
| 688 .RetiresOnSaturation(); |
| 689 |
| 690 cmds::DeletePathsCHROMIUM delete_cmd; |
| 691 delete_cmd.Init(kFirstClientID, kPathCount); |
| 692 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); |
| 693 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 694 } |
| 695 |
| 696 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, |
| 697 PathParameterXCHROMIUMInvalidArgs) { |
| 698 static GLuint kFirstClientID = client_path_id_ + 88; |
| 699 static GLsizei kPathCount = 2; |
| 700 static GLuint kFirstCreatedServiceID = 8000; |
| 701 |
| 702 // Create a paths so that we do not modify client_path_id_ |
| 703 EXPECT_CALL(*gl_, GenPathsNV(kPathCount)) |
| 704 .WillOnce(Return(kFirstCreatedServiceID)) |
| 705 .RetiresOnSaturation(); |
| 706 cmds::GenPathsCHROMIUM gen_cmd; |
| 707 gen_cmd.Init(kFirstClientID, kPathCount); |
| 708 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd)); |
| 709 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 710 |
| 711 cmds::PathParameterfCHROMIUM fcmd; |
| 712 cmds::PathParameteriCHROMIUM icmd; |
| 713 const struct { |
| 714 GLenum pname; |
| 715 GLfloat value; |
| 716 bool try_int_version; |
| 717 GLint error; |
| 718 } kTestcases[] = { |
| 719 {GL_PATH_STROKE_WIDTH_CHROMIUM, -1.0f, true, GL_INVALID_VALUE}, |
| 720 {GL_PATH_MITER_LIMIT_CHROMIUM, |
| 721 std::numeric_limits<float>::infinity(), |
| 722 false, |
| 723 GL_INVALID_VALUE}, |
| 724 {GL_PATH_MITER_LIMIT_CHROMIUM, |
| 725 std::numeric_limits<float>::quiet_NaN(), |
| 726 false, |
| 727 GL_INVALID_VALUE}, |
| 728 {GL_PATH_END_CAPS_CHROMIUM, 0x4, true, GL_INVALID_VALUE}, |
| 729 {GL_PATH_END_CAPS_CHROMIUM, |
| 730 GL_MITER_REVERT_CHROMIUM, |
| 731 true, |
| 732 GL_INVALID_VALUE}, |
| 733 {GL_PATH_JOIN_STYLE_CHROMIUM, GL_FLAT_CHROMIUM, true, GL_INVALID_VALUE}, |
| 734 {GL_PATH_MODELVIEW_CHROMIUM, GL_FLAT_CHROMIUM, true, GL_INVALID_ENUM}, |
| 735 }; |
| 736 |
| 737 EXPECT_CALL(*gl_, PathParameterfNV(_, _, _)).Times(0); |
| 738 EXPECT_CALL(*gl_, PathParameteriNV(_, _, _)).Times(0); |
| 739 |
| 740 for (auto& testcase : kTestcases) { |
| 741 fcmd.Init(kFirstClientID, testcase.pname, testcase.value); |
| 742 EXPECT_EQ(error::kNoError, ExecuteCmd(fcmd)); |
| 743 EXPECT_EQ(testcase.error, GetGLError()); |
| 744 if (!testcase.try_int_version) { |
| 745 continue; |
| 746 } |
| 747 icmd.Init(kFirstClientID + 1, testcase.pname, |
| 748 static_cast<GLint>(testcase.value)); |
| 749 EXPECT_EQ(error::kNoError, ExecuteCmd(icmd)); |
| 750 EXPECT_EQ(testcase.error, GetGLError()); |
| 751 } |
| 752 |
| 753 // Cleanup. |
| 754 EXPECT_CALL(*gl_, DeletePathsNV(kFirstCreatedServiceID, kPathCount)) |
| 755 .RetiresOnSaturation(); |
| 756 |
| 757 cmds::DeletePathsCHROMIUM delete_cmd; |
| 758 delete_cmd.Init(kFirstClientID, kPathCount); |
| 759 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd)); |
| 760 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 761 } |
| 762 |
| 763 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, StencilFillPathCHROMIUM) { |
| 764 SetupExpectationsForApplyingDefaultDirtyState(); |
| 765 |
| 766 cmds::StencilFillPathCHROMIUM cmd; |
| 767 cmds::StencilThenCoverFillPathCHROMIUM tcmd; |
| 768 |
| 769 static const GLenum kFillModes[] = { |
| 770 GL_INVERT, GL_COUNT_UP_CHROMIUM, GL_COUNT_DOWN_CHROMIUM}; |
| 771 static const GLuint kMask = 0x7F; |
| 772 |
| 773 for (auto& fill_mode : kFillModes) { |
| 774 EXPECT_CALL(*gl_, StencilFillPathNV(kServicePathId, fill_mode, kMask)) |
| 775 .RetiresOnSaturation(); |
| 776 cmd.Init(client_path_id_, fill_mode, kMask); |
| 777 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 778 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 779 |
| 780 EXPECT_CALL(*gl_, StencilThenCoverFillPathNV(kServicePathId, fill_mode, |
| 781 kMask, GL_BOUNDING_BOX_NV)) |
| 782 .RetiresOnSaturation(); |
| 783 tcmd.Init(client_path_id_, fill_mode, kMask, GL_BOUNDING_BOX_CHROMIUM); |
| 784 EXPECT_EQ(error::kNoError, ExecuteCmd(tcmd)); |
| 785 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 786 } |
| 787 |
| 788 // Non-existent path: no error, no call. |
| 789 cmd.Init(client_path_id_ - 1, GL_INVERT, 0x80); |
| 790 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 791 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 792 |
| 793 tcmd.Init(client_path_id_ - 1, GL_INVERT, 0x80, GL_BOUNDING_BOX_CHROMIUM); |
| 794 EXPECT_EQ(error::kNoError, ExecuteCmd(tcmd)); |
| 795 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 796 } |
| 797 |
| 798 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, |
| 799 StencilFillPathCHROMIUMInvalidArgs) { |
| 800 EXPECT_CALL(*gl_, StencilFillPathNV(_, _, _)).Times(0); |
| 801 EXPECT_CALL(*gl_, StencilThenCoverFillPathNV(_, _, _, GL_BOUNDING_BOX_NV)) |
| 802 .Times(0); |
| 803 |
| 804 cmds::StencilFillPathCHROMIUM cmd; |
| 805 cmds::StencilThenCoverFillPathCHROMIUM tcmd; |
| 806 |
| 807 cmd.Init(client_path_id_, GL_INVERT - 1, 0x80); |
| 808 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 809 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 810 |
| 811 tcmd.Init(client_path_id_, GL_INVERT - 1, 0x80, GL_BOUNDING_BOX_CHROMIUM); |
| 812 EXPECT_EQ(error::kNoError, ExecuteCmd(tcmd)); |
| 813 EXPECT_EQ(GL_INVALID_ENUM, GetGLError()); |
| 814 |
| 815 // The /mask/+1 is not power of two -> invalid value. |
| 816 cmd.Init(client_path_id_, GL_COUNT_UP_CHROMIUM, 0x80); |
| 817 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 818 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 819 |
| 820 tcmd.Init(client_path_id_, GL_COUNT_UP_CHROMIUM, 0x80, |
| 821 GL_BOUNDING_BOX_CHROMIUM); |
| 822 EXPECT_EQ(error::kNoError, ExecuteCmd(tcmd)); |
| 823 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 824 |
| 825 cmd.Init(client_path_id_, GL_COUNT_DOWN_CHROMIUM, 5); |
| 826 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 827 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 828 |
| 829 tcmd.Init(client_path_id_, GL_COUNT_DOWN_CHROMIUM, 5, |
| 830 GL_BOUNDING_BOX_CHROMIUM); |
| 831 EXPECT_EQ(error::kNoError, ExecuteCmd(tcmd)); |
| 832 EXPECT_EQ(GL_INVALID_VALUE, GetGLError()); |
| 833 } |
| 834 |
| 835 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, StencilStrokePathCHROMIUM) { |
| 836 SetupExpectationsForApplyingDefaultDirtyState(); |
| 837 |
| 838 EXPECT_CALL(*gl_, StencilStrokePathNV(kServicePathId, 1, 0x80)) |
| 839 .RetiresOnSaturation(); |
| 840 EXPECT_CALL(*gl_, StencilThenCoverStrokePathNV(kServicePathId, 1, 0x80, |
| 841 GL_BOUNDING_BOX_NV)) |
| 842 .RetiresOnSaturation(); |
| 843 |
| 844 cmds::StencilStrokePathCHROMIUM cmd; |
| 845 cmds::StencilThenCoverStrokePathCHROMIUM tcmd; |
| 846 |
| 847 cmd.Init(client_path_id_, 1, 0x80); |
| 848 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 849 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 850 |
| 851 tcmd.Init(client_path_id_, 1, 0x80, GL_BOUNDING_BOX_CHROMIUM); |
| 852 EXPECT_EQ(error::kNoError, ExecuteCmd(tcmd)); |
| 853 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 854 |
| 855 EXPECT_CALL(*gl_, StencilThenCoverStrokePathNV(kServicePathId, 1, 0x80, |
| 856 GL_CONVEX_HULL_NV)) |
| 857 .RetiresOnSaturation(); |
| 858 |
| 859 tcmd.Init(client_path_id_, 1, 0x80, GL_CONVEX_HULL_CHROMIUM); |
| 860 EXPECT_EQ(error::kNoError, ExecuteCmd(tcmd)); |
| 861 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 862 |
| 863 // Non-existent path: no error, no call. |
| 864 cmd.Init(client_path_id_ - 1, 1, 0x80); |
| 865 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 866 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 867 |
| 868 tcmd.Init(client_path_id_ - 1, 1, 0x80, GL_BOUNDING_BOX_CHROMIUM); |
| 869 EXPECT_EQ(error::kNoError, ExecuteCmd(tcmd)); |
| 870 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 871 } |
| 872 |
| 873 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, CoverFillPathCHROMIUM) { |
| 874 SetupExpectationsForApplyingDefaultDirtyState(); |
| 875 |
| 876 EXPECT_CALL(*gl_, CoverFillPathNV(kServicePathId, GL_BOUNDING_BOX_NV)) |
| 877 .RetiresOnSaturation(); |
| 878 cmds::CoverFillPathCHROMIUM cmd; |
| 879 cmd.Init(client_path_id_, GL_BOUNDING_BOX_CHROMIUM); |
| 880 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 881 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 882 |
| 883 EXPECT_CALL(*gl_, CoverFillPathNV(kServicePathId, GL_CONVEX_HULL_NV)) |
| 884 .RetiresOnSaturation(); |
| 885 cmd.Init(client_path_id_, GL_CONVEX_HULL_CHROMIUM); |
| 886 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 887 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 888 |
| 889 // Non-existent path: no error, no call. |
| 890 cmd.Init(client_path_id_ - 1, GL_BOUNDING_BOX_CHROMIUM); |
| 891 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 892 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 893 } |
| 894 |
| 895 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, CoverStrokePathCHROMIUM) { |
| 896 SetupExpectationsForApplyingDefaultDirtyState(); |
| 897 EXPECT_CALL(*gl_, CoverStrokePathNV(kServicePathId, GL_BOUNDING_BOX_NV)) |
| 898 .RetiresOnSaturation(); |
| 899 cmds::CoverStrokePathCHROMIUM cmd; |
| 900 cmd.Init(client_path_id_, GL_BOUNDING_BOX_CHROMIUM); |
| 901 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 902 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 903 |
| 904 EXPECT_CALL(*gl_, CoverStrokePathNV(kServicePathId, GL_CONVEX_HULL_NV)) |
| 905 .RetiresOnSaturation(); |
| 906 cmd.Init(client_path_id_, GL_CONVEX_HULL_CHROMIUM); |
| 907 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 908 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 909 |
| 910 // Non-existent path: no error, no call. |
| 911 cmd.Init(client_path_id_ - 1, GL_BOUNDING_BOX_CHROMIUM); |
| 912 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 913 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 914 } |
| 915 |
| 916 namespace { |
| 917 template <typename T> |
| 918 struct gl_type_enum {}; |
| 919 template <> |
| 920 struct gl_type_enum<GLbyte> { |
| 921 enum { kGLType = GL_BYTE }; |
| 922 }; |
| 923 template <> |
| 924 struct gl_type_enum<GLubyte> { |
| 925 enum { kGLType = GL_UNSIGNED_BYTE }; |
| 926 }; |
| 927 template <> |
| 928 struct gl_type_enum<GLshort> { |
| 929 enum { kGLType = GL_SHORT }; |
| 930 }; |
| 931 template <> |
| 932 struct gl_type_enum<GLushort> { |
| 933 enum { kGLType = GL_UNSIGNED_SHORT }; |
| 934 }; |
| 935 template <> |
| 936 struct gl_type_enum<GLfloat> { |
| 937 enum { kGLType = GL_FLOAT }; |
| 938 }; |
| 939 } |
| 940 |
| 941 template <typename TypeParam> |
| 942 void GLES2DecoderTestWithCHROMIUMPathRendering:: |
| 943 TestPathCommandsCHROMIUMCoordTypes() { |
| 944 static const GLsizei kCorrectCoordCount = 19; |
| 945 static const GLsizei kCorrectCommandCount = 6; |
| 946 |
| 947 TypeParam* coords = GetSharedMemoryAs<TypeParam*>(); |
| 948 unsigned commands_offset = sizeof(TypeParam) * kCorrectCoordCount; |
| 949 GLubyte* commands = GetSharedMemoryAsWithOffset<GLubyte*>(commands_offset); |
| 950 for (int i = 0; i < kCorrectCoordCount; ++i) { |
| 951 coords[i] = static_cast<TypeParam>(5 * i); |
| 952 } |
| 953 commands[0] = GL_MOVE_TO_CHROMIUM; |
| 954 commands[1] = GL_CLOSE_PATH_CHROMIUM; |
| 955 commands[2] = GL_LINE_TO_CHROMIUM; |
| 956 commands[3] = GL_QUADRATIC_CURVE_TO_CHROMIUM; |
| 957 commands[4] = GL_CUBIC_CURVE_TO_CHROMIUM; |
| 958 commands[5] = GL_CONIC_CURVE_TO_CHROMIUM; |
| 959 |
| 960 EXPECT_CALL(*gl_, PathCommandsNV(kServicePathId, kCorrectCommandCount, |
| 961 commands, kCorrectCoordCount, |
| 962 gl_type_enum<TypeParam>::kGLType, coords)) |
| 963 .RetiresOnSaturation(); |
| 964 |
| 965 cmds::PathCommandsCHROMIUM cmd; |
| 966 |
| 967 cmd.Init(client_path_id_, kCorrectCommandCount, shared_memory_id_, |
| 968 shared_memory_offset_ + commands_offset, kCorrectCoordCount, |
| 969 gl_type_enum<TypeParam>::kGLType, shared_memory_id_, |
| 970 shared_memory_offset_); |
| 971 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 972 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 973 } |
| 974 |
| 975 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, |
| 976 PathCommandsCHROMIUMCoordTypes) { |
| 977 // Not using a typed test case, because the base class is already parametrized |
| 978 // test case and uses GetParam. |
| 979 TestPathCommandsCHROMIUMCoordTypes<GLbyte>(); |
| 980 TestPathCommandsCHROMIUMCoordTypes<GLubyte>(); |
| 981 TestPathCommandsCHROMIUMCoordTypes<GLshort>(); |
| 982 TestPathCommandsCHROMIUMCoordTypes<GLushort>(); |
| 983 TestPathCommandsCHROMIUMCoordTypes<GLfloat>(); |
| 984 } |
| 985 |
59 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_extensions_autog
en.h" | 986 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_extensions_autog
en.h" |
60 | 987 |
61 } // namespace gles2 | 988 } // namespace gles2 |
62 } // namespace gpu | 989 } // namespace gpu |
63 | 990 |
OLD | NEW |