1 | // Copyright (C) 2019 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 "shaderimage_p.h" |
5 | #include <Qt3DRender/private/qshaderimage_p.h> |
6 | #include <Qt3DRender/qabstracttexture.h> |
7 | |
8 | |
9 | QT_BEGIN_NAMESPACE |
10 | |
11 | namespace Qt3DRender { |
12 | |
13 | namespace Render { |
14 | |
15 | ShaderImage::ShaderImage() |
16 | : BackendNode(BackendNode::ReadOnly) |
17 | , m_textureId() |
18 | , m_mipLevel(0) |
19 | , m_layer(0) |
20 | , m_layered(false) |
21 | , m_access(QShaderImage::ReadWrite) |
22 | , m_format(QShaderImage::NoFormat) |
23 | { |
24 | } |
25 | |
26 | void ShaderImage::cleanup() |
27 | { |
28 | QBackendNode::setEnabled(false); |
29 | m_textureId = Qt3DCore::QNodeId(); |
30 | m_mipLevel = 0; |
31 | m_layer = 0; |
32 | m_layered = false; |
33 | m_access = QShaderImage::ReadWrite; |
34 | m_format = QShaderImage::NoFormat; |
35 | } |
36 | |
37 | void ShaderImage::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) |
38 | { |
39 | const QShaderImage *node = qobject_cast<const QShaderImage *>(object: frontEnd); |
40 | if (!node) |
41 | return; |
42 | |
43 | BackendNode::syncFromFrontEnd(frontEnd, firstTime); |
44 | |
45 | const Qt3DCore::QNodeId textureNodeId = Qt3DCore::qIdForNode(node: node->texture()); |
46 | if (textureNodeId != m_textureId) { |
47 | m_textureId = textureNodeId; |
48 | markDirty(changes: AbstractRenderer::ParameterDirty); |
49 | } |
50 | |
51 | if (node->mipLevel() != m_mipLevel) { |
52 | m_mipLevel = node->mipLevel(); |
53 | markDirty(changes: AbstractRenderer::ParameterDirty); |
54 | } |
55 | |
56 | if (node->layer() != m_layer) { |
57 | m_layer = node->layer(); |
58 | markDirty(changes: AbstractRenderer::ParameterDirty); |
59 | } |
60 | |
61 | if (node->layered() != m_layered) { |
62 | m_layered = node->layered(); |
63 | markDirty(changes: AbstractRenderer::ParameterDirty); |
64 | } |
65 | |
66 | if (node->format() != m_format) { |
67 | m_format = node->format(); |
68 | markDirty(changes: AbstractRenderer::ParameterDirty); |
69 | } |
70 | if (node->access() != m_access) { |
71 | m_access = node->access(); |
72 | markDirty(changes: AbstractRenderer::ParameterDirty); |
73 | } |
74 | |
75 | } |
76 | |
77 | } // namespace Render |
78 | |
79 | } // namespace Qt3DRender |
80 | |
81 | QT_END_NAMESPACE |
82 |