aboutsummaryrefslogtreecommitdiffstats
path: root/src/effects/qquickrectangularshadow_p_p.h
blob: 6b6c3e3d2baac43bab1a016625f24ed26fc204bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QQUICKRECTANGULARSHADOW_P_P_H
#define QQUICKRECTANGULARSHADOW_P_P_H

//
//  W A R N I N G
//  -------------
//
// This file is not part of the Qt API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//

#include <private/qtquickglobal_p.h>

QT_REQUIRE_CONFIG(quick_shadereffect);

#include <private/qquickrectangularshadow_p.h>
#include <private/qquickitem_p.h>
#include <private/qlazilyallocated_p.h>

QT_BEGIN_NAMESPACE

class QQuickShaderEffect;

class QQuickRectangularShadowPrivate : public QQuickItemPrivate
{
    Q_DECLARE_PUBLIC(QQuickRectangularShadow)

public:
    QQuickRectangularShadowPrivate();

private:
    void initialize();
    void handleGeometryChange(const QRectF &newGeometry, const QRectF &oldGeometry);
    void handleItemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value);
    qreal getPadding() const;
    void updateColor();
    void updateShaderSource();
    void updateSizeProperties();
    void updateCached();
    qreal clampedRadius(qreal radius) const;
    QVector4D clampedRadius4R() const;
    QQuickItem *currentMaterial() const;
    void maybeSetImplicitAntialiasing();
    bool useIndividualRadius() const;
    void updateDefaultShader();

    QQuickShaderEffect *m_defaultMaterial = nullptr;
    QQuickItem *m_material = nullptr;
    QColor m_color = { 0, 0, 0, 255 };
    QVector2D m_offset;
    qreal m_blur = 10.0;
    qreal m_radius = 0.0;
    qreal m_spread = 0.0;
    bool m_cached = false;
    bool m_initialized = false;

    struct ExtraData {
        ExtraData()
            : topLeftRadius(0),
              topRightRadius(0),
              bottomLeftRadius(0),
              bottomRightRadius(0),
              isTopLeftRadiusSet(false),
              isTopRightRadiusSet(false),
              isBottomLeftRadiusSet(false),
              isBottomRightRadiusSet(false)
        {
        }
        qreal topLeftRadius;
        qreal topRightRadius;
        qreal bottomLeftRadius;
        qreal bottomRightRadius;

        unsigned isTopLeftRadiusSet : 1;
        unsigned isTopRightRadiusSet : 1;
        unsigned isBottomLeftRadiusSet : 1;
        unsigned isBottomRightRadiusSet : 1;
    };
    QLazilyAllocated<ExtraData> extra;
};

QT_END_NAMESPACE

#endif // QQUICKRECTANGULARSHADOW_P_P_H