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 3398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3409 // Attempt to consume the mailbox when no texture has been produced with it. | 3409 // Attempt to consume the mailbox when no texture has been produced with it. |
3410 Mailbox mailbox = Mailbox::Generate(); | 3410 Mailbox mailbox = Mailbox::Generate(); |
3411 GLuint new_texture_id = kNewClientId; | 3411 GLuint new_texture_id = kNewClientId; |
3412 | 3412 |
3413 EXPECT_CALL(*gl_, GenTextures(1, _)) | 3413 EXPECT_CALL(*gl_, GenTextures(1, _)) |
3414 .WillOnce(SetArgPointee<1>(kNewServiceId)) | 3414 .WillOnce(SetArgPointee<1>(kNewServiceId)) |
3415 .RetiresOnSaturation(); | 3415 .RetiresOnSaturation(); |
3416 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, _)) | 3416 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, _)) |
3417 .Times(2) | 3417 .Times(2) |
3418 .RetiresOnSaturation(); | 3418 .RetiresOnSaturation(); |
3419 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) | 3419 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)).Times(1).RetiresOnSaturation(); |
3420 .Times(1) | 3420 |
3421 .RetiresOnSaturation(); | 3421 ActiveTexture& texture_cmd = *GetImmediateAs<ActiveTexture>(); |
| 3422 texture_cmd.Init(GL_TEXTURE1); |
| 3423 EXPECT_EQ(error::kNoError, ExecuteCmd(texture_cmd)); |
3422 | 3424 |
3423 CreateAndConsumeTextureINTERNALImmediate& consume_cmd = | 3425 CreateAndConsumeTextureINTERNALImmediate& consume_cmd = |
3424 *GetImmediateAs<CreateAndConsumeTextureINTERNALImmediate>(); | 3426 *GetImmediateAs<CreateAndConsumeTextureINTERNALImmediate>(); |
3425 consume_cmd.Init(GL_TEXTURE_2D, new_texture_id, mailbox.name); | 3427 consume_cmd.Init(GL_TEXTURE_2D, new_texture_id, mailbox.name); |
3426 EXPECT_EQ(error::kNoError, | 3428 EXPECT_EQ(error::kNoError, |
3427 ExecuteImmediateCmd(consume_cmd, sizeof(mailbox.name))); | 3429 ExecuteImmediateCmd(consume_cmd, sizeof(mailbox.name))); |
3428 | 3430 |
3429 // CreateAndConsumeTexture should fail if the mailbox isn't associated with a | 3431 // CreateAndConsumeTexture should fail if the mailbox isn't associated with a |
3430 // texture. | 3432 // texture. |
3431 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); | 3433 EXPECT_EQ(GL_INVALID_OPERATION, GetGLError()); |
(...skipping 24 matching lines...) Expand all Loading... |
3456 EXPECT_EQ(error::kNoError, | 3458 EXPECT_EQ(error::kNoError, |
3457 ExecuteImmediateCmd(produce_cmd, sizeof(mailbox.name))); | 3459 ExecuteImmediateCmd(produce_cmd, sizeof(mailbox.name))); |
3458 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 3460 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
3459 | 3461 |
3460 EXPECT_CALL(*gl_, GenTextures(1, _)) | 3462 EXPECT_CALL(*gl_, GenTextures(1, _)) |
3461 .WillOnce(SetArgPointee<1>(kNewServiceId)) | 3463 .WillOnce(SetArgPointee<1>(kNewServiceId)) |
3462 .RetiresOnSaturation(); | 3464 .RetiresOnSaturation(); |
3463 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, _)) | 3465 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_CUBE_MAP, _)) |
3464 .Times(2) | 3466 .Times(2) |
3465 .RetiresOnSaturation(); | 3467 .RetiresOnSaturation(); |
3466 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) | 3468 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)).Times(1).RetiresOnSaturation(); |
3467 .Times(1) | 3469 |
3468 .RetiresOnSaturation(); | 3470 ActiveTexture& texture_cmd = *GetImmediateAs<ActiveTexture>(); |
| 3471 texture_cmd.Init(GL_TEXTURE1); |
| 3472 EXPECT_EQ(error::kNoError, ExecuteCmd(texture_cmd)); |
3469 | 3473 |
3470 // Attempt to consume the mailbox with a different target. | 3474 // Attempt to consume the mailbox with a different target. |
3471 GLuint new_texture_id = kNewClientId; | 3475 GLuint new_texture_id = kNewClientId; |
3472 CreateAndConsumeTextureINTERNALImmediate& consume_cmd = | 3476 CreateAndConsumeTextureINTERNALImmediate& consume_cmd = |
3473 *GetImmediateAs<CreateAndConsumeTextureINTERNALImmediate>(); | 3477 *GetImmediateAs<CreateAndConsumeTextureINTERNALImmediate>(); |
3474 consume_cmd.Init(GL_TEXTURE_CUBE_MAP, new_texture_id, mailbox.name); | 3478 consume_cmd.Init(GL_TEXTURE_CUBE_MAP, new_texture_id, mailbox.name); |
3475 EXPECT_EQ(error::kNoError, | 3479 EXPECT_EQ(error::kNoError, |
3476 ExecuteImmediateCmd(consume_cmd, sizeof(mailbox.name))); | 3480 ExecuteImmediateCmd(consume_cmd, sizeof(mailbox.name))); |
3477 | 3481 |
3478 // CreateAndConsumeTexture should fail if the produced texture had a different | 3482 // CreateAndConsumeTexture should fail if the produced texture had a different |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3865 Texture* texture = texture_ref->texture(); | 3869 Texture* texture = texture_ref->texture(); |
3866 EXPECT_EQ(kServiceTextureId, texture->service_id()); | 3870 EXPECT_EQ(kServiceTextureId, texture->service_id()); |
3867 | 3871 |
3868 const int32_t kImageId = 1; | 3872 const int32_t kImageId = 1; |
3869 scoped_refptr<MockGLImage> image(new MockGLImage); | 3873 scoped_refptr<MockGLImage> image(new MockGLImage); |
3870 GetImageManager()->AddImage(image.get(), kImageId); | 3874 GetImageManager()->AddImage(image.get(), kImageId); |
3871 | 3875 |
3872 // Bind image to texture. | 3876 // Bind image to texture. |
3873 EXPECT_CALL(*image.get(), BindTexImage(GL_TEXTURE_2D)) | 3877 EXPECT_CALL(*image.get(), BindTexImage(GL_TEXTURE_2D)) |
3874 .Times(1) | 3878 .Times(1) |
3875 .WillOnce(Return(false)) | 3879 .WillRepeatedly(Return(false)) |
3876 .RetiresOnSaturation(); | 3880 .RetiresOnSaturation(); |
3877 EXPECT_CALL(*image.get(), GetSize()) | 3881 EXPECT_CALL(*image.get(), GetSize()) |
3878 .Times(1) | 3882 .Times(1) |
3879 .WillOnce(Return(gfx::Size(1, 1))) | 3883 .WillOnce(Return(gfx::Size(1, 1))) |
3880 .RetiresOnSaturation(); | 3884 .RetiresOnSaturation(); |
3881 EXPECT_CALL(*image.get(), GetInternalFormat()) | 3885 EXPECT_CALL(*image.get(), GetInternalFormat()) |
3882 .Times(1) | 3886 .Times(1) |
3883 .WillOnce(Return(GL_RGBA)) | 3887 .WillOnce(Return(GL_RGBA)) |
3884 .RetiresOnSaturation(); | 3888 .RetiresOnSaturation(); |
3885 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. | 3889 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. |
3886 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId); | 3890 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId); |
| 3891 Mock::VerifyAndClearExpectations(gl_.get()); |
| 3892 |
| 3893 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)).Times(1).RetiresOnSaturation(); |
| 3894 ActiveTexture texture_cmd; |
| 3895 texture_cmd.Init(GL_TEXTURE1); |
| 3896 EXPECT_EQ(error::kNoError, ExecuteCmd(texture_cmd)); |
| 3897 Mock::VerifyAndClearExpectations(gl_.get()); |
3887 | 3898 |
3888 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); | 3899 AddExpectationsForSimulatedAttrib0(kNumVertices, 0); |
3889 SetupExpectationsForApplyingDefaultDirtyState(); | 3900 SetupExpectationsForApplyingDefaultDirtyState(); |
3890 | 3901 |
3891 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. | 3902 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. |
3892 EXPECT_CALL(*gl_, GetError()) | 3903 EXPECT_CALL(*gl_, GetError()) |
3893 .WillOnce(Return(GL_NO_ERROR)) | 3904 .WillOnce(Return(GL_NO_ERROR)) |
3894 .WillOnce(Return(GL_NO_ERROR)) | 3905 .WillOnce(Return(GL_NO_ERROR)) |
3895 .RetiresOnSaturation(); | 3906 .RetiresOnSaturation(); |
3896 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(2).RetiresOnSaturation(); | 3907 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) |
3897 EXPECT_CALL(*image.get(), CopyTexImage(GL_TEXTURE_2D)) | |
3898 .Times(1) | |
3899 .WillOnce(Return(true)) | |
3900 .RetiresOnSaturation(); | |
3901 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | |
3902 .Times(1) | 3908 .Times(1) |
3903 .RetiresOnSaturation(); | 3909 .RetiresOnSaturation(); |
| 3910 { |
| 3911 InSequence seq; |
| 3912 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) |
| 3913 .Times(1) |
| 3914 .RetiresOnSaturation(); |
| 3915 EXPECT_CALL(*image.get(), BindTexImage(GL_TEXTURE_2D)) |
| 3916 .Times(1) |
| 3917 .WillRepeatedly(Return(false)) |
| 3918 .RetiresOnSaturation(); |
| 3919 EXPECT_CALL(*image.get(), CopyTexImage(GL_TEXTURE_2D)) |
| 3920 .Times(1) |
| 3921 .WillOnce(Return(true)) |
| 3922 .RetiresOnSaturation(); |
| 3923 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) |
| 3924 .Times(1) |
| 3925 .RetiresOnSaturation(); |
| 3926 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE1)) |
| 3927 .Times(1) |
| 3928 .RetiresOnSaturation(); |
| 3929 } |
| 3930 |
3904 DrawArrays cmd; | 3931 DrawArrays cmd; |
3905 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | 3932 cmd.Init(GL_TRIANGLES, 0, kNumVertices); |
3906 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 3933 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
3907 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 3934 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
3908 | 3935 |
3909 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); | 3936 DoBindTexture(GL_TEXTURE_2D, client_texture_id_, kServiceTextureId); |
| 3937 |
| 3938 Mock::VerifyAndClearExpectations(gl_.get()); |
3910 // Re-bind image to texture. | 3939 // Re-bind image to texture. |
3911 ReleaseTexImage2DCHROMIUM release_tex_image_2d_cmd; | 3940 ReleaseTexImage2DCHROMIUM release_tex_image_2d_cmd; |
3912 release_tex_image_2d_cmd.Init(GL_TEXTURE_2D, kImageId); | 3941 release_tex_image_2d_cmd.Init(GL_TEXTURE_2D, kImageId); |
3913 EXPECT_EQ(error::kNoError, ExecuteCmd(release_tex_image_2d_cmd)); | 3942 EXPECT_EQ(error::kNoError, ExecuteCmd(release_tex_image_2d_cmd)); |
3914 EXPECT_CALL(*image.get(), BindTexImage(GL_TEXTURE_2D)) | 3943 EXPECT_CALL(*image.get(), BindTexImage(GL_TEXTURE_2D)) |
3915 .Times(1) | 3944 .Times(2) |
3916 .WillOnce(Return(false)) | 3945 .WillRepeatedly(Return(false)) |
3917 .RetiresOnSaturation(); | 3946 .RetiresOnSaturation(); |
3918 EXPECT_CALL(*image.get(), GetSize()) | 3947 EXPECT_CALL(*image.get(), GetSize()) |
3919 .Times(1) | 3948 .Times(1) |
3920 .WillOnce(Return(gfx::Size(1, 1))) | 3949 .WillOnce(Return(gfx::Size(1, 1))) |
3921 .RetiresOnSaturation(); | 3950 .RetiresOnSaturation(); |
3922 EXPECT_CALL(*image.get(), GetInternalFormat()) | 3951 EXPECT_CALL(*image.get(), GetInternalFormat()) |
3923 .Times(1) | 3952 .Times(1) |
3924 .WillOnce(Return(GL_RGBA)) | 3953 .WillOnce(Return(GL_RGBA)) |
3925 .RetiresOnSaturation(); | 3954 .RetiresOnSaturation(); |
3926 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId); | 3955 DoBindTexImage2DCHROMIUM(GL_TEXTURE_2D, kImageId); |
3927 | 3956 |
3928 DoBindFramebuffer( | 3957 DoBindFramebuffer( |
3929 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); | 3958 GL_FRAMEBUFFER, client_framebuffer_id_, kServiceFramebufferId); |
3930 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. | 3959 // ScopedGLErrorSuppressor calls GetError on its constructor and destructor. |
3931 EXPECT_CALL(*gl_, GetError()) | 3960 EXPECT_CALL(*gl_, GetError()) |
3932 .WillOnce(Return(GL_NO_ERROR)) | 3961 .WillOnce(Return(GL_NO_ERROR)) |
3933 .WillOnce(Return(GL_NO_ERROR)) | 3962 .WillOnce(Return(GL_NO_ERROR)) |
3934 .RetiresOnSaturation(); | 3963 .RetiresOnSaturation(); |
3935 EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)).Times(1).RetiresOnSaturation(); | |
3936 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) | 3964 EXPECT_CALL(*gl_, BindTexture(GL_TEXTURE_2D, kServiceTextureId)) |
3937 .Times(2) | 3965 .Times(2) |
3938 .RetiresOnSaturation(); | 3966 .RetiresOnSaturation(); |
3939 EXPECT_CALL(*image.get(), CopyTexImage(GL_TEXTURE_2D)) | 3967 EXPECT_CALL(*image.get(), CopyTexImage(GL_TEXTURE_2D)) |
3940 .Times(1) | 3968 .Times(1) |
3941 .WillOnce(Return(true)) | 3969 .WillOnce(Return(true)) |
3942 .RetiresOnSaturation(); | 3970 .RetiresOnSaturation(); |
3943 EXPECT_CALL(*gl_, | 3971 EXPECT_CALL(*gl_, |
3944 FramebufferTexture2DEXT(GL_FRAMEBUFFER, | 3972 FramebufferTexture2DEXT(GL_FRAMEBUFFER, |
3945 GL_COLOR_ATTACHMENT0, | 3973 GL_COLOR_ATTACHMENT0, |
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4966 // TODO(gman): CompressedTexSubImage2DImmediate | 4994 // TODO(gman): CompressedTexSubImage2DImmediate |
4967 | 4995 |
4968 // TODO(gman): TexImage2D | 4996 // TODO(gman): TexImage2D |
4969 | 4997 |
4970 // TODO(gman): TexImage2DImmediate | 4998 // TODO(gman): TexImage2DImmediate |
4971 | 4999 |
4972 // TODO(gman): TexSubImage2DImmediate | 5000 // TODO(gman): TexSubImage2DImmediate |
4973 | 5001 |
4974 } // namespace gles2 | 5002 } // namespace gles2 |
4975 } // namespace gpu | 5003 } // namespace gpu |
OLD | NEW |