aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-11-23 15:55:55 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-11-24 18:07:55 +0100
commit7a5c59f21fc68e3020c2acf0cd50146ef6a61005 (patch)
tree4e8fc809dc1d31184a40c15d29fd52fc2df26515 /src/quick/items
parenta10c980b1e4273b357702211148a2f9c4e2ebc2c (diff)
Simplify ShaderEffect's internal shaderInfoCache
Change-Id: Id542b473c1596f9933cdef747f7fe329988618d4 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/quick/items')
-rw-r--r--src/quick/items/qquickshadereffect.cpp28
1 files changed, 5 insertions, 23 deletions
diff --git a/src/quick/items/qquickshadereffect.cpp b/src/quick/items/qquickshadereffect.cpp
index ec05cf5ca1..b4d9f9f69d 100644
--- a/src/quick/items/qquickshadereffect.cpp
+++ b/src/quick/items/qquickshadereffect.cpp
@@ -1155,27 +1155,8 @@ static inline QVariant getValueFromProperty(QObject *item, const QMetaObject *it
return value;
}
-struct ShaderInfoCache
-{
- bool contains(const QUrl &key) const
- {
- return m_shaderInfoCache.contains(key);
- }
-
- QSGGuiThreadShaderEffectManager::ShaderInfo value(const QUrl &key) const
- {
- return m_shaderInfoCache.value(key);
- }
-
- void insert(const QUrl &key, const QSGGuiThreadShaderEffectManager::ShaderInfo &value)
- {
- m_shaderInfoCache.insert(key, value);
- }
-
- QHash<QUrl, QSGGuiThreadShaderEffectManager::ShaderInfo> m_shaderInfoCache;
-};
-
-Q_GLOBAL_STATIC(ShaderInfoCache, shaderInfoCache)
+using QQuickShaderInfoCache = QHash<QUrl, QSGGuiThreadShaderEffectManager::ShaderInfo>;
+Q_GLOBAL_STATIC(QQuickShaderInfoCache, shaderInfoCache)
bool QQuickShaderEffectImpl::updateShader(Shader shaderType, const QUrl &fileUrl)
{
@@ -1193,8 +1174,9 @@ bool QQuickShaderEffectImpl::updateShader(Shader shaderType, const QUrl &fileUrl
if (!fileUrl.isEmpty()) {
const QQmlContext *context = qmlContext(m_item);
const QUrl loadUrl = context ? context->resolvedUrl(fileUrl) : fileUrl;
- if (shaderInfoCache()->contains(loadUrl)) {
- m_shaders[shaderType].shaderInfo = shaderInfoCache()->value(loadUrl);
+ auto it = shaderInfoCache()->constFind(loadUrl);
+ if (it != shaderInfoCache()->cend()) {
+ m_shaders[shaderType].shaderInfo = *it;
m_shaders[shaderType].hasShaderCode = true;
} else {
// Each prepareShaderCode call needs its own work area, hence the