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// Qt-Security score:significant reason:default
4
5#ifndef QOPENGLGRADIENTCACHE_P_H
6#define QOPENGLGRADIENTCACHE_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QMultiHash>
20#include <QObject>
21#include <private/qopenglcontext_p.h>
22#include <QtCore/qmutex.h>
23#include <QGradient>
24#include <qrgba64.h>
25
27
29{
30 struct CacheInfo
31 {
32 inline CacheInfo(QGradientStops s, qreal op, QGradient::InterpolationMode mode) :
33 stops(std::move(s)), opacity(op), interpolationMode(mode) {}
34
35 GLuint texId;
36 QGradientStops stops;
37 qreal opacity;
38 QGradient::InterpolationMode interpolationMode;
39 };
40
41 typedef QMultiHash<quint64, CacheInfo> QOpenGLGradientColorTableHash;
42
43public:
44 static QOpenGL2GradientCache *cacheForContext(QOpenGLContext *context);
45
46 QOpenGL2GradientCache(QOpenGLContext *);
48
49 GLuint getBuffer(const QGradient &gradient, qreal opacity);
50 inline int paletteSize() const { return 1024; }
51
53 void freeResource(QOpenGLContext *ctx) override;
54
55private:
56 inline int maxCacheSize() const { return 60; }
57 inline void generateGradientColorTable(const QGradient& gradient,
58 QRgba64 *colorTable,
59 int size, qreal opacity) const;
60 inline void generateGradientColorTable(const QGradient& gradient,
61 uint *colorTable,
62 int size, qreal opacity) const;
63 GLuint addCacheElement(quint64 hash_val, const QGradient &gradient, qreal opacity);
64 void cleanCache();
65
66 QOpenGLGradientColorTableHash cache;
67 QMutex m_mutex;
68};
69
70QT_END_NAMESPACE
71
72#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:191