Bug 1250710 - User of ReadPixel should clear PBO to 0. - r=jrmuizel
MozReview-Commit-ID: JvXOfN6138g
--- a/gfx/gl/GLReadTexImageHelper.cpp
+++ b/gfx/gl/GLReadTexImageHelper.cpp
@@ -388,32 +388,28 @@ ReadPixelsIntoDataSurface(GLContext* gl,
return;
}
readSurf = tempSurf;
}
MOZ_ASSERT(readAlignment);
MOZ_ASSERT(reinterpret_cast<uintptr_t>(readSurf->GetData()) % readAlignment == 0);
- GLint currentPackAlignment = 0;
- gl->fGetIntegerv(LOCAL_GL_PACK_ALIGNMENT, ¤tPackAlignment);
-
- if (currentPackAlignment != readAlignment)
- gl->fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, readAlignment);
-
GLsizei width = dest->GetSize().width;
GLsizei height = dest->GetSize().height;
- gl->fReadPixels(0, 0,
- width, height,
- readFormat, readType,
- readSurf->GetData());
+ {
+ ScopedPackState safePackState(gl);
+ gl->fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, readAlignment);
- if (currentPackAlignment != readAlignment)
- gl->fPixelStorei(LOCAL_GL_PACK_ALIGNMENT, currentPackAlignment);
+ gl->fReadPixels(0, 0,
+ width, height,
+ readFormat, readType,
+ readSurf->GetData());
+ }
if (readSurf != dest) {
MOZ_ASSERT(readFormat == LOCAL_GL_RGBA);
MOZ_ASSERT(readType == LOCAL_GL_UNSIGNED_BYTE);
gfx::Factory::CopyDataSourceSurface(readSurf, dest);
}
// Check if GL is giving back 1.0 alpha for