diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-25 21:43:37 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-25 21:43:37 +0000 |
commit | cf6b8f6638e97929ffb632675a90c50c65446305 (patch) | |
tree | 54c1c676efd4c7768c2ecd9e22d8a6590de5582e /gpu/command_buffer/service | |
parent | 36d4896f7eda12f16307ac6657f5a682dcae7a4d (diff) | |
download | chromium_src-cf6b8f6638e97929ffb632675a90c50c65446305.zip chromium_src-cf6b8f6638e97929ffb632675a90c50c65446305.tar.gz chromium_src-cf6b8f6638e97929ffb632675a90c50c65446305.tar.bz2 |
Defer initializing the CopyTextureCHROMIUMResourceManager
It is takes 10s of milliseconds to initialize.
Review URL: https://chromiumcodereview.appspot.com/10450030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139127 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service')
3 files changed, 11 insertions, 137 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index d67fe8c..c8cfeff 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -2017,10 +2017,6 @@ bool GLES2DecoderImpl::Initialize( } CHECK_GL_ERROR(); - copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); - copy_texture_CHROMIUM_->Initialize(); - CHECK_GL_ERROR(); - disallowed_features_ = disallowed_features; vertex_attrib_manager_.reset(new VertexAttribManager()); @@ -8506,6 +8502,17 @@ void GLES2DecoderImpl::DoCopyTextureCHROMIUM( return; } + // Defer initializing the CopyTextureCHROMIUMResourceManager until it is + // needed because it takes 10s of milliseconds to initialize. + if (!copy_texture_CHROMIUM_.get()) { + CopyRealGLErrorsToWrapper(); + copy_texture_CHROMIUM_.reset(new CopyTextureCHROMIUMResourceManager()); + copy_texture_CHROMIUM_->Initialize(); + RestoreCurrentFramebufferBindings(); + if (PeekGLError() != GL_NO_ERROR) + return; + } + GLenum dest_type; GLenum dest_internal_format; bool dest_level_defined = dest_info->GetLevelSize(GL_TEXTURE_2D, level, 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 e0ce937..2886ed1 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc @@ -72,125 +72,6 @@ void GLES2DecoderTestBase::AddExpectationsForVertexAttribManager() { } } -// Setup the expectations required for the inialiazation of the resources -// used by the GL_CHROMIUM_copy_texture extension. -void GLES2DecoderTestBase::AddExpectationsForCopyTextureCHROMIUM() { - static GLuint copy_texture_chromium_buffer_ids[] = { - kServiceCopyTextureChromiumVertexBufferId, - kServiceCopyTextureChromiumTextureBufferId - }; - EXPECT_CALL(*gl_, GenBuffersARB(arraysize(copy_texture_chromium_buffer_ids), - _)) - .WillOnce(SetArrayArgument<1>(copy_texture_chromium_buffer_ids, - copy_texture_chromium_buffer_ids + arraysize( - copy_texture_chromium_buffer_ids))) - .RetiresOnSaturation(); - - EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, - kServiceCopyTextureChromiumVertexBufferId)) - .Times(1) - .RetiresOnSaturation(); - - EXPECT_CALL(*gl_, BufferData(GL_ARRAY_BUFFER, 16 * sizeof(GLfloat), _, - GL_STATIC_DRAW)) - .Times(1) - .RetiresOnSaturation(); - - EXPECT_CALL(*gl_, BindBuffer(GL_ARRAY_BUFFER, - kServiceCopyTextureChromiumTextureBufferId)) - .Times(1) - .RetiresOnSaturation(); - - EXPECT_CALL(*gl_, BufferData(GL_ARRAY_BUFFER, 8 * sizeof(GLfloat), _, - GL_STATIC_DRAW)) - .Times(1) - .RetiresOnSaturation(); - - static GLuint copy_texture_chromium_fbo_ids[] = { - kServiceCopyTextureChromiumFBOId - }; - EXPECT_CALL(*gl_, GenFramebuffersEXT(arraysize(copy_texture_chromium_fbo_ids), - _)) - .WillOnce(SetArrayArgument<1>(copy_texture_chromium_fbo_ids, - copy_texture_chromium_fbo_ids + arraysize( - copy_texture_chromium_fbo_ids))) - .RetiresOnSaturation(); - - for (int shader = 0; shader < 5; ++shader) { - EXPECT_CALL(*gl_, CreateShader( - shader == 0 ? GL_VERTEX_SHADER : GL_FRAGMENT_SHADER)) - .WillOnce(Return(kServiceCopyTextureChromiumShaderId + shader)) - .RetiresOnSaturation(); - - EXPECT_CALL(*gl_, ShaderSource(kServiceCopyTextureChromiumShaderId + shader, - 1, _, 0)) - .Times(1) - .RetiresOnSaturation(); - - EXPECT_CALL(*gl_, CompileShader( - kServiceCopyTextureChromiumShaderId + shader)) - .Times(1) - .RetiresOnSaturation(); -#ifndef NDEBUG - EXPECT_CALL(*gl_, GetShaderiv(kServiceCopyTextureChromiumShaderId + shader, - GL_COMPILE_STATUS, _)) - .WillOnce(SetArgPointee<2>(GL_TRUE)) - .RetiresOnSaturation(); -#endif - } - - for (int program = 0; program < 4; ++program) { - EXPECT_CALL(*gl_, CreateProgram()) - .WillOnce(Return(kServiceCopyTextureChromiumProgramId + program)) - .RetiresOnSaturation(); - - EXPECT_CALL(*gl_, AttachShader( - kServiceCopyTextureChromiumProgramId + program, - kServiceCopyTextureChromiumShaderId)) - .Times(1) - .RetiresOnSaturation(); - - EXPECT_CALL(*gl_, AttachShader( - kServiceCopyTextureChromiumProgramId + program, - kServiceCopyTextureChromiumShaderId + program + 1)) - .Times(1) - .RetiresOnSaturation(); - - EXPECT_CALL(*gl_, BindAttribLocation( - kServiceCopyTextureChromiumProgramId + program, 0, _)) - .Times(1) - .RetiresOnSaturation(); - - EXPECT_CALL(*gl_, BindAttribLocation( - kServiceCopyTextureChromiumProgramId + program, 1, _)) - .Times(1) - .RetiresOnSaturation(); - - EXPECT_CALL(*gl_, LinkProgram( - kServiceCopyTextureChromiumProgramId + program)) - .Times(1) - .RetiresOnSaturation(); - -#ifndef NDEBUG - EXPECT_CALL(*gl_, GetProgramiv( - kServiceCopyTextureChromiumProgramId + program, GL_LINK_STATUS, _)) - .WillOnce(SetArgPointee<2>(true)) - .RetiresOnSaturation(); -#endif - - EXPECT_CALL(*gl_, GetUniformLocation( - kServiceCopyTextureChromiumProgramId + program, _)) - .WillOnce(Return(kServiceCopyTextureChromiumSamplerLocation)) - .RetiresOnSaturation(); - } - - for (int shader = 0; shader < 5; ++shader) - EXPECT_CALL(*gl_, - DeleteShader(kServiceCopyTextureChromiumShaderId + shader)) - .Times(1) - .RetiresOnSaturation(); -} - void GLES2DecoderTestBase::InitDecoder( const char* extensions, bool has_alpha, @@ -211,7 +92,6 @@ void GLES2DecoderTestBase::InitDecoder( EXPECT_TRUE(group_->Initialize(DisallowedFeatures(), NULL)); - AddExpectationsForCopyTextureCHROMIUM(); AddExpectationsForVertexAttribManager(); EXPECT_CALL(*gl_, EnableVertexAttribArray(0)) @@ -377,18 +257,6 @@ void GLES2DecoderTestBase::TearDown() { // All Tests should have read all their GLErrors before getting here. EXPECT_EQ(GL_NO_ERROR, GetGLError()); - EXPECT_CALL(*gl_, DeleteFramebuffersEXT(1, - Pointee(kServiceCopyTextureChromiumFBOId))) - .Times(1) - .RetiresOnSaturation(); - - EXPECT_CALL(*gl_, DeleteProgram(_)) - .Times(4) - .RetiresOnSaturation(); - - EXPECT_CALL(*gl_, DeleteBuffersARB(2, _)) - .Times(1) - .RetiresOnSaturation(); EXPECT_CALL(*gl_, DeleteBuffersARB(1, _)) .Times(2) diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h index 37debd3..f98f0fc 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h @@ -500,7 +500,6 @@ class GLES2DecoderTestBase : public testing::Test { Buffer invalid_buffer_; }; - void AddExpectationsForCopyTextureCHROMIUM(); void AddExpectationsForVertexAttribManager(); scoped_ptr< ::testing::StrictMock<MockCommandBufferEngine> > engine_; |