Fix corrupt rendering when toggling rendernode-based items
Meaning the toggling of visibility. Having a QSGRenderNode come and
go in the scenegraph leads to visual problems, in case the adding
and removal of the node toggles the m_forceNoUseDepthBuffer flag,
which in turn makes useDepthBuffer() return a different value
than before (so disables and then enables doing the opaque
pass in the renderer). Changing this value needs a full rebuild
of the render lists. When adding a node, this is done (regardless
of toggling the flag). When removing, it was not done at all.
Now we do it when resetting the no-Z flag back to false.
Add a button to the customrendernode example to toggle visibility
since this is useful for example's purposes anyways. However, this
on its own is not sufficient to reproduce the issue. For that,
the DepthAwareRendering flag needs to be removed from the
QSGRenderNode subclass.
Pick-to: 6.5
Fixes: QTBUG-119160
Change-Id: I232354d88f5a4fe5f9f2d6102d0d5439d92782fb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
(cherry picked from commit d70b847f77
)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
476e32f86b
commit
ae2df32f79
|
@ -102,6 +102,11 @@ Item {
|
|||
}
|
||||
|
||||
|
||||
Button {
|
||||
text: qsTr("Toggle custom item visibility")
|
||||
onClicked: custom.visible = !custom.visible
|
||||
}
|
||||
|
||||
CustomRender {
|
||||
id: custom
|
||||
width: Math.min(parent.width, parent.height)
|
||||
|
|
|
@ -1222,8 +1222,13 @@ void Renderer::nodeWasRemoved(Node *node)
|
|||
if (e) {
|
||||
e->removed = true;
|
||||
m_elementsToDelete.add(e);
|
||||
if (m_renderNodeElements.isEmpty())
|
||||
if (m_renderNodeElements.isEmpty()) {
|
||||
m_forceNoDepthBuffer = false;
|
||||
// Must have a full rebuild given useDepthBuffer() now returns
|
||||
// a different value than before, meaning there can once again
|
||||
// be an opaque pass.
|
||||
m_rebuild |= FullRebuild;
|
||||
}
|
||||
|
||||
if (e->batch != nullptr)
|
||||
e->batch->needsPurge = true;
|
||||
|
|
Loading…
Reference in New Issue