Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qsggradientcache_p.h
Go to the documentation of this file.
1// Copyright (C) 2023 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 QSGGRADIENTCACHE_P_H
5#define QSGGRADIENTCACHE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of a number of Qt sources files. This header file may change from
13// version to version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qhash.h>
19#include <QtGui/qbrush.h>
20
21#include <QtQuick/qtquickexports.h>
22
24
25class QSGTexture;
26class QSGPlainTexture;
27class QRhi;
28
29struct Q_QUICK_EXPORT QSGGradientCacheKey
30{
32 : stops(stops), spread(spread)
33 { }
37 {
38 return spread == other.spread && stops == other.stops;
39 }
40};
41
42inline size_t qHash(const QSGGradientCacheKey &v, size_t seed = 0)
43{
44 size_t h = seed + v.spread;
45 for (int i = 0; i < 3 && i < v.stops.size(); ++i)
46 h += v.stops[i].second.rgba();
47 return h;
48}
49
50class Q_QUICK_EXPORT QSGGradientCache
51{
52public:
53 struct GradientDesc { // can fully describe a linear/radial/conical gradient
56 QPointF a; // start (L) or center point (R/C)
57 QPointF b; // end (L) or focal point (R)
58 qreal v0; // center radius (R) or start angle (C)
59 qreal v1; // focal radius (R)
60 };
61
63 static QSGGradientCache *cacheForRhi(QRhi *rhi);
65
66private:
67 QHash<QSGGradientCacheKey, QSGPlainTexture *> m_textures;
68};
69
71
72#endif // QSGGRADIENTCACHE_P_H
Spread
Specifies how the area outside the gradient area should be filled.
Definition qbrush.h:146
@ PadSpread
Definition qbrush.h:147
\inmodule QtCore\reentrant
Definition qpoint.h:217
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
Definition qrhi.h:1804
\inmodule QtQuick
Definition qsgtexture.h:20
Combined button and popup list for selecting options.
static QDBusError::ErrorType get(const char *name)
GLsizei const GLfloat * v
[13]
GLfloat GLfloat GLfloat GLfloat h
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
size_t qHash(const QSGGradientCacheKey &v, size_t seed=0)
double qreal
Definition qtypes.h:187
QSharedPointer< T > other(t)
[5]
QGradient::Spread spread
QSGGradientCacheKey(const QGradientStops &stops, QGradient::Spread spread)
bool operator==(const QSGGradientCacheKey &other) const