diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-19 09:50:45 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-19 09:50:45 +0000 |
commit | a2fee40504a1f7c2805aade4fbcf65be04ef6138 (patch) | |
tree | 6242918754f3133475e6a749a43434fa6d60ed85 /gpu | |
parent | d9bccd0ba566a40460a3520b7a9cbd4940ada88f (diff) | |
download | chromium_src-a2fee40504a1f7c2805aade4fbcf65be04ef6138.zip chromium_src-a2fee40504a1f7c2805aade4fbcf65be04ef6138.tar.gz chromium_src-a2fee40504a1f7c2805aade4fbcf65be04ef6138.tar.bz2 |
Set default GL state
TEST=unit tests
BUG=130617
Review URL: https://chromiumcodereview.appspot.com/10573004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142931 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder.cc | 39 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc | 111 |
2 files changed, 150 insertions, 0 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 091b96b..7bc3b10 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -2263,6 +2263,45 @@ bool GLES2DecoderImpl::Initialize( viewport_max_width_ = viewport_params[0]; viewport_max_height_ = viewport_params[1]; + // Set all the default state because some GL drivers get it wrong. + glActiveTexture(GL_TEXTURE0 + active_texture_unit_); + glLineWidth(1.0); + EnableDisable(GL_BLEND, enable_blend_); + glBlendColor(0.0f, 0.0, 0.0f, 0.0f); + glBlendFunc(GL_ONE, GL_ZERO); + glBlendEquation(GL_ADD); + glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ONE, GL_ZERO); + glClearColor(clear_red_, clear_green_, clear_blue_, clear_alpha_); + glColorMask(mask_red_, mask_green_, mask_blue_, mask_alpha_); + EnableDisable(GL_CULL_FACE, enable_cull_face_); + glCullFace(GL_BACK); + glClearDepth(clear_depth_); + glDepthFunc(GL_LESS); + glDepthRange(0.0f, 1.0f); + EnableDisable(GL_DEPTH_TEST, enable_depth_test_); + glEnable(GL_DITHER); + glFrontFace(GL_CCW); + glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE); + glLineWidth(1.0f); + glPixelStorei(GL_PACK_ALIGNMENT, pack_alignment_); + glPolygonOffset(0.0f, 0.0f); + glDisable(GL_POLYGON_OFFSET_FILL); + glSampleCoverage(1.0, false); + glScissor(viewport_x_, viewport_y_, viewport_width_, viewport_height_); + EnableDisable(GL_SCISSOR_TEST, enable_scissor_test_); + EnableDisable(GL_STENCIL_TEST, enable_stencil_test_); + glClearStencil(clear_stencil_); + glStencilFunc(GL_ALWAYS, 0, 0xFFFFFFFFU); + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); + glStencilMaskSeparate(GL_FRONT, mask_stencil_front_); + glStencilMaskSeparate(GL_BACK, mask_stencil_back_); + glPixelStorei(GL_UNPACK_ALIGNMENT, unpack_alignment_); + + DoBindBuffer(GL_ARRAY_BUFFER, 0); + DoBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + DoBindFramebuffer(GL_FRAMEBUFFER, 0); + DoBindRenderbuffer(GL_RENDERBUFFER, 0); + return true; } diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc index 7de1375..b942e9d 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc @@ -190,6 +190,117 @@ void GLES2DecoderTestBase::InitDecoder( max_viewport_dims, max_viewport_dims + arraysize(max_viewport_dims))) .RetiresOnSaturation(); + EXPECT_CALL(*gl_, ActiveTexture(GL_TEXTURE0)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, LineWidth(1.0)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, Disable(GL_BLEND)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, BlendColor(0.0f, 0.0, 0.0f, 0.0f)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, BlendFunc(GL_ONE, GL_ZERO)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, BlendEquation(GL_ADD)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, BlendFuncSeparate(GL_ONE, GL_ZERO, GL_ONE, GL_ZERO)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, ClearColor(0.0f, 0.0, 0.0f, 0.0f)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, ColorMask(true, true, true, true)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, Disable(GL_CULL_FACE)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, CullFace(GL_BACK)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, ClearDepth(1.0f)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, DepthFunc(GL_LESS)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, DepthRange(0.0f, 1.0f)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, Disable(GL_DEPTH_TEST)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, Enable(GL_DITHER)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, FrontFace(GL_CCW)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, Hint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, LineWidth(1.0f)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, PixelStorei(GL_PACK_ALIGNMENT, 4)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, PolygonOffset(0.0f, 0.0f)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, Disable(GL_POLYGON_OFFSET_FILL)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, SampleCoverage(1.0, false)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, Scissor( + kViewportX, kViewportY, kViewportWidth, kViewportHeight)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, Disable(GL_SCISSOR_TEST)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, Disable(GL_STENCIL_TEST)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, ClearStencil(0)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, StencilFunc(GL_ALWAYS, 0, 0xFFFFFFFFU)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, StencilOp(GL_KEEP, GL_KEEP, GL_KEEP)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, StencilMaskSeparate(GL_FRONT, 0xFFFFFFFFU)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, StencilMaskSeparate(GL_BACK, 0xFFFFFFFFU)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, PixelStorei(GL_UNPACK_ALIGNMENT, 4)) + .Times(1) + .RetiresOnSaturation(); + + EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, 0)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, BindFramebufferEXT(GL_FRAMEBUFFER, 0)) + .Times(1) + .RetiresOnSaturation(); + EXPECT_CALL(*gl_, BindRenderbufferEXT(GL_RENDERBUFFER, 0)) + .Times(1) + .RetiresOnSaturation(); + engine_.reset(new StrictMock<MockCommandBufferEngine>()); Buffer buffer = engine_->GetSharedMemoryBuffer(kSharedMemoryId); shared_memory_offset_ = kSharedMemoryOffset; |