1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QSGDEFAULTPAINTERNODE_P_H
5#define QSGDEFAULTPAINTERNODE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <private/qsgadaptationlayer_p.h>
19#include "qsgtexturematerial.h"
20#include "qsgplaintexture_p.h"
21
22#include <QtQuick/qquickpainteditem.h>
23
24#include <QtGui/qcolor.h>
25
26QT_BEGIN_NAMESPACE
27
28class QSGDefaultRenderContext;
29
30class Q_QUICK_PRIVATE_EXPORT QSGPainterTexture : public QSGPlainTexture
31{
32public:
33 QSGPainterTexture();
34
35 void setDirtyRect(const QRect &rect) { m_dirty_rect = rect; }
36
37 void commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates) override;
38
39private:
40 QRect m_dirty_rect;
41};
42
43class Q_QUICK_PRIVATE_EXPORT QSGDefaultPainterNode : public QSGPainterNode
44{
45public:
46 QSGDefaultPainterNode(QQuickPaintedItem *item);
47 virtual ~QSGDefaultPainterNode();
48
49 void setPreferredRenderTarget(QQuickPaintedItem::RenderTarget target) override;
50
51 void setSize(const QSize &size) override;
52 QSize size() const { return m_size; }
53
54 void setDirty(const QRect &dirtyRect = QRect()) override;
55
56 void setOpaquePainting(bool opaque) override;
57 bool opaquePainting() const { return m_opaquePainting; }
58
59 void setLinearFiltering(bool linearFiltering) override;
60 bool linearFiltering() const { return m_linear_filtering; }
61
62 void setMipmapping(bool mipmapping) override;
63 bool mipmapping() const { return m_mipmapping; }
64
65 void setSmoothPainting(bool s) override;
66 bool smoothPainting() const { return m_smoothPainting; }
67
68 void setFillColor(const QColor &c) override;
69 QColor fillColor() const { return m_fillColor; }
70
71 void setContentsScale(qreal s) override;
72 qreal contentsScale() const { return m_contentsScale; }
73
74 void setFastFBOResizing(bool fastResizing) override;
75 bool fastFBOResizing() const { return m_fastFBOResizing; }
76
77 void setTextureSize(const QSize &textureSize) override;
78 QSize textureSize() const { return m_textureSize; }
79
80 QImage toImage() const override;
81 void update() override;
82
83 void paint();
84
85 QSGTexture *texture() const override { return m_texture; }
86
87private:
88 void updateTexture();
89 void updateGeometry();
90 void updateRenderTarget();
91
92 QSGDefaultRenderContext *m_context;
93
94 QQuickPaintedItem::RenderTarget m_preferredRenderTarget;
95 QQuickPaintedItem::RenderTarget m_actualRenderTarget;
96
97 QQuickPaintedItem *m_item;
98
99 QImage m_image;
100
101 QSGOpaqueTextureMaterial m_material;
102 QSGTextureMaterial m_materialO;
103 QSGGeometry m_geometry;
104 QSGPainterTexture *m_texture;
105
106 QSize m_size;
107 QSize m_textureSize;
108 QRect m_dirtyRect;
109 QColor m_fillColor;
110 qreal m_contentsScale;
111
112 bool m_dirtyContents : 1;
113 bool m_opaquePainting : 1;
114 bool m_linear_filtering : 1;
115 bool m_mipmapping : 1;
116 bool m_smoothPainting : 1;
117 bool m_multisamplingSupported : 1;
118 bool m_fastFBOResizing : 1;
119 bool m_dirtyGeometry : 1;
120 bool m_dirtyRenderTarget : 1;
121 bool m_dirtyTexture : 1;
122};
123
124QT_END_NAMESPACE
125
126#endif // QSGDEFAULTPAINTERNODE_P_H
127

source code of qtdeclarative/src/quick/scenegraph/util/qsgdefaultpainternode_p.h