diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2019-09-18 07:38:17 +0200 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2019-09-20 14:27:41 +0200 |
commit | f8464b1daa8d8fd628b5e56d3256d01d0b7fa59e (patch) | |
tree | b196ecab31c0df5ee52ff3f563465da9fcb554f7 /src/render/framegraph | |
parent | c1deb350219fdd1af1226b99de16946f52e099e2 (diff) |
Update QBlitFramebuffer to use direct sync
Change-Id: I1d875e8581bfd3485f7baf5ee1e76ea7aafc398e
Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'src/render/framegraph')
-rw-r--r-- | src/render/framegraph/blitframebuffer.cpp | 76 | ||||
-rw-r--r-- | src/render/framegraph/blitframebuffer_p.h | 4 | ||||
-rw-r--r-- | src/render/framegraph/qblitframebuffer.cpp | 1 |
3 files changed, 38 insertions, 43 deletions
diff --git a/src/render/framegraph/blitframebuffer.cpp b/src/render/framegraph/blitframebuffer.cpp index 342594baf..c45d3fdbc 100644 --- a/src/render/framegraph/blitframebuffer.cpp +++ b/src/render/framegraph/blitframebuffer.cpp @@ -60,48 +60,44 @@ BlitFramebuffer::BlitFramebuffer() { } -void BlitFramebuffer::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) +void BlitFramebuffer::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) { - if (e->type() == PropertyUpdated) { - QPropertyUpdatedChangePtr propertyChange = qSharedPointerCast<QPropertyUpdatedChange>(e); - if (propertyChange->propertyName() == QByteArrayLiteral("sourceRenderTarget")) { - m_sourceRenderTargetId = propertyChange->value().value<QNodeId>(); - markDirty(AbstractRenderer::FrameGraphDirty); - } else if (propertyChange->propertyName() == QByteArrayLiteral("destinationRenderTarget")) { - m_destinationRenderTargetId = propertyChange->value().value<QNodeId>(); - markDirty(AbstractRenderer::FrameGraphDirty); - } else if (propertyChange->propertyName() == QByteArrayLiteral("sourceRect")) { - m_sourceRect = propertyChange->value().toRect(); - markDirty(AbstractRenderer::FrameGraphDirty); - } else if (propertyChange->propertyName() == QByteArrayLiteral("destinationRect")) { - m_destinationRect = propertyChange->value().toRect(); - markDirty(AbstractRenderer::FrameGraphDirty); - } else if (propertyChange->propertyName() == QByteArrayLiteral("sourceAttachmentPoint")) { - m_sourceAttachmentPoint = propertyChange->value().value<Qt3DRender::QRenderTargetOutput::AttachmentPoint>(); - markDirty(AbstractRenderer::FrameGraphDirty); - } else if (propertyChange->propertyName() == QByteArrayLiteral("destinationAttachmentPoint")) { - m_destinationAttachmentPoint = propertyChange->value().value<Qt3DRender::QRenderTargetOutput::AttachmentPoint>(); - markDirty(AbstractRenderer::FrameGraphDirty); - } else if (propertyChange->propertyName() == QByteArrayLiteral("interpolationMethod")) { - m_interpolationMethod = propertyChange->value().value<QBlitFramebuffer::InterpolationMethod>(); - markDirty(AbstractRenderer::FrameGraphDirty); - } - } - FrameGraphNode::sceneChangeEvent(e); -} + const QBlitFramebuffer *node = qobject_cast<const QBlitFramebuffer *>(frontEnd); + if (!node) + return; -void BlitFramebuffer::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) -{ - FrameGraphNode::initializeFromPeer(change); - const auto typedChange = qSharedPointerCast<Qt3DCore::QNodeCreatedChange<QBlitFramebufferData> >(change); - const auto &data = typedChange->data; - m_sourceRect = data.m_sourceRect; - m_destinationRect = data.m_destinationRect; - m_sourceRenderTargetId = data.m_sourceRenderTargetId; - m_destinationRenderTargetId = data.m_destinationRenderTargetId; - m_sourceAttachmentPoint = data.m_sourceAttachmentPoint; - m_destinationAttachmentPoint = data.m_destinationAttachmentPoint; - m_interpolationMethod = data.m_interpolationMethod; + FrameGraphNode::syncFromFrontEnd(frontEnd, firstTime); + + if (node->sourceRect().toRect() != m_sourceRect) { + m_sourceRect = node->sourceRect().toRect(); + markDirty(AbstractRenderer::FrameGraphDirty); + } + if (node->destinationRect().toRect() != m_destinationRect) { + m_destinationRect = node->destinationRect().toRect(); + markDirty(AbstractRenderer::FrameGraphDirty); + } + if (node->sourceAttachmentPoint() != m_sourceAttachmentPoint) { + m_sourceAttachmentPoint = node->sourceAttachmentPoint(); + markDirty(AbstractRenderer::FrameGraphDirty); + } + if (node->destinationAttachmentPoint() != m_destinationAttachmentPoint) { + m_destinationAttachmentPoint = node->destinationAttachmentPoint(); + markDirty(AbstractRenderer::FrameGraphDirty); + } + if (node->interpolationMethod() != m_interpolationMethod) { + m_interpolationMethod = node->interpolationMethod(); + markDirty(AbstractRenderer::FrameGraphDirty); + } + const QNodeId destinationNodeId = qIdForNode(node->destination()); + if (destinationNodeId != m_destinationRenderTargetId) { + m_destinationRenderTargetId = destinationNodeId; + markDirty(AbstractRenderer::FrameGraphDirty); + } + const QNodeId sourceNodeId = qIdForNode(node->source()); + if (sourceNodeId != m_sourceRenderTargetId) { + m_sourceRenderTargetId = sourceNodeId; + markDirty(AbstractRenderer::FrameGraphDirty); + } } Qt3DRender::QRenderTargetOutput::AttachmentPoint BlitFramebuffer::destinationAttachmentPoint() const diff --git a/src/render/framegraph/blitframebuffer_p.h b/src/render/framegraph/blitframebuffer_p.h index 796c223ca..fa9ddacd9 100644 --- a/src/render/framegraph/blitframebuffer_p.h +++ b/src/render/framegraph/blitframebuffer_p.h @@ -65,7 +65,7 @@ class Q_AUTOTEST_EXPORT BlitFramebuffer : public FrameGraphNode public: BlitFramebuffer(); - void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) override; + void syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) override; Qt3DCore::QNodeId sourceRenderTargetId() const; @@ -82,8 +82,6 @@ public: QBlitFramebuffer::InterpolationMethod interpolationMethod() const; private: - void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) final; - Qt3DCore::QNodeId m_sourceRenderTargetId; Qt3DCore::QNodeId m_destinationRenderTargetId; QRect m_sourceRect; diff --git a/src/render/framegraph/qblitframebuffer.cpp b/src/render/framegraph/qblitframebuffer.cpp index d0e1bdbf3..bf9e547cb 100644 --- a/src/render/framegraph/qblitframebuffer.cpp +++ b/src/render/framegraph/qblitframebuffer.cpp @@ -364,6 +364,7 @@ void QBlitFramebuffer::setDestination(QRenderTarget *destination) } } +// TO DO Qt6: convert QRectF to QRect /*! Sets the source rectangle to \a inputRect. The coordinates are assumed to follow the normal Qt coordinate system, meaning Y runs from top to bottom. |