DtkDeclarative
DTK Declarative module
载入中...
搜索中...
未找到
dmaskeffectnode_p.h
1// SPDX-FileCopyrightText: 2020 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DMASKEFFECTNODE_P_H
6#define DMASKEFFECTNODE_P_H
7
8#include "private/qsgtexturematerial_p.h"
9
10#include <dtkdeclarative_global.h>
11
12#include <QSGImageNode>
13#include <QPointer>
14#include <QPainter>
15
16DQUICK_BEGIN_NAMESPACE
17
18class OpaqueTextureMaterial : public QSGOpaqueTextureMaterial
19{
20public:
21 QSGMaterialType *type() const override;
22
23#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
24 QSGMaterialShader *createShader() const override;
25#else
26 QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
27#endif
28 int compare(const QSGMaterial *other) const override;
29
30 void setMaskTexture(QSGTexture *texture);
31 QSGTexture *maskTexture() const { return m_maskTexture.data(); }
32
33 void setMaskScale(QVector2D maskScale);
34 QVector2D maskScale() const { return m_maskScale; }
35
36 void setMaskOffset(QVector2D maskOffset);
37 QVector2D maskOffset() const { return m_maskOffset; }
38
39 void setSourceScale(QVector2D sourceScale);
40 QVector2D sourceScale() const { return m_sourceScale; }
41
42#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
43 QSGMaterialShader::GraphicsPipelineState::BlendFactor blendSrcColor() const
44 { return m_blendSrcColor; }
45
46 QSGMaterialShader::GraphicsPipelineState::BlendFactor blendDstColor() const
47 { return m_blendDstColor; }
48
49 void setBlendSrcColor(QSGMaterialShader::GraphicsPipelineState::BlendFactor factor);
50 void setBlendDstColor(QSGMaterialShader::GraphicsPipelineState::BlendFactor factor);
51#endif
52
53private:
54 QPointer<QSGTexture> m_maskTexture = nullptr;
55 QVector2D m_maskScale;
56 QVector2D m_maskOffset;
57 QVector2D m_sourceScale;
58#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
59 QSGMaterialShader::GraphicsPipelineState::BlendFactor m_blendSrcColor = QSGMaterialShader::GraphicsPipelineState::One;
60 QSGMaterialShader::GraphicsPipelineState::BlendFactor m_blendDstColor = QSGMaterialShader::GraphicsPipelineState::OneMinusSrcAlpha;
61#endif
62};
63
65{
66public:
67 QSGMaterialType *type() const override;
68#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
69 QSGMaterialShader *createShader() const override;
70#else
71 QSGMaterialShader *createShader(QSGRendererInterface::RenderMode renderMode) const override;
72#endif
73 int compare(const QSGMaterial *other) const override;
74};
75
76class MaskEffectNode : public QSGImageNode
77{
78public:
80 ~MaskEffectNode() override;
81
82 void setRect(const QRectF &rect) override;
83 QRectF rect() const override;
84
85 void setSourceRect(const QRectF &r) override;
86 QRectF sourceRect() const override;
87
88 void setTexture(QSGTexture *texture) override;
89 QSGTexture *texture() const override;
90
91 void setFiltering(QSGTexture::Filtering filtering) override;
92 QSGTexture::Filtering filtering() const override;
93
94 void setMipmapFiltering(QSGTexture::Filtering filtering) override;
95 QSGTexture::Filtering mipmapFiltering() const override;
96
97 void setTextureCoordinatesTransform(TextureCoordinatesTransformMode mode) override;
98 TextureCoordinatesTransformMode textureCoordinatesTransform() const override;
99
100 void setOwnsTexture(bool owns) override;
101 bool ownsTexture() const override;
102
103 void setAnisotropyLevel(QSGTexture::AnisotropyLevel level);
104
105 void setMaskTexture(QSGTexture *texture);
106 void setMaskScale(QVector2D maskScale);
107 void setMaskOffset(QVector2D maskOffset);
108 void setSourceScale(QVector2D sourceScale);
109#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
110 void setCompositionMode(QPainter::CompositionMode mode);
111#endif
112
113 QSGTexture::AnisotropyLevel anisotropyLevel() const;
114private:
115 QSGGeometry m_geometry;
116 OpaqueTextureMaterial m_opaque_material;
117 TextureMaterial m_material;
118 QRectF m_rect;
119 QRectF m_sourceRect;
120 TextureCoordinatesTransformMode m_texCoordMode;
121#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
122 QPainter::CompositionMode m_compositionMode = QPainter::CompositionMode_SourceOver;
123#endif
124
125 uint m_isAtlasTexture : 1;
126 uint m_ownsTexture : 1;
127};
128
129DQUICK_END_NAMESPACE
130
131#endif // DMASKEFFECTNODE_P_H
Definition dmaskeffectnode_p.h:77
Definition dmaskeffectnode_p.h:19
Definition dmaskeffectnode_p.h:65