Bug 1249483 - Stop filling A with 1.0 on readback from no-alpha. - r=jrmuizel
authorJeff Gilbert <jgilbert@mozilla.com>
Thu, 25 Feb 2016 17:47:50 -0800
changeset 321999 cf3f2dc292d5ca0503b39de756bd214f06f1f7da
parent 321998 946fe891d91e1e5a2578bbce2513d496339dacfb
child 322000 9da0d93d757dc9aaa3bd772b446b93c5aaba4f56
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1249483
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1249483 - Stop filling A with 1.0 on readback from no-alpha. - r=jrmuizel
dom/canvas/WebGLContextGL.cpp
--- a/dom/canvas/WebGLContextGL.cpp
+++ b/dom/canvas/WebGLContextGL.cpp
@@ -1202,67 +1202,16 @@ WebGLContext::PixelStorei(GLenum pname, 
 
     default:
         break;
     }
 
     ErrorInvalidEnumInfo("pixelStorei: parameter", pname);
 }
 
-// `width` in pixels.
-// `stride` in bytes.
-static void
-SetFullAlpha(void* data, GLenum format, GLenum type, size_t width, size_t height,
-             size_t stride)
-{
-    if (format == LOCAL_GL_ALPHA && type == LOCAL_GL_UNSIGNED_BYTE) {
-        // Just memset the rows.
-        uint8_t* row = static_cast<uint8_t*>(data);
-        for (size_t j = 0; j < height; ++j) {
-            memset(row, 0xff, width);
-            row += stride;
-        }
-
-        return;
-    }
-
-    if (format == LOCAL_GL_RGBA && type == LOCAL_GL_UNSIGNED_BYTE) {
-        for (size_t j = 0; j < height; ++j) {
-            uint8_t* row = static_cast<uint8_t*>(data) + j*stride;
-
-            uint8_t* pAlpha = row + 3;
-            uint8_t* pAlphaEnd = pAlpha + 4*width;
-            while (pAlpha != pAlphaEnd) {
-                *pAlpha = 0xff;
-                pAlpha += 4;
-            }
-        }
-
-        return;
-    }
-
-    if (format == LOCAL_GL_RGBA && type == LOCAL_GL_FLOAT) {
-        for (size_t j = 0; j < height; ++j) {
-            uint8_t* rowBytes = static_cast<uint8_t*>(data) + j*stride;
-            float* row = reinterpret_cast<float*>(rowBytes);
-
-            float* pAlpha = row + 3;
-            float* pAlphaEnd = pAlpha + 4*width;
-            while (pAlpha != pAlphaEnd) {
-                *pAlpha = 1.0f;
-                pAlpha += 4;
-            }
-        }
-
-        return;
-    }
-
-    MOZ_CRASH("Unhandled case, how'd we get here?");
-}
-
 bool
 WebGLContext::DoReadPixelsAndConvert(GLint x, GLint y, GLsizei width, GLsizei height,
                                      GLenum destFormat, GLenum destType, void* destBytes,
                                      GLenum auxReadFormat, GLenum auxReadType)
 {
     GLenum readFormat = destFormat;
     GLenum readType = destType;
 
@@ -1758,35 +1707,16 @@ WebGLContext::ReadPixels(GLint x, GLint 
         uint8_t* row = (uint8_t*)data + startOffset.value() + writeX * bytesPerPixel;
         row += writeY * rowStride.value();
         for (uint32_t j = 0; j < rwHeight; j++) {
             DoReadPixelsAndConvert(readX, readY+j, rwWidth, 1, format, type, row,
                                    auxReadFormat, auxReadType);
             row += rowStride.value();
         }
     }
-
-    // if we're reading alpha, we may need to do fixup.  Note that we don't allow
-    // GL_ALPHA to readpixels currently, but we had the code written for it already.
-    const bool formatHasAlpha = format == LOCAL_GL_ALPHA ||
-                                format == LOCAL_GL_RGBA;
-    if (!formatHasAlpha)
-        return;
-
-    bool needAlphaFilled;
-    if (mBoundReadFramebuffer) {
-        needAlphaFilled = !mBoundReadFramebuffer->ColorAttachment(0).HasAlpha();
-    } else {
-        needAlphaFilled = !mOptions.alpha;
-    }
-
-    if (!needAlphaFilled)
-        return;
-
-    SetFullAlpha(data, format, type, width, height, rowStride.value());
 }
 
 void
 WebGLContext::RenderbufferStorage_base(const char* funcName, GLenum target,
                                        GLsizei samples, GLenum internalFormat,
                                        GLsizei width, GLsizei height)
 {
     if (IsContextLost())