diff options
-rw-r--r-- | content/renderer/gpu/renderer_gl_context.cc | 10 | ||||
-rw-r--r-- | content/renderer/pepper_platform_context_3d_impl.cc | 14 | ||||
-rw-r--r-- | webkit/plugins/ppapi/ppb_surface_3d_impl.cc | 3 |
3 files changed, 20 insertions, 7 deletions
diff --git a/content/renderer/gpu/renderer_gl_context.cc b/content/renderer/gpu/renderer_gl_context.cc index 5b61c8a..d3486d6 100644 --- a/content/renderer/gpu/renderer_gl_context.cc +++ b/content/renderer/gpu/renderer_gl_context.cc @@ -231,8 +231,14 @@ bool RendererGLContext::SetParent(RendererGLContext* new_parent) { } // Free the previous parent's texture ID. - if (parent_.get() && parent_texture_id_ != 0) - parent_->gles2_implementation_->FreeTextureId(parent_texture_id_); + if (parent_.get() && parent_texture_id_ != 0) { + // Flush any remaining commands in the parent context to make sure the + // texture id accounting stays consistent. + gpu::gles2::GLES2Implementation* parent_gles2 = + parent_->GetImplementation(); + parent_gles2->helper()->CommandBufferHelper::Finish(); + parent_gles2->FreeTextureId(parent_texture_id_); + } if (new_parent) { parent_ = new_parent->AsWeakPtr(); diff --git a/content/renderer/pepper_platform_context_3d_impl.cc b/content/renderer/pepper_platform_context_3d_impl.cc index 3556db7..5daa1b5 100644 --- a/content/renderer/pepper_platform_context_3d_impl.cc +++ b/content/renderer/pepper_platform_context_3d_impl.cc @@ -22,6 +22,15 @@ PlatformContext3DImpl::PlatformContext3DImpl(RendererGLContext* parent_context) } PlatformContext3DImpl::~PlatformContext3DImpl() { + if (parent_context_.get() && parent_texture_id_ != 0) { + // Flush any remaining commands in the parent context to make sure the + // texture id accounting stays consistent. + gpu::gles2::GLES2Implementation* parent_gles2 = + parent_context_->GetImplementation(); + parent_gles2->helper()->CommandBufferHelper::Finish(); + parent_gles2->FreeTextureId(parent_texture_id_); + } + if (command_buffer_) { DCHECK(channel_.get()); channel_->DestroyCommandBuffer(command_buffer_); @@ -29,11 +38,6 @@ PlatformContext3DImpl::~PlatformContext3DImpl() { } channel_ = NULL; - - if (parent_context_.get() && parent_texture_id_ != 0) { - parent_context_->GetImplementation()->FreeTextureId(parent_texture_id_); - } - } bool PlatformContext3DImpl::Init() { diff --git a/webkit/plugins/ppapi/ppb_surface_3d_impl.cc b/webkit/plugins/ppapi/ppb_surface_3d_impl.cc index 5cab3f6d0..f1c9eef 100644 --- a/webkit/plugins/ppapi/ppb_surface_3d_impl.cc +++ b/webkit/plugins/ppapi/ppb_surface_3d_impl.cc @@ -93,6 +93,9 @@ bool PPB_Surface3D_Impl::BindToContext(PPB_Context3D_Impl* context) { if (context == context_) return true; + if (!context && bound_to_instance_) + instance()->BindGraphics(instance()->pp_instance(), 0); + // Unbind from the current context. if (context_ && context_->platform_context()) context_->platform_context()->SetSwapBuffersCallback(NULL); |