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
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 {
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:
44
47
48 GLuint getBuffer(const QGradient &gradient, qreal opacity);
49 inline int paletteSize() const { return 1024; }
50
51 void invalidateResource() override;
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
70
71#endif // QOPENGLGRADIENTCACHE_P_H
\inmodule QtGui
Definition qbrush.h:135
InterpolationMode
Definition qbrush.h:161
\inmodule QtCore
Definition qmutex.h:281
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...
EGLContext ctx
Combined button and popup list for selecting options.
static void * context
GLenum mode
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble s
[6]
Definition qopenglext.h:235
#define GLuint
unsigned long long quint64
Definition qtypes.h:61
unsigned int uint
Definition qtypes.h:34
double qreal
Definition qtypes.h:187