Bug 1204106 - Use correct alpha blend modes for OVER in CompositorOGL. r=jrmuizel
☠☠ backed out by ebe6bf3f6473 ☠ ☠
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 17 Sep 2015 19:31:00 -0400
changeset 295772 e18e75437c6edefdf26cd447d6352378752dd04e
parent 295771 e492a519db8c54e5f5b4cd0545d3113cd45cadea
child 295773 5ff4c724c6b7bd64817388512fdcdaa3541c543d
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1204106
milestone43.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 1204106 - Use correct alpha blend modes for OVER in CompositorOGL. r=jrmuizel
gfx/layers/opengl/CompositorOGL.cpp
layout/reftests/layers/opacity-blending-ref.html
layout/reftests/layers/opacity-blending.html
layout/reftests/layers/reftest.list
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -238,17 +238,17 @@ CompositorOGL::Initialize()
 
   MakeCurrent();
 
   mHasBGRA =
     mGLContext->IsExtensionSupported(gl::GLContext::EXT_texture_format_BGRA8888) ||
     mGLContext->IsExtensionSupported(gl::GLContext::EXT_bgra);
 
   mGLContext->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA,
-                                 LOCAL_GL_ONE, LOCAL_GL_ONE);
+                                 LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA);
   mGLContext->fEnable(LOCAL_GL_BLEND);
 
   // initialise a common shader to check that we can actually compile a shader
   RefPtr<EffectSolidColor> effect = new EffectSolidColor(Color(0, 0, 0, 0));
   ShaderConfigOGL config = GetShaderConfigFor(effect);
   if (!GetShaderProgramFor(config)) {
     return false;
   }
@@ -656,17 +656,17 @@ CompositorOGL::BeginFrame(const nsIntReg
   mPixelsFilled = 0;
 
 #if MOZ_WIDGET_ANDROID
   TexturePoolOGL::Fill(gl());
 #endif
 
   // Default blend function implements "OVER"
   mGLContext->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA,
-                                 LOCAL_GL_ONE, LOCAL_GL_ONE);
+                                 LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA);
   mGLContext->fEnable(LOCAL_GL_BLEND);
 
   // Make sure SCISSOR is enabled before setting the render target, since the RT
   // assumes scissor is enabled while it does clears.
   mGLContext->fEnable(LOCAL_GL_SCISSOR_TEST);
 
   // Prefer the native windowing system's provided window size for the viewport.
   IntSize viewportSize = mGLContext->GetTargetSize().valueOr(mWidgetSize);
@@ -900,17 +900,17 @@ static bool SetBlendMode(GLContext* aGL,
 {
   if (aBlendMode == gfx::CompositionOp::OP_OVER && aIsPremultiplied) {
     return false;
   }
 
   GLenum srcBlend;
   GLenum dstBlend;
   GLenum srcAlphaBlend = LOCAL_GL_ONE;
-  GLenum dstAlphaBlend = LOCAL_GL_ONE;
+  GLenum dstAlphaBlend = LOCAL_GL_ONE_MINUS_SRC_ALPHA;
 
   switch (aBlendMode) {
     case gfx::CompositionOp::OP_OVER:
       MOZ_ASSERT(!aIsPremultiplied);
       srcBlend = LOCAL_GL_SRC_ALPHA;
       dstBlend = LOCAL_GL_ONE_MINUS_SRC_ALPHA;
       break;
     case gfx::CompositionOp::OP_SCREEN:
@@ -1379,27 +1379,27 @@ CompositorOGL::DrawQuad(const Rect& aRec
 
       program->SetTexturePass2(true);
       BindAndDrawQuadWithTextureRect(program,
                                      aRect,
                                      effectComponentAlpha->mTextureCoords,
                                      effectComponentAlpha->mOnBlack);
 
       mGLContext->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA,
-                                     LOCAL_GL_ONE, LOCAL_GL_ONE);
+                                     LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA);
     }
     break;
   default:
     MOZ_ASSERT(false, "Unhandled effect type");
     break;
   }
 
   if (didSetBlendMode) {
     gl()->fBlendFuncSeparate(LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA,
-                             LOCAL_GL_ONE, LOCAL_GL_ONE);
+                             LOCAL_GL_ONE, LOCAL_GL_ONE_MINUS_SRC_ALPHA);
   }
 
   // in case rendering has used some other GL context
   MakeCurrent();
   LayerScope::DrawEnd(mGLContext, aEffectChain, aRect.width, aRect.height);
 }
 
 void
new file mode 100644
--- /dev/null
+++ b/layout/reftests/layers/opacity-blending-ref.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html lang="en">
+<meta charset="utf-8">
+<title>Compositor opacity blending should work correctly (and the same as canvas)</title>
+<html class="reftest-wait">
+<head>
+<script>
+    function load() {
+        var one = document.getElementById("one").getContext("2d");
+
+        one.fillStyle = "rgba(255,0,0,0.5)";
+        one.fillRect(0, 0, 200, 200);
+        one.fillStyle = "rgba(0,255,0,0.5)";
+        one.fillRect(0, 0, 200, 200);
+
+        document.documentElement.removeAttribute("class");
+    }
+</script>
+</head>
+<body onload="load()">
+
+<div style="opacity:0.8">
+    <canvas id="one" style="position:absolute; left:0px;"></canvas>
+</div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/layers/opacity-blending.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<html lang="en">
+<meta charset="utf-8">
+<title>Compositor opacity blending should work correctly (and the same as canvas)</title>
+<html class="reftest-wait">
+<head>
+<script>
+    function load() {
+        var one = document.getElementById("one").getContext("2d");
+        var two = document.getElementById("two").getContext("2d");
+
+        one.fillStyle = "rgba(255,0,0,0.5)";
+        one.fillRect(0, 0, 200, 200);
+        two.fillStyle = "rgba(0,255,0,0.5)";
+        two.fillRect(0, 0, 200, 200);
+
+        document.documentElement.removeAttribute("class");
+      }
+</script>
+</head>
+<body onload="load()">
+
+<div style="opacity:0.8">
+    <canvas id="one" style="position:absolute; left:0px;"></canvas>
+    <canvas id="two" style="position:absolute; left:0px;"></canvas>
+</div>
+</body>
+</html>
--- a/layout/reftests/layers/reftest.list
+++ b/layout/reftests/layers/reftest.list
@@ -13,8 +13,9 @@ skip != pull-background-animated-positio
 skip != pull-background-animated-position-4.html about:blank # Fails because PaintedLayer item assignment and background pulling don't recognize overflow:hidden clips
 skip != pull-background-animated-position-5.html about:blank # Fails because ownLayer bounds don't anticipate changes of animated contents, but doesn't fail with event regions
 skip-if(!asyncPan) != pull-background-displayport-1.html about:blank
 skip-if(!asyncPan) != pull-background-displayport-2.html about:blank
 skip-if(!asyncPan) != pull-background-displayport-3.html about:blank # fails with non-overlay scrollbars and event regions due to bug 1148515
 skip-if(!asyncPan) != pull-background-displayport-4.html about:blank # fails with non-overlay scrollbars and event regions due to bug 1148515
 fails skip-if(!asyncPan) != pull-background-displayport-5.html about:blank # bug 1147673
 skip-if(!asyncPan) != pull-background-displayport-6.html about:blank # fails with non-overlay scrollbars and event regions due to bug 1148515
+fuzzy(1,30000) == opacity-blending.html opacity-blending-ref.html