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

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

Issue 169403005: command_buffer: Implement path rendering functions for CHROMIUM_path_rendering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@nv-pr-02-texgen
Patch Set: make more consistent Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include "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 with non-zero command count.
544 cmd.Init(client_path_id_, kCorrectCommandCount, 0, 0, kCorrectCoordCount,
545 GL_FLOAT, shared_memory_id_, shared_memory_offset_);
546 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
547 EXPECT_EQ(GL_NO_ERROR, GetGLError());
548
549 // NULL shm coord id with non-zero coord count.
550 cmd.Init(client_path_id_, kCorrectCommandCount, shared_memory_id_,
551 shared_memory_offset_ + commands_offset, kCorrectCoordCount,
552 GL_FLOAT, 0, 0);
553 EXPECT_EQ(error::kOutOfBounds, ExecuteCmd(cmd));
554 EXPECT_EQ(GL_NO_ERROR, GetGLError());
555
556 // The coordCount not matching what is in commands.
557 // Expects kCorrectCoordCount+2 coords.
558 commands[1] = GL_MOVE_TO_CHROMIUM;
559 cmd.Init(client_path_id_, kCorrectCommandCount, shared_memory_id_,
560 shared_memory_offset_ + commands_offset, kCorrectCoordCount,
561 GL_FLOAT, shared_memory_id_, shared_memory_offset_);
562 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
563 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
564
565 // The coordCount not matching what is in commands.
566 // Expects kCorrectCoordCount-2 coords.
567 commands[0] = GL_CLOSE_PATH_CHROMIUM;
568 commands[1] = GL_CLOSE_PATH_CHROMIUM;
569 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
570 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
571
572 // NULL shm coord ids. Currently causes gl error, though client should not let
573 // this through.
574 cmd.Init(client_path_id_, kCorrectCommandCount, shared_memory_id_,
575 shared_memory_offset_ + commands_offset, kCorrectCoordCount,
576 GL_FLOAT, 0, 0);
577 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
578 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
579 }
580
581 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering,
582 PathCommandsCHROMIUMEmptyCommands) {
583 EXPECT_CALL(*gl_, PathCommandsNV(kServicePathId, 0, NULL, 0, GL_FLOAT, NULL))
584 .RetiresOnSaturation();
585 cmds::PathCommandsCHROMIUM cmd;
586 cmd.Init(client_path_id_, 0, 0, 0, 0, GL_FLOAT, 0, 0);
587 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
588 EXPECT_EQ(GL_NO_ERROR, GetGLError());
589 }
590
591 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering,
592 PathCommandsCHROMIUMInvalidCommands) {
593 EXPECT_CALL(*gl_, PathCommandsNV(_, _, _, _, _, _)).Times(0);
594
595 cmds::PathCommandsCHROMIUM cmd;
596
597 {
598 const GLsizei kCoordCount = 2;
599 const GLsizei kCommandCount = 2;
600 GLfloat* coords = GetSharedMemoryAs<GLfloat*>();
601 unsigned commands_offset = sizeof(GLfloat) * kCoordCount;
602 GLubyte* commands = GetSharedMemoryAsWithOffset<GLubyte*>(commands_offset);
603
604 coords[0] = 5.0f;
605 coords[1] = 5.0f;
606 commands[0] = 0x3; // Token MOVE_TO_RELATIVE in NV_path_rendering.
607 commands[1] = GL_CLOSE_PATH_CHROMIUM;
608
609 cmd.Init(client_path_id_ - 1, kCommandCount, shared_memory_id_,
610 shared_memory_offset_, kCoordCount, GL_FLOAT, shared_memory_id_,
611 shared_memory_offset_);
612 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
613 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
614 }
615 {
616 const GLsizei kCoordCount = 8;
617 const GLsizei kCommandCount = 4;
618 GLfloat* coords = GetSharedMemoryAs<GLfloat*>();
619 unsigned commands_offset = sizeof(GLfloat) * kCoordCount;
620 GLubyte* commands = GetSharedMemoryAsWithOffset<GLubyte*>(commands_offset);
621
622 for (int i = 0; i < kCoordCount; ++i) {
623 coords[i] = 5.0f * i;
624 }
625 commands[0] = GL_MOVE_TO_CHROMIUM;
626 commands[1] = GL_MOVE_TO_CHROMIUM;
627 commands[2] = 'M'; // Synonym to MOVE_TO in NV_path_rendering.
628 commands[3] = GL_MOVE_TO_CHROMIUM;
629
630 cmd.Init(client_path_id_ - 1, kCommandCount, shared_memory_id_,
631 shared_memory_offset_, kCoordCount, GL_FLOAT, shared_memory_id_,
632 shared_memory_offset_);
633 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
634 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError());
635 }
636 }
637
638 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, PathParameterXCHROMIUM) {
639 static GLuint kFirstClientID = client_path_id_ + 88;
640 static GLsizei kPathCount = 2;
641 static GLuint kFirstCreatedServiceID = 8000;
642
643 // Create a paths so that we do not modify client_path_id_
644 EXPECT_CALL(*gl_, GenPathsNV(kPathCount))
645 .WillOnce(Return(kFirstCreatedServiceID))
646 .RetiresOnSaturation();
647 cmds::GenPathsCHROMIUM gen_cmd;
648 gen_cmd.Init(kFirstClientID, kPathCount);
649 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd));
650 EXPECT_EQ(GL_NO_ERROR, GetGLError());
651
652 cmds::PathParameterfCHROMIUM fcmd;
653 cmds::PathParameteriCHROMIUM icmd;
654 const struct {
655 GLenum pname;
656 GLfloat value;
657 GLfloat expected_value;
658 } kTestcases[] = {
659 {GL_PATH_STROKE_WIDTH_CHROMIUM, 1.0f, 1.0f},
660 {GL_PATH_STROKE_WIDTH_CHROMIUM, 0.0f, 0.0f},
661 {GL_PATH_MITER_LIMIT_CHROMIUM, 500.0f, 500.0f},
662 {GL_PATH_STROKE_BOUND_CHROMIUM, .80f, .80f},
663 {GL_PATH_STROKE_BOUND_CHROMIUM, 1.80f, 1.0f},
664 {GL_PATH_STROKE_BOUND_CHROMIUM, -1.0f, 0.0f},
665 {GL_PATH_END_CAPS_CHROMIUM, GL_FLAT_CHROMIUM, GL_FLAT_CHROMIUM},
666 {GL_PATH_END_CAPS_CHROMIUM, GL_SQUARE_CHROMIUM, GL_SQUARE_CHROMIUM},
667 {GL_PATH_JOIN_STYLE_CHROMIUM,
668 GL_MITER_REVERT_CHROMIUM,
669 GL_MITER_REVERT_CHROMIUM},
670 };
671
672 for (auto& testcase : kTestcases) {
673 EXPECT_CALL(*gl_, PathParameterfNV(kFirstCreatedServiceID, testcase.pname,
674 testcase.expected_value))
675 .Times(1)
676 .RetiresOnSaturation();
677 fcmd.Init(kFirstClientID, testcase.pname, testcase.value);
678 EXPECT_EQ(error::kNoError, ExecuteCmd(fcmd));
679 EXPECT_EQ(GL_NO_ERROR, GetGLError());
680
681 EXPECT_CALL(*gl_,
682 PathParameteriNV(kFirstCreatedServiceID + 1, testcase.pname,
683 static_cast<GLint>(testcase.expected_value)))
684 .Times(1)
685 .RetiresOnSaturation();
686 icmd.Init(kFirstClientID + 1, testcase.pname,
687 static_cast<GLint>(testcase.value));
688 EXPECT_EQ(error::kNoError, ExecuteCmd(icmd));
689 EXPECT_EQ(GL_NO_ERROR, GetGLError());
690 }
691
692 // Cleanup.
693 EXPECT_CALL(*gl_, DeletePathsNV(kFirstCreatedServiceID, kPathCount))
694 .RetiresOnSaturation();
695
696 cmds::DeletePathsCHROMIUM delete_cmd;
697 delete_cmd.Init(kFirstClientID, kPathCount);
698 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd));
699 EXPECT_EQ(GL_NO_ERROR, GetGLError());
700 }
701
702 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering,
703 PathParameterXCHROMIUMInvalidArgs) {
704 static GLuint kFirstClientID = client_path_id_ + 88;
705 static GLsizei kPathCount = 2;
706 static GLuint kFirstCreatedServiceID = 8000;
707
708 // Create a paths so that we do not modify client_path_id_
709 EXPECT_CALL(*gl_, GenPathsNV(kPathCount))
710 .WillOnce(Return(kFirstCreatedServiceID))
711 .RetiresOnSaturation();
712 cmds::GenPathsCHROMIUM gen_cmd;
713 gen_cmd.Init(kFirstClientID, kPathCount);
714 EXPECT_EQ(error::kNoError, ExecuteCmd(gen_cmd));
715 EXPECT_EQ(GL_NO_ERROR, GetGLError());
716
717 cmds::PathParameterfCHROMIUM fcmd;
718 cmds::PathParameteriCHROMIUM icmd;
719 const struct {
720 GLenum pname;
721 GLfloat value;
722 bool try_int_version;
723 GLint error;
724 } kTestcases[] = {
725 {GL_PATH_STROKE_WIDTH_CHROMIUM, -1.0f, true, GL_INVALID_VALUE},
726 {GL_PATH_MITER_LIMIT_CHROMIUM,
727 std::numeric_limits<float>::infinity(),
728 false,
729 GL_INVALID_VALUE},
730 {GL_PATH_MITER_LIMIT_CHROMIUM,
731 std::numeric_limits<float>::quiet_NaN(),
732 false,
733 GL_INVALID_VALUE},
734 {GL_PATH_END_CAPS_CHROMIUM, 0x4, true, GL_INVALID_VALUE},
735 {GL_PATH_END_CAPS_CHROMIUM,
736 GL_MITER_REVERT_CHROMIUM,
737 true,
738 GL_INVALID_VALUE},
739 {GL_PATH_JOIN_STYLE_CHROMIUM, GL_FLAT_CHROMIUM, true, GL_INVALID_VALUE},
740 {GL_PATH_MODELVIEW_CHROMIUM, GL_FLAT_CHROMIUM, true, GL_INVALID_ENUM},
741 };
742
743 EXPECT_CALL(*gl_, PathParameterfNV(_, _, _)).Times(0);
744 EXPECT_CALL(*gl_, PathParameteriNV(_, _, _)).Times(0);
745
746 for (auto& testcase : kTestcases) {
747 fcmd.Init(kFirstClientID, testcase.pname, testcase.value);
748 EXPECT_EQ(error::kNoError, ExecuteCmd(fcmd));
749 EXPECT_EQ(testcase.error, GetGLError());
750 if (!testcase.try_int_version)
751 continue;
752
753 icmd.Init(kFirstClientID + 1, testcase.pname,
754 static_cast<GLint>(testcase.value));
755 EXPECT_EQ(error::kNoError, ExecuteCmd(icmd));
756 EXPECT_EQ(testcase.error, GetGLError());
757 }
758
759 // Cleanup.
760 EXPECT_CALL(*gl_, DeletePathsNV(kFirstCreatedServiceID, kPathCount))
761 .RetiresOnSaturation();
762
763 cmds::DeletePathsCHROMIUM delete_cmd;
764 delete_cmd.Init(kFirstClientID, kPathCount);
765 EXPECT_EQ(error::kNoError, ExecuteCmd(delete_cmd));
766 EXPECT_EQ(GL_NO_ERROR, GetGLError());
767 }
768
769 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, StencilFillPathCHROMIUM) {
770 SetupExpectationsForApplyingDefaultDirtyState();
771
772 cmds::StencilFillPathCHROMIUM cmd;
773 cmds::StencilThenCoverFillPathCHROMIUM tcmd;
774
775 static const GLenum kFillModes[] = {
776 GL_INVERT, GL_COUNT_UP_CHROMIUM, GL_COUNT_DOWN_CHROMIUM};
777 static const GLuint kMask = 0x7F;
778
779 for (auto& fill_mode : kFillModes) {
780 EXPECT_CALL(*gl_, StencilFillPathNV(kServicePathId, fill_mode, kMask))
781 .RetiresOnSaturation();
782 cmd.Init(client_path_id_, fill_mode, kMask);
783 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
784 EXPECT_EQ(GL_NO_ERROR, GetGLError());
785
786 EXPECT_CALL(*gl_, StencilThenCoverFillPathNV(kServicePathId, fill_mode,
787 kMask, GL_BOUNDING_BOX_NV))
788 .RetiresOnSaturation();
789 tcmd.Init(client_path_id_, fill_mode, kMask, GL_BOUNDING_BOX_CHROMIUM);
790 EXPECT_EQ(error::kNoError, ExecuteCmd(tcmd));
791 EXPECT_EQ(GL_NO_ERROR, GetGLError());
792 }
793
794 // Non-existent path: no error, no call.
795 cmd.Init(client_path_id_ - 1, GL_INVERT, 0x80);
796 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
797 EXPECT_EQ(GL_NO_ERROR, GetGLError());
798
799 tcmd.Init(client_path_id_ - 1, GL_INVERT, 0x80, GL_BOUNDING_BOX_CHROMIUM);
800 EXPECT_EQ(error::kNoError, ExecuteCmd(tcmd));
801 EXPECT_EQ(GL_NO_ERROR, GetGLError());
802 }
803
804 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering,
805 StencilFillPathCHROMIUMInvalidArgs) {
806 EXPECT_CALL(*gl_, StencilFillPathNV(_, _, _)).Times(0);
807 EXPECT_CALL(*gl_, StencilThenCoverFillPathNV(_, _, _, GL_BOUNDING_BOX_NV))
808 .Times(0);
809
810 cmds::StencilFillPathCHROMIUM cmd;
811 cmds::StencilThenCoverFillPathCHROMIUM tcmd;
812
813 cmd.Init(client_path_id_, GL_INVERT - 1, 0x80);
814 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
815 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
816
817 tcmd.Init(client_path_id_, GL_INVERT - 1, 0x80, GL_BOUNDING_BOX_CHROMIUM);
818 EXPECT_EQ(error::kNoError, ExecuteCmd(tcmd));
819 EXPECT_EQ(GL_INVALID_ENUM, GetGLError());
820
821 // The /mask/+1 is not power of two -> invalid value.
822 cmd.Init(client_path_id_, GL_COUNT_UP_CHROMIUM, 0x80);
823 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
824 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
825
826 tcmd.Init(client_path_id_, GL_COUNT_UP_CHROMIUM, 0x80,
827 GL_BOUNDING_BOX_CHROMIUM);
828 EXPECT_EQ(error::kNoError, ExecuteCmd(tcmd));
829 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
830
831 cmd.Init(client_path_id_, GL_COUNT_DOWN_CHROMIUM, 5);
832 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
833 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
834
835 tcmd.Init(client_path_id_, GL_COUNT_DOWN_CHROMIUM, 5,
836 GL_BOUNDING_BOX_CHROMIUM);
837 EXPECT_EQ(error::kNoError, ExecuteCmd(tcmd));
838 EXPECT_EQ(GL_INVALID_VALUE, GetGLError());
839 }
840
841 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, StencilStrokePathCHROMIUM) {
842 SetupExpectationsForApplyingDefaultDirtyState();
843
844 EXPECT_CALL(*gl_, StencilStrokePathNV(kServicePathId, 1, 0x80))
845 .RetiresOnSaturation();
846 EXPECT_CALL(*gl_, StencilThenCoverStrokePathNV(kServicePathId, 1, 0x80,
847 GL_BOUNDING_BOX_NV))
848 .RetiresOnSaturation();
849
850 cmds::StencilStrokePathCHROMIUM cmd;
851 cmds::StencilThenCoverStrokePathCHROMIUM tcmd;
852
853 cmd.Init(client_path_id_, 1, 0x80);
854 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
855 EXPECT_EQ(GL_NO_ERROR, GetGLError());
856
857 tcmd.Init(client_path_id_, 1, 0x80, GL_BOUNDING_BOX_CHROMIUM);
858 EXPECT_EQ(error::kNoError, ExecuteCmd(tcmd));
859 EXPECT_EQ(GL_NO_ERROR, GetGLError());
860
861 EXPECT_CALL(*gl_, StencilThenCoverStrokePathNV(kServicePathId, 1, 0x80,
862 GL_CONVEX_HULL_NV))
863 .RetiresOnSaturation();
864
865 tcmd.Init(client_path_id_, 1, 0x80, GL_CONVEX_HULL_CHROMIUM);
866 EXPECT_EQ(error::kNoError, ExecuteCmd(tcmd));
867 EXPECT_EQ(GL_NO_ERROR, GetGLError());
868
869 // Non-existent path: no error, no call.
870 cmd.Init(client_path_id_ - 1, 1, 0x80);
871 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
872 EXPECT_EQ(GL_NO_ERROR, GetGLError());
873
874 tcmd.Init(client_path_id_ - 1, 1, 0x80, GL_BOUNDING_BOX_CHROMIUM);
875 EXPECT_EQ(error::kNoError, ExecuteCmd(tcmd));
876 EXPECT_EQ(GL_NO_ERROR, GetGLError());
877 }
878
879 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, CoverFillPathCHROMIUM) {
880 SetupExpectationsForApplyingDefaultDirtyState();
881
882 EXPECT_CALL(*gl_, CoverFillPathNV(kServicePathId, GL_BOUNDING_BOX_NV))
883 .RetiresOnSaturation();
884 cmds::CoverFillPathCHROMIUM cmd;
885 cmd.Init(client_path_id_, GL_BOUNDING_BOX_CHROMIUM);
886 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
887 EXPECT_EQ(GL_NO_ERROR, GetGLError());
888
889 EXPECT_CALL(*gl_, CoverFillPathNV(kServicePathId, GL_CONVEX_HULL_NV))
890 .RetiresOnSaturation();
891 cmd.Init(client_path_id_, GL_CONVEX_HULL_CHROMIUM);
892 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
893 EXPECT_EQ(GL_NO_ERROR, GetGLError());
894
895 // Non-existent path: no error, no call.
896 cmd.Init(client_path_id_ - 1, GL_BOUNDING_BOX_CHROMIUM);
897 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
898 EXPECT_EQ(GL_NO_ERROR, GetGLError());
899 }
900
901 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering, CoverStrokePathCHROMIUM) {
902 SetupExpectationsForApplyingDefaultDirtyState();
903 EXPECT_CALL(*gl_, CoverStrokePathNV(kServicePathId, GL_BOUNDING_BOX_NV))
904 .RetiresOnSaturation();
905 cmds::CoverStrokePathCHROMIUM cmd;
906 cmd.Init(client_path_id_, GL_BOUNDING_BOX_CHROMIUM);
907 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
908 EXPECT_EQ(GL_NO_ERROR, GetGLError());
909
910 EXPECT_CALL(*gl_, CoverStrokePathNV(kServicePathId, GL_CONVEX_HULL_NV))
911 .RetiresOnSaturation();
912 cmd.Init(client_path_id_, GL_CONVEX_HULL_CHROMIUM);
913 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
914 EXPECT_EQ(GL_NO_ERROR, GetGLError());
915
916 // Non-existent path: no error, no call.
917 cmd.Init(client_path_id_ - 1, GL_BOUNDING_BOX_CHROMIUM);
918 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
919 EXPECT_EQ(GL_NO_ERROR, GetGLError());
920 }
921
922 namespace {
923 template <typename T>
924 struct gl_type_enum {};
925 template <>
926 struct gl_type_enum<GLbyte> {
927 enum { kGLType = GL_BYTE };
928 };
929 template <>
930 struct gl_type_enum<GLubyte> {
931 enum { kGLType = GL_UNSIGNED_BYTE };
932 };
933 template <>
934 struct gl_type_enum<GLshort> {
935 enum { kGLType = GL_SHORT };
936 };
937 template <>
938 struct gl_type_enum<GLushort> {
939 enum { kGLType = GL_UNSIGNED_SHORT };
940 };
941 template <>
942 struct gl_type_enum<GLfloat> {
943 enum { kGLType = GL_FLOAT };
944 };
945 }
946
947 template <typename TypeParam>
948 void GLES2DecoderTestWithCHROMIUMPathRendering::
949 TestPathCommandsCHROMIUMCoordTypes() {
950 static const GLsizei kCorrectCoordCount = 19;
951 static const GLsizei kCorrectCommandCount = 6;
952
953 TypeParam* coords = GetSharedMemoryAs<TypeParam*>();
954 unsigned commands_offset = sizeof(TypeParam) * kCorrectCoordCount;
955 GLubyte* commands = GetSharedMemoryAsWithOffset<GLubyte*>(commands_offset);
956 for (int i = 0; i < kCorrectCoordCount; ++i) {
957 coords[i] = static_cast<TypeParam>(5 * i);
958 }
959 commands[0] = GL_MOVE_TO_CHROMIUM;
960 commands[1] = GL_CLOSE_PATH_CHROMIUM;
961 commands[2] = GL_LINE_TO_CHROMIUM;
962 commands[3] = GL_QUADRATIC_CURVE_TO_CHROMIUM;
963 commands[4] = GL_CUBIC_CURVE_TO_CHROMIUM;
964 commands[5] = GL_CONIC_CURVE_TO_CHROMIUM;
965
966 EXPECT_CALL(*gl_, PathCommandsNV(kServicePathId, kCorrectCommandCount,
967 commands, kCorrectCoordCount,
968 gl_type_enum<TypeParam>::kGLType, coords))
969 .RetiresOnSaturation();
970
971 cmds::PathCommandsCHROMIUM cmd;
972
973 cmd.Init(client_path_id_, kCorrectCommandCount, shared_memory_id_,
974 shared_memory_offset_ + commands_offset, kCorrectCoordCount,
975 gl_type_enum<TypeParam>::kGLType, shared_memory_id_,
976 shared_memory_offset_);
977 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
978 EXPECT_EQ(GL_NO_ERROR, GetGLError());
979 }
980
981 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering,
982 PathCommandsCHROMIUMCoordTypes) {
983 // Not using a typed test case, because the base class is already parametrized
984 // test case and uses GetParam.
985 TestPathCommandsCHROMIUMCoordTypes<GLbyte>();
986 TestPathCommandsCHROMIUMCoordTypes<GLubyte>();
987 TestPathCommandsCHROMIUMCoordTypes<GLshort>();
988 TestPathCommandsCHROMIUMCoordTypes<GLushort>();
989 TestPathCommandsCHROMIUMCoordTypes<GLfloat>();
990 }
991
59 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_extensions_autog en.h" 992 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_extensions_autog en.h"
60 993
61 } // namespace gles2 994 } // namespace gles2
62 } // namespace gpu 995 } // namespace gpu
63 996
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698