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
3 // found in the LICENSE file.
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
7 #include "base/command_line.h"
8 #include "gpu/command_buffer/common/gles2_cmd_format.h"
9 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
10 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h"
11 #include "gpu/command_buffer/service/gpu_switches.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/gl/gl_mock.h"
15 using ::gfx::MockGLInterface
;
17 using ::testing::Return
;
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
{
27 GLES2DecoderTestDisabledExtensions() {}
29 INSTANTIATE_TEST_CASE_P(Service
,
30 GLES2DecoderTestDisabledExtensions
,
33 TEST_P(GLES2DecoderTestDisabledExtensions
, CHROMIUMPathRenderingDisabled
) {
34 const GLuint kClientPathId
= 0;
36 cmds::MatrixLoadfCHROMIUMImmediate
& cmd
=
37 *GetImmediateAs
<cmds::MatrixLoadfCHROMIUMImmediate
>();
41 cmd
.Init(GL_PATH_MODELVIEW_CHROMIUM
, temp
);
42 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd
, sizeof(temp
)));
43 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
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());
52 cmds::GenPathsCHROMIUM cmd
;
54 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
55 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
58 cmds::DeletePathsCHROMIUM cmd
;
60 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
61 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
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());
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());
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());
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());
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());
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());
100 cmds::StencilStrokePathCHROMIUM cmd
;
101 cmd
.Init(kClientPathId
, 1, 2);
102 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
103 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
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());
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());
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());
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());
131 class GLES2DecoderTestWithCHROMIUMPathRendering
: public GLES2DecoderTest
{
133 GLES2DecoderTestWithCHROMIUMPathRendering() : client_path_id_(125) {}
135 void SetUp() override
{
137 init
.gl_version
= "opengl es 3.1";
138 init
.has_alpha
= true;
139 init
.has_depth
= true;
140 init
.request_alpha
= true;
141 init
.request_depth
= true;
142 init
.bind_generates_resource
= true;
143 init
.extensions
= "GL_NV_path_rendering";
144 base::CommandLine
command_line(0, NULL
);
145 command_line
.AppendSwitch(switches::kEnableGLPathRendering
);
146 InitDecoderWithCommandLine(init
, &command_line
);
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
));
157 template <typename TypeParam
>
158 void TestPathCommandsCHROMIUMCoordTypes();
160 GLuint client_path_id_
;
161 static const GLuint kServicePathId
= 311;
164 INSTANTIATE_TEST_CASE_P(Service
,
165 GLES2DecoderTestWithCHROMIUMPathRendering
,
168 class GLES2DecoderTestWithBlendEquationAdvanced
: public GLES2DecoderTest
{
170 GLES2DecoderTestWithBlendEquationAdvanced() {}
171 void SetUp() override
{
173 init
.gl_version
= "opengl es 2.0";
174 init
.has_alpha
= true;
175 init
.has_depth
= true;
176 init
.request_alpha
= true;
177 init
.request_depth
= true;
178 init
.bind_generates_resource
= true;
179 init
.extensions
= "GL_KHR_blend_equation_advanced";
184 INSTANTIATE_TEST_CASE_P(Service
,
185 GLES2DecoderTestWithBlendEquationAdvanced
,
188 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering
, GenDeletePaths
) {
189 static GLuint kFirstClientID
= client_path_id_
+ 88;
190 static GLsizei kPathCount
= 58;
191 static GLuint kFirstCreatedServiceID
= 8000;
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());
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());
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());
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());
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());
221 // Normal Gen and Delete should cause the normal calls.
222 EXPECT_CALL(*gl_
, GenPathsNV(kPathCount
))
223 .WillOnce(Return(kFirstCreatedServiceID
))
224 .RetiresOnSaturation();
226 gen_cmd
.Init(kFirstClientID
, kPathCount
);
227 EXPECT_EQ(error::kNoError
, ExecuteCmd(gen_cmd
));
228 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
230 EXPECT_CALL(*gl_
, DeletePathsNV(kFirstCreatedServiceID
, kPathCount
))
231 .RetiresOnSaturation();
233 delete_cmd
.Init(kFirstClientID
, kPathCount
);
234 EXPECT_EQ(error::kNoError
, ExecuteCmd(delete_cmd
));
235 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
238 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering
, GenDeleteRanges
) {
239 static GLuint kFirstClientID
= client_path_id_
+ 77;
240 static GLsizei kPathCount
= 5800;
241 static GLuint kFirstCreatedServiceID
= 8000;
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());
253 EXPECT_CALL(*gl_
, DeletePathsNV(kFirstCreatedServiceID
+ (kPathCount
/ 2), 1))
254 .RetiresOnSaturation();
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());
261 EXPECT_CALL(*gl_
, DeletePathsNV(kFirstCreatedServiceID
, (kPathCount
/ 2)))
262 .RetiresOnSaturation();
263 EXPECT_CALL(*gl_
, DeletePathsNV(kFirstCreatedServiceID
+ (kPathCount
/ 2) + 1,
264 (kPathCount
/ 2) - 1)).RetiresOnSaturation();
266 delete_cmd
.Init(kFirstClientID
, kPathCount
);
267 EXPECT_EQ(error::kNoError
, ExecuteCmd(delete_cmd
));
268 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
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;
276 EXPECT_CALL(*gl_
, GenPathsNV(kPathCount
))
277 .WillOnce(Return(kFirstCreatedServiceID
))
278 .RetiresOnSaturation();
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());
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());
291 EXPECT_CALL(*gl_
, DeletePathsNV(kFirstCreatedServiceID
, kPathCount
))
292 .RetiresOnSaturation();
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());
299 // Delete every possible path.
300 // We run into the one created for client_path_id_.
301 EXPECT_CALL(*gl_
, DeletePathsNV(kServicePathId
, 1)).RetiresOnSaturation();
303 delete_cmd
.Init(1u, kPathCount
);
304 EXPECT_EQ(error::kNoError
, ExecuteCmd(delete_cmd
));
305 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
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());
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();
318 gen_cmd
.Init(1u, kPathCount
);
319 EXPECT_EQ(error::kNoError
, ExecuteCmd(gen_cmd
));
320 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
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());
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());
330 EXPECT_CALL(*gl_
, DeletePathsNV(kFirstClientID
, 4)).RetiresOnSaturation();
332 delete_cmd
.Init(kFirstClientID
, 4);
333 EXPECT_EQ(error::kNoError
, ExecuteCmd(delete_cmd
));
334 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
336 EXPECT_CALL(*gl_
, DeletePathsNV(kFirstClientID
* 3, 1)).RetiresOnSaturation();
338 delete_cmd
.Init(kFirstClientID
* 3, 1);
339 EXPECT_EQ(error::kNoError
, ExecuteCmd(delete_cmd
));
340 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
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();
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());
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());
362 EXPECT_CALL(*gl_
, DeletePathsNV(1u, kPathCount
)).RetiresOnSaturation();
363 EXPECT_CALL(*gl_
, DeletePathsNV(static_cast<GLuint
>(kPathCount
) + 1u,
364 kPathCount
)).RetiresOnSaturation();
366 delete_cmd
.Init(1u, kPathCount
);
367 EXPECT_EQ(error::kNoError
, ExecuteCmd(delete_cmd
));
368 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
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());
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();
379 gen_cmd
.Init(client_path_id_
, 1);
380 EXPECT_EQ(error::kNoError
, ExecuteCmd(gen_cmd
));
381 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
384 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering
,
385 GenPathsCHROMIUMInvalidCalls
) {
386 static GLuint kFirstClientID
= client_path_id_
+ 88;
387 static GLsizei kPathCount
= 5800;
388 static GLuint kFirstCreatedServiceID
= 8000;
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());
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());
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());
407 // Creating duplicate client_ids cause connection error.
408 EXPECT_CALL(*gl_
, GenPathsNV(kPathCount
))
409 .WillOnce(Return(kFirstCreatedServiceID
))
410 .RetiresOnSaturation();
412 gen_cmd
.Init(kFirstClientID
, kPathCount
);
413 EXPECT_EQ(error::kNoError
, ExecuteCmd(gen_cmd
));
414 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
416 // Create duplicate by executing the same cmd.
417 EXPECT_EQ(error::kInvalidArguments
, ExecuteCmd(gen_cmd
));
418 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
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());
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());
435 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering
,
436 DeletePathsCHROMIUMInvalidCalls
) {
437 static GLuint kFirstClientID
= client_path_id_
+ 88;
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());
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());
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
;
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
;
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
;
471 EXPECT_CALL(*gl_
, PathCommandsNV(kServicePathId
, kCorrectCommandCount
,
472 commands
, kCorrectCoordCount
, GL_FLOAT
,
473 coords
)).RetiresOnSaturation();
475 cmds::PathCommandsCHROMIUM cmd
;
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());
484 EXPECT_CALL(*gl_
, PathCommandsNV(_
, _
, _
, _
, _
, _
)).Times(0);
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());
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());
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());
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());
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());
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());
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());
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());
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());
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());
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
,
557 EXPECT_EQ(error::kOutOfBounds
, ExecuteCmd(cmd
));
558 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
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());
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());
576 // NULL shm coord ids. Currently causes gl error, though client should not let
578 cmd
.Init(client_path_id_
, kCorrectCommandCount
, shared_memory_id_
,
579 shared_memory_offset_
+ commands_offset
, kCorrectCoordCount
,
581 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
582 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
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());
595 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering
,
596 PathCommandsCHROMIUMInvalidCommands
) {
597 EXPECT_CALL(*gl_
, PathCommandsNV(_
, _
, _
, _
, _
, _
)).Times(0);
599 cmds::PathCommandsCHROMIUM cmd
;
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
);
610 commands
[0] = 0x3; // Token MOVE_TO_RELATIVE in NV_path_rendering.
611 commands
[1] = GL_CLOSE_PATH_CHROMIUM
;
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());
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
);
626 for (int i
= 0; i
< kCoordCount
; ++i
) {
627 coords
[i
] = 5.0f
* i
;
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
;
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());
642 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering
, PathParameterXCHROMIUM
) {
643 static GLuint kFirstClientID
= client_path_id_
+ 88;
644 static GLsizei kPathCount
= 2;
645 static GLuint kFirstCreatedServiceID
= 8000;
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());
656 cmds::PathParameterfCHROMIUM fcmd
;
657 cmds::PathParameteriCHROMIUM icmd
;
661 GLfloat expected_value
;
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
},
676 for (auto& testcase
: kTestcases
) {
677 EXPECT_CALL(*gl_
, PathParameterfNV(kFirstCreatedServiceID
, testcase
.pname
,
678 testcase
.expected_value
))
680 .RetiresOnSaturation();
681 fcmd
.Init(kFirstClientID
, testcase
.pname
, testcase
.value
);
682 EXPECT_EQ(error::kNoError
, ExecuteCmd(fcmd
));
683 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
686 PathParameteriNV(kFirstCreatedServiceID
+ 1, testcase
.pname
,
687 static_cast<GLint
>(testcase
.expected_value
)))
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());
697 EXPECT_CALL(*gl_
, DeletePathsNV(kFirstCreatedServiceID
, kPathCount
))
698 .RetiresOnSaturation();
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());
706 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering
,
707 PathParameterXCHROMIUMInvalidArgs
) {
708 static GLuint kFirstClientID
= client_path_id_
+ 88;
709 static GLsizei kPathCount
= 2;
710 static GLuint kFirstCreatedServiceID
= 8000;
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());
721 cmds::PathParameterfCHROMIUM fcmd
;
722 cmds::PathParameteriCHROMIUM icmd
;
726 bool try_int_version
;
729 {GL_PATH_STROKE_WIDTH_CHROMIUM
, -1.0f
, true, GL_INVALID_VALUE
},
730 {GL_PATH_MITER_LIMIT_CHROMIUM
,
731 std::numeric_limits
<float>::infinity(),
734 {GL_PATH_MITER_LIMIT_CHROMIUM
,
735 std::numeric_limits
<float>::quiet_NaN(),
738 {GL_PATH_END_CAPS_CHROMIUM
, 0x4, true, GL_INVALID_VALUE
},
739 {GL_PATH_END_CAPS_CHROMIUM
,
740 GL_MITER_REVERT_CHROMIUM
,
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
},
747 EXPECT_CALL(*gl_
, PathParameterfNV(_
, _
, _
)).Times(0);
748 EXPECT_CALL(*gl_
, PathParameteriNV(_
, _
, _
)).Times(0);
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
)
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());
764 EXPECT_CALL(*gl_
, DeletePathsNV(kFirstCreatedServiceID
, kPathCount
))
765 .RetiresOnSaturation();
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());
773 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering
, StencilFillPathCHROMIUM
) {
774 SetupExpectationsForApplyingDefaultDirtyState();
776 cmds::StencilFillPathCHROMIUM cmd
;
777 cmds::StencilThenCoverFillPathCHROMIUM tcmd
;
779 static const GLenum kFillModes
[] = {
780 GL_INVERT
, GL_COUNT_UP_CHROMIUM
, GL_COUNT_DOWN_CHROMIUM
};
781 static const GLuint kMask
= 0x7F;
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());
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());
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());
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());
808 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering
,
809 StencilFillPathCHROMIUMInvalidArgs
) {
810 EXPECT_CALL(*gl_
, StencilFillPathNV(_
, _
, _
)).Times(0);
811 EXPECT_CALL(*gl_
, StencilThenCoverFillPathNV(_
, _
, _
, GL_BOUNDING_BOX_NV
))
814 cmds::StencilFillPathCHROMIUM cmd
;
815 cmds::StencilThenCoverFillPathCHROMIUM tcmd
;
817 cmd
.Init(client_path_id_
, GL_INVERT
- 1, 0x80);
818 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
819 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
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());
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());
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());
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());
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());
845 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering
, StencilStrokePathCHROMIUM
) {
846 SetupExpectationsForApplyingDefaultDirtyState();
848 EXPECT_CALL(*gl_
, StencilStrokePathNV(kServicePathId
, 1, 0x80))
849 .RetiresOnSaturation();
850 EXPECT_CALL(*gl_
, StencilThenCoverStrokePathNV(kServicePathId
, 1, 0x80,
852 .RetiresOnSaturation();
854 cmds::StencilStrokePathCHROMIUM cmd
;
855 cmds::StencilThenCoverStrokePathCHROMIUM tcmd
;
857 cmd
.Init(client_path_id_
, 1, 0x80);
858 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
859 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
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());
865 EXPECT_CALL(*gl_
, StencilThenCoverStrokePathNV(kServicePathId
, 1, 0x80,
867 .RetiresOnSaturation();
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());
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());
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());
883 TEST_P(GLES2DecoderTestWithCHROMIUMPathRendering
, CoverFillPathCHROMIUM
) {
884 SetupExpectationsForApplyingDefaultDirtyState();
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());
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());
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());
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());
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());
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());
927 template <typename T
>
928 struct gl_type_enum
{};
930 struct gl_type_enum
<GLbyte
> {
931 enum { kGLType
= GL_BYTE
};
934 struct gl_type_enum
<GLubyte
> {
935 enum { kGLType
= GL_UNSIGNED_BYTE
};
938 struct gl_type_enum
<GLshort
> {
939 enum { kGLType
= GL_SHORT
};
942 struct gl_type_enum
<GLushort
> {
943 enum { kGLType
= GL_UNSIGNED_SHORT
};
946 struct gl_type_enum
<GLfloat
> {
947 enum { kGLType
= GL_FLOAT
};
951 template <typename TypeParam
>
952 void GLES2DecoderTestWithCHROMIUMPathRendering::
953 TestPathCommandsCHROMIUMCoordTypes() {
954 static const GLsizei kCorrectCoordCount
= 19;
955 static const GLsizei kCorrectCommandCount
= 6;
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
);
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
;
970 EXPECT_CALL(*gl_
, PathCommandsNV(kServicePathId
, kCorrectCommandCount
,
971 commands
, kCorrectCoordCount
,
972 gl_type_enum
<TypeParam
>::kGLType
, coords
))
973 .RetiresOnSaturation();
975 cmds::PathCommandsCHROMIUM cmd
;
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());
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
>();
996 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest_extensions_autogen.h"