Skip to content

Commit

Permalink
Add a QSGOpacityNode flag which allows a node to ignore inherited opa…
Browse files Browse the repository at this point in the history
…city.
  • Loading branch information
denexter committed Jun 16, 2020
1 parent 9194e2f commit 53b77fb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
Expand Up @@ -378,7 +378,12 @@ void Updater::visitOpacityNode(Node *n)
{
QSGOpacityNode *on = static_cast<QSGOpacityNode *>(n->sgNode);

qreal combined = m_opacity_stack.last() * on->opacity();
qreal combined = (on->flags() & QSGNode::IgnoreParentOpacity)
? on->opacity()
: m_opacity_stack.last() * on->opacity();
if (on->flags() & QSGNode::IgnoreParentOpacity) {
qDebug() << "Opacity node wan't to ignore parent opacity" << combined;
}
on->setCombinedOpacity(combined);
m_opacity_stack.add(combined);

Expand Down Expand Up @@ -1282,6 +1287,9 @@ void Renderer::buildRenderLists(QSGNode *node)
Q_ASSERT(e);

bool opaque = gn->inheritedOpacity() > OPAQUE_LIMIT && !(gn->activeMaterial()->flags() & QSGMaterial::Blending);
if (opaque) {
qDebug() << "Have an opaque node";
}
if (opaque && m_useDepthBuffer)
m_opaqueRenderList << e;
else
Expand Down
3 changes: 3 additions & 0 deletions src/quick/scenegraph/coreapi/qsgnode.h
Expand Up @@ -89,6 +89,9 @@ class Q_QUICK_EXPORT QSGNode
OwnsMaterial = 0x00020000,
OwnsOpaqueMaterial = 0x00040000,

// QSGOpacityNode
IgnoreParentOpacity = OwnsGeometry,

// Uppermost 8 bits are reserved for internal use.
#ifndef qdoc
IsVisitableNode = 0x01000000
Expand Down
4 changes: 3 additions & 1 deletion src/quick/scenegraph/coreapi/qsgnodeupdater.cpp
Expand Up @@ -185,7 +185,9 @@ void QSGNodeUpdater::leaveRenderNode(QSGRenderNode *r)

void QSGNodeUpdater::enterOpacityNode(QSGOpacityNode *o)
{
qreal opacity = m_opacity_stack.last() * o->opacity();
qreal opacity = (o->flags() & QSGNode::IgnoreParentOpacity)
? o->opacity()
: m_opacity_stack.last() * o->opacity();
o->setCombinedOpacity(opacity);
m_opacity_stack.add(opacity);

Expand Down

0 comments on commit 53b77fb

Please sign in to comment.