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 QQUICKFRAMEBUFFEROBJECT_H
5#define QQUICKFRAMEBUFFEROBJECT_H
6
7#include <QtQuick/QQuickItem>
8
9QT_BEGIN_NAMESPACE
10
11class QOpenGLFramebufferObject;
12class QQuickFramebufferObjectPrivate;
13class QSGFramebufferObjectNode;
14
15class Q_QUICK_EXPORT QQuickFramebufferObject : public QQuickItem
16{
17 Q_OBJECT
18 Q_DECLARE_PRIVATE(QQuickFramebufferObject)
19
20 Q_PROPERTY(bool textureFollowsItemSize READ textureFollowsItemSize WRITE setTextureFollowsItemSize NOTIFY textureFollowsItemSizeChanged FINAL)
21 Q_PROPERTY(bool mirrorVertically READ mirrorVertically WRITE setMirrorVertically NOTIFY mirrorVerticallyChanged FINAL)
22
23public:
24
25 class Q_QUICK_EXPORT Renderer {
26 protected:
27 Renderer();
28 virtual ~Renderer();
29 virtual void render() = 0;
30 virtual QOpenGLFramebufferObject *createFramebufferObject(const QSize &size);
31 virtual void synchronize(QQuickFramebufferObject *);
32 QOpenGLFramebufferObject *framebufferObject() const;
33 void update();
34 void invalidateFramebufferObject();
35 private:
36 friend class QSGFramebufferObjectNode;
37 friend class QQuickFramebufferObject;
38 void *data;
39 };
40
41 QQuickFramebufferObject(QQuickItem *parent = nullptr);
42
43 bool textureFollowsItemSize() const;
44 void setTextureFollowsItemSize(bool follows);
45
46 bool mirrorVertically() const;
47 void setMirrorVertically(bool enable);
48
49 virtual Renderer *createRenderer() const = 0;
50
51 bool isTextureProvider() const override;
52 QSGTextureProvider *textureProvider() const override;
53 void releaseResources() override;
54
55protected:
56 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
57
58protected:
59 QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *) override;
60
61Q_SIGNALS:
62 void textureFollowsItemSizeChanged(bool);
63 void mirrorVerticallyChanged(bool);
64
65private Q_SLOTS:
66 void invalidateSceneGraph();
67};
68
69QT_END_NAMESPACE
70
71#endif // QQUICKFRAMEBUFFEROBJECT_H
72

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