From fbac18a6359c2f063aff43afe4ef954fce000e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Mon, 5 Aug 2013 15:12:08 +0200 Subject: [PATCH] Hotfix GL crossfading MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not correct crossfading Purpose of the hotfix is to manipulate opacities of the "semi-crossfaded™" pixmaps so that on a quick animation and sloppy check it looks somehow believable (instead of bumping the window to full opacity) REVIEW: 111888 --- scene_opengl.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/scene_opengl.cpp b/scene_opengl.cpp index e62829f33f..e82c50767d 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -50,7 +50,7 @@ along with this program. If not, see . #include "screens.h" #include "workspace.h" -#include +#include #include #include @@ -1357,26 +1357,33 @@ void SceneOpenGL2Window::setupLeafNodes(LeafNode *nodes, const WindowQuadList *q getDecorationTextures(textures); nodes[LeftRightLeaf].texture = textures[0]; - nodes[LeftRightLeaf].opacity = data.opacity() * data.decorationOpacity(); + nodes[LeftRightLeaf].opacity = data.opacity(); nodes[LeftRightLeaf].hasAlpha = true; nodes[LeftRightLeaf].coordinateType = UnnormalizedCoordinates; nodes[TopBottomLeaf].texture = textures[1]; - nodes[TopBottomLeaf].opacity = data.opacity() * data.decorationOpacity(); + nodes[TopBottomLeaf].opacity = data.opacity(); nodes[TopBottomLeaf].hasAlpha = true; nodes[TopBottomLeaf].coordinateType = UnnormalizedCoordinates; } nodes[ContentLeaf].texture = s_frameTexture; nodes[ContentLeaf].hasAlpha = !isOpaque(); - nodes[ContentLeaf].opacity = data.opacity(); + // TODO: ARGB crsoofading is atm. a hack, playing on opacities for two dumb SrcOver operations + // Should be a shader + if (data.crossFadeProgress() != 1.0 && (data.opacity() < 0.95 || toplevel->hasAlpha())) { + const float opacity = 1.0 - data.crossFadeProgress(); + nodes[ContentLeaf].opacity = data.opacity() * (1 - pow(opacity, 1.0f + 2.0f * data.opacity())); + } else { + nodes[ContentLeaf].opacity = data.opacity(); + } nodes[ContentLeaf].coordinateType = UnnormalizedCoordinates; if (data.crossFadeProgress() != 1.0) { OpenGLWindowPixmap *previous = previousWindowPixmap(); nodes[PreviousContentLeaf].texture = previous ? previous->texture() : NULL; nodes[PreviousContentLeaf].hasAlpha = !isOpaque(); - nodes[PreviousContentLeaf].opacity = 1.0 - data.crossFadeProgress(); + nodes[PreviousContentLeaf].opacity = data.opacity() * (1.0 - data.crossFadeProgress()); nodes[PreviousContentLeaf].coordinateType = NormalizedCoordinates; } } @@ -1607,7 +1614,14 @@ void SceneOpenGL1Window::performPaint(int mask, QRegion region, WindowPaintData OpenGLWindowPixmap *previous = previousWindowPixmap(); const WindowQuadList contentQuads = data.quads.select(WindowQuadContents); if (previous && data.crossFadeProgress() != 1.0) { - paintContent(s_frameTexture, region, mask, data.opacity(), data, contentQuads, false); + // TODO: ARGB crsoofading is atm. a hack, playing on opacities for two dumb SrcOver operations + // Will require a caching texture or sth. else 1.2 compliant + float opacity = data.opacity(); + if (opacity < 0.95f || toplevel->hasAlpha()) { + opacity = 1 - data.crossFadeProgress(); + opacity = data.opacity() * (1 - pow(opacity, 1.0f + 2.0f * data.opacity())); + } + paintContent(s_frameTexture, region, mask, opacity, data, contentQuads, false); previous->texture()->setFilter(filter == Scene::ImageFilterGood ? GL_LINEAR : GL_NEAREST); WindowQuadList oldContents; const QRect &oldGeometry = previous->contentsRect(); @@ -1628,7 +1642,8 @@ void SceneOpenGL1Window::performPaint(int mask, QRegion region, WindowPaintData } oldContents.append(newQuad); } - paintContent(previous->texture(), region, mask, 1.0 - data.crossFadeProgress(), data, oldContents, true); + opacity = data.opacity() * (1.0 - data.crossFadeProgress()); + paintContent(previous->texture(), region, mask, opacity, data, oldContents, true); } else { paintContent(s_frameTexture, region, mask, data.opacity(), data, contentQuads, false); }