Bug 1413230 - Ensure we are attached to the GL context in SurfaceTextureHostOGL::PrepareTextureSource() r=jnicol,nical

MozReview-Commit-ID: BxDng9OG3RF
This commit is contained in:
James Willcox 2017-10-31 11:07:53 -05:00
parent 6931291fc3
commit bc001da86a
2 changed files with 27 additions and 16 deletions

View File

@ -453,12 +453,11 @@ SurfaceTextureHost::~SurfaceTextureHost()
void
SurfaceTextureHost::PrepareTextureSource(CompositableTextureSourceRef& aTexture)
{
GLContext* gl = this->gl();
if (!gl || !gl->MakeCurrent()) {
return;
}
if (!mContinuousUpdate && mSurfTex) {
if (!EnsureAttached()) {
return;
}
// UpdateTexImage() advances the internal buffer queue, so we only want to call this
// once per transactionwhen we are not in continuous mode (as we are here). Otherwise,
// the SurfaceTexture content will be de-synced from the rest of the page in subsequent
@ -474,14 +473,32 @@ SurfaceTextureHost::gl() const
}
bool
SurfaceTextureHost::Lock()
SurfaceTextureHost::EnsureAttached()
{
GLContext* gl = this->gl();
if (!gl || !gl->MakeCurrent()) {
return false;
}
if (!mSurfTex) {
return false;
}
GLContext* gl = this->gl();
if (!gl || !gl->MakeCurrent()) {
if (!mSurfTex->IsAttachedToGLContext((int64_t)gl)) {
GLuint texName;
gl->fGenTextures(1, &texName);
if (NS_FAILED(mSurfTex->AttachToGLContext((int64_t)gl, texName))) {
return false;
}
}
return true;
}
bool
SurfaceTextureHost::Lock()
{
if (!EnsureAttached()) {
return false;
}
@ -501,14 +518,6 @@ SurfaceTextureHost::Lock()
mIgnoreTransform);
}
if (!mSurfTex->IsAttachedToGLContext((int64_t)gl)) {
GLuint texName;
gl->fGenTextures(1, &texName);
if (NS_FAILED(mSurfTex->AttachToGLContext((int64_t)gl, texName))) {
return false;
}
}
return true;
}

View File

@ -429,6 +429,8 @@ public:
virtual const char* Name() override { return "SurfaceTextureHost"; }
protected:
bool EnsureAttached();
mozilla::java::GeckoSurfaceTexture::GlobalRef mSurfTex;
const gfx::IntSize mSize;
const gfx::SurfaceFormat mFormat;