diff options
author | Gunnar Sletta <gunnar.sletta@jollamobile.com> | 2014-06-04 18:59:58 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-06-05 16:31:00 +0200 |
commit | ec8f1ad27ebee154b3c4869922b953a432f9d944 (patch) | |
tree | 91aaf65d50bc3b666d42441227e26b2917af37d6 | |
parent | 13be09c97fe235ac8f453cbee9c1f794b6815db5 (diff) | |
download | qtdeclarative-ec8f1ad27ebee154b3c4869922b953a432f9d944.tar.gz |
Fix opacity issue in the renderer.
Given the following tree:
OpacityNode
|
TransformNode (which is a batch root)
|
GeometryNode
If both opacity and transform nodes were changed this frame, we would
hit the optimized "scrolling" path while traversing the tree and abort
updating that subtree. As a result the opacity change was not
propegated to the geometry node and it would be rendered incorrectly.
Fix this by skipping the optimized path when there are opacity changes
in an ancestor.
Task-number: QTBUG-39190
Change-Id: Ieaebfe3de62b961204bd3103fe9913d60e75e412
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | 4 | ||||
-rw-r--r-- | tests/auto/quick/scenegraph/data/render_OpacityThroughBatchRoot.qml | 90 | ||||
-rw-r--r-- | tests/auto/quick/scenegraph/tst_scenegraph.cpp | 9 |
3 files changed, 98 insertions, 5 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index e8f803f2a9..5c83528b82 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -417,7 +417,7 @@ void Updater::visitTransformNode(Node *n) // The only change in this subtree is ourselves and we are a batch root, so // only update subroots and return, saving tons of child-processing (flickable-panning) - if (!n->becameBatchRoot && m_added == 0 && m_force_update == 0 && dirty && (n->dirtyState & ~QSGNode::DirtyMatrix) == 0) { + if (!n->becameBatchRoot && m_added == 0 && m_force_update == 0 && m_opacityChange == 0 && dirty && (n->dirtyState & ~QSGNode::DirtyMatrix) == 0) { BatchRootInfo *info = renderer->batchRootInfo(n); for (QSet<Node *>::const_iterator it = info->subRoots.constBegin(); it != info->subRoots.constEnd(); ++it) { @@ -2015,6 +2015,8 @@ void Renderer::renderMergedBatch(const Batch *batch) << " root:" << batch->root; if (batch->drawSets.size() > 1) debug << "sets:" << batch->drawSets.size(); + if (!batch->isOpaque) + debug << "opacity:" << e->node->inheritedOpacity(); batch->uploadedThisFrame = false; } diff --git a/tests/auto/quick/scenegraph/data/render_OpacityThroughBatchRoot.qml b/tests/auto/quick/scenegraph/data/render_OpacityThroughBatchRoot.qml new file mode 100644 index 0000000000..ed55a98979 --- /dev/null +++ b/tests/auto/quick/scenegraph/data/render_OpacityThroughBatchRoot.qml @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Jolla Ltd, author: <gunnar.sletta@jollamobile.com> +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.2 + +/* + This test verifies that when we have an update to opacity above + a batch root, the opacity of the batch root's children is rendered + correctly. The Text element has 1000 glyphs in it, which is needed + for contentRoot to become a batch root when the scale changes. + + #samples: 2 + PixelPos R G B Error-tolerance + #base: 50 50 0.0 0.0 1.0 0.0 + #final: 50 50 0.5 0.5 1.0 0.05 +*/ + +RenderTestBase { + id: root + + Item { + id: failRoot; + property alias itemScale: contentItem.scale + + Item { + id: contentItem + width: 100 + height: 100 + Rectangle { + width: 100 + height: 100 + color: "blue" + Text { + id: input + color: "black" + Component.onCompleted: { for (var i = 0; i<1000; ++i) input.text += 'x' } + } + } + } + } + + SequentialAnimation { + id: unifiedAnimation; + NumberAnimation { properties: "opacity,itemScale"; duration: 256; from: 1; to: 0.5; target: failRoot } + ScriptAction { script: root.finalStageComplete = true; } + } + + onEnterFinalStage: { + unifiedAnimation.running = true; + } + +} diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp index ac4938e8bc..d510fdcda8 100644 --- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp +++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp @@ -43,7 +43,7 @@ #include <QtQuick> -#include <private/qsgcontext_p.h> +#include <private/qopenglcontext_p.h> #include <QtQml> @@ -168,7 +168,7 @@ void tst_SceneGraph::manyWindows_data() struct ShareContextResetter { public: - ~ShareContextResetter() { QSGContext::setSharedOpenGLContext(0); } + ~ShareContextResetter() { QOpenGLContextPrivate::setGlobalShareContext(0); } }; void tst_SceneGraph::manyWindows() @@ -181,7 +181,7 @@ void tst_SceneGraph::manyWindows() ShareContextResetter cleanup; // To avoid dangling pointer in case of test-failure. if (shared) { sharedGLContext.create(); - QSGContext::setSharedOpenGLContext(&sharedGLContext); + QOpenGLContextPrivate::setGlobalShareContext(&sharedGLContext); } QScopedPointer<QWindow> parent; @@ -328,7 +328,8 @@ void tst_SceneGraph::render_data() << "data/render_StackingOrder.qml" << "data/render_Mipmap.qml" << "data/render_ImageFiltering.qml" - << "data/render_bug37555.qml" + << "data/render_bug37422.qml" + << "data/render_OpacityThroughBatchRoot.qml" ; QRegExp sampleCount("#samples: *(\\d+)"); |