--- a/dom/canvas/TexUnpackBlob.cpp
+++ b/dom/canvas/TexUnpackBlob.cpp
@@ -552,17 +552,19 @@ TexUnpackSurface::ConvertSurface(WebGLCo
{
*out_outOfMemory = false;
const size_t width = surf->GetSize().width;
const size_t height = surf->GetSize().height;
// Source args:
+ MOZ_ASSERT(webgl->gl->IsCurrent());
gfx::DataSourceSurface::ScopedMap srcMap(surf, gfx::DataSourceSurface::MapType::READ);
+ MOZ_ASSERT(webgl->gl->IsCurrent());
if (!srcMap.IsMapped())
return false;
const void* const srcBegin = srcMap.GetData();
const size_t srcStride = srcMap.GetStride();
WebGLTexelFormat srcFormat;
if (!GetFormatForSurf(surf, &srcFormat))
@@ -598,27 +600,29 @@ TexUnpackSurface::ConvertSurface(WebGLCo
}
void* const dstBegin = dstBuffer.get();
gl::OriginPos srcOrigin, dstOrigin;
OriginsForDOM(webgl, &srcOrigin, &dstOrigin);
const bool dstPremultiplied = webgl->mPixelStore_PremultiplyAlpha;
+ MOZ_ASSERT(webgl->gl->IsCurrent());
// And go!:
if (!ConvertImage(width, height,
srcBegin, srcStride, srcOrigin, srcFormat, srcPremultiplied,
dstBegin, dstStride, dstOrigin, dstFormat, dstPremultiplied))
{
MOZ_ASSERT(false, "ConvertImage failed unexpectedly.");
NS_ERROR("ConvertImage failed unexpectedly.");
*out_outOfMemory = true;
return false;
}
+ MOZ_ASSERT(webgl->gl->IsCurrent());
*out_convertedBuffer = Move(dstBuffer);
*out_convertedAlignment = dstAlignment;
return true;
}
////////////////////
@@ -632,30 +636,36 @@ TexUnpackSurface::TexUnpackSurface(const
void
TexUnpackSurface::TexOrSubImage(bool isSubImage, const char* funcName, WebGLTexture* tex,
TexImageTarget target, GLint level,
const webgl::DriverUnpackInfo* dui, GLint xOffset,
GLint yOffset, GLint zOffset, GLenum* const out_glError)
{
*out_glError = 0;
+ WebGLContext* webgl = tex->mContext;
+
// TODO: Do blitting of the native SourceSurface.
+ MOZ_ASSERT(webgl->gl->IsCurrent());
+
RefPtr<gfx::DataSourceSurface> dataSurf = mSurf->GetDataSurface();
MOZ_ASSERT(dataSurf);
- WebGLContext* webgl = tex->mContext;
+ MOZ_ASSERT(webgl->gl->IsCurrent());
GLenum error;
if (UploadDataSurface(isSubImage, webgl, target, level, dui, xOffset, yOffset,
zOffset, mWidth, mHeight, dataSurf, mIsAlphaPremult, &error))
{
return;
}
+ MOZ_ASSERT(webgl->gl->IsCurrent());
+
if (error == LOCAL_GL_OUT_OF_MEMORY) {
*out_glError = LOCAL_GL_OUT_OF_MEMORY;
return;
}
// CPU conversion. (++numCopies)
UniqueBuffer convertedBuffer;
@@ -669,16 +679,18 @@ TexUnpackSurface::TexOrSubImage(bool isS
*out_glError = LOCAL_GL_OUT_OF_MEMORY;
} else {
NS_ERROR("Failed to convert surface.");
*out_glError = LOCAL_GL_OUT_OF_MEMORY;
}
return;
}
+ MOZ_ASSERT(webgl->gl->IsCurrent());
+
ScopedUnpackReset scopedReset(webgl);
webgl->gl->fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, convertedAlignment);
error = DoTexOrSubImage(isSubImage, webgl->gl, target.get(), level, dui, xOffset,
yOffset, zOffset, mWidth, mHeight, mDepth,
convertedBuffer.get());
*out_glError = error;
}
--- a/dom/canvas/WebGLTextureUpload.cpp
+++ b/dom/canvas/WebGLTextureUpload.cpp
@@ -1133,16 +1133,17 @@ WebGLTexture::TexImage(const char* funcN
return;
}
}
////////////////////////////////////
// Do the thing!
MOZ_ALWAYS_TRUE( mContext->gl->MakeCurrent() );
+ MOZ_ASSERT(mContext->gl->IsCurrent());
// It's tempting to do allocation first, and TexSubImage second, but this is generally
// slower.
const bool isSubImage = false;
const GLint xOffset = 0;
const GLint yOffset = 0;
const GLint zOffset = 0;