Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Unified Diff: gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc

Issue 2735853002: Offset scissor and viewport when using SetDrawRectangle on surface. (Closed)
Patch Set: remove flag Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc
index fbad893fcf5980c46e381231db12982031d7eb5d..0fc0769ee500e5adc51893148fc6937ccf9cbb13 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_framebuffers.cc
@@ -4038,6 +4038,106 @@ TEST_P(GLES3DecoderTest, BlitFramebufferMissingDepthOrStencil) {
}
}
+class GLES2DecoderTestWithDrawRectangle : public GLES2DecoderTest {
+ void SetUp() override {
+ surface_supports_draw_rectangle_ = true;
+ GLES2DecoderTest::SetUp();
+ }
+};
+
+// Test that the draw offset is correctly honored when SetDrawRectangle is
+// supported.
+TEST_P(GLES2DecoderTestWithDrawRectangle, FramebufferDrawRectangleClear) {
+ EXPECT_CALL(*gl_, Scissor(101, 202, 3, 4)).Times(1).RetiresOnSaturation();
+ cmds::Scissor scissor_cmd;
+ scissor_cmd.Init(1, 2, 3, 4);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(scissor_cmd));
+
+ // Scissor and Viewport should be restored to (0,0) offset on when clearing
+ // a framebuffer.
+ {
+ const GLuint kFBOClientTextureId = 4100;
+ const GLuint kFBOServiceTextureId = 4101;
+
+ // Register a texture id.
+ EXPECT_CALL(*gl_, GenTextures(_, _))
+ .WillOnce(SetArgPointee<1>(kFBOServiceTextureId))
+ .RetiresOnSaturation();
+ GenHelper<GenTexturesImmediate>(kFBOClientTextureId);
+
+ // Setup "render to" texture.
+ DoBindTexture(GL_TEXTURE_2D, kFBOClientTextureId, kFBOServiceTextureId);
+ DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
+ 0, 0);
+ DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_,
+ kServiceFramebufferId);
+ DoFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
+ kFBOClientTextureId, kFBOServiceTextureId, 0,
+ GL_NO_ERROR);
+ // Set scissor rect and enable GL_SCISSOR_TEST to make sure we re-enable it
+ // and restore the rect again after the clear.
+ DoEnableDisable(GL_SCISSOR_TEST, true);
+ EXPECT_CALL(*gl_, Viewport(0, 0, 128, 64)).Times(1).RetiresOnSaturation();
+ EXPECT_CALL(*gl_, Scissor(1, 2, 3, 4)).Times(1).RetiresOnSaturation();
+
+ // Setup "render from" texture.
+ SetupTexture();
+
+ SetupExpectationsForFramebufferClearing(GL_FRAMEBUFFER, // target
+ GL_COLOR_BUFFER_BIT, // clear bits
+ 0, 0, 0,
+ 0, // color
+ 0, // stencil
+ 1.0f, // depth
+ true, // scissor test
+ 1, 2, 3, 4);
+ SetupExpectationsForApplyingDirtyState(false, // Framebuffer is RGB
+ false, // Framebuffer has depth
+ false, // Framebuffer has stencil
+ 0x1111, // color bits
+ false, // depth mask
+ false, // depth enabled
+ 0, // front stencil mask
+ 0, // back stencil mask
+ false); // stencil enabled
+
+ EXPECT_CALL(*gl_, Clear(GL_COLOR_BUFFER_BIT))
+ .Times(1)
+ .RetiresOnSaturation();
+
+ Clear cmd;
+ cmd.Init(GL_COLOR_BUFFER_BIT);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+ }
+
+ // Check that the draw offset is used when switching to the default
+ // framebuffer and clearing it.
+ {
+ DoBindFramebuffer(GL_FRAMEBUFFER, 0, 0);
+ EXPECT_CALL(*gl_, Clear(GL_COLOR_BUFFER_BIT))
+ .Times(1)
+ .RetiresOnSaturation();
+ SetupExpectationsForColorMask(true, true, true, true);
+ SetupExpectationsForDepthMask(true);
+ SetupExpectationsForStencilMask(0, 0);
+ SetupExpectationsForEnableDisable(GL_DEPTH_TEST, false);
+ SetupExpectationsForEnableDisable(GL_STENCIL_TEST, false);
+ EXPECT_CALL(*gl_, Viewport(100, 200, 128, 64))
+ .Times(1)
+ .RetiresOnSaturation();
+ EXPECT_CALL(*gl_, Scissor(101, 202, 3, 4)).Times(1).RetiresOnSaturation();
+ Clear cmd;
+ cmd.Init(GL_COLOR_BUFFER_BIT);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+ EXPECT_EQ(GL_NO_ERROR, GetGLError());
+ }
+}
+
+INSTANTIATE_TEST_CASE_P(Service,
+ GLES2DecoderTestWithDrawRectangle,
+ ::testing::Bool());
+
// TODO(gman): PixelStorei
// TODO(gman): SwapBuffers
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc ('k') | gpu/ipc/service/direct_composition_surface_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698