5#include <private/qdrawhelper_p.h>
6#include <private/qopenglcontext_p.h>
7#include <private/qrgba64_p.h>
8#include <QtCore/qmutex.h>
9#include <QtCore/qrandom.h>
11#include <private/qopenglextensions_p.h>
14#define GL_RGBA16 0x805B
60void QOpenGL2GradientCache::cleanCache()
66 const CacheInfo &cache_info =
it.value();
67 funcs->glDeleteTextures(1, &cache_info.texId);
77 for (
int i = 0;
i < stops.
size() &&
i <= 2;
i++)
78 hash_val += stops[
i].second.rgba();
84 return addCacheElement(hash_val, gradient, opacity);
87 const CacheInfo &cache_info =
it.value();
88 if (cache_info.stops == stops && cache_info.opacity == opacity
91 return cache_info.texId;
94 }
while (
it != cache.
constEnd() &&
it.key() == hash_val);
96 return addCacheElement(hash_val, gradient, opacity);
104 if (cache.
size() == maxCacheSize()) {
111 funcs->glDeleteTextures(1, &
it.value().texId);
117 funcs->glGenTextures(1, &cache_entry.texId);
118 funcs->glBindTexture(GL_TEXTURE_2D, cache_entry.texId);
130 return cache.
insert(hash_val, cache_entry).value().texId;
135void QOpenGL2GradientCache::generateGradientColorTable(
const QGradient& gradient,
QRgba64 *colorTable,
int size,
qreal opacity)
const
145 qreal fpos = 1.5 * incr;
148 while (fpos <=
s.first().first) {
149 colorTable[
pos] = colorTable[
pos - 1];
154 if (colorInterpolation)
157 const int sLast =
s.size() - 1;
158 for (
int i = 0;
i < sLast; ++
i) {
159 qreal delta = 1/(
s[
i+1].first -
s[
i].first);
161 if (colorInterpolation)
165 int dist = int(256 * ((fpos -
s[
i].
first) * delta));
166 int idist = 256 -
dist;
167 if (colorInterpolation)
174 current_color = next_color;
181 colorTable[
pos] = last_color;
184 colorTable[
size-1] = last_color;
187void QOpenGL2GradientCache::generateGradientColorTable(
const QGradient& gradient,
uint *colorTable,
int size,
qreal opacity)
const
198 qreal fpos = 1.5 * incr;
201 while (fpos <=
s.first().first) {
202 colorTable[
pos] = colorTable[
pos - 1];
207 if (colorInterpolation)
210 const int sLast =
s.size() - 1;
211 for (
int i = 0;
i < sLast; ++
i) {
212 qreal delta = 1/(
s[
i+1].first -
s[
i].first);
214 if (colorInterpolation)
218 int dist = int(256 * ((fpos -
s[
i].
first) * delta));
219 int idist = 256 -
dist;
220 if (colorInterpolation)
227 current_color = next_color;
234 colorTable[
pos] = last_color;
237 colorTable[
size-1] = last_color;
InterpolationMode interpolationMode() const
QGradientStops stops() const
Returns the stop points for this gradient.
qsizetype size() const noexcept
const_iterator constBegin() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.
const_iterator constEnd() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the ...
qsizetype remove(const Key &key)
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
QList< Key > keys() const
Returns a list containing all the keys in the hash, in an arbitrary order.
qsizetype size() const noexcept
friend class const_iterator
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
const_iterator constFind(const Key &key) const noexcept
QOpenGL2GradientCache * cacheForContext(QOpenGLContext *context)
static QOpenGL2GradientCache * cacheForContext(QOpenGLContext *context)
GLuint getBuffer(const QGradient &gradient, qreal opacity)
void freeResource(QOpenGLContext *ctx) override
void invalidateResource() override
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...
QOpenGLFunctions * functions() const
Get the QOpenGLFunctions instance for this context.
The QOpenGLFunctions class provides cross-platform access to the OpenGL ES 2.0 API.
The QOpenGLMultiGroupSharedResource keeps track of a shared resource that might be needed from multip...
QOpenGLSharedResource * value(QOpenGLContext *context)
The QOpenGLSharedResource class is used to keep track of resources that are shared between OpenGL con...
static Q_DECL_CONST_FUNCTION QRandomGenerator * global()
\threadsafe
double bounded(double highest)
Generates one random double in the range between 0 (inclusive) and highest (exclusive).
static VulkanServerBufferGlFunctions * funcs
QSet< QString >::iterator it
Combined button and popup list for selecting options.
#define ARGB_COMBINE_ALPHA(argb, alpha)
static uint INTERPOLATE_PIXEL_256(uint x, uint a, uint y, uint b)
static QRgba64 interpolate256(QRgba64 x, uint alpha1, QRgba64 y, uint alpha2)
int qRound(qfloat16 d) noexcept
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLfloat GLfloat GLfloat alpha
static quint32 ARGB2RGBA(quint32 x)
constexpr QRgb qPremultiply(QRgb x)
QT_BEGIN_NAMESPACE QRgba64 combineAlpha256(QRgba64 rgba64, uint alpha256)
unsigned long long quint64
std::uniform_real_distribution dist(1, 2.5)
[2]