DtkDeclarative
DTK Declarative module
载入中...
搜索中...
未找到
dsoftwareeffectrendernode.h
1// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DSOFTWARERENDERNODE_H
6#define DSOFTWARERENDERNODE_H
7
8#include <dtkdeclarative_global.h>
9
10#include <QObject>
11#include <QImage>
12#include <QSGRenderNode>
13#include <QPointer>
14#include <QPainter>
15#include <QSGTextureProvider>
16
17QT_BEGIN_NAMESPACE
18class QQuickWindow;
19class QQuickItem;
20//class QSGTextureProvider;
21class QSGTexture;
22QT_END_NAMESPACE
23
24DQUICK_BEGIN_NAMESPACE
25
26class DSoftwareEffectRenderNode : public QObject, public QSGRenderNode
27{
28 Q_OBJECT
29public:
30 explicit DSoftwareEffectRenderNode(QSGTextureProvider *sourceProvider);
31
32 RenderingFlags flags() const override { return BoundedRectRendering; }
33 void preprocess() override;
34 StateFlags changedStates() const override { return {}; }
35 virtual QImage process(const QImage &sourceImage, QPainter::RenderHints hints) = 0;
36 virtual void sync(QQuickItem *item);
37 void render(const RenderState *state) override final;
38
39 void setCached(bool cached);
40 bool cached() const;
41
42 void markChanged();
43
44protected Q_SLOTS:
45 void onRenderTextureChanged();
46
47protected:
48 QImage updateCachedImage(QSGTextureProvider *provider);
49 bool updateTexture(QSGTexture *texture);
50
51private:
52 void renderImpl(QPainter *p);
53
54private:
55 QPointer<QSGTextureProvider> m_sourceProvider;
56 QImage m_sourceImage;
57 QImage m_renderDevice;
58 QQuickItem *m_item = nullptr;
59 QQuickWindow *m_window = nullptr;
60 bool m_cached = false;
61 bool m_changed = true;
62 bool m_antialiasing = false;
63 bool m_smooth = false;
64};
65
66DQUICK_END_NAMESPACE
67
68#endif // DSOFTWARERENDERNODE_H
Definition dsoftwareeffectrendernode.h:27