1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2017 Klaralvdalens Datakonsult AB (KDAB). |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the Qt3D module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #include <Qt3DRender/private/qblitframebuffer_p.h> |
41 | #include <Qt3DRender/private/blitframebuffer_p.h> |
42 | |
43 | QT_BEGIN_NAMESPACE |
44 | |
45 | using namespace Qt3DCore; |
46 | |
47 | namespace Qt3DRender { |
48 | namespace Render { |
49 | |
50 | BlitFramebuffer::BlitFramebuffer() |
51 | : FrameGraphNode(FrameGraphNode::BlitFramebuffer) |
52 | , m_sourceRenderTargetId(Qt3DCore::QNodeId()) |
53 | , m_destinationRenderTargetId(Qt3DCore::QNodeId()) |
54 | , m_sourceRect(QRect()) |
55 | , m_destinationRect(QRect()) |
56 | , m_sourceAttachmentPoint(Qt3DRender::QRenderTargetOutput::Color0) |
57 | , m_destinationAttachmentPoint(Qt3DRender::QRenderTargetOutput::Color0) |
58 | , m_interpolationMethod(Qt3DRender::QBlitFramebuffer::Linear) |
59 | { |
60 | } |
61 | |
62 | void BlitFramebuffer::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime) |
63 | { |
64 | const QBlitFramebuffer *node = qobject_cast<const QBlitFramebuffer *>(object: frontEnd); |
65 | if (!node) |
66 | return; |
67 | |
68 | FrameGraphNode::syncFromFrontEnd(frontEnd, firstTime); |
69 | |
70 | if (node->sourceRect().toRect() != m_sourceRect) { |
71 | m_sourceRect = node->sourceRect().toRect(); |
72 | markDirty(changes: AbstractRenderer::FrameGraphDirty); |
73 | } |
74 | if (node->destinationRect().toRect() != m_destinationRect) { |
75 | m_destinationRect = node->destinationRect().toRect(); |
76 | markDirty(changes: AbstractRenderer::FrameGraphDirty); |
77 | } |
78 | if (node->sourceAttachmentPoint() != m_sourceAttachmentPoint) { |
79 | m_sourceAttachmentPoint = node->sourceAttachmentPoint(); |
80 | markDirty(changes: AbstractRenderer::FrameGraphDirty); |
81 | } |
82 | if (node->destinationAttachmentPoint() != m_destinationAttachmentPoint) { |
83 | m_destinationAttachmentPoint = node->destinationAttachmentPoint(); |
84 | markDirty(changes: AbstractRenderer::FrameGraphDirty); |
85 | } |
86 | if (node->interpolationMethod() != m_interpolationMethod) { |
87 | m_interpolationMethod = node->interpolationMethod(); |
88 | markDirty(changes: AbstractRenderer::FrameGraphDirty); |
89 | } |
90 | const QNodeId destinationNodeId = qIdForNode(node: node->destination()); |
91 | if (destinationNodeId != m_destinationRenderTargetId) { |
92 | m_destinationRenderTargetId = destinationNodeId; |
93 | markDirty(changes: AbstractRenderer::FrameGraphDirty); |
94 | } |
95 | const QNodeId sourceNodeId = qIdForNode(node: node->source()); |
96 | if (sourceNodeId != m_sourceRenderTargetId) { |
97 | m_sourceRenderTargetId = sourceNodeId; |
98 | markDirty(changes: AbstractRenderer::FrameGraphDirty); |
99 | } |
100 | } |
101 | |
102 | Qt3DRender::QRenderTargetOutput::AttachmentPoint BlitFramebuffer::destinationAttachmentPoint() const |
103 | { |
104 | return m_destinationAttachmentPoint; |
105 | } |
106 | |
107 | QBlitFramebuffer::InterpolationMethod BlitFramebuffer::interpolationMethod() const |
108 | { |
109 | return m_interpolationMethod; |
110 | } |
111 | |
112 | Qt3DRender::QRenderTargetOutput::AttachmentPoint BlitFramebuffer::sourceAttachmentPoint() const |
113 | { |
114 | return m_sourceAttachmentPoint; |
115 | } |
116 | |
117 | QRect BlitFramebuffer::destinationRect() const |
118 | { |
119 | return m_destinationRect; |
120 | } |
121 | |
122 | QRect BlitFramebuffer::sourceRect() const |
123 | { |
124 | return m_sourceRect; |
125 | } |
126 | |
127 | Qt3DCore::QNodeId BlitFramebuffer::destinationRenderTargetId() const |
128 | { |
129 | return m_destinationRenderTargetId; |
130 | } |
131 | |
132 | Qt3DCore::QNodeId BlitFramebuffer::sourceRenderTargetId() const |
133 | { |
134 | return m_sourceRenderTargetId; |
135 | } |
136 | |
137 | } // namespace Render |
138 | } // namespace Qt3DRender |
139 | |
140 | QT_END_NAMESPACE |
141 | |