Fix premultiplied alpha issue with color correction

When correcting a color that was with premultiplied alpha, the alpha
value was not multiplied back again as a final step. This was breaking
color correction when the blend function was GL_ONE,
GL_ONE_MINUS_SRC_ALPHA. The blend function was changed for normal
windows (a workaround), but not for effect frames, i.e. the effect
frames were broken with color correction enabled.

Removes the blend function workaround.

Removes a useless setupForOutput.

BUG: 311319
REVIEW: 108189
This commit is contained in:
Casian Andrei 2013-01-05 05:39:02 +02:00
parent df034c16ad
commit 7a6e48ef3b
2 changed files with 5 additions and 11 deletions

View file

@ -235,7 +235,7 @@ void ColorServerInterface::callFinishedSlot(QDBusPendingCallWatcher *watcher)
static const char s_ccVars[] =
"uniform sampler3D u_ccLookupTexture;\n";
static const char s_ccAlteration[] =
"gl_FragColor.rgb = texture3D(u_ccLookupTexture, gl_FragColor.rgb / gl_FragColor.a).rgb;\n";
"gl_FragColor.rgb = texture3D(u_ccLookupTexture, gl_FragColor.rgb / gl_FragColor.a).rgb * gl_FragColor.a;\n";
/*

View file

@ -1240,8 +1240,6 @@ void SceneOpenGL2Window::beginRenderWindow(int mask, const WindowPaintData &data
}
shader->setUniform(GLShader::WindowTransformation, transformation(mask, data));
static_cast<SceneOpenGL2*>(m_scene)->colorCorrection()->setupForOutput(data.screen());
}
void SceneOpenGL2Window::endRenderWindow(const WindowPaintData &data)
@ -1270,15 +1268,11 @@ void SceneOpenGL2Window::prepareStates(TextureType type, qreal opacity, qreal br
}
if (!opaque) {
glEnable(GL_BLEND);
if (static_cast<SceneOpenGL2*>(m_scene)->colorCorrection()->isEnabled()) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
if (alpha) {
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
} else {
if (alpha) {
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
} else {
glBlendColor((float)opacity, (float)opacity, (float)opacity, (float)opacity);
glBlendFunc(GL_ONE, GL_ONE_MINUS_CONSTANT_ALPHA);
}
glBlendColor((float)opacity, (float)opacity, (float)opacity, (float)opacity);
glBlendFunc(GL_ONE, GL_ONE_MINUS_CONSTANT_ALPHA);
}
}
m_blendingEnabled = !opaque;