1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtQuick 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#ifndef QSGSOFTWARERENDERABLENODE_H
41#define QSGSOFTWARERENDERABLENODE_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is not part of the Qt API. It exists purely as an
48// implementation detail. This header file may change from version to
49// version without notice, or even be removed.
50//
51// We mean it.
52//
53
54#include <QtQuick/private/qtquickglobal_p.h>
55
56#include <QtGui/QRegion>
57#include <QtCore/QRect>
58#include <QtGui/QTransform>
59#include <QtQuick/qsgrectanglenode.h>
60#include <QtQuick/qsgimagenode.h>
61#include <QtQuick/qsgninepatchnode.h>
62
63QT_BEGIN_NAMESPACE
64
65class QSGSimpleRectNode;
66class QSGSimpleTextureNode;
67class QSGSoftwareInternalImageNode;
68class QSGSoftwarePainterNode;
69class QSGSoftwareInternalRectangleNode;
70class QSGSoftwareGlyphNode;
71class QSGSoftwareNinePatchNode;
72class QSGSoftwareSpriteNode;
73class QSGRenderNode;
74
75class Q_QUICK_PRIVATE_EXPORT QSGSoftwareRenderableNode
76{
77public:
78 enum NodeType {
79 Invalid = -1,
80 SimpleRect,
81 SimpleTexture,
82 Image,
83 Painter,
84 Rectangle,
85 Glyph,
86 NinePatch,
87 SimpleRectangle,
88 SimpleImage,
89#if QT_CONFIG(quick_sprite)
90 SpriteNode,
91#endif
92 RenderNode
93 };
94
95 QSGSoftwareRenderableNode(NodeType type, QSGNode *node);
96 ~QSGSoftwareRenderableNode();
97
98 void update();
99
100 QRegion renderNode(QPainter *painter, bool forceOpaquePainting = false);
101 QRect boundingRectMin() const { return m_boundingRectMin; }
102 QRect boundingRectMax() const { return m_boundingRectMax; }
103 NodeType type() const { return m_nodeType; }
104 bool isOpaque() const { return m_isOpaque; }
105 bool isDirty() const { return m_isDirty; }
106 bool isDirtyRegionEmpty() const;
107 QSGNode *handle() const { return m_handle.node; }
108
109 void setTransform(const QTransform &transform);
110 void setClipRegion(const QRegion &clipRegion, bool hasClipRegion = true);
111 void setOpacity(float opacity);
112 QTransform transform() const { return m_transform; }
113 QRegion clipRegion() const { return m_clipRegion; }
114 float opacity() const { return m_opacity; }
115
116 void markGeometryDirty();
117 void markMaterialDirty();
118
119 void addDirtyRegion(const QRegion &dirtyRegion, bool forceDirty = true);
120 void subtractDirtyRegion(const QRegion &dirtyRegion);
121
122 QRegion previousDirtyRegion(bool wasRemoved = false) const;
123 QRegion dirtyRegion() const;
124
125private:
126 union RenderableNodeHandle {
127 QSGNode *node;
128 QSGSimpleRectNode *simpleRectNode;
129 QSGSimpleTextureNode *simpleTextureNode;
130 QSGSoftwareInternalImageNode *imageNode;
131 QSGSoftwarePainterNode *painterNode;
132 QSGSoftwareInternalRectangleNode *rectangleNode;
133 QSGSoftwareGlyphNode *glpyhNode;
134 QSGSoftwareNinePatchNode *ninePatchNode;
135 QSGRectangleNode *simpleRectangleNode;
136 QSGImageNode *simpleImageNode;
137 QSGSoftwareSpriteNode *spriteNode;
138 QSGRenderNode *renderNode;
139 };
140
141 const NodeType m_nodeType;
142 RenderableNodeHandle m_handle;
143
144 bool m_isOpaque;
145
146 bool m_isDirty;
147 QRegion m_dirtyRegion;
148 QRegion m_previousDirtyRegion;
149
150 QTransform m_transform;
151 QRegion m_clipRegion;
152 bool m_hasClipRegion;
153 float m_opacity;
154
155 QRect m_boundingRectMin;
156 QRect m_boundingRectMax;
157};
158
159QT_END_NAMESPACE
160
161#endif // QSGSOFTWARERENDERABLENODE_H
162

source code of qtdeclarative/src/quick/scenegraph/adaptations/software/qsgsoftwarerenderablenode_p.h