Commit 7bb331d6 authored by Vikas Soni's avatar Vikas Soni Committed by Commit Bot

Make Context current before destroying a texture.

Make context current in ~AbstractTextureImplOnSharedContextPassthrough()
before destroying the |texture_| since the destructor is not guaranteed
to be called from the same context on which the |texture_| was created.

Bug: 1054865
Change-Id: I1647d1ec8aede954031aae70692943c2f14920e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2068892
Commit-Queue: Khushal <khushalsagar@chromium.org>
Reviewed-by: default avatarKhushal <khushalsagar@chromium.org>
Auto-Submit: vikas soni <vikassoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743809}
parent be37ca15
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "gpu/command_buffer/service/context_state.h" #include "gpu/command_buffer/service/context_state.h"
#include "gpu/command_buffer/service/texture_manager.h" #include "gpu/command_buffer/service/texture_manager.h"
#include "ui/gl/gl_context.h" #include "ui/gl/gl_context.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/scoped_binders.h" #include "ui/gl/scoped_binders.h"
#include "ui/gl/scoped_make_current.h" #include "ui/gl/scoped_make_current.h"
...@@ -155,6 +156,30 @@ AbstractTextureImplOnSharedContextPassthrough:: ...@@ -155,6 +156,30 @@ AbstractTextureImplOnSharedContextPassthrough::
~AbstractTextureImplOnSharedContextPassthrough() { ~AbstractTextureImplOnSharedContextPassthrough() {
if (cleanup_cb_) if (cleanup_cb_)
std::move(cleanup_cb_).Run(this); std::move(cleanup_cb_).Run(this);
// Save the current context and make it current again after deleting the
// |texture_|.
scoped_refptr<gl::GLContext> previous_context = gl::GLContext::GetCurrent();
scoped_refptr<gl::GLSurface> previous_surface = gl::GLSurface::GetCurrent();
// If the shared context is lost, |shared_context_state_| will be null and the
// |texture_| is already marked to have lost its context.
if (shared_context_state_) {
// Make the |shared_context_state_|'s context current before destroying the
// |texture_| since
// destructor is not guaranteed to be called on the context on which the
// |texture_| was created.
if (!shared_context_state_->IsCurrent(nullptr)) {
shared_context_state_->MakeCurrent(shared_context_state_->surface(),
true /* needs_gl */);
}
shared_context_state_->RemoveContextLostObserver(this);
}
texture_.reset();
// Make the previous context current again.
if (!previous_context->IsCurrent(previous_surface.get()))
previous_context->MakeCurrent(previous_surface.get());
} }
TextureBase* AbstractTextureImplOnSharedContextPassthrough::GetTextureBase() TextureBase* AbstractTextureImplOnSharedContextPassthrough::GetTextureBase()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment