diff options
Diffstat (limited to 'content/common')
4 files changed, 13 insertions, 15 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. |