aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickitem.cpp
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@theqtcompany.com>2015-08-10 14:33:14 +0300
committerMiikka Heikkinen <miikka.heikkinen@theqtcompany.com>2015-08-20 09:49:18 +0000
commit3f4d7a755585f1b79c7e9675220b8210f10f358e (patch)
tree50e4e4faef56413bede418bcf495ca7fe41677ba /src/quick/items/qquickitem.cpp
parent04f30db289225e700fe99c163f53f0dd7e920caf (diff)
Add possibility to mirror ShaderEffectSource generated textures
Using textures generated by ShaderEffectSource items (or Item.layer) with custom OpenGL code was non-intuitive due to mismatching coordinate systems, so added a possibility to control the generated texture orientation. [ChangeLog][QtQuick][ShaderEffectSource] Added possibility to mirror generated OpenGL texture. Change-Id: I7c03d8b6fbfc43d69812c15d244200fb8e7c7bb9 Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/quick/items/qquickitem.cpp')
-rw-r--r--src/quick/items/qquickitem.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 32c3e651dd..0c9ee4fe73 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -7488,6 +7488,7 @@ QQuickItemLayer::QQuickItemLayer(QQuickItem *item)
, m_effectComponent(0)
, m_effect(0)
, m_effectSource(0)
+ , m_textureMirroring(QQuickShaderEffectSource::MirrorVertically)
{
}
@@ -7559,6 +7560,7 @@ void QQuickItemLayer::activate()
m_effectSource->setMipmap(m_mipmap);
m_effectSource->setWrapMode(m_wrapMode);
m_effectSource->setFormat(m_format);
+ m_effectSource->setTextureMirroring(m_textureMirroring);
if (m_effectComponent)
activateEffect();
@@ -7812,6 +7814,35 @@ void QQuickItemLayer::setWrapMode(QQuickShaderEffectSource::WrapMode mode)
}
/*!
+ \qmlproperty enumeration QtQuick::Item::layer.textureMirroring
+ \since 5.6
+
+ This property defines how the generated OpenGL texture should be mirrored.
+ The default value is \c{ShaderEffectSource.MirrorVertically}.
+ Custom mirroring can be useful if the generated texture is directly accessed by custom shaders,
+ such as those specified by ShaderEffect. If no effect is specified for the layered
+ item, mirroring has no effect on the UI representation of the item.
+
+ \list
+ \li ShaderEffectSource.NoMirroring - No mirroring
+ \li ShaderEffectSource.MirrorHorizontally - The generated texture is flipped along X-axis.
+ \li ShaderEffectSource.MirrorVertically - The generated texture is flipped along Y-axis.
+ \endlist
+ */
+
+void QQuickItemLayer::setTextureMirroring(QQuickShaderEffectSource::TextureMirroring mirroring)
+{
+ if (mirroring == m_textureMirroring)
+ return;
+ m_textureMirroring = mirroring;
+
+ if (m_effectSource)
+ m_effectSource->setTextureMirroring(m_textureMirroring);
+
+ emit textureMirroringChanged(mirroring);
+}
+
+/*!
\qmlproperty string QtQuick::Item::layer.samplerName
Holds the name of the effect's source texture property.