Chromium Code Reviews| Index: content/renderer/pepper/ppb_graphics_3d_impl.cc |
| diff --git a/content/renderer/pepper/ppb_graphics_3d_impl.cc b/content/renderer/pepper/ppb_graphics_3d_impl.cc |
| index a5625a464da25f658f1e17c415d405de0d2a7f2f..47bc0a3cf2bd27055b9ea492c21a00905ef2baa1 100644 |
| --- a/content/renderer/pepper/ppb_graphics_3d_impl.cc |
| +++ b/content/renderer/pepper/ppb_graphics_3d_impl.cc |
| @@ -244,27 +244,28 @@ bool PPB_Graphics3D_Impl::InitRaw(PPB_Graphics3D_API* share_context, |
| gpu_preference); |
| if (!command_buffer_) |
| return false; |
| + |
| + command_buffer_->SetGpuControlClient(this); |
| + |
| if (!command_buffer_->Initialize()) |
| return false; |
| + |
| if (shared_state_handle) |
| *shared_state_handle = command_buffer_->GetSharedStateHandle(); |
| if (capabilities) |
| *capabilities = command_buffer_->GetCapabilities(); |
| if (command_buffer_id) |
| *command_buffer_id = command_buffer_->GetCommandBufferID(); |
| + |
| mailbox_ = gpu::Mailbox::Generate(); |
| if (!command_buffer_->ProduceFrontBuffer(mailbox_)) |
| return false; |
| - command_buffer_->SetContextLostCallback(base::Bind( |
| - &PPB_Graphics3D_Impl::OnContextLost, weak_ptr_factory_.GetWeakPtr())); |
| - |
| - command_buffer_->SetOnConsoleMessageCallback(base::Bind( |
| - &PPB_Graphics3D_Impl::OnConsoleMessage, weak_ptr_factory_.GetWeakPtr())); |
|
no sievers
2016/04/08 18:11:45
Unlike PepeprVideoEncoderHost, here the WeakPtr fa
danakj
2016/04/08 18:38:58
Sure, done.
|
| return true; |
| } |
| -void PPB_Graphics3D_Impl::OnConsoleMessage(const std::string& message, int id) { |
| +void PPB_Graphics3D_Impl::OnGpuControlErrorMessage(const char* message, |
| + int32_t id) { |
| if (!bound_to_instance_) |
| return; |
| WebPluginContainer* container = |
| @@ -279,17 +280,14 @@ void PPB_Graphics3D_Impl::OnConsoleMessage(const std::string& message, int id) { |
| frame->addMessageToConsole(console_message); |
| } |
| -void PPB_Graphics3D_Impl::OnSwapBuffers() { |
| - if (HasPendingSwap()) { |
| - // If we're off-screen, no need to trigger and wait for compositing. |
| - // Just send the swap-buffers ACK to the plugin immediately. |
| - commit_pending_ = false; |
| - SwapBuffersACK(PP_OK); |
| - } |
| -} |
| +void PPB_Graphics3D_Impl::OnGpuControlLostContext() { |
| +#if DCHECK_IS_ON() |
| + // This should never occur more than once. |
| + DCHECK(!lost_context_); |
| + lost_context_ = true; |
| +#endif |
| -void PPB_Graphics3D_Impl::OnContextLost() { |
| - // Don't need to check for NULL from GetPluginInstance since when we're |
| + // Don't need to check for null from GetPluginInstance since when we're |
| // bound, we know our instance is valid. |
| if (bound_to_instance_) { |
| HostGlobals::Get()->GetInstance(pp_instance())->BindGraphics(pp_instance(), |
| @@ -303,6 +301,15 @@ void PPB_Graphics3D_Impl::OnContextLost() { |
| weak_ptr_factory_.GetWeakPtr())); |
| } |
| +void PPB_Graphics3D_Impl::OnSwapBuffers() { |
| + if (HasPendingSwap()) { |
| + // If we're off-screen, no need to trigger and wait for compositing. |
| + // Just send the swap-buffers ACK to the plugin immediately. |
| + commit_pending_ = false; |
| + SwapBuffersACK(PP_OK); |
| + } |
| +} |
| + |
| void PPB_Graphics3D_Impl::SendContextLost() { |
| // By the time we run this, the instance may have been deleted, or in the |
| // process of being deleted. Even in the latter case, we don't want to send a |