aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-05-02 13:05:29 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-05-04 11:53:46 +0200
commitd857160431412ccdf2791bb4543f70d56ff2f8d0 (patch)
tree2868d402bb8981720f3a80d5abc1719323bc6628
parent9a133c2140c7c10deb61adb86f298d0262058314 (diff)
Move some QSGRenderNodePrivate members
Task-number: QTBUG-82997 Change-Id: Icea5ebe2f76cd5714435f17374388c73a5efda6d Reviewed-by: Andy Nichols <andy.nichols@qt.io>
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp5
-rw-r--r--src/quick/scenegraph/coreapi/qsgrendernode.cpp22
-rw-r--r--src/quick/scenegraph/coreapi/qsgrendernode.h4
-rw-r--r--src/quick/scenegraph/coreapi/qsgrendernode_p.h6
4 files changed, 25 insertions, 12 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
index e5f8f81f21..c18f4f6a2e 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
@@ -4538,8 +4538,7 @@ bool Renderer::prepareRhiRenderNode(Batch *batch, PreparedRenderBatch *renderBat
opacity = opacity->parent();
}
- if (rd->m_prepareCallback)
- rd->m_prepareCallback();
+ e->renderNode->prepare();
renderBatch->batch = batch;
renderBatch->sms = nullptr;
@@ -4572,7 +4571,7 @@ void Renderer::renderRhiRenderNode(const Batch *batch) // split prepare-render (
const QSGRenderNode::StateFlags changes = e->renderNode->changedStates();
QRhiCommandBuffer *cb = commandBuffer();
- const bool needsExternal = rd->m_needsExternalRendering;
+ const bool needsExternal = !e->renderNode->flags().testFlag(QSGRenderNode::NoExternalRendering);
if (needsExternal)
cb->beginExternal();
e->renderNode->render(&state);
diff --git a/src/quick/scenegraph/coreapi/qsgrendernode.cpp b/src/quick/scenegraph/coreapi/qsgrendernode.cpp
index 8112ed2da7..ec8e3dda57 100644
--- a/src/quick/scenegraph/coreapi/qsgrendernode.cpp
+++ b/src/quick/scenegraph/coreapi/qsgrendernode.cpp
@@ -77,8 +77,6 @@ QSGRenderNodePrivate::QSGRenderNodePrivate()
: m_matrix(nullptr)
, m_clip_list(nullptr)
, m_opacity(1)
- , m_needsExternalRendering(true)
- , m_prepareCallback(nullptr)
{
}
@@ -137,6 +135,24 @@ QSGRenderNode::StateFlags QSGRenderNode::changedStates() const
}
/*!
+ Called from the frame preparation phase. There is a call to this function
+ before each invocation of render().
+
+ Unlike render(), this function is called before the scenegraph starts
+ recording the render pass for the current frame on the underlying command
+ buffer. This is useful when doing rendering with graphics APIs, such as
+ Vulkan, where copy type of operations will need to be recorded before the
+ render pass.
+
+ The default implementation is empty.
+
+ \since 6.0
+ */
+void QSGRenderNode::prepare()
+{
+}
+
+/*!
\fn void QSGRenderNode::render(const RenderState *state)
This function is called by the renderer and should paint this node with
@@ -301,6 +317,8 @@ void QSGRenderNode::releaseResources()
transparent pixels. Setting this flag can improve performance in some
cases.
+ \omitvalue NoExternalRendering
+
\sa render(), rect()
*/
diff --git a/src/quick/scenegraph/coreapi/qsgrendernode.h b/src/quick/scenegraph/coreapi/qsgrendernode.h
index 0fb83b080c..2a5a5ce106 100644
--- a/src/quick/scenegraph/coreapi/qsgrendernode.h
+++ b/src/quick/scenegraph/coreapi/qsgrendernode.h
@@ -64,7 +64,8 @@ public:
enum RenderingFlag {
BoundedRectRendering = 0x01,
DepthAwareRendering = 0x02,
- OpaqueRendering = 0x04
+ OpaqueRendering = 0x04,
+ NoExternalRendering = 0x08
};
Q_DECLARE_FLAGS(RenderingFlags, RenderingFlag)
@@ -83,6 +84,7 @@ public:
~QSGRenderNode() override;
virtual StateFlags changedStates() const;
+ virtual void prepare();
virtual void render(const RenderState *state) = 0;
virtual void releaseResources();
virtual RenderingFlags flags() const;
diff --git a/src/quick/scenegraph/coreapi/qsgrendernode_p.h b/src/quick/scenegraph/coreapi/qsgrendernode_p.h
index 534d630f15..ca38f344ef 100644
--- a/src/quick/scenegraph/coreapi/qsgrendernode_p.h
+++ b/src/quick/scenegraph/coreapi/qsgrendernode_p.h
@@ -54,7 +54,6 @@
#include <QtQuick/private/qtquickglobal_p.h>
#include <QtQuick/qsgnode.h>
#include <QtQuick/qsgrendernode.h>
-#include <functional>
QT_BEGIN_NAMESPACE
@@ -68,11 +67,6 @@ public:
const QMatrix4x4 *m_matrix;
const QSGClipNode *m_clip_list;
qreal m_opacity;
-
- // ### Qt 6: change this into a value for flags()
- bool m_needsExternalRendering;
- // ### Qt 6: change this into a virtual prepare() function
- std::function<void()> m_prepareCallback;
};
QT_END_NAMESPACE