diff options
| -rw-r--r-- | content/common/gpu/gpu_command_buffer_stub.cc | 35 | ||||
| -rw-r--r-- | content/common/gpu/gpu_command_buffer_stub.h | 1 |
2 files changed, 18 insertions, 18 deletions
diff --git a/content/common/gpu/gpu_command_buffer_stub.cc b/content/common/gpu/gpu_command_buffer_stub.cc index 123c734..a5509bc 100644 --- a/content/common/gpu/gpu_command_buffer_stub.cc +++ b/content/common/gpu/gpu_command_buffer_stub.cc @@ -91,14 +91,8 @@ bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { // Echo, which just sends an IPC). if (decoder_.get() && message.type() != GpuCommandBufferMsg_Echo::ID) { - if (!decoder_->MakeCurrent()) { - DLOG(ERROR) << "Context lost because MakeCurrent failed."; - command_buffer_->SetContextLostReason(decoder_->GetContextLostReason()); - command_buffer_->SetParseError(gpu::error::kLostContext); - if (gfx::GLContext::LosesAllContextsOnContextLost()) - channel_->LoseAllContexts(); + if (!MakeCurrent()) return false; - } } // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers @@ -167,16 +161,8 @@ bool GpuCommandBufferStub::HasMoreWork() { } void GpuCommandBufferStub::PollWork() { - if (decoder_.get()) { - if (!decoder_->MakeCurrent()) { - DLOG(ERROR) << "Context lost because MakeCurrent failed."; - command_buffer_->SetContextLostReason(decoder_->GetContextLostReason()); - command_buffer_->SetParseError(gpu::error::kLostContext); - if (gfx::GLContext::LosesAllContextsOnContextLost()) - channel_->LoseAllContexts(); - return; - } - } + if (decoder_.get() && !MakeCurrent()) + return; if (scheduler_.get()) scheduler_->PollUnscheduleFences(); } @@ -214,6 +200,17 @@ void GpuCommandBufferStub::OnReschedule() { channel_->OnScheduled(); } +bool GpuCommandBufferStub::MakeCurrent() { + if (decoder_->MakeCurrent()) + return true; + DLOG(ERROR) << "Context lost because MakeCurrent failed."; + command_buffer_->SetContextLostReason(decoder_->GetContextLostReason()); + command_buffer_->SetParseError(gpu::error::kLostContext); + if (gfx::GLContext::LosesAllContextsOnContextLost()) + channel_->LoseAllContexts(); + return false; +} + void GpuCommandBufferStub::Destroy() { while (!sync_points_.empty()) OnRetireSyncPoint(sync_points_.front()); @@ -740,7 +737,9 @@ const GpuCommandBufferStubBase::SurfaceState& void GpuCommandBufferStub::SetMemoryAllocation( const GpuMemoryAllocation& allocation) { Send(new GpuCommandBufferMsg_SetMemoryAllocation(route_id_, allocation)); - if (!surface_) + // This can be called outside of OnMessageReceived, so the context needs to be + // made current before calling methods on the surface. + if (!surface_ || !MakeCurrent()) return; surface_->SetFrontbufferAllocation(allocation.suggest_have_frontbuffer); } diff --git a/content/common/gpu/gpu_command_buffer_stub.h b/content/common/gpu/gpu_command_buffer_stub.h index c09a4c0..1e0c0bf 100644 --- a/content/common/gpu/gpu_command_buffer_stub.h +++ b/content/common/gpu/gpu_command_buffer_stub.h @@ -174,6 +174,7 @@ class GpuCommandBufferStub void SetPreemptByCounter(scoped_refptr<gpu::RefCountedCounter> counter); private: + bool MakeCurrent(); void Destroy(); // Cleans up and sends reply if OnInitialize failed. |
