diff options
Diffstat (limited to 'tests/auto/quick/qquickitemlayer/data')
14 files changed, 447 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickitemlayer/data/DisableLayer.qml b/tests/auto/quick/qquickitemlayer/data/DisableLayer.qml new file mode 100644 index 0000000000..70fc05e937 --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/DisableLayer.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Item { + width: 200 + height: 200 + Rectangle { + width: 100 + height: 100 + color: "red" + layer.enabled: true + Component.onCompleted: { + layer.enabled = false + visible = false + width = 120 + x = 10 + } + } +} diff --git a/tests/auto/quick/qquickitemlayer/data/Effect.qml b/tests/auto/quick/qquickitemlayer/data/Effect.qml new file mode 100644 index 0000000000..630c8f90ed --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/Effect.qml @@ -0,0 +1,34 @@ +import QtQuick 2.0 + +Item +{ + width: 100 + height: 100 + + Rectangle { + id: box + width: 100 + height: 100 + + color: "#0000ff" + + Rectangle { + x: 50 + width: 50 + height: 100 + color: "#00ff00" + } + + layer.enabled: true + layer.effect: ShaderEffect { + fragmentShader: " + uniform lowp sampler2D source; + uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor = texture2D(source, qt_TexCoord0).bgra * qt_Opacity; + }" + } + + } +} diff --git a/tests/auto/quick/qquickitemlayer/data/Enabled.qml b/tests/auto/quick/qquickitemlayer/data/Enabled.qml new file mode 100644 index 0000000000..0e7d4f56b8 --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/Enabled.qml @@ -0,0 +1,25 @@ +import QtQuick 2.0 + +Item +{ + width: 200 + height: 200 + + Item { + width: 20 + height: 20 + scale: 10 + + layer.enabled: true + anchors.centerIn: parent + + Rectangle { + width: 20 + height: 20 + gradient: Gradient { + GradientStop { position: 0; color: "white" } + GradientStop { position: 1; color: "black" } + } + } + } +} diff --git a/tests/auto/quick/qquickitemlayer/data/ItemEffect.qml b/tests/auto/quick/qquickitemlayer/data/ItemEffect.qml new file mode 100644 index 0000000000..2f17d78efd --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/ItemEffect.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +Item { + width: 200 + height: 200 + Rectangle { + anchors.fill: parent + anchors.margins: 99 + gradient: Gradient { + GradientStop { position: 0.3; color: "red" } + GradientStop { position: 0.7; color: "blue" } + } + layer.enabled: true + layer.effect: Item { + property variant source + ShaderEffect { + anchors.fill: parent + anchors.margins: -99 + property variant source: parent.source + } + } + } +} diff --git a/tests/auto/quick/qquickitemlayer/data/Mipmap.qml b/tests/auto/quick/qquickitemlayer/data/Mipmap.qml new file mode 100644 index 0000000000..8de41076e9 --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/Mipmap.qml @@ -0,0 +1,30 @@ +import QtQuick 2.0 + +Item +{ + width: 100 + height: 100 + + Rectangle { + id: box + width: 600 + height: 600 + + scale: 1 / 6. + + color: "black" + + layer.enabled: true + layer.mipmap: true + layer.smooth: true + + anchors.centerIn: parent + + Rectangle { + x: 1 + width: 1 + height: parent.height + color: "white" + } + } +} diff --git a/tests/auto/quick/qquickitemlayer/data/RectangleEffect.qml b/tests/auto/quick/qquickitemlayer/data/RectangleEffect.qml new file mode 100644 index 0000000000..94c43f2caf --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/RectangleEffect.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 + +Item { + width: 200 + height: 200 + Rectangle { + width: 100 + height: 100 + x: 50 + y: 50 + scale: 1.5 + z: 1 + rotation: 45 + color: "#ff0000" + layer.enabled: true + layer.effect: Rectangle { color: "#0000ff" } + } + Rectangle { + anchors.fill: parent + color: "#00ff00" + } +} diff --git a/tests/auto/quick/qquickitemlayer/data/SamplerNameChange.qml b/tests/auto/quick/qquickitemlayer/data/SamplerNameChange.qml new file mode 100644 index 0000000000..a4c2ebff6b --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/SamplerNameChange.qml @@ -0,0 +1,18 @@ +import QtQuick 2.0 + +Rectangle { + width: 200 + height: 200 + color: "blue" + layer.enabled: true + layer.effect: ShaderEffect { + fragmentShader: " + uniform sampler2D foo; + uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor = texture2D(foo, qt_TexCoord0) * qt_Opacity; + }" + } + Component.onCompleted: layer.samplerName = "foo" +} diff --git a/tests/auto/quick/qquickitemlayer/data/Smooth.qml b/tests/auto/quick/qquickitemlayer/data/Smooth.qml new file mode 100644 index 0000000000..3f9575bb0b --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/Smooth.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + + +Item { + width: 200 + height: 100 + + Row { + id: layerRoot + + width: 20 + height: 10 + + Rectangle { width: 10; height: 10; color: "red" } + Rectangle { width: 10; height: 10; color: "blue" } + + layer.enabled: true + layer.smooth: true + + anchors.centerIn: parent + scale: 10 + } +} diff --git a/tests/auto/quick/qquickitemlayer/data/SourceRect.qml b/tests/auto/quick/qquickitemlayer/data/SourceRect.qml new file mode 100644 index 0000000000..7cc7e8b21e --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/SourceRect.qml @@ -0,0 +1,33 @@ +import QtQuick 2.0 + +Item +{ + width: 100 + height: 100 + + Rectangle { + id: box + width: 100 + height: 100 + + color: "#ff0000" + + layer.enabled: true + layer.sourceRect: Qt.rect(-10, -10, box.width + 20, box.height + 20); + + // A shader that pads the transparent pixels with blue. + layer.effect: ShaderEffect { + fragmentShader: " + uniform lowp sampler2D source; + uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main() { + vec4 c = texture2D(source, qt_TexCoord0); + if (c.a == 0.) + c = vec4(0, 0, 1, 1); + gl_FragColor = c * qt_Opacity; + } + " + } + } +} diff --git a/tests/auto/quick/qquickitemlayer/data/TextureProvider.qml b/tests/auto/quick/qquickitemlayer/data/TextureProvider.qml new file mode 100644 index 0000000000..ccd515652a --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/TextureProvider.qml @@ -0,0 +1,40 @@ +import QtQuick 2.0 + +Item +{ + width: 100 + height: 100 + + Rectangle { + id: box + width: 100 + height: 100 + + color: "#0000ff" + + Rectangle { + x: 50 + width: 50 + height: 100 + color: "#00ff00" + } + + visible: false + + layer.enabled: true + } + + ShaderEffect { + anchors.fill: parent + property variant source: box + + fragmentShader: " + uniform lowp sampler2D source; + uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor = texture2D(source, qt_TexCoord0).bgra * qt_Opacity; + }" + } + +} diff --git a/tests/auto/quick/qquickitemlayer/data/ToggleLayerAndEffect.qml b/tests/auto/quick/qquickitemlayer/data/ToggleLayerAndEffect.qml new file mode 100644 index 0000000000..174b669b6c --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/ToggleLayerAndEffect.qml @@ -0,0 +1,23 @@ +import QtQuick 2.0 + +Item { + width: 200 + height: 200 + Rectangle { + width: 100 + height: 100 + color: "red" + Component.onCompleted: { + layer.enabled = true + layer.effect = effectComponent + layer.enabled = false + visible = false + width = 120 + x = 10 + } + } + Component { + id: effectComponent + ShaderEffect { } + } +} diff --git a/tests/auto/quick/qquickitemlayer/data/Visible.qml b/tests/auto/quick/qquickitemlayer/data/Visible.qml new file mode 100644 index 0000000000..8267f18250 --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/Visible.qml @@ -0,0 +1,56 @@ +import QtQuick 2.0 + +Item +{ + id: root + + width: 100 + height: 100 + + property bool layerEffect: false; + onLayerEffectChanged: root.maybeUse(); + Component.onCompleted: root.maybeUse(); + + property real layerOpacity: 1; + property bool layerVisible: true; + + function maybeUse() { + if (root.layerEffect) + box.layer.effect = shaderEffect + } + + Component { + id: shaderEffect + ShaderEffect { + fragmentShader: " + uniform lowp sampler2D source; + uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor = texture2D(source, qt_TexCoord0).bgra * qt_Opacity; + } + " + } + + } + + Rectangle { + id: box + width: 100 + height: 100 + + color: "#0000ff" + visible: parent.layerVisible; + opacity: parent.layerOpacity; + + Rectangle { + x: 50 + width: 50 + height: 100 + color: "#00ff00" + } + + layer.enabled: true + + } +} diff --git a/tests/auto/quick/qquickitemlayer/data/ZOrder.qml b/tests/auto/quick/qquickitemlayer/data/ZOrder.qml new file mode 100644 index 0000000000..59ccb32224 --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/ZOrder.qml @@ -0,0 +1,52 @@ +import QtQuick 2.0 + +Item +{ + id: root + + width: 200 + height: 200 + + Component { + id: shaderEffect + ShaderEffect { } + } + + property bool layerEffect: false; + onLayerEffectChanged: root.maybeUse(); + Component.onCompleted: root.maybeUse(); + + function maybeUse() { + if (root.layerEffect) + box.layer.effect = shaderEffect + } + + + Rectangle { + color: "red" + anchors.left: parent.left + anchors.top: parent.top + width: 100 + height: 100 + z: 1 + } + + Rectangle { + color: "#00ff00" + anchors.bottom: parent.bottom + anchors.right: parent.right + width: 100 + height: 100 + z: 3 + } + + Rectangle { + id: box + color: "blue" + anchors.fill: parent + anchors.margins: 10 + layer.enabled: true + z: 2 + } + +} diff --git a/tests/auto/quick/qquickitemlayer/data/ZOrderChange.qml b/tests/auto/quick/qquickitemlayer/data/ZOrderChange.qml new file mode 100644 index 0000000000..ebbd3b7e15 --- /dev/null +++ b/tests/auto/quick/qquickitemlayer/data/ZOrderChange.qml @@ -0,0 +1,50 @@ +import QtQuick 2.0 + +Item { + width: 200 + height: 200 + property bool layerEffect: false + property bool layerEnabled: false + property real layerZ: 0 + Rectangle { + anchors.fill: parent + color: "#00ffff" + } + Rectangle { + id: foo + anchors.fill: parent + color: "#ffff00" + Rectangle { + width: 100 + height: 100 + color: "#00ffff" + } + layer.enabled: parent.layerEnabled + layer.effect: parent.layerEffect ? effectComponent : null + opacity: 0.5 + z: layerZ + } + Rectangle { + width: 100 + height: 100 + x: 100 + color: "#ff0000" + } + Rectangle { + width: 100 + height: 100 + y: 100 + color: "#0000ff" + z: 1 + } + Component { + id: effectComponent + ShaderEffect { + fragmentShader: " + uniform sampler2D source; + uniform lowp float qt_Opacity; + varying highp vec2 qt_TexCoord0; + void main() { gl_FragColor = texture2D(source, qt_TexCoord0).xzyw * qt_Opacity; }" + } + } +} |