Bug 1159034 - Only fake no-alpha for the backbuffer. - r=kamidphish a=lhenry
authorJeff Gilbert <jgilbert@mozilla.com>
Mon, 27 Apr 2015 15:36:29 -0700
changeset 267436 6f582552506753416b8632b2fb1725f699fdd9d4
parent 267435 a65c4683eebcc943527348790800a0d9b0184e2a
child 267437 7b3b5bf797d4353bc9d366cea57d45c41a0fd703
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskamidphish, lhenry
bugs1159034
milestone39.0
Bug 1159034 - Only fake no-alpha for the backbuffer. - r=kamidphish a=lhenry
dom/canvas/WebGLContext.cpp
dom/canvas/WebGLContext.h
dom/canvas/WebGLFramebuffer.cpp
dom/canvas/WebGLTexture.cpp
--- a/dom/canvas/WebGLContext.cpp
+++ b/dom/canvas/WebGLContext.cpp
@@ -1298,21 +1298,22 @@ WebGLContext::ClearScreen()
     GLbitfield clearMask = LOCAL_GL_COLOR_BUFFER_BIT;
     if (mOptions.depth)
         clearMask |= LOCAL_GL_DEPTH_BUFFER_BIT;
     if (mOptions.stencil)
         clearMask |= LOCAL_GL_STENCIL_BUFFER_BIT;
 
     colorAttachmentsMask[0] = true;
 
-    ForceClearFramebufferWithDefaultValues(clearMask, colorAttachmentsMask);
+    ForceClearFramebufferWithDefaultValues(mNeedsFakeNoAlpha, clearMask,
+                                           colorAttachmentsMask);
 }
 
 void
-WebGLContext::ForceClearFramebufferWithDefaultValues(GLbitfield mask,
+WebGLContext::ForceClearFramebufferWithDefaultValues(bool fakeNoAlpha, GLbitfield mask,
                                                      const bool colorAttachmentsMask[kMaxColorAttachments])
 {
     MakeContextCurrent();
 
     bool initializeColorBuffer = 0 != (mask & LOCAL_GL_COLOR_BUFFER_BIT);
     bool initializeDepthBuffer = 0 != (mask & LOCAL_GL_DEPTH_BUFFER_BIT);
     bool initializeStencilBuffer = 0 != (mask & LOCAL_GL_STENCIL_BUFFER_BIT);
     bool drawBuffersIsEnabled = IsExtensionEnabled(WebGLExtensionID::WEBGL_draw_buffers);
@@ -1348,17 +1349,17 @@ WebGLContext::ForceClearFramebufferWithD
             // calling draw buffers can cause resolves on adreno drivers so
             // we try to avoid calling it
             if (shouldOverrideDrawBuffers)
                 gl->fDrawBuffers(mGLMaxDrawBuffers, drawBuffersCommand);
         }
 
         gl->fColorMask(1, 1, 1, 1);
 
-        if (mNeedsFakeNoAlpha) {
+        if (fakeNoAlpha) {
             gl->fClearColor(0.0f, 0.0f, 0.0f, 1.0f);
         } else {
             gl->fClearColor(0.0f, 0.0f, 0.0f, 0.0f);
         }
     }
 
     if (initializeDepthBuffer) {
         gl->fDepthMask(1);
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -323,17 +323,17 @@ public:
     const WebGLRectangleObject* CurValidReadFBRectObject() const;
 
     static const size_t kMaxColorAttachments = 16;
 
     // This is similar to GLContext::ClearSafely, but tries to minimize the
     // amount of work it does.
     // It only clears the buffers we specify, and can reset its state without
     // first having to query anything, as WebGL knows its state at all times.
-    void ForceClearFramebufferWithDefaultValues(GLbitfield mask,
+    void ForceClearFramebufferWithDefaultValues(bool fakeNoAlpha, GLbitfield mask,
                                                 const bool colorAttachmentsMask[kMaxColorAttachments]);
 
     // Calls ForceClearFramebufferWithDefaultValues() for the Context's 'screen'.
     void ClearScreen();
     void ClearBackbufferIfNeeded();
 
     bool MinCapabilityMode() const { return mMinCapability; }
 
--- a/dom/canvas/WebGLFramebuffer.cpp
+++ b/dom/canvas/WebGLFramebuffer.cpp
@@ -797,17 +797,17 @@ WebGLFramebuffer::CheckAndInitializeAtta
     for (size_t i = 0; i < moreColorAttachmentCount; i++) {
         if (mMoreColorAttachments[i].HasUninitializedImageData()) {
           colorAttachmentsMask[1 + i] = true;
           mask |= LOCAL_GL_COLOR_BUFFER_BIT;
         }
     }
 
     // Clear!
-    mContext->ForceClearFramebufferWithDefaultValues(mask, colorAttachmentsMask);
+    mContext->ForceClearFramebufferWithDefaultValues(false, mask, colorAttachmentsMask);
 
     // Mark all the uninitialized images as initialized.
     if (mColorAttachment0.HasUninitializedImageData())
         mColorAttachment0.SetImageDataStatus(WebGLImageDataStatus::InitializedImageData);
     if (mDepthAttachment.HasUninitializedImageData())
         mDepthAttachment.SetImageDataStatus(WebGLImageDataStatus::InitializedImageData);
     if (mStencilAttachment.HasUninitializedImageData())
         mStencilAttachment.SetImageDataStatus(WebGLImageDataStatus::InitializedImageData);
--- a/dom/canvas/WebGLTexture.cpp
+++ b/dom/canvas/WebGLTexture.cpp
@@ -524,17 +524,17 @@ ClearByMask(WebGLContext* webgl, GLbitfi
     if (status != LOCAL_GL_FRAMEBUFFER_COMPLETE)
         return false;
 
     bool colorAttachmentsMask[WebGLContext::kMaxColorAttachments] = {false};
     if (mask & LOCAL_GL_COLOR_BUFFER_BIT) {
         colorAttachmentsMask[0] = true;
     }
 
-    webgl->ForceClearFramebufferWithDefaultValues(mask, colorAttachmentsMask);
+    webgl->ForceClearFramebufferWithDefaultValues(false, mask, colorAttachmentsMask);
     return true;
 }
 
 // `mask` from glClear.
 static bool
 ClearWithTempFB(WebGLContext* webgl, GLuint tex,
                 TexImageTarget texImageTarget, GLint level,
                 TexInternalFormat baseInternalFormat,