Bug 1203744 - Fix the SCREEN blend mode with CompositorOGL when the source data is unpremultiplied. r=dvander
authorMatt Woodrow <mwoodrow@mozilla.com>
Mon, 14 Sep 2015 14:17:39 -0400
changeset 262425 302f955a522753026f16c43ad3803cdfe7221087
parent 262424 be88a56c48561612de43572a2e5ed03ebc98b9eb
child 262426 4f9c34eb2d6175b2cb5b9b73a2389930f4294dd9
push id15180
push userkwierso@gmail.com
push dateTue, 15 Sep 2015 00:28:33 +0000
treeherderfx-team@e543c88468c0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdvander
bugs1203744
milestone43.0a1
Bug 1203744 - Fix the SCREEN blend mode with CompositorOGL when the source data is unpremultiplied. r=dvander
gfx/layers/opengl/CompositorOGL.cpp
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -839,17 +839,18 @@ CompositorOGL::GetShaderConfigFor(Effect
                   source->GetFormat() == gfx::SurfaceFormat::R8G8B8A8 ||
                   source->GetFormat() == gfx::SurfaceFormat::R8G8B8X8);
     MOZ_ASSERT_IF(source->GetTextureTarget() == LOCAL_GL_TEXTURE_RECTANGLE_ARB,
                   source->GetFormat() == gfx::SurfaceFormat::R8G8B8A8 ||
                   source->GetFormat() == gfx::SurfaceFormat::R8G8B8X8 ||
                   source->GetFormat() == gfx::SurfaceFormat::R5G6B5);
     config = ShaderConfigFromTargetAndFormat(source->GetTextureTarget(),
                                              source->GetFormat());
-    if (aOp == gfx::CompositionOp::OP_MULTIPLY &&
+    if ((aOp == gfx::CompositionOp::OP_MULTIPLY ||
+         aOp == gfx::CompositionOp::OP_SCREEN) &&
         !texturedEffect->mPremultiplied) {
       // We can do these blend modes just using glBlendFunc but we need the data
       // to be premultiplied first.
       config.SetPremultiply(true);
     }
     break;
   }
   }
@@ -908,17 +909,19 @@ static bool SetBlendMode(GLContext* aGL,
 
   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:
-      srcBlend = aIsPremultiplied ? LOCAL_GL_ONE : LOCAL_GL_SRC_ALPHA;
+      // If the source data was un-premultiplied we should have already
+      // asked the fragment shader to fix that.
+      srcBlend = LOCAL_GL_ONE;
       dstBlend = LOCAL_GL_ONE_MINUS_SRC_COLOR;
       break;
     case gfx::CompositionOp::OP_MULTIPLY:
       // If the source data was un-premultiplied we should have already
       // asked the fragment shader to fix that.
       srcBlend = LOCAL_GL_DST_COLOR;
       dstBlend = LOCAL_GL_ONE_MINUS_SRC_ALPHA;
       break;