Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qopenglgradientcache_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 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 QOPENGLGRADIENTCACHE_P_H
5#define QOPENGLGRADIENTCACHE_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 purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QMultiHash>
19#include <QObject>
20#include <private/qopenglcontext_p.h>
21#include <QtCore/qmutex.h>
22#include <QGradient>
23#include <qrgba64.h>
24
26
28{
29 struct CacheInfo
30 {
31 inline CacheInfo(QGradientStops s, qreal op, QGradient::InterpolationMode mode) :
32 stops(std::move(s)), opacity(op), interpolationMode(mode) {}
33
34 GLuint texId;
35 QGradientStops stops;
36 qreal opacity;
37 QGradient::InterpolationMode interpolationMode;
38 };
39
40 typedef QMultiHash<quint64, CacheInfo> QOpenGLGradientColorTableHash;
41
42public:
43 static QOpenGL2GradientCache *cacheForContext(QOpenGLContext *context);
44
45 QOpenGL2GradientCache(QOpenGLContext *);
47
48 GLuint getBuffer(const QGradient &gradient, qreal opacity);
49 inline int paletteSize() const { return 1024; }
50
52 void freeResource(QOpenGLContext *ctx) override;
53
54private:
55 inline int maxCacheSize() const { return 60; }
56 inline void generateGradientColorTable(const QGradient& gradient,
57 QRgba64 *colorTable,
58 int size, qreal opacity) const;
59 inline void generateGradientColorTable(const QGradient& gradient,
60 uint *colorTable,
61 int size, qreal opacity) const;
62 GLuint addCacheElement(quint64 hash_val, const QGradient &gradient, qreal opacity);
63 void cleanCache();
64
65 QOpenGLGradientColorTableHash cache;
66 QMutex m_mutex;
67};
68
69QT_END_NAMESPACE
70
71#endif // QOPENGLGRADIENTCACHE_P_H
QOpenGL2GradientCache * cacheForContext(QOpenGLContext *context)
static QOpenGL2GradientCache * cacheForContext(QOpenGLContext *context)
GLuint getBuffer(const QGradient &gradient, qreal opacity)
QOpenGL2GradientCache(QOpenGLContext *)
void freeResource(QOpenGLContext *ctx) override
\inmodule QtGui
The QOpenGLSharedResource class is used to keep track of resources that are shared between OpenGL con...
Combined button and popup list for selecting options.
#define GL_RGBA16
constexpr QRgba64 qPremultiply(QRgba64 c)
Definition qrgba64.h:190