4#ifndef QSGGRADIENTCACHE_P_H
5#define QSGGRADIENTCACHE_P_H
18#include <QtCore/qhash.h>
19#include <QtCore/qcache.h>
20#include <QtGui/qbrush.h>
22#include <QtQuick/qtquickexports.h>
32 QSGGradientCacheKey(
const QGradientStops &stops, QGradient::Spread spread)
33 : stops(stops), spread(spread)
37 bool operator==(
const QSGGradientCacheKey &other)
const
39 return spread == other.spread && stops == other.stops;
43inline size_t qHash(
const QSGGradientCacheKey &v, size_t seed = 0)
45 size_t h = qHash(size_t(v.spread), seed);
46 for (
int i = 0; i < 2 && i < v.stops.size(); ++i)
47 h = qHash(v.stops[i].first, qHash(v.stops[i].second.rgba64(), h));
56 QGradient::Spread spread = QGradient::PadSpread;
62 int compare(
const GradientDesc &other)
const {
63 if (
int d = a.x() - other.a.x())
65 if (
int d = a.y() - other.a.y())
67 if (
int d = b.x() - other.b.x())
69 if (
int d = b.y() - other.b.y())
72 if (
int d = v0 - other.v0)
74 if (
int d = v1 - other.v1)
77 if (
int d = spread - other.spread)
80 if (
int d = stops.size() - other.stops.size())
83 for (
int i = 0; i < stops.size(); ++i) {
84 if (
int d = stops[i].first - other.stops[i].first)
86 if (
int d = stops[i].second.rgba() - other.stops[i].second.rgba())
96 static QSGGradientCache *cacheForRhi(QRhi *rhi);
97 QSGTexture *get(
const QSGGradientCacheKey &grad);
100 void setTextureData(QSGPlainTexture *tx,
const QSGGradientCacheKey &grad);
103 ~IndexHolder() {
if (freeIndex && idx >= 0) *freeIndex = idx; }
105 qsizetype *freeIndex =
nullptr;
107 QList<QSGPlainTexture *> m_textures;
108 QCache<QSGGradientCacheKey, IndexHolder> m_cache;
109 qsizetype m_freeIndex = -1;
void updateSampledImage(RenderState &state, int binding, QSGTexture **texture, QSGMaterial *newMaterial, QSGMaterial *oldMaterial) override
This function is called by the scene graph to prepare use of sampled images in the shader,...
QSGCurveFillMaterialShader(QGradient::Type gradientType, bool useTextureFill, bool useDerivatives, int viewCount)
bool updateUniformData(RenderState &state, QSGMaterial *newEffect, QSGMaterial *oldEffect) override
This function is called by the scene graph to get the contents of the shader program's uniform buffer...
Combined button and popup list for selecting options.
constexpr size_t qHash(const QSize &s, size_t seed=0) noexcept
bool operator==(const QSGGradientCacheKey &other) const