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