| 1 | // Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). |
|---|---|
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | #include <Qt3DRender/private/rendertargetoutput_p.h> |
| 5 | #include <Qt3DRender/qtexture.h> |
| 6 | #include <Qt3DRender/private/qrendertargetoutput_p.h> |
| 7 | #include <QVariant> |
| 8 | |
| 9 | QT_BEGIN_NAMESPACE |
| 10 | |
| 11 | |
| 12 | namespace Qt3DRender { |
| 13 | namespace Render { |
| 14 | |
| 15 | using namespace Qt3DCore; |
| 16 | |
| 17 | RenderTargetOutput::RenderTargetOutput() |
| 18 | : BackendNode() |
| 19 | { |
| 20 | } |
| 21 | |
| 22 | void RenderTargetOutput::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) |
| 23 | { |
| 24 | const QRenderTargetOutput *node = qobject_cast<const QRenderTargetOutput *>(object: frontEnd); |
| 25 | if (!node) |
| 26 | return; |
| 27 | |
| 28 | const bool oldEnabled = isEnabled(); |
| 29 | BackendNode::syncFromFrontEnd(frontEnd, firstTime); |
| 30 | |
| 31 | if (node->attachmentPoint() != m_attachmentData.m_point) { |
| 32 | m_attachmentData.m_point = node->attachmentPoint(); |
| 33 | markDirty(changes: AbstractRenderer::AllDirty); |
| 34 | } |
| 35 | if (node->mipLevel() != m_attachmentData.m_mipLevel) { |
| 36 | m_attachmentData.m_mipLevel = node->mipLevel(); |
| 37 | markDirty(changes: AbstractRenderer::AllDirty); |
| 38 | } |
| 39 | if (node->layer() != m_attachmentData.m_layer) { |
| 40 | m_attachmentData.m_layer = node->layer(); |
| 41 | markDirty(changes: AbstractRenderer::AllDirty); |
| 42 | } |
| 43 | if (node->face() != m_attachmentData.m_face) { |
| 44 | m_attachmentData.m_face = node->face(); |
| 45 | markDirty(changes: AbstractRenderer::AllDirty); |
| 46 | } |
| 47 | const auto textureId = Qt3DCore::qIdForNode(node: node->texture()); |
| 48 | if (textureId != m_attachmentData.m_textureUuid) { |
| 49 | m_attachmentData.m_textureUuid = textureId; |
| 50 | markDirty(changes: AbstractRenderer::AllDirty); |
| 51 | } |
| 52 | |
| 53 | if (oldEnabled != isEnabled()) |
| 54 | markDirty(changes: AbstractRenderer::AllDirty); |
| 55 | } |
| 56 | |
| 57 | Qt3DCore::QNodeId RenderTargetOutput::textureUuid() const |
| 58 | { |
| 59 | return m_attachmentData.m_textureUuid; |
| 60 | } |
| 61 | |
| 62 | int RenderTargetOutput::mipLevel() const |
| 63 | { |
| 64 | return m_attachmentData.m_mipLevel; |
| 65 | } |
| 66 | |
| 67 | int RenderTargetOutput::layer() const |
| 68 | { |
| 69 | return m_attachmentData.m_layer; |
| 70 | } |
| 71 | |
| 72 | QString RenderTargetOutput::name() const |
| 73 | { |
| 74 | return m_attachmentData.m_name; |
| 75 | } |
| 76 | |
| 77 | QAbstractTexture::CubeMapFace RenderTargetOutput::face() const |
| 78 | { |
| 79 | return m_attachmentData.m_face; |
| 80 | } |
| 81 | |
| 82 | QRenderTargetOutput::AttachmentPoint RenderTargetOutput::point() const |
| 83 | { |
| 84 | return m_attachmentData.m_point; |
| 85 | } |
| 86 | |
| 87 | Qt3DRender::Render::Attachment *RenderTargetOutput::attachment() |
| 88 | { |
| 89 | return &m_attachmentData; |
| 90 | } |
| 91 | |
| 92 | const Attachment *RenderTargetOutput::attachment() const |
| 93 | { |
| 94 | return &m_attachmentData; |
| 95 | } |
| 96 | |
| 97 | } // namespace Render |
| 98 | } // namespace Qt3DRender |
| 99 | |
| 100 | QT_END_NAMESPACE |
| 101 |
