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
qquickshadereffectsource_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// Qt-Security score:significant reason:default
4
5#ifndef QQUICKSHADEREFFECTSOURCE_P_H
6#define QQUICKSHADEREFFECTSOURCE_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtQuick/private/qtquickglobal_p.h>
20
22
23#include "qquickitem.h"
24#include <QtQuick/qsgtextureprovider.h>
25#include <private/qsgadaptationlayer_p.h>
26#include <QtQuick/private/qsgcontext_p.h>
27#include <private/qsgdefaultinternalimagenode_p.h>
28#include <private/qquickitemchangelistener_p.h>
29
30#include "qpointer.h"
31#include "qsize.h"
32#include "qrect.h"
33
35
36class QSGNode;
37class UpdatePaintNodeData;
38class QOpenGLFramebufferObject;
39class QSGSimpleRectNode;
40
42
43class Q_QUICK_EXPORT QQuickShaderEffectSource : public QQuickItem,
44 public QSafeQuickItemChangeListener<QQuickShaderEffectSource>
45{
46 Q_OBJECT
47 Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged)
48 Q_PROPERTY(QQuickItem *sourceItem READ sourceItem WRITE setSourceItem NOTIFY sourceItemChanged)
49 Q_PROPERTY(QRectF sourceRect READ sourceRect WRITE setSourceRect NOTIFY sourceRectChanged)
50 Q_PROPERTY(QSize textureSize READ textureSize WRITE setTextureSize NOTIFY textureSizeChanged)
51 Q_PROPERTY(Format format READ format WRITE setFormat NOTIFY formatChanged)
52 Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged)
53 Q_PROPERTY(bool hideSource READ hideSource WRITE setHideSource NOTIFY hideSourceChanged)
54 Q_PROPERTY(bool mipmap READ mipmap WRITE setMipmap NOTIFY mipmapChanged)
55 Q_PROPERTY(bool recursive READ recursive WRITE setRecursive NOTIFY recursiveChanged)
56 Q_PROPERTY(TextureMirroring textureMirroring READ textureMirroring WRITE setTextureMirroring NOTIFY textureMirroringChanged REVISION(2, 6))
57 Q_PROPERTY(int samples READ samples WRITE setSamples NOTIFY samplesChanged REVISION(2, 9))
58 QML_NAMED_ELEMENT(ShaderEffectSource)
59 QML_ADDED_IN_VERSION(2, 0)
60
61public:
62 enum WrapMode {
63 ClampToEdge,
64 RepeatHorizontally,
65 RepeatVertically,
66 Repeat
67 };
68 Q_ENUM(WrapMode)
69
70 enum Format {
71 RGBA8 = 1,
72 RGBA16F,
73 RGBA32F,
74
75 // Qt 5 legacy values that were ignored starting from Qt 6.0
76 Alpha = RGBA8,
77 RGB = RGBA8,
78 RGBA = RGBA8
79 };
80 Q_ENUM(Format)
81
82 enum TextureMirroring {
83 NoMirroring = 0x00,
84 MirrorHorizontally = 0x01,
85 MirrorVertically = 0x02
86 };
87 Q_ENUM(TextureMirroring)
88
89 QQuickShaderEffectSource(QQuickItem *parent = nullptr);
90 ~QQuickShaderEffectSource() override;
91
92 WrapMode wrapMode() const;
93 void setWrapMode(WrapMode mode);
94
95 QQuickItem *sourceItem() const;
96 void setSourceItem(QQuickItem *item);
97
98 QRectF sourceRect() const;
99 void setSourceRect(const QRectF &rect);
100
101 QSize textureSize() const;
102 void setTextureSize(const QSize &size);
103
104 Format format() const;
105 void setFormat(Format format);
106
107 bool live() const;
108 void setLive(bool live);
109
110 bool hideSource() const;
111 void setHideSource(bool hide);
112
113 bool mipmap() const;
114 void setMipmap(bool enabled);
115
116 bool recursive() const;
117 void setRecursive(bool enabled);
118
119 TextureMirroring textureMirroring() const;
120 void setTextureMirroring(TextureMirroring mirroring);
121
122 bool isTextureProvider() const override { return true; }
123 QSGTextureProvider *textureProvider() const override;
124
125 Q_INVOKABLE void scheduleUpdate();
126
127 int samples() const;
128 void setSamples(int count);
129
130Q_SIGNALS:
131 void wrapModeChanged();
132 void sourceItemChanged();
133 void sourceRectChanged();
134 void textureSizeChanged();
135 void formatChanged();
136 void liveChanged();
137 void hideSourceChanged();
138 void mipmapChanged();
139 void recursiveChanged();
140 void textureMirroringChanged();
141 void samplesChanged();
142
143 void scheduledUpdateCompleted();
144
145private Q_SLOTS:
146 void sourceItemDestroyed(QObject *item);
147 void invalidateSceneGraph();
148
149protected:
150 void releaseResources() override;
151 QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
152
153 void itemGeometryChanged(QQuickItem *item, QQuickGeometryChange change, const QRectF &) override;
154 void itemChange(ItemChange change, const ItemChangeData &value) override;
155
156private:
157 void ensureTexture();
158
159 QQuickShaderEffectSourceTextureProvider *m_provider;
160 QSGLayer *m_texture;
161 WrapMode m_wrapMode;
162 QQuickItem *m_sourceItem;
163 QRectF m_sourceRect;
164 QSize m_textureSize;
165 Format m_format;
166 int m_samples;
167 uint m_live : 1;
168 uint m_hideSource : 1;
169 uint m_mipmap : 1;
170 uint m_recursive : 1;
171 uint m_grab : 1;
172 uint m_textureMirroring : 2; // Stores TextureMirroring enum
173};
174
175QT_END_NAMESPACE
176
177#endif // QQUICKSHADEREFFECTSOURCE_P_H
QQuickShaderEffectSourceCleanup(QSGLayer *t, QQuickShaderEffectSourceTextureProvider *p)
QQuickShaderEffectSourceTextureProvider * provider
void run() override
Implement this pure virtual function in your subclass.
QT_REQUIRE_CONFIG(quick_shadereffect)
static void get_wrap_mode(QQuickShaderEffectSource::WrapMode mode, QSGTexture::WrapMode *hWrap, QSGTexture::WrapMode *vWrap)
static QSGLayer::Format toLayerFormat(QQuickShaderEffectSource::Format format)