Bug 1204106 - Use correct alpha blend modes for OVER in CompositorOGL. r=jrmuizel

This commit is contained in:
Matt Woodrow 2015-09-17 19:31:00 -04:00
parent 044f3b47c5
commit cd70d8e2f5
4 changed files with 60 additions and 5 deletions

View File

@ -243,7 +243,7 @@ CompositorOGL::Initialize()
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
@ -661,7 +661,7 @@ CompositorOGL::BeginFrame(const nsIntRegion& aInvalidRegion,
// 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
@ -905,7 +905,7 @@ static bool SetBlendMode(GLContext* aGL, gfx::CompositionOp aBlendMode, bool aIs
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:
@ -1384,7 +1384,7 @@ CompositorOGL::DrawQuad(const Rect& aRect,
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:
@ -1394,7 +1394,7 @@ CompositorOGL::DrawQuad(const Rect& aRect,
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

View File

@ -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>

View File

@ -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>

View File

@ -18,3 +18,4 @@ skip-if(!asyncPan) != pull-background-displayport-3.html about:blank # fails wit
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