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 QQUICKPAINTEDITEM_P_H
41#define QQUICKPAINTEDITEM_P_H
42
43#include <QtQuick/qquickitem.h>
44#include <QtGui/qcolor.h>
45
46QT_BEGIN_NAMESPACE
47
48class QQuickPaintedItemPrivate;
49class Q_QUICK_EXPORT QQuickPaintedItem : public QQuickItem
50{
51 Q_OBJECT
52
53 Q_PROPERTY(QSize contentsSize READ contentsSize WRITE setContentsSize NOTIFY contentsSizeChanged)
54 Q_PROPERTY(QColor fillColor READ fillColor WRITE setFillColor NOTIFY fillColorChanged)
55 Q_PROPERTY(qreal contentsScale READ contentsScale WRITE setContentsScale NOTIFY contentsScaleChanged)
56 Q_PROPERTY(RenderTarget renderTarget READ renderTarget WRITE setRenderTarget NOTIFY renderTargetChanged)
57 Q_PROPERTY(QSize textureSize READ textureSize WRITE setTextureSize NOTIFY textureSizeChanged)
58
59 QML_NAMED_ELEMENT(PaintedItem)
60 QML_UNCREATABLE("Cannot create instance of abstract class PaintedItem.")
61
62public:
63 explicit QQuickPaintedItem(QQuickItem *parent = nullptr);
64 ~QQuickPaintedItem() override;
65
66 enum RenderTarget {
67 Image,
68 FramebufferObject,
69 InvertedYFramebufferObject
70 };
71 Q_ENUM(RenderTarget)
72
73 enum PerformanceHint {
74 FastFBOResizing = 0x1
75 };
76 Q_DECLARE_FLAGS(PerformanceHints, PerformanceHint)
77 Q_FLAG(PerformanceHints)
78
79 void update(const QRect &rect = QRect());
80
81 bool opaquePainting() const;
82 void setOpaquePainting(bool opaque);
83
84 bool antialiasing() const;
85 void setAntialiasing(bool enable);
86
87 bool mipmap() const;
88 void setMipmap(bool enable);
89
90 PerformanceHints performanceHints() const;
91 void setPerformanceHint(PerformanceHint hint, bool enabled = true);
92 void setPerformanceHints(PerformanceHints hints);
93
94 QRectF contentsBoundingRect() const;
95
96 QSize contentsSize() const;
97 void setContentsSize(const QSize &);
98 void resetContentsSize();
99
100 qreal contentsScale() const;
101 void setContentsScale(qreal);
102
103 QSize textureSize() const;
104 void setTextureSize(const QSize &size);
105
106 QColor fillColor() const;
107 void setFillColor(const QColor&);
108
109 RenderTarget renderTarget() const;
110 void setRenderTarget(RenderTarget target);
111
112 virtual void paint(QPainter *painter) = 0;
113
114 bool isTextureProvider() const override;
115 QSGTextureProvider *textureProvider() const override;
116
117Q_SIGNALS:
118 void fillColorChanged();
119 void contentsSizeChanged();
120 void contentsScaleChanged();
121 void renderTargetChanged();
122 void textureSizeChanged();
123
124protected:
125 QQuickPaintedItem(QQuickPaintedItemPrivate &dd, QQuickItem *parent = nullptr);
126 QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
127 void releaseResources() override;
128 void itemChange(ItemChange, const ItemChangeData &) override;
129
130private Q_SLOTS:
131 void invalidateSceneGraph();
132
133private:
134 Q_DISABLE_COPY(QQuickPaintedItem)
135 Q_DECLARE_PRIVATE(QQuickPaintedItem)
136};
137
138Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickPaintedItem::PerformanceHints)
139
140QT_END_NAMESPACE
141
142#endif // QQUICKPAINTEDITEM_P_H
143

source code of qtdeclarative/src/quick/items/qquickpainteditem.h