diff options
author | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-08 19:22:44 +0000 |
---|---|---|
committer | piman@chromium.org <piman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-08 19:22:44 +0000 |
commit | 811f5f849de53c825808f38f59c64faa7af75bfd (patch) | |
tree | 0921ce9a03ea1739a1519c2476f6bd7617ebecb4 /content | |
parent | f6876fba5d77d53f90e258ac1bd1e47dc0bcd10e (diff) | |
download | chromium_src-811f5f849de53c825808f38f59c64faa7af75bfd.zip chromium_src-811f5f849de53c825808f38f59c64faa7af75bfd.tar.gz chromium_src-811f5f849de53c825808f38f59c64faa7af75bfd.tar.bz2 |
Fix asserts with compositor thread
BUG=113100
TEST=chrome --force-compositing-mode --enable-threaded-compositing google.com
Review URL: http://codereview.chromium.org/9361001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121018 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
5 files changed, 13 insertions, 17 deletions
diff --git a/content/common/gpu/client/command_buffer_proxy.cc b/content/common/gpu/client/command_buffer_proxy.cc index 62fce6d..1a25c1a 100644 --- a/content/common/gpu/client/command_buffer_proxy.cc +++ b/content/common/gpu/client/command_buffer_proxy.cc @@ -100,9 +100,6 @@ void CommandBufferProxy::SetChannelErrorCallback( } bool CommandBufferProxy::Initialize() { - if (!channel_->factory()->IsMainThread()) - return false; - bool result; if (!Send(new GpuCommandBufferMsg_Initialize(route_id_, &result))) { LOG(ERROR) << "Could not send GpuCommandBufferMsg_Initialize."; diff --git a/content/common/gpu/client/gpu_channel_host.cc b/content/common/gpu/client/gpu_channel_host.cc index 7b26415..cdb93e8 100644 --- a/content/common/gpu/client/gpu_channel_host.cc +++ b/content/common/gpu/client/gpu_channel_host.cc @@ -192,7 +192,6 @@ CommandBufferProxy* GpuChannelHost::CreateViewCommandBuffer( const std::vector<int32>& attribs, const GURL& active_url, gfx::GpuPreference gpu_preference) { - DCHECK(factory_->IsMainThread()); #if defined(ENABLE_GPU) AutoLock lock(context_lock_); // An error occurred. Need to get the host again to reinitialize it. diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc index a05908c..b9ebc2f 100644 --- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc +++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc @@ -143,13 +143,6 @@ bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL() { TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::MaybeInitializeGL"); - // If the context is being initialized on something other than the main - // thread, then make sure the swap_client_ pointer is NULL so we don't - // accidentally dereference it. - GpuChannelHostFactory* factory = GpuChannelHostFactory::instance(); - if (!factory || !factory->IsMainThread()) - DCHECK(!swap_client_.get()); - // Convert WebGL context creation attributes into ContentGLContext / EGL size // requests. const int alpha_size = attributes_.alpha ? 8 : 0; @@ -283,7 +276,7 @@ WebGLId WebGraphicsContext3DCommandBufferImpl::getPlatformTextureId() { void WebGraphicsContext3DCommandBufferImpl::prepareTexture() { // Copies the contents of the off-screen render target into the texture // used by the compositor. - if (swap_client_.get()) + if (ShouldUseSwapClient()) swap_client_->OnViewContextSwapBuffersPosted(); context_->SwapBuffers(); context_->Echo(base::Bind( @@ -301,7 +294,7 @@ void WebGraphicsContext3DCommandBufferImpl::postSubBufferCHROMIUM( int x, int y, int width, int height) { // Same flow control as WebGraphicsContext3DCommandBufferImpl::prepareTexture // (see above). - if (swap_client_.get()) + if (ShouldUseSwapClient()) swap_client_->OnViewContextSwapBuffersPosted(); gl_->PostSubBufferCHROMIUM(x, y, width, height); context_->Echo(base::Bind( @@ -1112,10 +1105,15 @@ void WebGraphicsContext3DCommandBufferImpl::deleteTexture(WebGLId texture) { gl_->DeleteTextures(1, &texture); } +bool WebGraphicsContext3DCommandBufferImpl::ShouldUseSwapClient() { + GpuChannelHostFactory* factory = GpuChannelHostFactory::instance(); + return factory && factory->IsMainThread() && swap_client_.get(); +} + void WebGraphicsContext3DCommandBufferImpl::OnSwapBuffersComplete() { typedef WebGraphicsContext3DSwapBuffersClient WGC3DSwapClient; // This may be called after tear-down of the RenderView. - if (swap_client_.get()) { + if (ShouldUseSwapClient()) { MessageLoop::current()->PostTask(FROM_HERE, base::Bind( &WGC3DSwapClient::OnViewContextSwapBuffersComplete, swap_client_)); } @@ -1187,7 +1185,7 @@ void WebGraphicsContext3DCommandBufferImpl::OnContextLost( } if (attributes_.shareResources) ClearSharedContexts(); - if (swap_client_.get()) + if (ShouldUseSwapClient()) swap_client_->OnViewContextSwapBuffersAborted(); } diff --git a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h index 5545bc8..2eda115 100644 --- a/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h +++ b/content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h @@ -495,6 +495,10 @@ class WebGraphicsContext3DCommandBufferImpl virtual void OnContextLost(ContentGLContext::ContextLostReason reason); virtual void OnErrorMessage(const std::string& message, int id); + // Check if we should call into the swap client. We can only do that on the + // main thread. + bool ShouldUseSwapClient(); + bool initialize_failed_; // The context we use for OpenGL rendering. diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc index 20649de..09e9622 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc @@ -704,8 +704,6 @@ base::WaitableEvent* RenderThreadImpl::GetShutDownEvent() { scoped_ptr<base::SharedMemory> RenderThreadImpl::AllocateSharedMemory( uint32 size) { - if (!IsMainThread()) - return scoped_ptr<base::SharedMemory>(); base::SharedMemoryHandle handle; if (!ChildThread::Send(new ChildProcessHostMsg_SyncAllocateSharedMemory( size, |