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 <limits.h> | 7 #include <limits.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 4020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4031 BlitFramebufferCHROMIUM cmd; | 4031 BlitFramebufferCHROMIUM cmd; |
4032 cmd.Init(0, 0, 1, 1, 0, 0, 1, 1, GL_DEPTH_BUFFER_BIT, GL_NEAREST); | 4032 cmd.Init(0, 0, 1, 1, 0, 0, 1, 1, GL_DEPTH_BUFFER_BIT, GL_NEAREST); |
4033 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 4033 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
4034 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 4034 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
4035 cmd.Init(0, 0, 1, 1, 0, 0, 1, 1, GL_STENCIL_BUFFER_BIT, GL_NEAREST); | 4035 cmd.Init(0, 0, 1, 1, 0, 0, 1, 1, GL_STENCIL_BUFFER_BIT, GL_NEAREST); |
4036 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 4036 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
4037 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 4037 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
4038 } | 4038 } |
4039 } | 4039 } |
4040 | 4040 |
| 4041 class GLES2DecoderTestWithDrawRectangle : public GLES2DecoderTest { |
| 4042 void SetUp() override { |
| 4043 surface_supports_draw_rectangle_ = true; |
| 4044 GLES2DecoderTest::SetUp(); |
| 4045 } |
| 4046 }; |
| 4047 |
| 4048 // Test that the draw offset is correctly honored when SetDrawRectangle is |
| 4049 // supported. |
| 4050 TEST_P(GLES2DecoderTestWithDrawRectangle, FramebufferDrawRectangleClear) { |
| 4051 EXPECT_CALL(*gl_, Scissor(101, 202, 3, 4)).Times(1).RetiresOnSaturation(); |
| 4052 cmds::Scissor scissor_cmd; |
| 4053 scissor_cmd.Init(1, 2, 3, 4); |
| 4054 EXPECT_EQ(error::kNoError, ExecuteCmd(scissor_cmd)); |
| 4055 |
| 4056 // Scissor and Viewport should be restored to (0,0) offset on when clearing |
| 4057 // a framebuffer. |
| 4058 { |
| 4059 const GLuint kFBOClientTextureId = 4100; |
| 4060 const GLuint kFBOServiceTextureId = 4101; |
| 4061 |
| 4062 // Register a texture id. |
| 4063 EXPECT_CALL(*gl_, GenTextures(_, _)) |
| 4064 .WillOnce(SetArgPointee<1>(kFBOServiceTextureId)) |
| 4065 .RetiresOnSaturation(); |
| 4066 GenHelper<GenTexturesImmediate>(kFBOClientTextureId); |
| 4067 |
| 4068 // Setup "render to" texture. |
| 4069 DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId); |
| 4070 DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
| 4071 0, 0); |
| 4072 DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, |
| 4073 kServiceFramebufferId); |
| 4074 DoFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, |
| 4075 kFBOClientTextureId, kFBOServiceTextureId, 0, |
| 4076 GL_NO_ERROR); |
| 4077 // Set scissor rect and enable GL_SCISSOR_TEST to make sure we re-enable it |
| 4078 // and restore the rect again after the clear. |
| 4079 DoEnableDisable(GL_SCISSOR_TEST, true); |
| 4080 EXPECT_CALL(*gl_, Viewport(0, 0, 128, 64)).Times(1).RetiresOnSaturation(); |
| 4081 EXPECT_CALL(*gl_, Scissor(1, 2, 3, 4)).Times(1).RetiresOnSaturation(); |
| 4082 |
| 4083 // Setup "render from" texture. |
| 4084 SetupTexture(); |
| 4085 |
| 4086 SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER, // target |
| 4087 GL_COLOR_BUFFER_BIT, // clear bits |
| 4088 0, 0, 0, |
| 4089 0, // color |
| 4090 0, // stencil |
| 4091 1.0f, // depth |
| 4092 true, // scissor test |
| 4093 1, 2, 3, 4); |
| 4094 SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB |
| 4095 false, // Framebuffer has depth |
| 4096 false, // Framebuffer has stencil |
| 4097 0x1111, // color bits |
| 4098 false, // depth mask |
| 4099 false, // depth enabled |
| 4100 0, // front stencil mask |
| 4101 0, // back stencil mask |
| 4102 false); // stencil enabled |
| 4103 |
| 4104 EXPECT_CALL(*gl_, Clear(GL_COLOR_BUFFER_BIT)) |
| 4105 .Times(1) |
| 4106 .RetiresOnSaturation(); |
| 4107 |
| 4108 Clear cmd; |
| 4109 cmd.Init(GL_COLOR_BUFFER_BIT); |
| 4110 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4111 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4112 } |
| 4113 |
| 4114 // Check that the draw offset is used when switching to the default |
| 4115 // framebuffer and clearing it. |
| 4116 { |
| 4117 DoBindFramebuffer(GL_FRAMEBUFFER, 0, 0); |
| 4118 EXPECT_CALL(*gl_, Clear(GL_COLOR_BUFFER_BIT)) |
| 4119 .Times(1) |
| 4120 .RetiresOnSaturation(); |
| 4121 SetupExpectationsForColorMask(true, true, true, true); |
| 4122 SetupExpectationsForDepthMask(true); |
| 4123 SetupExpectationsForStencilMask(0, 0); |
| 4124 SetupExpectationsForEnableDisable(GL_DEPTH_TEST, false); |
| 4125 SetupExpectationsForEnableDisable(GL_STENCIL_TEST, false); |
| 4126 EXPECT_CALL(*gl_, Viewport(100, 200, 128, 64)) |
| 4127 .Times(1) |
| 4128 .RetiresOnSaturation(); |
| 4129 EXPECT_CALL(*gl_, Scissor(101, 202, 3, 4)).Times(1).RetiresOnSaturation(); |
| 4130 Clear cmd; |
| 4131 cmd.Init(GL_COLOR_BUFFER_BIT); |
| 4132 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
| 4133 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
| 4134 } |
| 4135 } |
| 4136 |
| 4137 INSTANTIATE_TEST_CASE_P(Service, |
| 4138 GLES2DecoderTestWithDrawRectangle, |
| 4139 ::testing::Bool()); |
| 4140 |
4041 // TODO(gman): PixelStorei | 4141 // TODO(gman): PixelStorei |
4042 | 4142 |
4043 // TODO(gman): SwapBuffers | 4143 // TODO(gman): SwapBuffers |
4044 | 4144 |
4045 } // namespace gles2 | 4145 } // namespace gles2 |
4046 } // namespace gpu | 4146 } // namespace gpu |
OLD | NEW |