Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 using ::testing::Mock; | 42 using ::testing::Mock; |
| 43 using ::testing::Pointee; | 43 using ::testing::Pointee; |
| 44 using ::testing::Return; | 44 using ::testing::Return; |
| 45 using ::testing::SaveArg; | 45 using ::testing::SaveArg; |
| 46 using ::testing::SetArrayArgument; | 46 using ::testing::SetArrayArgument; |
| 47 using ::testing::SetArgumentPointee; | 47 using ::testing::SetArgumentPointee; |
| 48 using ::testing::SetArgPointee; | 48 using ::testing::SetArgPointee; |
| 49 using ::testing::StrEq; | 49 using ::testing::StrEq; |
| 50 using ::testing::StrictMock; | 50 using ::testing::StrictMock; |
| 51 | 51 |
| 52 namespace { | |
| 53 class EmulatingRGBImageStub : public gl::GLImageStub { | |
| 54 protected: | |
| 55 ~EmulatingRGBImageStub() override {} | |
| 56 bool EmulatingRGB() const override { | |
| 57 return true; | |
| 58 } | |
| 59 }; | |
| 60 } // namespace | |
| 61 | |
| 52 namespace gpu { | 62 namespace gpu { |
| 53 namespace gles2 { | 63 namespace gles2 { |
| 54 | 64 |
| 55 using namespace cmds; | 65 using namespace cmds; |
| 56 | 66 |
| 57 TEST_P(GLES2DecoderTest, GenerateMipmapWrongFormatsFails) { | 67 TEST_P(GLES2DecoderTest, GenerateMipmapWrongFormatsFails) { |
| 58 EXPECT_CALL(*gl_, GenerateMipmapEXT(_)).Times(0); | 68 EXPECT_CALL(*gl_, GenerateMipmapEXT(_)).Times(0); |
| 59 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 69 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 60 DoTexImage2D( | 70 DoTexImage2D( |
| 61 GL_TEXTURE_2D, 0, GL_RGBA, 16, 17, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); | 71 GL_TEXTURE_2D, 0, GL_RGBA, 16, 17, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0, 0); |
| (...skipping 3607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3669 .Times(1) | 3679 .Times(1) |
| 3670 .RetiresOnSaturation(); | 3680 .RetiresOnSaturation(); |
| 3671 EXPECT_CALL(*gl_, BindTexture(kTarget, _)) | 3681 EXPECT_CALL(*gl_, BindTexture(kTarget, _)) |
| 3672 .Times(1) | 3682 .Times(1) |
| 3673 .RetiresOnSaturation(); | 3683 .RetiresOnSaturation(); |
| 3674 | 3684 |
| 3675 EXPECT_TRUE(decoder_->ClearLevel3D( | 3685 EXPECT_TRUE(decoder_->ClearLevel3D( |
| 3676 texture, kTarget, kLevel, kFormat, kType, kWidth, kHeight, kDepth)); | 3686 texture, kTarget, kLevel, kFormat, kType, kWidth, kHeight, kDepth)); |
| 3677 } | 3687 } |
| 3678 | 3688 |
| 3689 // Test that copyTexImage2D uses the emulated internal format, rather than the | |
| 3690 // real internal format. | |
| 3691 TEST_P(GLES2DecoderWithShaderTest, CHROMIUMImageEmulatingRGB) { | |
| 3692 const GLuint kFBOClientTextureId = 4100; | |
| 3693 const GLuint kFBOServiceTextureId = 4101; | |
| 3694 GLenum target = GL_TEXTURE_2D; | |
| 3695 GLint level = 0; | |
| 3696 GLsizei width = 1; | |
| 3697 GLsizei height = 1; | |
| 3698 | |
| 3699 // Generate the source framebuffer. | |
| 3700 EXPECT_CALL(*gl_, GenTextures(_, _)) | |
| 3701 .WillOnce(SetArgPointee<1>(kFBOServiceTextureId)) | |
| 3702 .RetiresOnSaturation(); | |
| 3703 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); | |
| 3704 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, | |
| 3705 kServiceFramebufferId); | |
| 3706 | |
| 3707 for (int image_id = 1; image_id < 3; ++image_id) { | |
| 3708 bool use_emulation = (image_id == 2); | |
| 3709 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); | |
| 3710 | |
| 3711 // Generate and bind the source image. | |
| 3712 scoped_refptr<gl::GLImage> image; | |
| 3713 if (use_emulation) | |
| 3714 image = new EmulatingRGBImageStub; | |
| 3715 else | |
| 3716 image = new gl::GLImageStub; | |
| 3717 GetImageManager()->AddImage(image.get(), image_id); | |
| 3718 EXPECT_FALSE(GetImageManager()->LookupImage(image_id) == NULL); | |
| 3719 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, image_id); | |
| 3720 DoFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, target, | |
| 3721 kFBOClientTextureId, kFBOServiceTextureId, level, | |
| 3722 GL_NO_ERROR); | |
| 3723 | |
| 3724 if (!use_emulation) { | |
| 3725 EXPECT_CALL(*gl_, GetError()) | |
| 3726 .WillOnce(Return(GL_NO_ERROR)) | |
| 3727 .RetiresOnSaturation(); | |
| 3728 EXPECT_CALL(*gl_, | |
| 3729 CopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 1, 1, 0)) | |
| 3730 .Times(1) | |
| 3731 .RetiresOnSaturation(); | |
| 3732 EXPECT_CALL(*gl_, GetError()) | |
| 3733 .WillOnce(Return(GL_NO_ERROR)) | |
| 3734 .RetiresOnSaturation(); | |
| 3735 } | |
| 3736 | |
| 3737 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) | |
| 3738 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) | |
| 3739 .RetiresOnSaturation(); | |
| 3740 | |
| 3741 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | |
| 3742 CopyTexImage2D cmd; | |
| 3743 cmd.Init(target, level, GL_RGBA, 0, 0, width, height); | |
|
piman
2016/04/14 21:51:37
Can you add a check that GL_RGB does work?
erikchen
2016/04/15 00:17:05
Done.
| |
| 3744 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | |
| 3745 GLenum expectation = use_emulation ? GL_INVALID_OPERATION : GL_NO_ERROR; | |
| 3746 EXPECT_EQ(expectation, static_cast<GLenum>(GetGLError())); | |
| 3747 } | |
| 3748 } | |
| 3749 | |
| 3679 // TODO(gman): Complete this test. | 3750 // TODO(gman): Complete this test. |
| 3680 // TEST_P(GLES2DecoderTest, CompressedTexImage2DGLError) { | 3751 // TEST_P(GLES2DecoderTest, CompressedTexImage2DGLError) { |
| 3681 // } | 3752 // } |
| 3682 | 3753 |
| 3683 // TODO(gman): CompressedTexImage2D | 3754 // TODO(gman): CompressedTexImage2D |
| 3684 | 3755 |
| 3685 // TODO(gman): CompressedTexImage2DImmediate | 3756 // TODO(gman): CompressedTexImage2DImmediate |
| 3686 | 3757 |
| 3687 // TODO(gman): CompressedTexSubImage2DImmediate | 3758 // TODO(gman): CompressedTexSubImage2DImmediate |
| 3688 | 3759 |
| 3689 // TODO(gman): TexImage2D | 3760 // TODO(gman): TexImage2D |
| 3690 | 3761 |
| 3691 // TODO(gman): TexImage2DImmediate | 3762 // TODO(gman): TexImage2DImmediate |
| 3692 | 3763 |
| 3693 // TODO(gman): TexSubImage2DImmediate | 3764 // TODO(gman): TexSubImage2DImmediate |
| 3694 | 3765 |
| 3695 } // namespace gles2 | 3766 } // namespace gles2 |
| 3696 } // namespace gpu | 3767 } // namespace gpu |
| OLD | NEW |