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 | using namespace Qt3DCore; |
12 | |
13 | namespace Qt3DRender { |
14 | namespace Render { |
15 | |
16 | RenderTargetOutput::RenderTargetOutput() |
17 | : BackendNode() |
18 | { |
19 | } |
20 | |
21 | void RenderTargetOutput::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) |
22 | { |
23 | const QRenderTargetOutput *node = qobject_cast<const QRenderTargetOutput *>(object: frontEnd); |
24 | if (!node) |
25 | return; |
26 | |
27 | const bool oldEnabled = isEnabled(); |
28 | BackendNode::syncFromFrontEnd(frontEnd, firstTime); |
29 | |
30 | if (node->attachmentPoint() != m_attachmentData.m_point) { |
31 | m_attachmentData.m_point = node->attachmentPoint(); |
32 | markDirty(changes: AbstractRenderer::AllDirty); |
33 | } |
34 | if (node->mipLevel() != m_attachmentData.m_mipLevel) { |
35 | m_attachmentData.m_mipLevel = node->mipLevel(); |
36 | markDirty(changes: AbstractRenderer::AllDirty); |
37 | } |
38 | if (node->layer() != m_attachmentData.m_layer) { |
39 | m_attachmentData.m_layer = node->layer(); |
40 | markDirty(changes: AbstractRenderer::AllDirty); |
41 | } |
42 | if (node->face() != m_attachmentData.m_face) { |
43 | m_attachmentData.m_face = node->face(); |
44 | markDirty(changes: AbstractRenderer::AllDirty); |
45 | } |
46 | const auto textureId = Qt3DCore::qIdForNode(node: node->texture()); |
47 | if (textureId != m_attachmentData.m_textureUuid) { |
48 | m_attachmentData.m_textureUuid = textureId; |
49 | markDirty(changes: AbstractRenderer::AllDirty); |
50 | } |
51 | |
52 | if (oldEnabled != isEnabled()) |
53 | markDirty(changes: AbstractRenderer::AllDirty); |
54 | } |
55 | |
56 | Qt3DCore::QNodeId RenderTargetOutput::textureUuid() const |
57 | { |
58 | return m_attachmentData.m_textureUuid; |
59 | } |
60 | |
61 | int RenderTargetOutput::mipLevel() const |
62 | { |
63 | return m_attachmentData.m_mipLevel; |
64 | } |
65 | |
66 | int RenderTargetOutput::layer() const |
67 | { |
68 | return m_attachmentData.m_layer; |
69 | } |
70 | |
71 | QString RenderTargetOutput::name() const |
72 | { |
73 | return m_attachmentData.m_name; |
74 | } |
75 | |
76 | QAbstractTexture::CubeMapFace RenderTargetOutput::face() const |
77 | { |
78 | return m_attachmentData.m_face; |
79 | } |
80 | |
81 | QRenderTargetOutput::AttachmentPoint RenderTargetOutput::point() const |
82 | { |
83 | return m_attachmentData.m_point; |
84 | } |
85 | |
86 | Qt3DRender::Render::Attachment *RenderTargetOutput::attachment() |
87 | { |
88 | return &m_attachmentData; |
89 | } |
90 | |
91 | const Attachment *RenderTargetOutput::attachment() const |
92 | { |
93 | return &m_attachmentData; |
94 | } |
95 | |
96 | } // namespace Render |
97 | } // namespace Qt3DRender |
98 | |
99 | QT_END_NAMESPACE |
100 |