Qt 4.8
qt-4.8.6
src
opengl
gl2paintengineex
qglgradientcache_p.h
Go to the documentation of this file.
1
/****************************************************************************
2
**
3
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
5
**
6
** This file is part of the QtOpenGL module of the Qt Toolkit.
7
**
8
** $QT_BEGIN_LICENSE:LGPL$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
16
**
17
** GNU Lesser General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU Lesser
19
** General Public License version 2.1 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24
**
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28
**
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
36
**
37
**
38
** $QT_END_LICENSE$
39
**
40
****************************************************************************/
41
42
//
43
// W A R N I N G
44
// -------------
45
//
46
// This file is not part of the Qt API. It exists purely as an
47
// implementation detail. This header file may change from version to
48
// version without notice, or even be removed.
49
//
50
// We mean it.
51
//
52
53
#include <QMultiHash>
54
#include <QObject>
55
#include <QtOpenGL/QtOpenGL>
56
#include <private/qgl_p.h>
57
#include <QtCore/qmutex.h>
58
59
QT_BEGIN_NAMESPACE
60
61
class
QGL2GradientCache
62
{
63
struct
CacheInfo
64
{
65
inline
CacheInfo
(
QGradientStops
s,
qreal
op,
QGradient::InterpolationMode
mode) :
66
stops
(s),
opacity
(op),
interpolationMode
(mode) {}
67
68
GLuint
texId
;
69
QGradientStops
stops
;
70
qreal
opacity
;
71
QGradient::InterpolationMode
interpolationMode
;
72
};
73
74
typedef
QMultiHash<quint64, CacheInfo>
QGLGradientColorTableHash
;
75
76
public
:
77
static
QGL2GradientCache
*
cacheForContext
(
const
QGLContext
*context);
78
79
QGL2GradientCache
(
const
QGLContext
*) {}
80
~QGL2GradientCache
() {
cleanCache
(); }
81
82
GLuint
getBuffer
(
const
QGradient
&gradient,
qreal
opacity
);
83
inline
int
paletteSize
()
const
{
return
1024; }
84
85
private
:
86
inline
int
maxCacheSize
()
const
{
return
60; }
87
inline
void
generateGradientColorTable
(
const
QGradient
& gradient,
88
uint
*colorTable,
89
int
size,
qreal
opacity)
const
;
90
GLuint
addCacheElement
(
quint64
hash_val,
const
QGradient
&gradient,
qreal
opacity);
91
void
cleanCache
();
92
93
QGLGradientColorTableHash
cache
;
94
QMutex
m_mutex
;
95
};
96
97
QT_END_NAMESPACE
98
QMultiHash< quint64, CacheInfo >
QGL2GradientCache::addCacheElement
GLuint addCacheElement(quint64 hash_val, const QGradient &gradient, qreal opacity)
Definition:
qglgradientcache.cpp:109
QGL2GradientCache::CacheInfo::CacheInfo
CacheInfo(QGradientStops s, qreal op, QGradient::InterpolationMode mode)
Definition:
qglgradientcache_p.h:65
qreal
double qreal
Definition:
qglobal.h:1193
QT_END_NAMESPACE
#define QT_END_NAMESPACE
This macro expands to.
Definition:
qglobal.h:90
QMutex
The QMutex class provides access serialization between threads.
Definition:
qmutex.h:60
QGL2GradientCache::CacheInfo::stops
QGradientStops stops
Definition:
qglgradientcache_p.h:69
QGL2GradientCache::~QGL2GradientCache
~QGL2GradientCache()
Definition:
qglgradientcache_p.h:80
QVector< QGradientStop >
QGL2GradientCache::CacheInfo
Definition:
qglgradientcache_p.h:63
QGL2GradientCache::cache
QGLGradientColorTableHash cache
Definition:
qglgradientcache_p.h:93
QGL2GradientCache::CacheInfo::opacity
qreal opacity
Definition:
qglgradientcache_p.h:70
QT_BEGIN_NAMESPACE
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition:
qglobal.h:89
quint64
unsigned __int64 quint64
Definition:
qglobal.h:943
QGLContext
The QGLContext class encapsulates an OpenGL rendering context.
Definition:
qgl.h:310
QGL2GradientCache::CacheInfo::interpolationMode
QGradient::InterpolationMode interpolationMode
Definition:
qglgradientcache_p.h:71
QGL2GradientCache::QGL2GradientCache
QGL2GradientCache(const QGLContext *)
Definition:
qglgradientcache_p.h:79
uint
unsigned int uint
Definition:
qglobal.h:996
QGL2GradientCache::paletteSize
int paletteSize() const
Definition:
qglgradientcache_p.h:83
QGL2GradientCache::maxCacheSize
int maxCacheSize() const
Definition:
qglgradientcache_p.h:86
QGL2GradientCache::QGLGradientColorTableHash
QMultiHash< quint64, CacheInfo > QGLGradientColorTableHash
Definition:
qglgradientcache_p.h:74
QGL2GradientCache::getBuffer
GLuint getBuffer(const QGradient &gradient, qreal opacity)
Definition:
qglgradientcache.cpp:80
QGL2GradientCache::cleanCache
void cleanCache()
Definition:
qglgradientcache.cpp:69
QGL2GradientCache::m_mutex
QMutex m_mutex
Definition:
qglgradientcache_p.h:94
QGL2GradientCache::cacheForContext
static QGL2GradientCache * cacheForContext(const QGLContext *context)
Definition:
qglgradientcache.cpp:64
QGradient
The QGradient class is used in combination with QBrush to specify gradient fills. ...
Definition:
qbrush.h:201
QGradient::InterpolationMode
InterpolationMode
Definition:
qbrush.h:225
QGL2GradientCache::generateGradientColorTable
void generateGradientColorTable(const QGradient &gradient, uint *colorTable, int size, qreal opacity) const
Definition:
qglgradientcache.cpp:151
QGL2GradientCache::CacheInfo::texId
GLuint texId
Definition:
qglgradientcache_p.h:68
QGL2GradientCache
Definition:
qglgradientcache_p.h:61
Qt 4.8 Source Code Browser