diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-05-05 18:29:46 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-05-10 11:39:10 +0200 |
commit | a6705dc99a81b7eab35db61957963d375e723fce (patch) | |
tree | 784e6a1ace5c0a39d9894bc76e72254fccfdc2e2 /tests | |
parent | 64c22f1691ff78e538800e1715da3488ba9e1baf (diff) |
Do full overlap checks within the alpha render list when rebuilding
Not applicable to Qt 6.1 and newer because those already have this as
part of another patch (9aa3db2e19b2e1622b878cf34b1978f4fdbcac39), which
was meant to be a performance optimization.
With the example provided it is clear however that there is an actual
batching problem in there, with certain scenes, where the problem of
incorrectly batching two elements together becomes visible only upon
a set of conditions such as:
- there is a set of mergeable and non-mergeable nodes (e.g. non-atlased
Images + Rectangles or non-atlased Images + Texts)
- all in the alpha render list (semi-transparency, e.g. Image with
alpha, Text, Rectangle with opacity, etc.)
- laid out in a certain way that certain overlaps occur, e.g. in
a column with the Images under each other, with Rectangles or Texts
on top of the last two.
- then trigger certain scene changes, e.g. swap the source of the
second and third Image.
Certain changes will end up with the incorrect merging described
in the render_AlphaOverlapRebuild.qml test case. If the two Rectangles
or Texts get merged in one batch, rendered before the third Image,
the result is incorrect since the "background" Image is then on top.
This can be difficult to reproduce as there are a number of
preconditions for the scene and the changes in the scene. But when it
happens, it is a critical rendering error.
Fixes: QTBUG-92984
Change-Id: I016614d8465f6917ebf6c7d9b2460a31decdda34
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/quick/scenegraph/data/render_AlphaOverlapRebuild.qml | 115 | ||||
-rw-r--r-- | tests/auto/quick/scenegraph/data/widebtn1.png | bin | 0 -> 1969 bytes | |||
-rw-r--r-- | tests/auto/quick/scenegraph/data/widebtn2.png | bin | 0 -> 1965 bytes | |||
-rw-r--r-- | tests/auto/quick/scenegraph/tst_scenegraph.cpp | 4 |
4 files changed, 118 insertions, 1 deletions
diff --git a/tests/auto/quick/scenegraph/data/render_AlphaOverlapRebuild.qml b/tests/auto/quick/scenegraph/data/render_AlphaOverlapRebuild.qml new file mode 100644 index 0000000000..f06be8f553 --- /dev/null +++ b/tests/auto/quick/scenegraph/data/render_AlphaOverlapRebuild.qml @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.15 + +/* + QTBUG-92984. + + Have three Image (with semi-transparency) and two semi-transparent + Rectangle elements, and so all in the alpha render list, with images that + are big enough to not get atlased. (meaning the underlying nodes never get + merged, but the nodes for the Rectangle elements might) + + Lay them out vertically below each other, with the two Rectangles on top of + the second and third Images, respectively. Then change (swap) the source + property of the Images. This triggers a rebuild in the batch renderer. + + Verify that the results are still correct, i.e. that the two Rectangle + elements do not get merged. An incorrect result would be having the third + Image rendered on top of the corresponding Rectangle due the two Rectangles + (incorrectly) being in one merged batch. The Image should always be below, + regardless of which nodes get changed, invalidated, and how batches get + rebuilt. + + The base-final sample set 1 just verifies that the Image changes from the + blueish to greenish. The important part is the second set of samples: this + checks that the red(ish) rectangle is still on top of the third Image. With + incorrect merging behavior the second final result would be the same as the + first final one (i.e. the "background" Image rendered, incorrectly, on top + of the Rectangle). + + #samples: 4 + PixelPos R G B Error-tolerance + #base: 30 115 0.24313 0.30588 0.99607 0.05 + #base: 30 124 0.847059 0.062745 0.2 0.05 + #final: 30 115 0.36078 0.99607 0.42745 0.05 + #final: 30 124 0.870588 0.2 0.0862745 0.05 +*/ + +RenderTestBase { + id: root + + property string selectedItem: "item2" + + Item { + width: 150; height: 50 + Image { + width: parent.width + objectName: "item1" + source: "widebtn1.png" + } + } + + Item { + y: 50; width: 150; height: 50 + Image { + width: parent.width + objectName: "item2" + source: selectedItem == objectName ? "widebtn2.png" : "widebtn1.png" + } + Rectangle { + anchors.fill: parent + anchors.margins: 20 + color: "red" + opacity: 0.8 + } + } + + Item { + y: 100; width: 150; height: 50 + Image { + id: img3 + width: parent.width + objectName: "item3" + source: selectedItem == objectName ? "widebtn2.png" : "widebtn1.png" + } + Rectangle { + width: parent.width + 50 + anchors.centerIn: parent + height: img3.height - 40 + color: "red" + opacity: 0.8 + } + } + + onEnterFinalStage: { + selectedItem = "item3"; + finalStageComplete = true; + } +} diff --git a/tests/auto/quick/scenegraph/data/widebtn1.png b/tests/auto/quick/scenegraph/data/widebtn1.png Binary files differnew file mode 100644 index 0000000000..1150b67a7a --- /dev/null +++ b/tests/auto/quick/scenegraph/data/widebtn1.png diff --git a/tests/auto/quick/scenegraph/data/widebtn2.png b/tests/auto/quick/scenegraph/data/widebtn2.png Binary files differnew file mode 100644 index 0000000000..40afe08363 --- /dev/null +++ b/tests/auto/quick/scenegraph/data/widebtn2.png diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp index 12f7efb7d5..cf85e262c0 100644 --- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp +++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp @@ -402,7 +402,9 @@ void tst_SceneGraph::render_data() << "render_StackingOrder.qml" << "render_ImageFiltering.qml" << "render_bug37422.qml" - << "render_OpacityThroughBatchRoot.qml"; + << "render_OpacityThroughBatchRoot.qml" + << "render_AlphaOverlapRebuild.qml"; + if (!m_brokenMipmapSupport) files << "render_Mipmap.qml"; |