Q_ASSERT(!m_effect);
QObject *created = m_effectComponent->create();
- m_effect = qobject_cast<QQuickShaderEffect *>(created);
+ m_effect = qobject_cast<QQuickItem *>(created);
if (!m_effect) {
- qWarning("Item: layer.effect is not a ShaderEffect.");
+ qWarning("Item: layer.effect is not a QML Item.");
delete created;
return;
}
Holds the effect that is applied to this layer.
- The effect must be a \l ShaderEffect.
+ The effect is typically a \l ShaderEffect component, although any \l Item component can be
+ assigned. The effect should have a source texture property with a name matching \l samplerName.
\sa samplerName
*/
void toggleLayerAndEffect();
void disableLayer();
void changeSamplerName();
+ void itemEffect();
+ void rectangleEffect();
private:
bool m_isMesaSoftwareRasterizer;
QCOMPARE(fb.pixel(0, 0), qRgb(0, 0, 0xff));
}
+void tst_QQuickItemLayer::itemEffect()
+{
+ if (m_isMesaSoftwareRasterizer && m_mesaVersion < QT_VERSION_CHECK(7, 11, 0))
+ QSKIP("Mesa Software Rasterizer below version 7.11 does not render this test correctly.");
+ QImage fb = runTest(testFile("ItemEffect.qml"));
+ QCOMPARE(fb.pixel(0, 0), qRgb(0xff, 0, 0));
+ QCOMPARE(fb.pixel(199, 0), qRgb(0xff, 0, 0));
+ QCOMPARE(fb.pixel(0, 199), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(199, 199), qRgb(0, 0, 0xff));
+}
+
+void tst_QQuickItemLayer::rectangleEffect()
+{
+ QImage fb = runTest(testFile("RectangleEffect.qml"));
+ QCOMPARE(fb.pixel(0, 0), qRgb(0, 0xff, 0));
+ QCOMPARE(fb.pixel(199, 0), qRgb(0, 0xff, 0));
+ QCOMPARE(fb.pixel(0, 199), qRgb(0, 0xff, 0));
+ QCOMPARE(fb.pixel(199, 199), qRgb(0, 0xff, 0));
+
+ QCOMPARE(fb.pixel(100, 0), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(199, 100), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(100, 199), qRgb(0, 0, 0xff));
+ QCOMPARE(fb.pixel(0, 100), qRgb(0, 0, 0xff));
+}
+
+
QTEST_MAIN(tst_QQuickItemLayer)
#include "tst_qquickitemlayer.moc"