From 887e2c8b190e9586f10ac16a3a90ec209ec6b7bb Mon Sep 17 00:00:00 2001 From: "jgilbert@mozilla.com" Date: Thu, 24 May 2018 15:45:25 -0700 Subject: Bug 1458264 - Reset UNPACK_SKIP vars when uploading zeros. --- dom/canvas/WebGLContextDraw.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'dom/canvas') diff --git a/dom/canvas/WebGLContextDraw.cpp b/dom/canvas/WebGLContextDraw.cpp index 867e47cbd..fd9ee4957 100644 --- a/dom/canvas/WebGLContextDraw.cpp +++ b/dom/canvas/WebGLContextDraw.cpp @@ -216,7 +216,21 @@ WebGLContext::BindFakeBlack(uint32_t texUnit, TexTarget target, FakeBlackType fa UniquePtr& fakeBlackTex = *slot; if (!fakeBlackTex) { + gl->fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, 1); + if (IsWebGL2()) { + gl->fPixelStorei(LOCAL_GL_UNPACK_SKIP_PIXELS, 0); + gl->fPixelStorei(LOCAL_GL_UNPACK_SKIP_ROWS, 0); + gl->fPixelStorei(LOCAL_GL_UNPACK_SKIP_IMAGES, 0); + } + fakeBlackTex = FakeBlackTexture::Create(gl, target, fakeBlack); + + gl->fPixelStorei(LOCAL_GL_UNPACK_ALIGNMENT, mPixelStore_UnpackAlignment); + if (IsWebGL2()) { + gl->fPixelStorei(LOCAL_GL_UNPACK_SKIP_PIXELS, mPixelStore_UnpackSkipPixels); + gl->fPixelStorei(LOCAL_GL_UNPACK_SKIP_ROWS, mPixelStore_UnpackSkipRows); + gl->fPixelStorei(LOCAL_GL_UNPACK_SKIP_IMAGES, mPixelStore_UnpackSkipImages); + } if (!fakeBlackTex) { return false; } @@ -1212,13 +1226,8 @@ WebGLContext::FakeBlackTexture::Create(gl::GLContext* gl, TexTarget target, gl->fTexParameteri(target.get(), LOCAL_GL_TEXTURE_MIN_FILTER, LOCAL_GL_NEAREST); gl->fTexParameteri(target.get(), LOCAL_GL_TEXTURE_MAG_FILTER, LOCAL_GL_NEAREST); - // We allocate our zeros on the heap, and we overallocate (16 bytes instead of 4) to - // minimize the risk of running into a driver bug in texImage2D, as it is a bit - // unusual maybe to create 1x1 textures, and the stack may not have the alignment that - // TexImage2D expects. - const webgl::DriverUnpackInfo dui = {texFormat, texFormat, LOCAL_GL_UNSIGNED_BYTE}; - UniqueBuffer zeros = moz_xcalloc(1, 16); // Infallible allocation. + UniqueBuffer zeros = moz_xcalloc(1, 4); // Infallible allocation. MOZ_ASSERT(gl->IsCurrent()); -- cgit v1.2.3