Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsgdefaultpainternode_p.h
Go to the documentation of this file.
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>
21
22#include <QtQuick/qquickpainteditem.h>
23
24#include <QtGui/qcolor.h>
25
26#if QT_CONFIG(opengl)
27#include <QOpenGLFramebufferObject>
28#include <QOpenGLPaintDevice>
29#endif
30
32
33class QSGDefaultRenderContext;
34class QRhiTexture;
35
36class Q_QUICK_EXPORT QSGPainterTexture : public QSGPlainTexture
37{
38public:
39 QSGPainterTexture();
40
41 void setDirtyRect(const QRect &rect) { m_dirty_rect = rect; }
42
43 void commitTextureOperations(QRhi *rhi, QRhiResourceUpdateBatch *resourceUpdates) override;
44
45private:
46 QRect m_dirty_rect;
47};
48
49class Q_QUICK_EXPORT QSGDefaultPainterNode : public QSGPainterNode
50{
51public:
52 QSGDefaultPainterNode(QQuickPaintedItem *item);
53 virtual ~QSGDefaultPainterNode();
54
55 void setPreferredRenderTarget(QQuickPaintedItem::RenderTarget target) override;
56
57 void setSize(const QSize &size) override;
58 QSize size() const { return m_size; }
59
60 void setDirty(const QRect &dirtyRect = QRect()) override;
61
62 void setOpaquePainting(bool opaque) override;
63 bool opaquePainting() const { return m_opaquePainting; }
64
65 void setLinearFiltering(bool linearFiltering) override;
66 bool linearFiltering() const { return m_linear_filtering; }
67
68 void setMipmapping(bool mipmapping) override;
69 bool mipmapping() const { return m_mipmapping; }
70
71 void setSmoothPainting(bool s) override;
72 bool smoothPainting() const { return m_smoothPainting; }
73
74 void setFillColor(const QColor &c) override;
75 QColor fillColor() const { return m_fillColor; }
76
77 void setContentsScale(qreal s) override;
78 qreal contentsScale() const { return m_contentsScale; }
79
80 void setFastFBOResizing(bool fastResizing) override;
81 bool fastFBOResizing() const { return m_fastFBOResizing; }
82
83 void setTextureSize(const QSize &textureSize) override;
84 QSize textureSize() const { return m_textureSize; }
85
86 QImage toImage() const override;
87 void update() override;
88
89 void paint();
90
91 QSGTexture *texture() const override { return m_texture; }
92
93private:
94 void updateTexture();
95 void updateGeometry();
96 void updateRenderTarget();
97
98#if QT_CONFIG(opengl)
99 void updateFBOSize();
100#endif
101
102 QSGDefaultRenderContext *m_context;
103
104 QQuickPaintedItem::RenderTarget m_preferredRenderTarget;
105 QQuickPaintedItem::RenderTarget m_actualRenderTarget;
106
107 QQuickPaintedItem *m_item;
108
109 QImage m_image;
110
111 QSGOpaqueTextureMaterial m_material;
112 QSGTextureMaterial m_materialO;
113 QSGGeometry m_geometry;
114 QSGPainterTexture *m_texture;
115
116#if QT_CONFIG(opengl)
117 QOpenGLFramebufferObject *m_fbo;
118 QOpenGLFramebufferObject *m_multisampledFbo;
119 QOpenGLPaintDevice *m_gl_device;
120 QRhiTexture *m_wrapperTexture;
121 QSize m_fboSize;
122#endif
123
124 QSize m_size;
125 QSize m_textureSize;
126 QRect m_dirtyRect;
127 QColor m_fillColor;
128 qreal m_contentsScale;
129
130 bool m_dirtyContents : 1;
131 bool m_opaquePainting : 1;
132 bool m_linear_filtering : 1;
133 bool m_mipmapping : 1;
134 bool m_smoothPainting : 1;
135#if QT_CONFIG(opengl)
136 bool m_extensionsChecked : 1;
137 bool m_multisamplingSupported : 1;
138#endif
139 bool m_fastFBOResizing : 1;
140 bool m_dirtyGeometry : 1;
141 bool m_dirtyRenderTarget : 1;
142 bool m_dirtyTexture : 1;
143};
144
145QT_END_NAMESPACE
146
147#endif // QSGDEFAULTPAINTERNODE_P_H