DtkDeclarative
DTK Declarative module
载入中...
搜索中...
未找到
dsoftwareroundedimagenode_p.h
1// SPDX-FileCopyrightText: 2021 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DSOFTWAREROUNDEDIMAGENODE_P_H
6#define DSOFTWAREROUNDEDIMAGENODE_P_H
7
8#include <dtkdeclarative_global.h>
9#include <QSGRenderNode>
10#include <QImage>
11#include <QPainterPath>
12#include <QPainter>
13
14QT_BEGIN_NAMESPACE
15class QQuickItem;
16class QSGTexture;
17QT_END_NAMESPACE
18
19DQUICK_BEGIN_NAMESPACE
20
21class Q_DECL_EXPORT DSoftwareRoundedImageNode : public QSGRenderNode
22{
23public:
24 DSoftwareRoundedImageNode(QQuickItem *owner);
25
26 void setTexture(QSGTexture *texture);
27 inline QSGTexture *texture() const
28 { return m_texture;}
29 void setRadius(qreal radius);
30 void setSmooth(bool smooth);
31 void setSourceRect(const QRectF &source);
32 void setRect(const QRectF &target);
33 void setCompositionMode(QPainter::CompositionMode mode);
34
35 void render(const RenderState *state) override;
36 void releaseResources() override;
37 RenderingFlags flags() const override;
38 QRectF rect() const override;
39
40private:
41 void updateCachedImage();
42 QRectF convertToTextureNormalizedSourceRect() const;
43
44 qreal radius = 0;
45 bool smooth = false;
46 QRectF sourceRect;
47 QRectF targetRect;
48 QPainterPath clipPath;
49 QPainter::CompositionMode m_compositionMode = QPainter::CompositionMode_SourceOver;
50
51 QSGTexture *m_texture = nullptr;
52 QQuickItem *item = nullptr;
53 QImage cachedImage;
54};
55
56DQUICK_END_NAMESPACE
57
58#endif // DSOFTWAREROUNDEDIMAGENODE_P_H
Definition dsoftwareroundedimagenode_p.h:22