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 "base/strings/string_number_conversions.h"
9 #include "gpu/command_buffer/common/gles2_cmd_format.h"
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
11 #include "gpu/command_buffer/common/id_allocator.h"
12 #include "gpu/command_buffer/service/async_pixel_transfer_delegate_mock.h"
13 #include "gpu/command_buffer/service/async_pixel_transfer_manager.h"
14 #include "gpu/command_buffer/service/async_pixel_transfer_manager_mock.h"
15 #include "gpu/command_buffer/service/cmd_buffer_engine.h"
16 #include "gpu/command_buffer/service/context_group.h"
17 #include "gpu/command_buffer/service/context_state.h"
18 #include "gpu/command_buffer/service/gl_surface_mock.h"
19 #include "gpu/command_buffer/service/gles2_cmd_decoder_unittest.h"
21 #include "gpu/command_buffer/service/gpu_switches.h"
22 #include "gpu/command_buffer/service/image_manager.h"
23 #include "gpu/command_buffer/service/mailbox_manager.h"
24 #include "gpu/command_buffer/service/mocks.h"
25 #include "gpu/command_buffer/service/program_manager.h"
26 #include "gpu/command_buffer/service/test_helper.h"
27 #include "testing/gtest/include/gtest/gtest.h"
28 #include "ui/gl/gl_image_stub.h"
29 #include "ui/gl/gl_implementation.h"
30 #include "ui/gl/gl_mock.h"
31 #include "ui/gl/gl_surface_stub.h"
33 #if !defined(GL_DEPTH24_STENCIL8)
34 #define GL_DEPTH24_STENCIL8 0x88F0
37 using ::gfx::MockGLInterface
;
39 using ::testing::DoAll
;
40 using ::testing::InSequence
;
41 using ::testing::Invoke
;
42 using ::testing::MatcherCast
;
43 using ::testing::Mock
;
44 using ::testing::Pointee
;
45 using ::testing::Return
;
46 using ::testing::SaveArg
;
47 using ::testing::SetArrayArgument
;
48 using ::testing::SetArgumentPointee
;
49 using ::testing::SetArgPointee
;
50 using ::testing::StrEq
;
51 using ::testing::StrictMock
;
58 TEST_P(GLES2DecoderTest
, GenerateMipmapWrongFormatsFails
) {
59 EXPECT_CALL(*gl_
, GenerateMipmapEXT(_
)).Times(0);
60 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
62 GL_TEXTURE_2D
, 0, GL_RGBA
, 16, 17, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
64 cmd
.Init(GL_TEXTURE_2D
);
65 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
66 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
69 TEST_P(GLES2DecoderTest
, GenerateMipmapHandlesOutOfMemory
) {
70 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
71 TextureManager
* manager
= group().texture_manager();
72 TextureRef
* texture_ref
= manager
->GetTexture(client_texture_id_
);
73 ASSERT_TRUE(texture_ref
!= NULL
);
74 Texture
* texture
= texture_ref
->texture();
77 EXPECT_FALSE(texture
->GetLevelSize(GL_TEXTURE_2D
, 2, &width
, &height
));
78 DoTexImage2D(GL_TEXTURE_2D
,
88 EXPECT_CALL(*gl_
, GenerateMipmapEXT(GL_TEXTURE_2D
)).Times(1);
89 EXPECT_CALL(*gl_
, GetError())
90 .WillOnce(Return(GL_NO_ERROR
))
91 .WillOnce(Return(GL_OUT_OF_MEMORY
))
92 .RetiresOnSaturation();
94 cmd
.Init(GL_TEXTURE_2D
);
95 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
96 EXPECT_EQ(GL_OUT_OF_MEMORY
, GetGLError());
97 EXPECT_FALSE(texture
->GetLevelSize(GL_TEXTURE_2D
, 2, &width
, &height
));
100 TEST_P(GLES2DecoderTest
, GenerateMipmapClearsUnclearedTexture
) {
101 EXPECT_CALL(*gl_
, GenerateMipmapEXT(_
)).Times(0);
102 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
104 GL_TEXTURE_2D
, 0, GL_RGBA
, 2, 2, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
105 SetupClearTextureExpectations(kServiceTextureId
,
115 EXPECT_CALL(*gl_
, GenerateMipmapEXT(GL_TEXTURE_2D
));
116 EXPECT_CALL(*gl_
, GetError())
117 .WillOnce(Return(GL_NO_ERROR
))
118 .WillOnce(Return(GL_NO_ERROR
))
119 .RetiresOnSaturation();
121 cmd
.Init(GL_TEXTURE_2D
);
122 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
123 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
126 // Same as GenerateMipmapClearsUnclearedTexture, but with workaround
127 // |set_texture_filters_before_generating_mipmap|.
128 TEST_P(GLES2DecoderManualInitTest
, SetTextureFiltersBeforeGenerateMipmap
) {
129 base::CommandLine
command_line(0, NULL
);
130 command_line
.AppendSwitchASCII(
131 switches::kGpuDriverBugWorkarounds
,
132 base::IntToString(gpu::SET_TEXTURE_FILTER_BEFORE_GENERATING_MIPMAP
));
134 init
.bind_generates_resource
= true;
135 InitDecoderWithCommandLine(init
, &command_line
);
137 EXPECT_CALL(*gl_
, GenerateMipmapEXT(_
)).Times(0);
138 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
140 GL_TEXTURE_2D
, 0, GL_RGBA
, 2, 2, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
141 SetupClearTextureExpectations(kServiceTextureId
,
154 GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST_MIPMAP_NEAREST
))
156 .RetiresOnSaturation();
157 EXPECT_CALL(*gl_
, GenerateMipmapEXT(GL_TEXTURE_2D
));
161 GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST_MIPMAP_LINEAR
))
163 .RetiresOnSaturation();
164 EXPECT_CALL(*gl_
, GetError())
165 .WillOnce(Return(GL_NO_ERROR
))
166 .WillOnce(Return(GL_NO_ERROR
))
167 .RetiresOnSaturation();
169 cmd
.Init(GL_TEXTURE_2D
);
170 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
171 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
174 TEST_P(GLES2DecoderTest
, ActiveTextureValidArgs
) {
175 EXPECT_CALL(*gl_
, ActiveTexture(GL_TEXTURE1
));
176 SpecializedSetup
<ActiveTexture
, 0>(true);
178 cmd
.Init(GL_TEXTURE1
);
179 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
180 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
183 TEST_P(GLES2DecoderTest
, ActiveTextureInvalidArgs
) {
184 EXPECT_CALL(*gl_
, ActiveTexture(_
)).Times(0);
185 SpecializedSetup
<ActiveTexture
, 0>(false);
187 cmd
.Init(GL_TEXTURE0
- 1);
188 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
189 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
190 cmd
.Init(kNumTextureUnits
);
191 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
192 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
195 TEST_P(GLES2DecoderTest
, TexSubImage2DValidArgs
) {
196 const int kWidth
= 16;
197 const int kHeight
= 8;
198 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
199 DoTexImage2D(GL_TEXTURE_2D
,
208 kSharedMemoryOffset
);
210 TexSubImage2D(GL_TEXTURE_2D
,
218 shared_memory_address_
))
220 .RetiresOnSaturation();
222 cmd
.Init(GL_TEXTURE_2D
,
233 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
234 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
237 TEST_P(GLES2DecoderTest
, TexSubImage2DBadArgs
) {
238 const int kWidth
= 16;
239 const int kHeight
= 8;
240 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
241 DoTexImage2D(GL_TEXTURE_2D
,
252 cmd
.Init(GL_TEXTURE0
,
263 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
264 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
265 cmd
.Init(GL_TEXTURE_2D
,
276 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
277 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
278 cmd
.Init(GL_TEXTURE_2D
,
289 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
290 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
291 cmd
.Init(GL_TEXTURE_2D
,
302 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
303 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
304 cmd
.Init(GL_TEXTURE_2D
,
315 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
316 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
317 cmd
.Init(GL_TEXTURE_2D
,
328 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
329 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
330 cmd
.Init(GL_TEXTURE_2D
,
341 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
342 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
343 cmd
.Init(GL_TEXTURE_2D
,
354 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
355 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
356 cmd
.Init(GL_TEXTURE_2D
,
367 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
368 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
369 cmd
.Init(GL_TEXTURE_2D
,
380 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
381 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
382 cmd
.Init(GL_TEXTURE_2D
,
389 GL_UNSIGNED_SHORT_4_4_4_4
,
393 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
394 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
395 cmd
.Init(GL_TEXTURE_2D
,
403 kInvalidSharedMemoryId
,
406 EXPECT_NE(error::kNoError
, ExecuteCmd(cmd
));
407 cmd
.Init(GL_TEXTURE_2D
,
416 kInvalidSharedMemoryOffset
,
418 EXPECT_NE(error::kNoError
, ExecuteCmd(cmd
));
421 TEST_P(GLES2DecoderTest
, CopyTexSubImage2DValidArgs
) {
422 const int kWidth
= 16;
423 const int kHeight
= 8;
424 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
425 DoTexImage2D(GL_TEXTURE_2D
,
434 kSharedMemoryOffset
);
436 CopyTexSubImage2D(GL_TEXTURE_2D
, 1, 0, 0, 0, 0, kWidth
, kHeight
))
438 .RetiresOnSaturation();
439 CopyTexSubImage2D cmd
;
440 cmd
.Init(GL_TEXTURE_2D
, 1, 0, 0, 0, 0, kWidth
, kHeight
);
441 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
442 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
445 TEST_P(GLES2DecoderTest
, CopyTexSubImage2DBadArgs
) {
446 const int kWidth
= 16;
447 const int kHeight
= 8;
448 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
449 DoTexImage2D(GL_TEXTURE_2D
,
459 CopyTexSubImage2D cmd
;
460 cmd
.Init(GL_TEXTURE0
, 1, 0, 0, 0, 0, kWidth
, kHeight
);
461 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
462 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
463 cmd
.Init(GL_TEXTURE_2D
, 1, -1, 0, 0, 0, kWidth
, kHeight
);
464 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
465 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
466 cmd
.Init(GL_TEXTURE_2D
, 1, 1, 0, 0, 0, kWidth
, kHeight
);
467 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
468 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
469 cmd
.Init(GL_TEXTURE_2D
, 1, 0, -1, 0, 0, kWidth
, kHeight
);
470 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
471 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
472 cmd
.Init(GL_TEXTURE_2D
, 1, 0, 1, 0, 0, kWidth
, kHeight
);
473 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
474 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
475 cmd
.Init(GL_TEXTURE_2D
, 1, 0, 0, 0, 0, kWidth
+ 1, kHeight
);
476 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
477 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
478 cmd
.Init(GL_TEXTURE_2D
, 1, 0, 0, 0, 0, kWidth
, kHeight
+ 1);
479 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
480 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
483 TEST_P(GLES2DecoderTest
, TexImage2DRedefinitionSucceeds
) {
484 const int kWidth
= 16;
485 const int kHeight
= 8;
486 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
487 EXPECT_CALL(*gl_
, GetError()).WillRepeatedly(Return(GL_NO_ERROR
));
488 for (int ii
= 0; ii
< 2; ++ii
) {
492 TexImage2D(GL_TEXTURE_2D
,
502 .RetiresOnSaturation();
503 cmd
.Init(GL_TEXTURE_2D
,
511 kSharedMemoryOffset
);
513 SetupClearTextureExpectations(kServiceTextureId
,
523 cmd
.Init(GL_TEXTURE_2D
,
533 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
535 TexSubImage2D(GL_TEXTURE_2D
,
543 shared_memory_address_
))
545 .RetiresOnSaturation();
546 // Consider this TexSubImage2D command part of the previous TexImage2D
547 // (last GL_TRUE argument). It will be skipped if there are bugs in the
548 // redefinition case.
550 cmd2
.Init(GL_TEXTURE_2D
,
561 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
565 TEST_P(GLES2DecoderTest
, TexImage2DGLError
) {
566 GLenum target
= GL_TEXTURE_2D
;
568 GLenum internal_format
= GL_RGBA
;
572 GLenum format
= GL_RGBA
;
573 GLenum type
= GL_UNSIGNED_BYTE
;
574 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
575 TextureManager
* manager
= group().texture_manager();
576 TextureRef
* texture_ref
= manager
->GetTexture(client_texture_id_
);
577 ASSERT_TRUE(texture_ref
!= NULL
);
578 Texture
* texture
= texture_ref
->texture();
579 EXPECT_FALSE(texture
->GetLevelSize(GL_TEXTURE_2D
, level
, &width
, &height
));
580 EXPECT_CALL(*gl_
, GetError())
581 .WillOnce(Return(GL_NO_ERROR
))
582 .WillOnce(Return(GL_OUT_OF_MEMORY
))
583 .RetiresOnSaturation();
595 .RetiresOnSaturation();
605 kSharedMemoryOffset
);
606 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
607 EXPECT_EQ(GL_OUT_OF_MEMORY
, GetGLError());
608 EXPECT_FALSE(texture
->GetLevelSize(GL_TEXTURE_2D
, level
, &width
, &height
));
611 TEST_P(GLES2DecoderTest
, CopyTexImage2DGLError
) {
612 GLenum target
= GL_TEXTURE_2D
;
614 GLenum internal_format
= GL_RGBA
;
618 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
619 TextureManager
* manager
= group().texture_manager();
620 TextureRef
* texture_ref
= manager
->GetTexture(client_texture_id_
);
621 ASSERT_TRUE(texture_ref
!= NULL
);
622 Texture
* texture
= texture_ref
->texture();
623 EXPECT_FALSE(texture
->GetLevelSize(GL_TEXTURE_2D
, level
, &width
, &height
));
624 EXPECT_CALL(*gl_
, GetError())
625 .WillOnce(Return(GL_NO_ERROR
))
626 .WillOnce(Return(GL_OUT_OF_MEMORY
))
627 .RetiresOnSaturation();
630 target
, level
, internal_format
, 0, 0, width
, height
, border
))
632 .RetiresOnSaturation();
634 cmd
.Init(target
, level
, internal_format
, 0, 0, width
, height
);
635 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
636 EXPECT_EQ(GL_OUT_OF_MEMORY
, GetGLError());
637 EXPECT_FALSE(texture
->GetLevelSize(GL_TEXTURE_2D
, level
, &width
, &height
));
640 TEST_P(GLES2DecoderManualInitTest
, CompressedTexImage2DBucketBadBucket
) {
642 init
.extensions
= "GL_EXT_texture_compression_s3tc";
643 init
.bind_generates_resource
= true;
646 const uint32 kBadBucketId
= 123;
647 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
648 CompressedTexImage2DBucket cmd
;
649 cmd
.Init(GL_TEXTURE_2D
,
651 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
,
655 EXPECT_NE(error::kNoError
, ExecuteCmd(cmd
));
656 CompressedTexSubImage2DBucket cmd2
;
657 cmd2
.Init(GL_TEXTURE_2D
,
663 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
,
665 EXPECT_NE(error::kNoError
, ExecuteCmd(cmd
));
670 struct S3TCTestData
{
675 } // anonymous namespace.
677 TEST_P(GLES2DecoderManualInitTest
, CompressedTexImage2DS3TC
) {
679 init
.extensions
= "GL_EXT_texture_compression_s3tc";
680 init
.bind_generates_resource
= true;
682 const uint32 kBucketId
= 123;
683 CommonDecoder::Bucket
* bucket
= decoder_
->CreateBucket(kBucketId
);
684 ASSERT_TRUE(bucket
!= NULL
);
686 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
688 static const S3TCTestData test_data
[] = {
690 GL_COMPRESSED_RGB_S3TC_DXT1_EXT
, 8,
693 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
, 8,
696 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
, 16,
699 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
, 16,
703 for (size_t ii
= 0; ii
< arraysize(test_data
); ++ii
) {
704 const S3TCTestData
& test
= test_data
[ii
];
705 CompressedTexImage2DBucket cmd
;
707 DoCompressedTexImage2D(
708 GL_TEXTURE_2D
, 0, test
.format
, 2, 4, 0, test
.block_size
, kBucketId
);
709 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
712 cmd
.Init(GL_TEXTURE_2D
, 0, test
.format
, 5, 4, kBucketId
);
713 bucket
->SetSize(test
.block_size
* 2);
714 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
715 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
717 // test small height.
718 DoCompressedTexImage2D(
719 GL_TEXTURE_2D
, 0, test
.format
, 4, 2, 0, test
.block_size
, kBucketId
);
720 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
722 // test too bad height.
723 cmd
.Init(GL_TEXTURE_2D
, 0, test
.format
, 4, 5, kBucketId
);
724 bucket
->SetSize(test
.block_size
* 2);
725 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
726 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
728 // test small for level 0.
729 DoCompressedTexImage2D(
730 GL_TEXTURE_2D
, 0, test
.format
, 1, 1, 0, test
.block_size
, kBucketId
);
731 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
733 // test small for level 0.
734 DoCompressedTexImage2D(
735 GL_TEXTURE_2D
, 0, test
.format
, 2, 2, 0, test
.block_size
, kBucketId
);
736 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
738 // test size too large.
739 cmd
.Init(GL_TEXTURE_2D
, 0, test
.format
, 4, 4, kBucketId
);
740 bucket
->SetSize(test
.block_size
* 2);
741 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
742 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
744 // test size too small.
745 cmd
.Init(GL_TEXTURE_2D
, 0, test
.format
, 4, 4, kBucketId
);
746 bucket
->SetSize(test
.block_size
/ 2);
747 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
748 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
751 DoCompressedTexImage2D(
752 GL_TEXTURE_2D
, 0, test
.format
, 4, 4, 0, test
.block_size
, kBucketId
);
753 DoCompressedTexImage2D(
754 GL_TEXTURE_2D
, 1, test
.format
, 2, 2, 0, test
.block_size
, kBucketId
);
755 DoCompressedTexImage2D(
756 GL_TEXTURE_2D
, 2, test
.format
, 1, 1, 0, test
.block_size
, kBucketId
);
757 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
760 DoCompressedTexImage2D(GL_TEXTURE_2D
,
766 test
.block_size
* 4 * 4,
768 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
770 CompressedTexSubImage2DBucket sub_cmd
;
771 bucket
->SetSize(test
.block_size
);
772 // Test sub image bad xoffset
773 sub_cmd
.Init(GL_TEXTURE_2D
, 0, 1, 0, 4, 4, test
.format
, kBucketId
);
774 EXPECT_EQ(error::kNoError
, ExecuteCmd(sub_cmd
));
775 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
777 // Test sub image bad yoffset
778 sub_cmd
.Init(GL_TEXTURE_2D
, 0, 0, 2, 4, 4, test
.format
, kBucketId
);
779 EXPECT_EQ(error::kNoError
, ExecuteCmd(sub_cmd
));
780 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
782 // Test sub image bad width
783 bucket
->SetSize(test
.block_size
* 2);
784 sub_cmd
.Init(GL_TEXTURE_2D
, 0, 0, 0, 5, 4, test
.format
, kBucketId
);
785 EXPECT_EQ(error::kNoError
, ExecuteCmd(sub_cmd
));
786 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
788 // Test sub image bad height
789 sub_cmd
.Init(GL_TEXTURE_2D
, 0, 0, 0, 4, 5, test
.format
, kBucketId
);
790 EXPECT_EQ(error::kNoError
, ExecuteCmd(sub_cmd
));
791 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
793 // Test sub image bad size
794 bucket
->SetSize(test
.block_size
+ 1);
795 sub_cmd
.Init(GL_TEXTURE_2D
, 0, 0, 0, 4, 4, test
.format
, kBucketId
);
796 EXPECT_EQ(error::kNoError
, ExecuteCmd(sub_cmd
));
797 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
799 for (GLint yoffset
= 0; yoffset
<= 8; yoffset
+= 4) {
800 for (GLint xoffset
= 0; xoffset
<= 8; xoffset
+= 4) {
801 for (GLsizei height
= 4; height
<= 8; height
+= 4) {
802 for (GLsizei width
= 4; width
<= 8; width
+= 4) {
803 GLsizei size
= test
.block_size
* (width
/ 4) * (height
/ 4);
804 bucket
->SetSize(size
);
806 CompressedTexSubImage2D(GL_TEXTURE_2D
,
816 .RetiresOnSaturation();
817 sub_cmd
.Init(GL_TEXTURE_2D
,
825 EXPECT_EQ(error::kNoError
, ExecuteCmd(sub_cmd
));
826 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
834 TEST_P(GLES2DecoderManualInitTest
, CompressedTexImage2DETC1
) {
836 init
.extensions
= "GL_OES_compressed_ETC1_RGB8_texture";
837 init
.gl_version
= "opengl es 2.0";
838 init
.bind_generates_resource
= true;
840 const uint32 kBucketId
= 123;
841 CommonDecoder::Bucket
* bucket
= decoder_
->CreateBucket(kBucketId
);
842 ASSERT_TRUE(bucket
!= NULL
);
844 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
846 const GLenum kFormat
= GL_ETC1_RGB8_OES
;
847 const size_t kBlockSize
= 8;
849 CompressedTexImage2DBucket cmd
;
851 DoCompressedTexImage2D(GL_TEXTURE_2D
, 0, kFormat
, 4, 8, 0, 16, kBucketId
);
852 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
854 // test small height.
855 DoCompressedTexImage2D(GL_TEXTURE_2D
, 0, kFormat
, 8, 4, 0, 16, kBucketId
);
856 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
858 // test size too large.
859 cmd
.Init(GL_TEXTURE_2D
, 0, kFormat
, 4, 4, kBucketId
);
860 bucket
->SetSize(kBlockSize
* 2);
861 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
862 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
864 // test size too small.
865 cmd
.Init(GL_TEXTURE_2D
, 0, kFormat
, 4, 4, kBucketId
);
866 bucket
->SetSize(kBlockSize
/ 2);
867 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
868 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
871 DoCompressedTexImage2D(
872 GL_TEXTURE_2D
, 0, kFormat
, 16, 16, 0, kBlockSize
* 16, kBucketId
);
873 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
875 // Test CompressedTexSubImage not allowed
876 CompressedTexSubImage2DBucket sub_cmd
;
877 bucket
->SetSize(kBlockSize
);
878 sub_cmd
.Init(GL_TEXTURE_2D
, 0, 0, 0, 4, 4, kFormat
, kBucketId
);
879 EXPECT_EQ(error::kNoError
, ExecuteCmd(sub_cmd
));
880 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
882 // Test TexSubImage not allowed for ETC1 compressed texture
883 TextureRef
* texture_ref
= GetTexture(client_texture_id_
);
884 ASSERT_TRUE(texture_ref
!= NULL
);
885 Texture
* texture
= texture_ref
->texture();
886 GLenum type
, internal_format
;
887 EXPECT_TRUE(texture
->GetLevelType(GL_TEXTURE_2D
, 0, &type
, &internal_format
));
888 EXPECT_EQ(kFormat
, internal_format
);
889 TexSubImage2D texsub_cmd
;
890 texsub_cmd
.Init(GL_TEXTURE_2D
,
901 EXPECT_EQ(error::kNoError
, ExecuteCmd(texsub_cmd
));
902 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
904 // Test CopyTexSubImage not allowed for ETC1 compressed texture
905 CopyTexSubImage2D copy_cmd
;
906 copy_cmd
.Init(GL_TEXTURE_2D
, 0, 0, 0, 0, 0, 4, 4);
907 EXPECT_EQ(error::kNoError
, ExecuteCmd(copy_cmd
));
908 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
911 TEST_P(GLES2DecoderManualInitTest
, EGLImageExternalBindTexture
) {
913 init
.extensions
= "GL_OES_EGL_image_external";
914 init
.gl_version
= "opengl es 2.0";
915 init
.bind_generates_resource
= true;
917 EXPECT_CALL(*gl_
, BindTexture(GL_TEXTURE_EXTERNAL_OES
, kNewServiceId
));
918 EXPECT_CALL(*gl_
, GenTextures(1, _
))
919 .WillOnce(SetArgumentPointee
<1>(kNewServiceId
));
921 cmd
.Init(GL_TEXTURE_EXTERNAL_OES
, kNewClientId
);
922 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
923 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
924 TextureRef
* texture_ref
= GetTexture(kNewClientId
);
925 EXPECT_TRUE(texture_ref
!= NULL
);
926 EXPECT_TRUE(texture_ref
->texture()->target() == GL_TEXTURE_EXTERNAL_OES
);
929 TEST_P(GLES2DecoderManualInitTest
, EGLImageExternalGetBinding
) {
931 init
.extensions
= "GL_OES_EGL_image_external";
932 init
.gl_version
= "opengl es 2.0";
933 init
.bind_generates_resource
= true;
935 DoBindTexture(GL_TEXTURE_EXTERNAL_OES
, client_texture_id_
, kServiceTextureId
);
937 EXPECT_CALL(*gl_
, GetError())
938 .WillOnce(Return(GL_NO_ERROR
))
939 .WillOnce(Return(GL_NO_ERROR
))
940 .RetiresOnSaturation();
941 typedef GetIntegerv::Result Result
;
942 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
944 GetIntegerv(GL_TEXTURE_BINDING_EXTERNAL_OES
, result
->GetData()))
948 cmd
.Init(GL_TEXTURE_BINDING_EXTERNAL_OES
,
950 shared_memory_offset_
);
951 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
952 EXPECT_EQ(decoder_
->GetGLES2Util()->GLGetNumValuesReturned(
953 GL_TEXTURE_BINDING_EXTERNAL_OES
),
954 result
->GetNumResults());
955 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
956 EXPECT_EQ(client_texture_id_
, (uint32
)result
->GetData()[0]);
959 TEST_P(GLES2DecoderManualInitTest
, EGLImageExternalTextureDefaults
) {
961 init
.extensions
= "GL_OES_EGL_image_external";
962 init
.gl_version
= "opengl es 2.0";
963 init
.bind_generates_resource
= true;
965 DoBindTexture(GL_TEXTURE_EXTERNAL_OES
, client_texture_id_
, kServiceTextureId
);
967 TextureRef
* texture_ref
= GetTexture(client_texture_id_
);
968 EXPECT_TRUE(texture_ref
!= NULL
);
969 Texture
* texture
= texture_ref
->texture();
970 EXPECT_TRUE(texture
->target() == GL_TEXTURE_EXTERNAL_OES
);
971 EXPECT_TRUE(texture
->min_filter() == GL_LINEAR
);
972 EXPECT_TRUE(texture
->wrap_s() == GL_CLAMP_TO_EDGE
);
973 EXPECT_TRUE(texture
->wrap_t() == GL_CLAMP_TO_EDGE
);
976 TEST_P(GLES2DecoderManualInitTest
, EGLImageExternalTextureParam
) {
978 init
.extensions
= "GL_OES_EGL_image_external";
979 init
.gl_version
= "opengl es 2.0";
980 init
.bind_generates_resource
= true;
982 DoBindTexture(GL_TEXTURE_EXTERNAL_OES
, client_texture_id_
, kServiceTextureId
);
986 GL_TEXTURE_EXTERNAL_OES
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
));
989 TexParameteri(GL_TEXTURE_EXTERNAL_OES
, GL_TEXTURE_MIN_FILTER
, GL_LINEAR
));
993 GL_TEXTURE_EXTERNAL_OES
, GL_TEXTURE_WRAP_S
, GL_CLAMP_TO_EDGE
));
997 GL_TEXTURE_EXTERNAL_OES
, GL_TEXTURE_WRAP_T
, GL_CLAMP_TO_EDGE
));
999 cmd
.Init(GL_TEXTURE_EXTERNAL_OES
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
1000 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1001 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1003 cmd
.Init(GL_TEXTURE_EXTERNAL_OES
, GL_TEXTURE_MIN_FILTER
, GL_LINEAR
);
1004 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1005 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1007 cmd
.Init(GL_TEXTURE_EXTERNAL_OES
, GL_TEXTURE_WRAP_S
, GL_CLAMP_TO_EDGE
);
1008 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1009 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1011 cmd
.Init(GL_TEXTURE_EXTERNAL_OES
, GL_TEXTURE_WRAP_T
, GL_CLAMP_TO_EDGE
);
1012 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1013 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1015 TextureRef
* texture_ref
= GetTexture(client_texture_id_
);
1016 EXPECT_TRUE(texture_ref
!= NULL
);
1017 Texture
* texture
= texture_ref
->texture();
1018 EXPECT_TRUE(texture
->target() == GL_TEXTURE_EXTERNAL_OES
);
1019 EXPECT_TRUE(texture
->min_filter() == GL_LINEAR
);
1020 EXPECT_TRUE(texture
->wrap_s() == GL_CLAMP_TO_EDGE
);
1021 EXPECT_TRUE(texture
->wrap_t() == GL_CLAMP_TO_EDGE
);
1024 TEST_P(GLES2DecoderManualInitTest
, EGLImageExternalTextureParamInvalid
) {
1026 init
.extensions
= "GL_OES_EGL_image_external";
1027 init
.gl_version
= "opengl es 2.0";
1028 init
.bind_generates_resource
= true;
1030 DoBindTexture(GL_TEXTURE_EXTERNAL_OES
, client_texture_id_
, kServiceTextureId
);
1033 cmd
.Init(GL_TEXTURE_EXTERNAL_OES
,
1034 GL_TEXTURE_MIN_FILTER
,
1035 GL_NEAREST_MIPMAP_NEAREST
);
1036 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1037 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
1039 cmd
.Init(GL_TEXTURE_EXTERNAL_OES
, GL_TEXTURE_WRAP_S
, GL_REPEAT
);
1040 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1041 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
1043 cmd
.Init(GL_TEXTURE_EXTERNAL_OES
, GL_TEXTURE_WRAP_T
, GL_REPEAT
);
1044 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1045 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
1047 TextureRef
* texture_ref
= GetTexture(client_texture_id_
);
1048 EXPECT_TRUE(texture_ref
!= NULL
);
1049 Texture
* texture
= texture_ref
->texture();
1050 EXPECT_TRUE(texture
->target() == GL_TEXTURE_EXTERNAL_OES
);
1051 EXPECT_TRUE(texture
->min_filter() == GL_LINEAR
);
1052 EXPECT_TRUE(texture
->wrap_s() == GL_CLAMP_TO_EDGE
);
1053 EXPECT_TRUE(texture
->wrap_t() == GL_CLAMP_TO_EDGE
);
1056 TEST_P(GLES2DecoderManualInitTest
, EGLImageExternalTexImage2DError
) {
1058 init
.extensions
= "GL_OES_EGL_image_external";
1059 init
.gl_version
= "opengl es 2.0";
1060 init
.bind_generates_resource
= true;
1063 GLenum target
= GL_TEXTURE_EXTERNAL_OES
;
1065 GLenum internal_format
= GL_RGBA
;
1068 GLenum format
= GL_RGBA
;
1069 GLenum type
= GL_UNSIGNED_BYTE
;
1070 DoBindTexture(GL_TEXTURE_EXTERNAL_OES
, client_texture_id_
, kServiceTextureId
);
1071 ASSERT_TRUE(GetTexture(client_texture_id_
) != NULL
);
1081 kSharedMemoryOffset
);
1082 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1084 // TexImage2D is not allowed with GL_TEXTURE_EXTERNAL_OES targets.
1085 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
1088 TEST_P(GLES2DecoderManualInitTest
, DefaultTextureZero
) {
1093 cmd1
.Init(GL_TEXTURE_2D
, 0);
1094 EXPECT_CALL(*gl_
, BindTexture(GL_TEXTURE_2D
, 0));
1095 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd1
));
1096 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1099 cmd2
.Init(GL_TEXTURE_CUBE_MAP
, 0);
1100 EXPECT_CALL(*gl_
, BindTexture(GL_TEXTURE_CUBE_MAP
, 0));
1101 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
1102 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1105 TEST_P(GLES2DecoderManualInitTest
, DefaultTextureBGR
) {
1107 init
.bind_generates_resource
= true;
1111 cmd1
.Init(GL_TEXTURE_2D
, 0);
1113 *gl_
, BindTexture(GL_TEXTURE_2D
, TestHelper::kServiceDefaultTexture2dId
));
1114 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd1
));
1115 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1118 cmd2
.Init(GL_TEXTURE_CUBE_MAP
, 0);
1120 BindTexture(GL_TEXTURE_CUBE_MAP
,
1121 TestHelper::kServiceDefaultTextureCubemapId
));
1122 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
1123 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1126 // Test that default texture 0 is immutable.
1127 TEST_P(GLES2DecoderManualInitTest
, NoDefaultTexParameterf
) {
1133 cmd1
.Init(GL_TEXTURE_2D
, 0);
1134 EXPECT_CALL(*gl_
, BindTexture(GL_TEXTURE_2D
, 0));
1135 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd1
));
1136 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1139 cmd2
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1140 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
1141 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
1146 cmd1
.Init(GL_TEXTURE_CUBE_MAP
, 0);
1147 EXPECT_CALL(*gl_
, BindTexture(GL_TEXTURE_CUBE_MAP
, 0));
1148 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd1
));
1149 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1152 cmd2
.Init(GL_TEXTURE_CUBE_MAP
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1153 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
1154 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
1158 TEST_P(GLES2DecoderManualInitTest
, NoDefaultTexParameteri
) {
1164 cmd1
.Init(GL_TEXTURE_2D
, 0);
1165 EXPECT_CALL(*gl_
, BindTexture(GL_TEXTURE_2D
, 0));
1166 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd1
));
1167 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1170 cmd2
.Init(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1171 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
1172 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
1177 cmd1
.Init(GL_TEXTURE_CUBE_MAP
, 0);
1178 EXPECT_CALL(*gl_
, BindTexture(GL_TEXTURE_CUBE_MAP
, 0));
1179 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd1
));
1180 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1183 cmd2
.Init(GL_TEXTURE_CUBE_MAP
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
1184 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
1185 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
1189 TEST_P(GLES2DecoderManualInitTest
, NoDefaultTexParameterfv
) {
1195 cmd1
.Init(GL_TEXTURE_2D
, 0);
1196 EXPECT_CALL(*gl_
, BindTexture(GL_TEXTURE_2D
, 0));
1197 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd1
));
1198 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1200 GLfloat data
= GL_NEAREST
;
1201 TexParameterfvImmediate
& cmd2
=
1202 *GetImmediateAs
<TexParameterfvImmediate
>();
1203 cmd2
.Init(GL_TEXTURE_2D
,
1204 GL_TEXTURE_MAG_FILTER
,
1206 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd2
, sizeof(data
)));
1207 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
1212 cmd1
.Init(GL_TEXTURE_CUBE_MAP
, 0);
1213 EXPECT_CALL(*gl_
, BindTexture(GL_TEXTURE_CUBE_MAP
, 0));
1214 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd1
));
1215 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1217 GLfloat data
= GL_NEAREST
;
1218 TexParameterfvImmediate
& cmd2
=
1219 *GetImmediateAs
<TexParameterfvImmediate
>();
1220 cmd2
.Init(GL_TEXTURE_CUBE_MAP
,
1221 GL_TEXTURE_MAG_FILTER
,
1223 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd2
, sizeof(data
)));
1224 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
1228 TEST_P(GLES2DecoderManualInitTest
, NoDefaultTexParameteriv
) {
1234 cmd1
.Init(GL_TEXTURE_2D
, 0);
1235 EXPECT_CALL(*gl_
, BindTexture(GL_TEXTURE_2D
, 0));
1236 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd1
));
1237 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1239 GLfloat data
= GL_NEAREST
;
1240 TexParameterfvImmediate
& cmd2
=
1241 *GetImmediateAs
<TexParameterfvImmediate
>();
1242 cmd2
.Init(GL_TEXTURE_2D
,
1243 GL_TEXTURE_MAG_FILTER
,
1245 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd2
, sizeof(data
)));
1246 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
1251 cmd1
.Init(GL_TEXTURE_CUBE_MAP
, 0);
1252 EXPECT_CALL(*gl_
, BindTexture(GL_TEXTURE_CUBE_MAP
, 0));
1253 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd1
));
1254 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1256 GLfloat data
= GL_NEAREST
;
1257 TexParameterfvImmediate
& cmd2
=
1258 *GetImmediateAs
<TexParameterfvImmediate
>();
1259 cmd2
.Init(GL_TEXTURE_CUBE_MAP
,
1260 GL_TEXTURE_MAG_FILTER
,
1262 EXPECT_EQ(error::kNoError
, ExecuteImmediateCmd(cmd2
, sizeof(data
)));
1263 EXPECT_EQ(GL_INVALID_VALUE
, GetGLError());
1267 TEST_P(GLES2DecoderManualInitTest
, NoDefaultTexImage2D
) {
1272 cmd1
.Init(GL_TEXTURE_2D
, 0);
1273 EXPECT_CALL(*gl_
, BindTexture(GL_TEXTURE_2D
, 0));
1274 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd1
));
1275 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1278 cmd2
.Init(GL_TEXTURE_2D
,
1286 kSharedMemoryOffset
);
1287 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
1288 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1291 TEST_P(GLES2DecoderManualInitTest
, NoDefaultTexSubImage2D
) {
1296 cmd1
.Init(GL_TEXTURE_2D
, 0);
1297 EXPECT_CALL(*gl_
, BindTexture(GL_TEXTURE_2D
, 0));
1298 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd1
));
1299 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1302 cmd2
.Init(GL_TEXTURE_2D
,
1311 kSharedMemoryOffset
,
1313 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd2
));
1314 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
1317 TEST_P(GLES2DecoderManualInitTest
, ARBTextureRectangleBindTexture
) {
1319 init
.extensions
= "GL_ARB_texture_rectangle";
1320 init
.bind_generates_resource
= true;
1322 EXPECT_CALL(*gl_
, BindTexture(GL_TEXTURE_RECTANGLE_ARB
, kNewServiceId
));
1323 EXPECT_CALL(*gl_
, GenTextures(1, _
))
1324 .WillOnce(SetArgumentPointee
<1>(kNewServiceId
));
1326 cmd
.Init(GL_TEXTURE_RECTANGLE_ARB
, kNewClientId
);
1327 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1328 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1329 Texture
* texture
= GetTexture(kNewClientId
)->texture();
1330 EXPECT_TRUE(texture
!= NULL
);
1331 EXPECT_TRUE(texture
->target() == GL_TEXTURE_RECTANGLE_ARB
);
1334 TEST_P(GLES2DecoderManualInitTest
, ARBTextureRectangleGetBinding
) {
1336 init
.extensions
= "GL_ARB_texture_rectangle";
1337 init
.bind_generates_resource
= true;
1340 GL_TEXTURE_RECTANGLE_ARB
, client_texture_id_
, kServiceTextureId
);
1342 EXPECT_CALL(*gl_
, GetError())
1343 .WillOnce(Return(GL_NO_ERROR
))
1344 .WillOnce(Return(GL_NO_ERROR
))
1345 .RetiresOnSaturation();
1346 typedef GetIntegerv::Result Result
;
1347 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
1349 GetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB
, result
->GetData()))
1353 cmd
.Init(GL_TEXTURE_BINDING_RECTANGLE_ARB
,
1355 shared_memory_offset_
);
1356 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1357 EXPECT_EQ(decoder_
->GetGLES2Util()->GLGetNumValuesReturned(
1358 GL_TEXTURE_BINDING_RECTANGLE_ARB
),
1359 result
->GetNumResults());
1360 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1361 EXPECT_EQ(client_texture_id_
, (uint32
)result
->GetData()[0]);
1364 TEST_P(GLES2DecoderManualInitTest
, ARBTextureRectangleTextureDefaults
) {
1366 init
.extensions
= "GL_ARB_texture_rectangle";
1367 init
.bind_generates_resource
= true;
1370 GL_TEXTURE_RECTANGLE_ARB
, client_texture_id_
, kServiceTextureId
);
1372 Texture
* texture
= GetTexture(client_texture_id_
)->texture();
1373 EXPECT_TRUE(texture
!= NULL
);
1374 EXPECT_TRUE(texture
->target() == GL_TEXTURE_RECTANGLE_ARB
);
1375 EXPECT_TRUE(texture
->min_filter() == GL_LINEAR
);
1376 EXPECT_TRUE(texture
->wrap_s() == GL_CLAMP_TO_EDGE
);
1377 EXPECT_TRUE(texture
->wrap_t() == GL_CLAMP_TO_EDGE
);
1380 TEST_P(GLES2DecoderManualInitTest
, ARBTextureRectangleTextureParam
) {
1382 init
.extensions
= "GL_ARB_texture_rectangle";
1383 init
.bind_generates_resource
= true;
1387 GL_TEXTURE_RECTANGLE_ARB
, client_texture_id_
, kServiceTextureId
);
1391 GL_TEXTURE_RECTANGLE_ARB
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
));
1394 GL_TEXTURE_RECTANGLE_ARB
, GL_TEXTURE_MIN_FILTER
, GL_LINEAR
));
1398 GL_TEXTURE_RECTANGLE_ARB
, GL_TEXTURE_WRAP_S
, GL_CLAMP_TO_EDGE
));
1402 GL_TEXTURE_RECTANGLE_ARB
, GL_TEXTURE_WRAP_T
, GL_CLAMP_TO_EDGE
));
1404 cmd
.Init(GL_TEXTURE_RECTANGLE_ARB
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
1405 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1406 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1408 cmd
.Init(GL_TEXTURE_RECTANGLE_ARB
, GL_TEXTURE_MIN_FILTER
, GL_LINEAR
);
1409 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1410 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1412 cmd
.Init(GL_TEXTURE_RECTANGLE_ARB
, GL_TEXTURE_WRAP_S
, GL_CLAMP_TO_EDGE
);
1413 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1414 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1416 cmd
.Init(GL_TEXTURE_RECTANGLE_ARB
, GL_TEXTURE_WRAP_T
, GL_CLAMP_TO_EDGE
);
1417 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1418 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1420 Texture
* texture
= GetTexture(client_texture_id_
)->texture();
1421 EXPECT_TRUE(texture
!= NULL
);
1422 EXPECT_TRUE(texture
->target() == GL_TEXTURE_RECTANGLE_ARB
);
1423 EXPECT_TRUE(texture
->min_filter() == GL_LINEAR
);
1424 EXPECT_TRUE(texture
->wrap_s() == GL_CLAMP_TO_EDGE
);
1425 EXPECT_TRUE(texture
->wrap_t() == GL_CLAMP_TO_EDGE
);
1428 TEST_P(GLES2DecoderManualInitTest
, ARBTextureRectangleTextureParamInvalid
) {
1430 init
.extensions
= "GL_ARB_texture_rectangle";
1431 init
.bind_generates_resource
= true;
1435 GL_TEXTURE_RECTANGLE_ARB
, client_texture_id_
, kServiceTextureId
);
1438 cmd
.Init(GL_TEXTURE_RECTANGLE_ARB
,
1439 GL_TEXTURE_MIN_FILTER
,
1440 GL_NEAREST_MIPMAP_NEAREST
);
1441 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1442 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
1444 cmd
.Init(GL_TEXTURE_RECTANGLE_ARB
, GL_TEXTURE_WRAP_S
, GL_REPEAT
);
1445 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1446 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
1448 cmd
.Init(GL_TEXTURE_RECTANGLE_ARB
, GL_TEXTURE_WRAP_T
, GL_REPEAT
);
1449 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1450 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
1452 Texture
* texture
= GetTexture(client_texture_id_
)->texture();
1453 EXPECT_TRUE(texture
!= NULL
);
1454 EXPECT_TRUE(texture
->target() == GL_TEXTURE_RECTANGLE_ARB
);
1455 EXPECT_TRUE(texture
->min_filter() == GL_LINEAR
);
1456 EXPECT_TRUE(texture
->wrap_s() == GL_CLAMP_TO_EDGE
);
1457 EXPECT_TRUE(texture
->wrap_t() == GL_CLAMP_TO_EDGE
);
1460 TEST_P(GLES2DecoderManualInitTest
, ARBTextureRectangleTexImage2DError
) {
1462 init
.extensions
= "GL_ARB_texture_rectangle";
1463 init
.bind_generates_resource
= true;
1466 GLenum target
= GL_TEXTURE_RECTANGLE_ARB
;
1468 GLenum internal_format
= GL_RGBA
;
1471 GLenum format
= GL_RGBA
;
1472 GLenum type
= GL_UNSIGNED_BYTE
;
1474 GL_TEXTURE_RECTANGLE_ARB
, client_texture_id_
, kServiceTextureId
);
1475 ASSERT_TRUE(GetTexture(client_texture_id_
) != NULL
);
1485 kSharedMemoryOffset
);
1486 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1488 // TexImage2D is not allowed with GL_TEXTURE_RECTANGLE_ARB targets.
1489 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
1492 TEST_P(GLES2DecoderManualInitTest
, TexSubImage2DClearsAfterTexImage2DNULL
) {
1494 init
.gl_version
= "opengl es 2.0";
1495 init
.has_alpha
= true;
1496 init
.has_depth
= true;
1497 init
.request_alpha
= true;
1498 init
.request_depth
= true;
1501 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
1503 GL_TEXTURE_2D
, 0, GL_RGBA
, 2, 2, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
1504 SetupClearTextureExpectations(kServiceTextureId
,
1515 TexSubImage2D(GL_TEXTURE_2D
,
1523 shared_memory_address_
))
1525 .RetiresOnSaturation();
1527 cmd
.Init(GL_TEXTURE_2D
,
1536 kSharedMemoryOffset
,
1538 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1539 // Test if we call it again it does not clear.
1541 TexSubImage2D(GL_TEXTURE_2D
,
1549 shared_memory_address_
))
1551 .RetiresOnSaturation();
1552 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1555 TEST_P(GLES2DecoderTest
, TexSubImage2DDoesNotClearAfterTexImage2DNULLThenData
) {
1556 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
1558 GL_TEXTURE_2D
, 0, GL_RGBA
, 2, 2, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
1559 DoTexImage2D(GL_TEXTURE_2D
,
1568 kSharedMemoryOffset
);
1570 TexSubImage2D(GL_TEXTURE_2D
,
1578 shared_memory_address_
))
1580 .RetiresOnSaturation();
1582 cmd
.Init(GL_TEXTURE_2D
,
1591 kSharedMemoryOffset
,
1593 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1594 // Test if we call it again it does not clear.
1596 TexSubImage2D(GL_TEXTURE_2D
,
1604 shared_memory_address_
))
1606 .RetiresOnSaturation();
1607 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1611 GLES2DecoderManualInitTest
,
1612 TexSubImage2DDoesNotClearAfterTexImage2DNULLThenDataWithTexImage2DIsFaster
) {
1613 base::CommandLine
command_line(0, NULL
);
1614 command_line
.AppendSwitchASCII(
1615 switches::kGpuDriverBugWorkarounds
,
1616 base::IntToString(gpu::TEXSUBIMAGE2D_FASTER_THAN_TEXIMAGE2D
));
1618 init
.bind_generates_resource
= true;
1619 InitDecoderWithCommandLine(init
, &command_line
);
1620 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
1622 GL_TEXTURE_2D
, 0, GL_RGBA
, 2, 2, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
1625 // Uses texSubimage internally because the above workaround is active and
1626 // the update is for the full size of the texture.
1629 GL_TEXTURE_2D
, 0, 0, 0, 2, 2, GL_RGBA
, GL_UNSIGNED_BYTE
, _
))
1631 .RetiresOnSaturation();
1632 cmds::TexImage2D cmd
;
1633 cmd
.Init(GL_TEXTURE_2D
,
1641 kSharedMemoryOffset
);
1642 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1646 TexSubImage2D(GL_TEXTURE_2D
,
1654 shared_memory_address_
))
1656 .RetiresOnSaturation();
1658 cmd
.Init(GL_TEXTURE_2D
,
1667 kSharedMemoryOffset
,
1669 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1670 // Test if we call it again it does not clear.
1672 TexSubImage2D(GL_TEXTURE_2D
,
1680 shared_memory_address_
))
1682 .RetiresOnSaturation();
1683 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1686 TEST_P(GLES2DecoderTest
, TexSubImage2DClearsAfterTexImage2DWithDataThenNULL
) {
1687 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
1688 // Put in data (so it should be marked as cleared)
1689 DoTexImage2D(GL_TEXTURE_2D
,
1698 kSharedMemoryOffset
);
1702 GL_TEXTURE_2D
, 0, GL_RGBA
, 2, 2, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
1703 // It won't actually call TexImage2D, just mark it as uncleared.
1704 EXPECT_EQ(error::kNoError
, ExecuteCmd(tex_cmd
));
1705 // Next call to TexSubImage2d should clear.
1706 SetupClearTextureExpectations(kServiceTextureId
,
1717 TexSubImage2D(GL_TEXTURE_2D
,
1725 shared_memory_address_
))
1727 .RetiresOnSaturation();
1729 cmd
.Init(GL_TEXTURE_2D
,
1738 kSharedMemoryOffset
,
1740 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1743 TEST_P(GLES2DecoderTest
, CopyTexImage2DMarksTextureAsCleared
) {
1744 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
1746 TextureManager
* manager
= group().texture_manager();
1747 TextureRef
* texture_ref
= manager
->GetTexture(client_texture_id_
);
1748 ASSERT_TRUE(texture_ref
!= NULL
);
1749 Texture
* texture
= texture_ref
->texture();
1751 EXPECT_CALL(*gl_
, GetError())
1752 .WillOnce(Return(GL_NO_ERROR
))
1753 .RetiresOnSaturation();
1754 EXPECT_CALL(*gl_
, CopyTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA
, 0, 0, 1, 1, 0))
1756 .RetiresOnSaturation();
1757 EXPECT_CALL(*gl_
, GetError())
1758 .WillOnce(Return(GL_NO_ERROR
))
1759 .RetiresOnSaturation();
1761 cmd
.Init(GL_TEXTURE_2D
, 0, GL_RGBA
, 0, 0, 1, 1);
1762 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1764 EXPECT_TRUE(texture
->SafeToRenderFrom());
1767 TEST_P(GLES2DecoderTest
, CopyTexSubImage2DClearsUnclearedTexture
) {
1768 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
1770 GL_TEXTURE_2D
, 0, GL_RGBA
, 2, 2, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
1772 SetupClearTextureExpectations(kServiceTextureId
,
1782 EXPECT_CALL(*gl_
, CopyTexSubImage2D(GL_TEXTURE_2D
, 0, 0, 0, 0, 0, 1, 1))
1784 .RetiresOnSaturation();
1785 CopyTexSubImage2D cmd
;
1786 cmd
.Init(GL_TEXTURE_2D
, 0, 0, 0, 0, 0, 1, 1);
1787 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1789 TextureManager
* manager
= group().texture_manager();
1790 TextureRef
* texture_ref
= manager
->GetTexture(client_texture_id_
);
1791 ASSERT_TRUE(texture_ref
!= NULL
);
1792 Texture
* texture
= texture_ref
->texture();
1793 EXPECT_TRUE(texture
->SafeToRenderFrom());
1796 TEST_P(GLES2DecoderTest
, CopyTexSubImage2DClearsUnclearedBackBufferSizedTexture
) {
1797 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
1798 DoTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA
, kBackBufferWidth
, kBackBufferHeight
,
1799 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
1801 EXPECT_CALL(*gl_
, CopyTexSubImage2D(GL_TEXTURE_2D
, 0, 0, 0, 0, 0,
1802 kBackBufferWidth
, kBackBufferHeight
))
1804 .RetiresOnSaturation();
1805 CopyTexSubImage2D cmd
;
1806 cmd
.Init(GL_TEXTURE_2D
, 0, 0, 0, 0, 0, kBackBufferWidth
, kBackBufferHeight
);
1807 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1809 TextureManager
* manager
= group().texture_manager();
1810 TextureRef
* texture_ref
= manager
->GetTexture(client_texture_id_
);
1811 ASSERT_TRUE(texture_ref
!= NULL
);
1812 Texture
* texture
= texture_ref
->texture();
1813 EXPECT_TRUE(texture
->SafeToRenderFrom());
1816 TEST_P(GLES2DecoderManualInitTest
, CompressedImage2DMarksTextureAsCleared
) {
1818 init
.extensions
= "GL_EXT_texture_compression_s3tc";
1819 init
.bind_generates_resource
= true;
1822 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
1823 EXPECT_CALL(*gl_
, GetError())
1824 .WillOnce(Return(GL_NO_ERROR
))
1825 .RetiresOnSaturation();
1828 CompressedTexImage2D(
1829 GL_TEXTURE_2D
, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT
, 4, 4, 0, 8, _
))
1831 .RetiresOnSaturation();
1832 EXPECT_CALL(*gl_
, GetError())
1833 .WillOnce(Return(GL_NO_ERROR
))
1834 .RetiresOnSaturation();
1835 CompressedTexImage2D cmd
;
1836 cmd
.Init(GL_TEXTURE_2D
,
1838 GL_COMPRESSED_RGB_S3TC_DXT1_EXT
,
1843 kSharedMemoryOffset
);
1844 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1845 TextureManager
* manager
= group().texture_manager();
1846 TextureRef
* texture_ref
= manager
->GetTexture(client_texture_id_
);
1847 EXPECT_TRUE(texture_ref
->texture()->SafeToRenderFrom());
1850 TEST_P(GLES2DecoderTest
, TextureUsageAngleExtNotEnabledByDefault
) {
1851 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
1855 GL_TEXTURE_2D
, GL_TEXTURE_USAGE_ANGLE
, GL_FRAMEBUFFER_ATTACHMENT_ANGLE
);
1856 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
1857 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
1860 TEST_P(GLES2DecoderTest
, ProduceAndConsumeTextureCHROMIUM
) {
1861 Mailbox mailbox
= Mailbox::Generate();
1863 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
1865 GL_TEXTURE_2D
, 0, GL_RGBA
, 3, 1, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
1867 GL_TEXTURE_2D
, 1, GL_RGBA
, 2, 4, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
1868 TextureRef
* texture_ref
=
1869 group().texture_manager()->GetTexture(client_texture_id_
);
1870 ASSERT_TRUE(texture_ref
!= NULL
);
1871 Texture
* texture
= texture_ref
->texture();
1872 EXPECT_EQ(kServiceTextureId
, texture
->service_id());
1874 ProduceTextureCHROMIUMImmediate
& produce_cmd
=
1875 *GetImmediateAs
<ProduceTextureCHROMIUMImmediate
>();
1876 produce_cmd
.Init(GL_TEXTURE_2D
, mailbox
.name
);
1877 EXPECT_EQ(error::kNoError
,
1878 ExecuteImmediateCmd(produce_cmd
, sizeof(mailbox
.name
)));
1879 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1881 // Texture didn't change.
1885 GLenum internal_format
;
1887 EXPECT_TRUE(texture
->GetLevelSize(GL_TEXTURE_2D
, 0, &width
, &height
));
1888 EXPECT_EQ(3, width
);
1889 EXPECT_EQ(1, height
);
1890 EXPECT_TRUE(texture
->GetLevelType(GL_TEXTURE_2D
, 0, &type
, &internal_format
));
1891 EXPECT_EQ(static_cast<GLenum
>(GL_RGBA
), internal_format
);
1892 EXPECT_EQ(static_cast<GLenum
>(GL_UNSIGNED_BYTE
), type
);
1894 EXPECT_TRUE(texture
->GetLevelSize(GL_TEXTURE_2D
, 1, &width
, &height
));
1895 EXPECT_EQ(2, width
);
1896 EXPECT_EQ(4, height
);
1897 EXPECT_TRUE(texture
->GetLevelType(GL_TEXTURE_2D
, 1, &type
, &internal_format
));
1898 EXPECT_EQ(static_cast<GLenum
>(GL_RGBA
), internal_format
);
1899 EXPECT_EQ(static_cast<GLenum
>(GL_UNSIGNED_BYTE
), type
);
1901 // Service ID has not changed.
1902 EXPECT_EQ(kServiceTextureId
, texture
->service_id());
1904 // Create new texture for consume.
1905 EXPECT_CALL(*gl_
, GenTextures(_
, _
))
1906 .WillOnce(SetArgumentPointee
<1>(kNewServiceId
))
1907 .RetiresOnSaturation();
1908 DoBindTexture(GL_TEXTURE_2D
, kNewClientId
, kNewServiceId
);
1910 // Assigns and binds original service size texture ID.
1911 EXPECT_CALL(*gl_
, DeleteTextures(1, _
)).Times(1).RetiresOnSaturation();
1912 EXPECT_CALL(*gl_
, BindTexture(GL_TEXTURE_2D
, kServiceTextureId
))
1914 .RetiresOnSaturation();
1916 ConsumeTextureCHROMIUMImmediate
& consume_cmd
=
1917 *GetImmediateAs
<ConsumeTextureCHROMIUMImmediate
>();
1918 consume_cmd
.Init(GL_TEXTURE_2D
, mailbox
.name
);
1919 EXPECT_EQ(error::kNoError
,
1920 ExecuteImmediateCmd(consume_cmd
, sizeof(mailbox
.name
)));
1921 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1923 // Texture is redefined.
1924 EXPECT_TRUE(texture
->GetLevelSize(GL_TEXTURE_2D
, 0, &width
, &height
));
1925 EXPECT_EQ(3, width
);
1926 EXPECT_EQ(1, height
);
1927 EXPECT_TRUE(texture
->GetLevelType(GL_TEXTURE_2D
, 0, &type
, &internal_format
));
1928 EXPECT_EQ(static_cast<GLenum
>(GL_RGBA
), internal_format
);
1929 EXPECT_EQ(static_cast<GLenum
>(GL_UNSIGNED_BYTE
), type
);
1931 EXPECT_TRUE(texture
->GetLevelSize(GL_TEXTURE_2D
, 1, &width
, &height
));
1932 EXPECT_EQ(2, width
);
1933 EXPECT_EQ(4, height
);
1934 EXPECT_TRUE(texture
->GetLevelType(GL_TEXTURE_2D
, 1, &type
, &internal_format
));
1935 EXPECT_EQ(static_cast<GLenum
>(GL_RGBA
), internal_format
);
1936 EXPECT_EQ(static_cast<GLenum
>(GL_UNSIGNED_BYTE
), type
);
1938 // Service ID is restored.
1939 EXPECT_EQ(kServiceTextureId
, texture
->service_id());
1942 TEST_P(GLES2DecoderTest
, ProduceAndConsumeDirectTextureCHROMIUM
) {
1943 Mailbox mailbox
= Mailbox::Generate();
1945 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
1947 GL_TEXTURE_2D
, 0, GL_RGBA
, 3, 1, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
1949 GL_TEXTURE_2D
, 1, GL_RGBA
, 2, 4, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
1950 TextureRef
* texture_ref
=
1951 group().texture_manager()->GetTexture(client_texture_id_
);
1952 ASSERT_TRUE(texture_ref
!= NULL
);
1953 Texture
* texture
= texture_ref
->texture();
1954 EXPECT_EQ(kServiceTextureId
, texture
->service_id());
1956 ProduceTextureDirectCHROMIUMImmediate
& produce_cmd
=
1957 *GetImmediateAs
<ProduceTextureDirectCHROMIUMImmediate
>();
1958 produce_cmd
.Init(client_texture_id_
, GL_TEXTURE_2D
, mailbox
.name
);
1959 EXPECT_EQ(error::kNoError
,
1960 ExecuteImmediateCmd(produce_cmd
, sizeof(mailbox
.name
)));
1961 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1963 // Texture didn't change.
1967 GLenum internal_format
;
1969 EXPECT_TRUE(texture
->GetLevelSize(GL_TEXTURE_2D
, 0, &width
, &height
));
1970 EXPECT_EQ(3, width
);
1971 EXPECT_EQ(1, height
);
1972 EXPECT_TRUE(texture
->GetLevelType(GL_TEXTURE_2D
, 0, &type
, &internal_format
));
1973 EXPECT_EQ(static_cast<GLenum
>(GL_RGBA
), internal_format
);
1974 EXPECT_EQ(static_cast<GLenum
>(GL_UNSIGNED_BYTE
), type
);
1976 EXPECT_TRUE(texture
->GetLevelSize(GL_TEXTURE_2D
, 1, &width
, &height
));
1977 EXPECT_EQ(2, width
);
1978 EXPECT_EQ(4, height
);
1979 EXPECT_TRUE(texture
->GetLevelType(GL_TEXTURE_2D
, 1, &type
, &internal_format
));
1980 EXPECT_EQ(static_cast<GLenum
>(GL_RGBA
), internal_format
);
1981 EXPECT_EQ(static_cast<GLenum
>(GL_UNSIGNED_BYTE
), type
);
1983 // Service ID has not changed.
1984 EXPECT_EQ(kServiceTextureId
, texture
->service_id());
1986 // Consume the texture into a new client ID.
1987 GLuint new_texture_id
= kNewClientId
;
1988 CreateAndConsumeTextureCHROMIUMImmediate
& consume_cmd
=
1989 *GetImmediateAs
<CreateAndConsumeTextureCHROMIUMImmediate
>();
1990 consume_cmd
.Init(GL_TEXTURE_2D
, new_texture_id
, mailbox
.name
);
1991 EXPECT_EQ(error::kNoError
,
1992 ExecuteImmediateCmd(consume_cmd
, sizeof(mailbox
.name
)));
1993 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
1995 // Make sure the new client ID is associated with the produced service ID.
1996 texture_ref
= group().texture_manager()->GetTexture(new_texture_id
);
1997 ASSERT_TRUE(texture_ref
!= NULL
);
1998 texture
= texture_ref
->texture();
1999 EXPECT_EQ(kServiceTextureId
, texture
->service_id());
2001 DoBindTexture(GL_TEXTURE_2D
, kNewClientId
, kServiceTextureId
);
2003 // Texture is redefined.
2004 EXPECT_TRUE(texture
->GetLevelSize(GL_TEXTURE_2D
, 0, &width
, &height
));
2005 EXPECT_EQ(3, width
);
2006 EXPECT_EQ(1, height
);
2007 EXPECT_TRUE(texture
->GetLevelType(GL_TEXTURE_2D
, 0, &type
, &internal_format
));
2008 EXPECT_EQ(static_cast<GLenum
>(GL_RGBA
), internal_format
);
2009 EXPECT_EQ(static_cast<GLenum
>(GL_UNSIGNED_BYTE
), type
);
2011 EXPECT_TRUE(texture
->GetLevelSize(GL_TEXTURE_2D
, 1, &width
, &height
));
2012 EXPECT_EQ(2, width
);
2013 EXPECT_EQ(4, height
);
2014 EXPECT_TRUE(texture
->GetLevelType(GL_TEXTURE_2D
, 1, &type
, &internal_format
));
2015 EXPECT_EQ(static_cast<GLenum
>(GL_RGBA
), internal_format
);
2016 EXPECT_EQ(static_cast<GLenum
>(GL_UNSIGNED_BYTE
), type
);
2019 TEST_P(GLES2DecoderTest
, ProduceTextureCHROMIUMInvalidTarget
) {
2020 Mailbox mailbox
= Mailbox::Generate();
2022 DoBindTexture(GL_TEXTURE_CUBE_MAP
, client_texture_id_
, kServiceTextureId
);
2024 GL_TEXTURE_CUBE_MAP_POSITIVE_X
, 0, GL_RGBA
, 3, 1, 0, GL_RGBA
,
2025 GL_UNSIGNED_BYTE
, 0, 0);
2026 TextureRef
* texture_ref
=
2027 group().texture_manager()->GetTexture(client_texture_id_
);
2028 ASSERT_TRUE(texture_ref
!= NULL
);
2029 Texture
* texture
= texture_ref
->texture();
2030 EXPECT_EQ(kServiceTextureId
, texture
->service_id());
2032 ProduceTextureDirectCHROMIUMImmediate
& produce_cmd
=
2033 *GetImmediateAs
<ProduceTextureDirectCHROMIUMImmediate
>();
2034 produce_cmd
.Init(client_texture_id_
, GL_TEXTURE_2D
, mailbox
.name
);
2035 EXPECT_EQ(error::kNoError
,
2036 ExecuteImmediateCmd(produce_cmd
, sizeof(mailbox
.name
)));
2038 // ProduceTexture should fail it the texture and produce targets don't match.
2039 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
2042 TEST_P(GLES2DecoderTest
, CreateAndConsumeTextureCHROMIUMInvalidMailbox
) {
2043 // Attempt to consume the mailbox when no texture has been produced with it.
2044 Mailbox mailbox
= Mailbox::Generate();
2045 GLuint new_texture_id
= kNewClientId
;
2047 EXPECT_CALL(*gl_
, GenTextures(1, _
))
2048 .WillOnce(SetArgumentPointee
<1>(kNewServiceId
))
2049 .RetiresOnSaturation();
2050 EXPECT_CALL(*gl_
, BindTexture(GL_TEXTURE_2D
, _
))
2052 .RetiresOnSaturation();
2053 EXPECT_CALL(*gl_
, ActiveTexture(GL_TEXTURE0
))
2055 .RetiresOnSaturation();
2057 CreateAndConsumeTextureCHROMIUMImmediate
& consume_cmd
=
2058 *GetImmediateAs
<CreateAndConsumeTextureCHROMIUMImmediate
>();
2059 consume_cmd
.Init(GL_TEXTURE_2D
, new_texture_id
, mailbox
.name
);
2060 EXPECT_EQ(error::kNoError
,
2061 ExecuteImmediateCmd(consume_cmd
, sizeof(mailbox
.name
)));
2063 // CreateAndConsumeTexture should fail if the mailbox isn't associated with a
2065 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
2067 // Make sure the new client_id is associated with a texture ref even though
2068 // CreateAndConsumeTexture failed.
2069 TextureRef
* texture_ref
=
2070 group().texture_manager()->GetTexture(new_texture_id
);
2071 ASSERT_TRUE(texture_ref
!= NULL
);
2072 Texture
* texture
= texture_ref
->texture();
2073 // New texture should have the correct target type.
2074 EXPECT_TRUE(texture
->target() == GL_TEXTURE_2D
);
2075 // New texture should have a valid service_id.
2076 EXPECT_EQ(kNewServiceId
, texture
->service_id());
2079 TEST_P(GLES2DecoderTest
, CreateAndConsumeTextureCHROMIUMInvalidTarget
) {
2080 Mailbox mailbox
= Mailbox::Generate();
2082 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
2083 TextureRef
* texture_ref
=
2084 group().texture_manager()->GetTexture(client_texture_id_
);
2085 ASSERT_TRUE(texture_ref
!= NULL
);
2087 ProduceTextureDirectCHROMIUMImmediate
& produce_cmd
=
2088 *GetImmediateAs
<ProduceTextureDirectCHROMIUMImmediate
>();
2089 produce_cmd
.Init(client_texture_id_
, GL_TEXTURE_2D
, mailbox
.name
);
2090 EXPECT_EQ(error::kNoError
,
2091 ExecuteImmediateCmd(produce_cmd
, sizeof(mailbox
.name
)));
2092 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2094 EXPECT_CALL(*gl_
, GenTextures(1, _
))
2095 .WillOnce(SetArgumentPointee
<1>(kNewServiceId
))
2096 .RetiresOnSaturation();
2097 EXPECT_CALL(*gl_
, BindTexture(GL_TEXTURE_CUBE_MAP
, _
))
2099 .RetiresOnSaturation();
2100 EXPECT_CALL(*gl_
, ActiveTexture(GL_TEXTURE0
))
2102 .RetiresOnSaturation();
2104 // Attempt to consume the mailbox with a different target.
2105 GLuint new_texture_id
= kNewClientId
;
2106 CreateAndConsumeTextureCHROMIUMImmediate
& consume_cmd
=
2107 *GetImmediateAs
<CreateAndConsumeTextureCHROMIUMImmediate
>();
2108 consume_cmd
.Init(GL_TEXTURE_CUBE_MAP
, new_texture_id
, mailbox
.name
);
2109 EXPECT_EQ(error::kNoError
,
2110 ExecuteImmediateCmd(consume_cmd
, sizeof(mailbox
.name
)));
2112 // CreateAndConsumeTexture should fail if the produced texture had a different
2114 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
2116 // Make sure the new client_id is associated with a texture ref even though
2117 // CreateAndConsumeTexture failed.
2118 texture_ref
= group().texture_manager()->GetTexture(new_texture_id
);
2119 ASSERT_TRUE(texture_ref
!= NULL
);
2120 Texture
* texture
= texture_ref
->texture();
2121 // New texture should have the correct target type.
2122 EXPECT_TRUE(texture
->target() == GL_TEXTURE_CUBE_MAP
);
2123 // New texture should have a valid service_id.
2124 EXPECT_EQ(kNewServiceId
, texture
->service_id());
2126 // Make sure the client_id did not become associated with the produced texture
2128 EXPECT_NE(kServiceTextureId
, texture
->service_id());
2131 TEST_P(GLES2DecoderManualInitTest
, DepthTextureBadArgs
) {
2133 init
.extensions
= "GL_ANGLE_depth_texture";
2134 init
.gl_version
= "opengl es 2.0";
2135 init
.has_depth
= true;
2136 init
.has_stencil
= true;
2137 init
.request_depth
= true;
2138 init
.request_stencil
= true;
2139 init
.bind_generates_resource
= true;
2142 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
2143 // Check trying to upload data fails.
2145 tex_cmd
.Init(GL_TEXTURE_2D
,
2153 kSharedMemoryOffset
);
2154 EXPECT_EQ(error::kNoError
, ExecuteCmd(tex_cmd
));
2155 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
2157 tex_cmd
.Init(GL_TEXTURE_2D
,
2166 EXPECT_EQ(error::kNoError
, ExecuteCmd(tex_cmd
));
2167 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
2168 // Make a 1 pixel depth texture.
2169 DoTexImage2D(GL_TEXTURE_2D
,
2179 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2181 // Check that trying to update it fails.
2182 TexSubImage2D tex_sub_cmd
;
2183 tex_sub_cmd
.Init(GL_TEXTURE_2D
,
2192 kSharedMemoryOffset
,
2194 EXPECT_EQ(error::kNoError
, ExecuteCmd(tex_sub_cmd
));
2195 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
2197 // Check that trying to CopyTexImage2D fails
2198 CopyTexImage2D copy_tex_cmd
;
2199 copy_tex_cmd
.Init(GL_TEXTURE_2D
, 0, GL_DEPTH_COMPONENT
, 0, 0, 1, 1);
2200 EXPECT_EQ(error::kNoError
, ExecuteCmd(copy_tex_cmd
));
2201 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
2203 // Check that trying to CopyTexSubImage2D fails
2204 CopyTexSubImage2D copy_sub_cmd
;
2205 copy_sub_cmd
.Init(GL_TEXTURE_2D
, 0, 0, 0, 0, 0, 1, 1);
2206 EXPECT_EQ(error::kNoError
, ExecuteCmd(copy_sub_cmd
));
2207 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
2210 TEST_P(GLES2DecoderManualInitTest
, GenerateMipmapDepthTexture
) {
2212 init
.extensions
= "GL_ANGLE_depth_texture";
2213 init
.gl_version
= "opengl es 2.0";
2214 init
.has_depth
= true;
2215 init
.has_stencil
= true;
2216 init
.request_depth
= true;
2217 init
.request_stencil
= true;
2218 init
.bind_generates_resource
= true;
2220 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
2221 DoTexImage2D(GL_TEXTURE_2D
,
2232 cmd
.Init(GL_TEXTURE_2D
);
2233 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
2234 EXPECT_EQ(GL_INVALID_OPERATION
, GetGLError());
2237 TEST_P(GLES2DecoderTest
, BindTexImage2DCHROMIUM
) {
2238 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
2240 GL_TEXTURE_2D
, 0, GL_RGBA
, 3, 1, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
2241 TextureRef
* texture_ref
=
2242 group().texture_manager()->GetTexture(client_texture_id_
);
2243 ASSERT_TRUE(texture_ref
!= NULL
);
2244 Texture
* texture
= texture_ref
->texture();
2245 EXPECT_EQ(kServiceTextureId
, texture
->service_id());
2247 scoped_refptr
<gfx::GLImage
> image(new gfx::GLImageStub
);
2248 GetImageManager()->AddImage(image
.get(), 1);
2249 EXPECT_FALSE(GetImageManager()->LookupImage(1) == NULL
);
2254 GLenum internal_format
;
2256 EXPECT_TRUE(texture
->GetLevelSize(GL_TEXTURE_2D
, 0, &width
, &height
));
2257 EXPECT_EQ(3, width
);
2258 EXPECT_EQ(1, height
);
2259 EXPECT_TRUE(texture
->GetLevelType(GL_TEXTURE_2D
, 0, &type
, &internal_format
));
2260 EXPECT_EQ(static_cast<GLenum
>(GL_RGBA
), internal_format
);
2261 EXPECT_EQ(static_cast<GLenum
>(GL_UNSIGNED_BYTE
), type
);
2262 EXPECT_TRUE(texture
->GetLevelImage(GL_TEXTURE_2D
, 0) == NULL
);
2264 // Bind image to texture.
2265 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
2266 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D
, 1);
2267 EXPECT_TRUE(texture
->GetLevelSize(GL_TEXTURE_2D
, 0, &width
, &height
));
2268 // Image should now be set.
2269 EXPECT_FALSE(texture
->GetLevelImage(GL_TEXTURE_2D
, 0) == NULL
);
2271 // Define new texture image.
2273 GL_TEXTURE_2D
, 0, GL_RGBA
, 3, 1, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
2274 EXPECT_TRUE(texture
->GetLevelSize(GL_TEXTURE_2D
, 0, &width
, &height
));
2275 // Image should no longer be set.
2276 EXPECT_TRUE(texture
->GetLevelImage(GL_TEXTURE_2D
, 0) == NULL
);
2279 TEST_P(GLES2DecoderTest
, BindTexImage2DCHROMIUMCubeMapNotAllowed
) {
2280 scoped_refptr
<gfx::GLImage
> image(new gfx::GLImageStub
);
2281 GetImageManager()->AddImage(image
.get(), 1);
2282 DoBindTexture(GL_TEXTURE_CUBE_MAP
, client_texture_id_
, kServiceTextureId
);
2284 BindTexImage2DCHROMIUM bind_tex_image_2d_cmd
;
2285 bind_tex_image_2d_cmd
.Init(GL_TEXTURE_CUBE_MAP
, 1);
2286 EXPECT_EQ(error::kNoError
, ExecuteCmd(bind_tex_image_2d_cmd
));
2287 EXPECT_EQ(GL_INVALID_ENUM
, GetGLError());
2290 TEST_P(GLES2DecoderTest
, OrphanGLImageWithTexImage2D
) {
2291 scoped_refptr
<gfx::GLImage
> image(new gfx::GLImageStub
);
2292 GetImageManager()->AddImage(image
.get(), 1);
2293 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
2295 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D
, 1);
2297 TextureRef
* texture_ref
=
2298 group().texture_manager()->GetTexture(client_texture_id_
);
2299 ASSERT_TRUE(texture_ref
!= NULL
);
2300 Texture
* texture
= texture_ref
->texture();
2302 EXPECT_TRUE(texture
->GetLevelImage(GL_TEXTURE_2D
, 0) == image
.get());
2304 GL_TEXTURE_2D
, 0, GL_RGBA
, 3, 1, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
2305 EXPECT_TRUE(texture
->GetLevelImage(GL_TEXTURE_2D
, 0) == NULL
);
2308 TEST_P(GLES2DecoderTest
, GLImageAttachedAfterSubTexImage2D
) {
2309 // Specifically tests that TexSubImage2D is not optimized to TexImage2D
2310 // in the presence of image attachments.
2312 feature_info()->workarounds().texsubimage2d_faster_than_teximage2d
);
2314 scoped_refptr
<gfx::GLImage
> image(new gfx::GLImageStub
);
2315 GetImageManager()->AddImage(image
.get(), 1);
2316 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
2318 GLenum target
= GL_TEXTURE_2D
;
2325 GLenum format
= GL_RGBA
;
2326 GLenum type
= GL_UNSIGNED_BYTE
;
2327 uint32_t pixels_shm_id
= kSharedMemoryId
;
2328 uint32_t pixels_shm_offset
= kSharedMemoryOffset
;
2329 GLboolean internal
= 0;
2331 // Define texture first.
2332 DoTexImage2D(target
, level
, format
, width
, height
, border
, format
, type
,
2333 pixels_shm_id
, pixels_shm_offset
);
2335 // Bind texture to GLImage.
2336 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D
, 1);
2339 TextureRef
* texture_ref
=
2340 group().texture_manager()->GetTexture(client_texture_id_
);
2341 ASSERT_TRUE(texture_ref
!= NULL
);
2342 Texture
* texture
= texture_ref
->texture();
2343 EXPECT_TRUE(texture
->GetLevelImage(GL_TEXTURE_2D
, 0) == image
.get());
2345 // TexSubImage2D should not unbind GLImage.
2346 EXPECT_CALL(*gl_
, TexSubImage2D(target
, level
, xoffset
, yoffset
, width
,
2347 height
, format
, type
, _
))
2349 .RetiresOnSaturation();
2350 cmds::TexSubImage2D tex_sub_image_2d_cmd
;
2351 tex_sub_image_2d_cmd
.Init(target
, level
, xoffset
, yoffset
, width
, height
,
2352 format
, type
, pixels_shm_id
, pixels_shm_offset
,
2354 EXPECT_EQ(error::kNoError
, ExecuteCmd(tex_sub_image_2d_cmd
));
2355 EXPECT_TRUE(texture
->GetLevelImage(GL_TEXTURE_2D
, 0) == image
.get());
2358 TEST_P(GLES2DecoderTest
, GLImageAttachedAfterClearLevel
) {
2359 scoped_refptr
<gfx::GLImage
> image(new gfx::GLImageStub
);
2360 GetImageManager()->AddImage(image
.get(), 1);
2361 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
2363 GLenum target
= GL_TEXTURE_2D
;
2370 GLenum format
= GL_RGBA
;
2371 GLenum type
= GL_UNSIGNED_BYTE
;
2372 uint32_t pixels_shm_id
= kSharedMemoryId
;
2373 uint32_t pixels_shm_offset
= kSharedMemoryOffset
;
2375 // Define texture first.
2376 DoTexImage2D(target
, level
, format
, width
, height
, border
, format
, type
,
2377 pixels_shm_id
, pixels_shm_offset
);
2379 // Bind texture to GLImage.
2380 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D
, 1);
2383 TextureRef
* texture_ref
=
2384 group().texture_manager()->GetTexture(client_texture_id_
);
2385 ASSERT_TRUE(texture_ref
!= NULL
);
2386 Texture
* texture
= texture_ref
->texture();
2387 EXPECT_TRUE(texture
->GetLevelImage(GL_TEXTURE_2D
, 0) == image
.get());
2389 // ClearLevel should use glTexSubImage2D to avoid unbinding GLImage.
2390 EXPECT_CALL(*gl_
, BindTexture(GL_TEXTURE_2D
, kServiceTextureId
))
2392 .RetiresOnSaturation();
2393 EXPECT_CALL(*gl_
, TexSubImage2D(target
, level
, xoffset
, yoffset
, width
,
2394 height
, format
, type
, _
))
2396 .RetiresOnSaturation();
2397 GetDecoder()->ClearLevel(texture
, target
, level
, format
, format
, type
, width
,
2399 EXPECT_TRUE(texture
->GetLevelImage(GL_TEXTURE_2D
, 0) == image
.get());
2402 TEST_P(GLES2DecoderTest
, ReleaseTexImage2DCHROMIUM
) {
2403 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
2405 GL_TEXTURE_2D
, 0, GL_RGBA
, 3, 1, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, 0, 0);
2406 TextureRef
* texture_ref
=
2407 group().texture_manager()->GetTexture(client_texture_id_
);
2408 ASSERT_TRUE(texture_ref
!= NULL
);
2409 Texture
* texture
= texture_ref
->texture();
2410 EXPECT_EQ(kServiceTextureId
, texture
->service_id());
2412 scoped_refptr
<gfx::GLImage
> image(new gfx::GLImageStub
);
2413 GetImageManager()->AddImage(image
.get(), 1);
2414 EXPECT_FALSE(GetImageManager()->LookupImage(1) == NULL
);
2419 GLenum internal_format
;
2421 EXPECT_TRUE(texture
->GetLevelSize(GL_TEXTURE_2D
, 0, &width
, &height
));
2422 EXPECT_EQ(3, width
);
2423 EXPECT_EQ(1, height
);
2424 EXPECT_TRUE(texture
->GetLevelType(GL_TEXTURE_2D
, 0, &type
, &internal_format
));
2425 EXPECT_EQ(static_cast<GLenum
>(GL_RGBA
), internal_format
);
2426 EXPECT_EQ(static_cast<GLenum
>(GL_UNSIGNED_BYTE
), type
);
2427 EXPECT_TRUE(texture
->GetLevelImage(GL_TEXTURE_2D
, 0) == NULL
);
2429 // Bind image to texture.
2430 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
2431 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D
, 1);
2432 EXPECT_TRUE(texture
->GetLevelSize(GL_TEXTURE_2D
, 0, &width
, &height
));
2433 // Image should now be set.
2434 EXPECT_FALSE(texture
->GetLevelImage(GL_TEXTURE_2D
, 0) == NULL
);
2436 // Release image from texture.
2437 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
2438 EXPECT_CALL(*gl_
, GetError())
2439 .WillOnce(Return(GL_NO_ERROR
))
2440 .WillOnce(Return(GL_NO_ERROR
))
2441 .RetiresOnSaturation();
2442 ReleaseTexImage2DCHROMIUM release_tex_image_2d_cmd
;
2443 release_tex_image_2d_cmd
.Init(GL_TEXTURE_2D
, 1);
2444 EXPECT_EQ(error::kNoError
, ExecuteCmd(release_tex_image_2d_cmd
));
2445 EXPECT_TRUE(texture
->GetLevelSize(GL_TEXTURE_2D
, 0, &width
, &height
));
2446 // Image should no longer be set.
2447 EXPECT_TRUE(texture
->GetLevelImage(GL_TEXTURE_2D
, 0) == NULL
);
2450 class MockGLImage
: public gfx::GLImage
{
2454 // Overridden from gfx::GLImage:
2455 MOCK_METHOD0(GetSize
, gfx::Size());
2456 MOCK_METHOD1(Destroy
, void(bool));
2457 MOCK_METHOD1(BindTexImage
, bool(unsigned));
2458 MOCK_METHOD1(ReleaseTexImage
, void(unsigned));
2459 MOCK_METHOD1(CopyTexImage
, bool(unsigned));
2460 MOCK_METHOD0(WillUseTexImage
, void());
2461 MOCK_METHOD0(DidUseTexImage
, void());
2462 MOCK_METHOD0(WillModifyTexImage
, void());
2463 MOCK_METHOD0(DidModifyTexImage
, void());
2464 MOCK_METHOD5(ScheduleOverlayPlane
, bool(gfx::AcceleratedWidget
,
2466 gfx::OverlayTransform
,
2468 const gfx::RectF
&));
2471 virtual ~MockGLImage() {}
2474 TEST_P(GLES2DecoderWithShaderTest
, UseTexImage
) {
2475 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
2476 DoTexImage2D(GL_TEXTURE_2D
,
2485 kSharedMemoryOffset
);
2487 TextureRef
* texture_ref
=
2488 group().texture_manager()->GetTexture(client_texture_id_
);
2489 ASSERT_TRUE(texture_ref
!= NULL
);
2490 Texture
* texture
= texture_ref
->texture();
2491 EXPECT_EQ(kServiceTextureId
, texture
->service_id());
2493 const int32 kImageId
= 1;
2494 scoped_refptr
<MockGLImage
> image(new MockGLImage
);
2495 GetImageManager()->AddImage(image
.get(), kImageId
);
2497 // Bind image to texture.
2498 EXPECT_CALL(*image
.get(), BindTexImage(GL_TEXTURE_2D
))
2500 .WillOnce(Return(true))
2501 .RetiresOnSaturation();
2502 EXPECT_CALL(*image
.get(), GetSize())
2504 .WillOnce(Return(gfx::Size(1, 1)))
2505 .RetiresOnSaturation();
2506 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
2507 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D
, kImageId
);
2509 AddExpectationsForSimulatedAttrib0(kNumVertices
, 0);
2510 SetupExpectationsForApplyingDefaultDirtyState();
2512 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
2513 EXPECT_CALL(*gl_
, GetError())
2514 .WillOnce(Return(GL_NO_ERROR
))
2515 .WillOnce(Return(GL_NO_ERROR
))
2516 .WillOnce(Return(GL_NO_ERROR
))
2517 .WillOnce(Return(GL_NO_ERROR
))
2518 .RetiresOnSaturation();
2519 EXPECT_CALL(*gl_
, ActiveTexture(GL_TEXTURE0
)).Times(3).RetiresOnSaturation();
2520 EXPECT_CALL(*image
.get(), WillUseTexImage()).Times(1).RetiresOnSaturation();
2521 EXPECT_CALL(*image
.get(), DidUseTexImage()).Times(1).RetiresOnSaturation();
2522 EXPECT_CALL(*gl_
, DrawArrays(GL_TRIANGLES
, 0, kNumVertices
))
2524 .RetiresOnSaturation();
2526 cmd
.Init(GL_TRIANGLES
, 0, kNumVertices
);
2527 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
2528 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2531 GL_FRAMEBUFFER
, client_framebuffer_id_
, kServiceFramebufferId
);
2532 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
2533 EXPECT_CALL(*gl_
, GetError())
2534 .WillOnce(Return(GL_NO_ERROR
))
2535 .WillOnce(Return(GL_NO_ERROR
))
2536 .RetiresOnSaturation();
2537 EXPECT_CALL(*gl_
, ActiveTexture(GL_TEXTURE0
)).Times(1).RetiresOnSaturation();
2538 EXPECT_CALL(*gl_
, BindTexture(GL_TEXTURE_2D
, kServiceTextureId
))
2540 .RetiresOnSaturation();
2541 // Image will be 'in use' as long as bound to a framebuffer.
2542 EXPECT_CALL(*image
.get(), WillUseTexImage()).Times(1).RetiresOnSaturation();
2544 FramebufferTexture2DEXT(GL_FRAMEBUFFER
,
2545 GL_COLOR_ATTACHMENT0
,
2550 .RetiresOnSaturation();
2551 EXPECT_CALL(*gl_
, GetError())
2552 .WillOnce(Return(GL_NO_ERROR
))
2553 .WillOnce(Return(GL_NO_ERROR
))
2554 .RetiresOnSaturation();
2555 FramebufferTexture2D fbtex_cmd
;
2556 fbtex_cmd
.Init(GL_FRAMEBUFFER
,
2557 GL_COLOR_ATTACHMENT0
,
2559 client_texture_id_
);
2560 EXPECT_EQ(error::kNoError
, ExecuteCmd(fbtex_cmd
));
2561 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2563 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor.
2564 EXPECT_CALL(*gl_
, GetError())
2565 .WillOnce(Return(GL_NO_ERROR
))
2566 .WillOnce(Return(GL_NO_ERROR
))
2567 .RetiresOnSaturation();
2569 FramebufferRenderbufferEXT(GL_FRAMEBUFFER
,
2570 GL_COLOR_ATTACHMENT0
,
2572 kServiceRenderbufferId
))
2574 .RetiresOnSaturation();
2575 EXPECT_CALL(*gl_
, ActiveTexture(GL_TEXTURE0
)).Times(1).RetiresOnSaturation();
2576 EXPECT_CALL(*gl_
, BindTexture(GL_TEXTURE_2D
, kServiceTextureId
))
2578 .RetiresOnSaturation();
2579 // Image should no longer be 'in use' after being unbound from framebuffer.
2580 EXPECT_CALL(*image
.get(), DidUseTexImage()).Times(1).RetiresOnSaturation();
2581 EXPECT_CALL(*gl_
, GetError())
2582 .WillOnce(Return(GL_NO_ERROR
))
2583 .WillOnce(Return(GL_NO_ERROR
))
2584 .RetiresOnSaturation();
2585 FramebufferRenderbuffer fbrb_cmd
;
2586 fbrb_cmd
.Init(GL_FRAMEBUFFER
,
2587 GL_COLOR_ATTACHMENT0
,
2589 client_renderbuffer_id_
);
2590 EXPECT_EQ(error::kNoError
, ExecuteCmd(fbrb_cmd
));
2593 TEST_P(GLES2DecoderManualInitTest
, DrawWithGLImageExternal
) {
2595 init
.extensions
= "GL_OES_EGL_image_external";
2596 init
.gl_version
= "opengl es 2.0";
2597 init
.has_alpha
= true;
2598 init
.has_depth
= true;
2599 init
.request_alpha
= true;
2600 init
.request_depth
= true;
2601 init
.bind_generates_resource
= true;
2604 TextureRef
* texture_ref
= GetTexture(client_texture_id_
);
2605 scoped_refptr
<MockGLImage
> image(new MockGLImage
);
2606 group().texture_manager()->SetTarget(texture_ref
, GL_TEXTURE_EXTERNAL_OES
);
2607 group().texture_manager()->SetLevelInfo(texture_ref
,
2608 GL_TEXTURE_EXTERNAL_OES
,
2618 group().texture_manager()->SetLevelImage(
2619 texture_ref
, GL_TEXTURE_EXTERNAL_OES
, 0, image
.get());
2621 DoBindTexture(GL_TEXTURE_EXTERNAL_OES
, client_texture_id_
, kServiceTextureId
);
2622 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2624 SetupSamplerExternalProgram();
2626 AddExpectationsForSimulatedAttrib0(kMaxValidIndex
+ 1, 0);
2627 SetupExpectationsForApplyingDefaultDirtyState();
2628 EXPECT_TRUE(group().texture_manager()->CanRender(texture_ref
));
2631 EXPECT_CALL(*gl_
, GetError())
2632 .WillOnce(Return(GL_NO_ERROR
))
2633 .RetiresOnSaturation();
2634 EXPECT_CALL(*gl_
, ActiveTexture(GL_TEXTURE0
)).Times(1).RetiresOnSaturation();
2635 EXPECT_CALL(*image
.get(), WillUseTexImage()).Times(1).RetiresOnSaturation();
2636 EXPECT_CALL(*gl_
, GetError())
2637 .WillOnce(Return(GL_NO_ERROR
))
2638 .RetiresOnSaturation();
2639 EXPECT_CALL(*gl_
, DrawElements(_
, _
, _
, _
)).Times(1);
2640 EXPECT_CALL(*gl_
, GetError())
2641 .WillOnce(Return(GL_NO_ERROR
))
2642 .RetiresOnSaturation();
2643 EXPECT_CALL(*gl_
, ActiveTexture(GL_TEXTURE0
)).Times(1).RetiresOnSaturation();
2644 EXPECT_CALL(*image
.get(), DidUseTexImage()).Times(1).RetiresOnSaturation();
2645 EXPECT_CALL(*gl_
, GetError())
2646 .WillOnce(Return(GL_NO_ERROR
))
2647 .RetiresOnSaturation();
2648 EXPECT_CALL(*gl_
, ActiveTexture(GL_TEXTURE0
)).Times(1).RetiresOnSaturation();
2650 cmd
.Init(GL_TRIANGLES
,
2651 kValidIndexRangeCount
,
2653 kValidIndexRangeStart
* 2);
2654 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
2655 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2658 TEST_P(GLES2DecoderManualInitTest
, TexImage2DFloatOnGLES2
) {
2660 init
.extensions
= "GL_OES_texture_float";
2661 init
.gl_version
= "opengl es 2.0";
2663 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
2664 DoTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA
, 16, 17, 0, GL_RGBA
, GL_FLOAT
, 0, 0);
2665 DoTexImage2D(GL_TEXTURE_2D
, 0, GL_RGB
, 16, 17, 0, GL_RGB
, GL_FLOAT
, 0, 0);
2667 GL_TEXTURE_2D
, 0, GL_LUMINANCE
, 16, 17, 0, GL_LUMINANCE
, GL_FLOAT
, 0, 0);
2668 DoTexImage2D(GL_TEXTURE_2D
, 0, GL_ALPHA
, 16, 17, 0, GL_ALPHA
, GL_FLOAT
, 0, 0);
2669 DoTexImage2D(GL_TEXTURE_2D
,
2681 TEST_P(GLES2DecoderManualInitTest
, TexImage2DFloatOnGLES3
) {
2683 init
.extensions
= "GL_OES_texture_float GL_EXT_color_buffer_float";
2684 init
.gl_version
= "opengl es 3.0";
2686 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
2687 DoTexImage2D(GL_TEXTURE_2D
, 0, GL_RGBA
, 16, 17, 0, GL_RGBA
, GL_FLOAT
, 0, 0);
2688 DoTexImage2D(GL_TEXTURE_2D
, 0, GL_RGB
, 16, 17, 0, GL_RGB
, GL_FLOAT
, 0, 0);
2690 GL_TEXTURE_2D
, 0, GL_RGBA32F
, 16, 17, 0, GL_RGBA
, GL_FLOAT
, 0, 0);
2692 GL_TEXTURE_2D
, 0, GL_LUMINANCE
, 16, 17, 0, GL_LUMINANCE
, GL_FLOAT
, 0, 0);
2693 DoTexImage2D(GL_TEXTURE_2D
, 0, GL_ALPHA
, 16, 17, 0, GL_ALPHA
, GL_FLOAT
, 0, 0);
2694 DoTexImage2D(GL_TEXTURE_2D
,
2706 TEST_P(GLES2DecoderManualInitTest
, TexSubImage2DFloatOnGLES3
) {
2708 init
.extensions
= "GL_OES_texture_float GL_EXT_color_buffer_float";
2709 init
.gl_version
= "opengl es 3.0";
2711 const int kWidth
= 8;
2712 const int kHeight
= 4;
2713 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
2714 DoTexImage2D(GL_TEXTURE_2D
,
2725 TexImage2D(GL_TEXTURE_2D
,
2733 shared_memory_address_
))
2735 .RetiresOnSaturation();
2737 cmd
.Init(GL_TEXTURE_2D
,
2746 kSharedMemoryOffset
,
2748 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
2749 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2752 TEST_P(GLES2DecoderManualInitTest
, TexSubImage2DFloatDoesClearOnGLES3
) {
2754 init
.extensions
= "GL_OES_texture_float GL_EXT_color_buffer_float";
2755 init
.gl_version
= "opengl es 3.0";
2757 const int kWidth
= 8;
2758 const int kHeight
= 4;
2759 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
2760 DoTexImage2D(GL_TEXTURE_2D
,
2770 SetupClearTextureExpectations(kServiceTextureId
,
2781 TexSubImage2D(GL_TEXTURE_2D
,
2789 shared_memory_address_
))
2791 .RetiresOnSaturation();
2793 cmd
.Init(GL_TEXTURE_2D
,
2802 kSharedMemoryOffset
,
2804 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
2805 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2808 TEST_P(GLES2DecoderManualInitTest
, TexImage2DFloatConvertsFormatDesktop
) {
2810 init
.extensions
= "GL_ARB_texture_float";
2812 DoBindTexture(GL_TEXTURE_2D
, client_texture_id_
, kServiceTextureId
);
2814 GL_TEXTURE_2D
, 0, GL_RGBA32F
, 16, 17, 0, GL_RGBA
, GL_FLOAT
, 0, 0);
2815 DoTexImage2D(GL_TEXTURE_2D
, 0, GL_RGB32F
, 16, 17, 0, GL_RGB
, GL_FLOAT
, 0, 0);
2816 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D
,
2827 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D
,
2838 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D
,
2848 GL_LUMINANCE32F_ARB
);
2849 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D
,
2860 DoTexImage2DConvertInternalFormat(GL_TEXTURE_2D
,
2870 GL_LUMINANCE_ALPHA32F_ARB
);
2873 class GLES2DecoderCompressedFormatsTest
: public GLES2DecoderManualInitTest
{
2875 GLES2DecoderCompressedFormatsTest() {}
2877 static bool ValueInArray(GLint value
, GLint
* array
, GLint count
) {
2878 for (GLint ii
= 0; ii
< count
; ++ii
) {
2879 if (array
[ii
] == value
) {
2886 void CheckFormats(const char* extension
, const GLenum
* formats
, int count
) {
2888 init
.extensions
= extension
;
2889 init
.bind_generates_resource
= true;
2892 EXPECT_CALL(*gl_
, GetError())
2893 .WillOnce(Return(GL_NO_ERROR
))
2894 .WillOnce(Return(GL_NO_ERROR
))
2895 .WillOnce(Return(GL_NO_ERROR
))
2896 .WillOnce(Return(GL_NO_ERROR
))
2897 .RetiresOnSaturation();
2899 typedef GetIntegerv::Result Result
;
2900 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
2903 EXPECT_CALL(*gl_
, GetIntegerv(_
, _
)).Times(0).RetiresOnSaturation();
2904 cmd
.Init(GL_NUM_COMPRESSED_TEXTURE_FORMATS
,
2906 shared_memory_offset_
);
2907 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
2908 EXPECT_EQ(1, result
->GetNumResults());
2909 GLint num_formats
= result
->GetData()[0];
2910 EXPECT_EQ(count
, num_formats
);
2911 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2914 cmd
.Init(GL_COMPRESSED_TEXTURE_FORMATS
,
2916 shared_memory_offset_
);
2917 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
2918 EXPECT_EQ(num_formats
, result
->GetNumResults());
2920 for (int i
= 0; i
< count
; ++i
) {
2922 ValueInArray(formats
[i
], result
->GetData(), result
->GetNumResults()));
2925 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2929 INSTANTIATE_TEST_CASE_P(Service
,
2930 GLES2DecoderCompressedFormatsTest
,
2933 TEST_P(GLES2DecoderCompressedFormatsTest
, GetCompressedTextureFormatsS3TC
) {
2934 const GLenum formats
[] = {
2935 GL_COMPRESSED_RGB_S3TC_DXT1_EXT
, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
,
2936 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
};
2937 CheckFormats("GL_EXT_texture_compression_s3tc", formats
, 4);
2940 TEST_P(GLES2DecoderCompressedFormatsTest
, GetCompressedTextureFormatsATC
) {
2941 const GLenum formats
[] = {GL_ATC_RGB_AMD
, GL_ATC_RGBA_EXPLICIT_ALPHA_AMD
,
2942 GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD
};
2943 CheckFormats("GL_AMD_compressed_ATC_texture", formats
, 3);
2946 TEST_P(GLES2DecoderCompressedFormatsTest
, GetCompressedTextureFormatsPVRTC
) {
2947 const GLenum formats
[] = {
2948 GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG
, GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
,
2949 GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
};
2950 CheckFormats("GL_IMG_texture_compression_pvrtc", formats
, 4);
2953 TEST_P(GLES2DecoderCompressedFormatsTest
, GetCompressedTextureFormatsETC1
) {
2954 const GLenum formats
[] = {GL_ETC1_RGB8_OES
};
2955 CheckFormats("GL_OES_compressed_ETC1_RGB8_texture", formats
, 1);
2958 TEST_P(GLES2DecoderManualInitTest
, GetNoCompressedTextureFormats
) {
2960 init
.bind_generates_resource
= true;
2963 EXPECT_CALL(*gl_
, GetError())
2964 .WillOnce(Return(GL_NO_ERROR
))
2965 .WillOnce(Return(GL_NO_ERROR
))
2966 .WillOnce(Return(GL_NO_ERROR
))
2967 .WillOnce(Return(GL_NO_ERROR
))
2968 .RetiresOnSaturation();
2970 typedef GetIntegerv::Result Result
;
2971 Result
* result
= static_cast<Result
*>(shared_memory_address_
);
2974 EXPECT_CALL(*gl_
, GetIntegerv(_
, _
)).Times(0).RetiresOnSaturation();
2975 cmd
.Init(GL_NUM_COMPRESSED_TEXTURE_FORMATS
,
2977 shared_memory_offset_
);
2978 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
2979 EXPECT_EQ(1, result
->GetNumResults());
2980 GLint num_formats
= result
->GetData()[0];
2981 EXPECT_EQ(0, num_formats
);
2982 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2986 GL_COMPRESSED_TEXTURE_FORMATS
, shared_memory_id_
, shared_memory_offset_
);
2987 EXPECT_EQ(error::kNoError
, ExecuteCmd(cmd
));
2988 EXPECT_EQ(num_formats
, result
->GetNumResults());
2990 EXPECT_EQ(GL_NO_ERROR
, GetGLError());
2993 // TODO(gman): Complete this test.
2994 // TEST_P(GLES2DecoderTest, CompressedTexImage2DGLError) {
2997 // TODO(gman): CompressedTexImage2D
2999 // TODO(gman): CompressedTexImage2DImmediate
3001 // TODO(gman): CompressedTexSubImage2DImmediate
3003 // TODO(gman): TexImage2D
3005 // TODO(gman): TexImage2DImmediate
3007 // TODO(gman): TexSubImage2DImmediate
3009 } // namespace gles2