diff options
Diffstat (limited to 'tests/manual/declarative')
42 files changed, 3650 insertions, 0 deletions
diff --git a/tests/manual/declarative/declarative.pro b/tests/manual/declarative/declarative.pro new file mode 100644 index 0000000..337db2f --- /dev/null +++ b/tests/manual/declarative/declarative.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +contains(QT_CONFIG, opengl): SUBDIRS += qmlshadersplugin + diff --git a/tests/manual/declarative/qmlshadersplugin/main.cpp b/tests/manual/declarative/qmlshadersplugin/main.cpp new file mode 100644 index 0000000..3f40e92 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/main.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtGui/QApplication> +#include <QtOpenGL> +#include "qmlapplicationviewer.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QGLFormat format = QGLFormat::defaultFormat(); + format.setSampleBuffers(false); + format.setSwapInterval(1); + + QGLWidget* glWidget = new QGLWidget(format); + glWidget->setAutoFillBackground(false); + + QmlApplicationViewer viewer; + viewer.setViewportUpdateMode(QGraphicsView::FullViewportUpdate); + viewer.setViewport(glWidget); + viewer.setAttribute(Qt::WA_OpaquePaintEvent); + viewer.setAttribute(Qt::WA_NoSystemBackground); + viewer.setOrientation(QmlApplicationViewer::Auto); + viewer.setMainQmlFile(QLatin1String("qml/qmlshadersplugintest/main.qml")); + viewer.show(); + + return app.exec(); +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestActive.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestActive.qml new file mode 100644 index 0000000..303c7db --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestActive.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "red" + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + //effect.active = !effect.active + effect.visible = !effect.visible + } + } + + ShaderEffectItem { + id: effect + anchors.fill: parent; + fragmentShader: " + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); + } + " + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + + Text { + id: label + anchors.centerIn: parent + text: effect.visible ? "Effect active (display should be green)" : "Effect not active (display should be red)" + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestBasic.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestBasic.qml new file mode 100644 index 0000000..b70cac0 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestBasic.qml @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Item { + anchors.fill: parent; + + ShaderEffectItem { + anchors.fill: parent; + fragmentShader: " + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor = vec4(qt_TexCoord0.x, qt_TexCoord0.y, 1, 1); + } + " + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestBlending.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestBlending.qml new file mode 100644 index 0000000..0c31419 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestBlending.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "green" + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + effect.blending = !effect.blending + } + } + + ShaderEffectItem { + id: effect + anchors.fill: parent; + fragmentShader: " + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor = vec4(1.0, 0.0, 0.0, 0.0); + } + " + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + + Text { + id: label + anchors.centerIn: parent + text: effect.blending ? "Effect blending (display should be orange)" : "Effect not blending (display should be red)" + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestBlendingModes.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestBlendingModes.qml new file mode 100644 index 0000000..47f5bc3 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestBlendingModes.qml @@ -0,0 +1,267 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Item { + id: blendModeTest + property real blendItemHeight: 60 + + anchors.fill: parent; + + Rectangle { + width: parent.width / 6 + height: parent.height + color: "black" + } + Rectangle { + x: parent.width/6 * 1 + width: parent.width / 6 + height: parent.height + color: "white" + } + Rectangle { + x: parent.width/6 * 2 + width: parent.width / 6 + height: parent.height + color: "gray" + } + Rectangle { + x: parent.width/6 * 3 + width: parent.width / 6 + height: parent.height + color: "red" + } + Rectangle { + x: parent.width/6 * 4 + width: parent.width / 6 + height: parent.height + color: "green" + } + Rectangle { + x: parent.width/6 * 5 + width: parent.width / 6 + height: parent.height + color: "blue" + } + + + Image { + anchors.fill: parent; + source: "image.png" + + } + + Rectangle { + id: first + anchors.top: parent.top + anchors.topMargin: 60 + width: parent.width + height: blendModeTest.blendItemHeight + color: "#8000ff00" + Text { + anchors.bottom: parent.bottom + anchors.bottomMargin: 5 + text: " Rectangle color #8000ff00" + color: "white" + } + } + Rectangle { + id: second + anchors.top: first.bottom + anchors.topMargin: 5 + width: parent.width + height: blendModeTest.blendItemHeight + color: "#ff00ff00" + opacity: 0.5 + Text { + anchors.bottom: parent.bottom + anchors.bottomMargin: 5 + text: " Rectangle color #ff00ff00, opacity 0.5" + color: "white" + } + } + + ShaderEffectItem { + id: effect + anchors.top: second.bottom + anchors.topMargin: 5 + width: parent.width + height: blendModeTest.blendItemHeight + fragmentShader: " + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor = vec4(0.0, 1.0, 0.0, 0.5); + } + " + Text { + anchors.bottom: parent.bottom + anchors.bottomMargin: 5 + text: " ShaderEffectItem gl_FragColor=vec4(0.0, 1.0, 0.0, 0.5)" + color: "white" + } + } + + ShaderEffectItem { + id: effect2 + anchors.top: effect.bottom + anchors.topMargin: 5 + width: parent.width + height: blendModeTest.blendItemHeight + fragmentShader: " + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor = vec4(0.0, 0.5, 0.0, 0.5); + } + " + Text { + anchors.bottom: parent.bottom + anchors.bottomMargin: 5 + text: " ShaderEffectItem gl_FragColor=vec4(0.0, 0.5, 0.0, 0.5)" + color: "white" + } + } + + + Image { + id: image1 + source: "green_image_transparent.png" + anchors.top: effect2.bottom + anchors.topMargin: 5 + width: parent.width + height: blendModeTest.blendItemHeight + } + Text { + anchors.bottom: image1.bottom + anchors.bottomMargin: 5 + text: " Image, green and 50% alpha" + color: "white" + } + + + ShaderEffectItem { + id: effect3 + property variant source: ShaderEffectSource { + sourceItem: image1 + hideSource: false + } + anchors.top: image1.bottom + anchors.topMargin: 5 + + width: parent.width + height: blendModeTest.blendItemHeight + Text { + anchors.bottom: parent.bottom + anchors.bottomMargin: 5 + text: " ShaderEffectItem, source item green 50% alpha." + color: "white" + } + } + + ShaderEffectItem { + id: effect4 + property variant source: ShaderEffectSource { + sourceItem: Image { source: "green_image_transparent.png" } + hideSource: true + } + anchors.top: effect3.bottom + anchors.topMargin: 5 + width: parent.width + height: blendModeTest.blendItemHeight + Text { + anchors.bottom: parent.bottom + anchors.bottomMargin: 5 + text: " ShaderEffectItem, source image green 50% alpha." + color: "white" + } + } + + + Rectangle { + id: greenRect2 + anchors.top: effect4.bottom + anchors.topMargin: 5 + width: parent.width + height: blendModeTest.blendItemHeight + opacity: 0.5 + color: "green" + } + + + ShaderEffectItem { + id: effect5 + property variant source: ShaderEffectSource { sourceItem: greenRect2; hideSource: true } + anchors.top: effect4.bottom + anchors.topMargin: 5 + + width: parent.width + height: blendModeTest.blendItemHeight + Text { + anchors.bottom: parent.bottom + anchors.bottomMargin: 5 + text: " ShaderEffectItem, source item green rect with 0.5 opacity." + color: "white" + } + } + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + } + } + + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + + Text { + id: label + anchors.centerIn: parent + text: "Blending test" + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestEffectHierarchy.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestEffectHierarchy.qml new file mode 100644 index 0000000..1cad5b1 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestEffectHierarchy.qml @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + id :root + anchors.fill: parent; + color: "green" + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + effect1.visible = !effect1.visible + effect2.visible = !effect2.visible + //effect3.visible = !effect3.visible + } + } + + Rectangle { + id: a + x: 90 + y: 90 + color: "red" + width: 220 + height: 220 + Rectangle { + id: b + x: 10 + y: 10 + color: "blue" + width: 100 + height: 100 + rotation: 5 + Rectangle { + id: c + x: 10 + y: 10 + color: "black" + width: 80 + height: 80 + } + } + Rectangle { + id: d + x: 10 + y: 110 + color: "yellow" + width: 100 + height: 100 + } + } + + ShaderEffectItem { + id: effect1 + anchors.fill: a + property variant source: ShaderEffectSource{ sourceItem: a; hideSource: true } + } + + ShaderEffectItem { + id: effect2 + x: 100 + y: 100 + width: 100 + height: 100 + rotation: 5 + property variant source: ShaderEffectSource{ sourceItem: b; hideSource: true } + } + +// ShaderEffectItem { +// id: effect3 +// x: 110 +// y: 210 +// width: 80 +// height: 80 +// property variant source: ShaderEffectSource{ sourceItem: c; hideSource: true } +// } + + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + + Text { + id: label + anchors.centerIn: parent + text: effect1.visible ? "Effects active" : "Effects NOT active" + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestEffectInsideAnotherEffect.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestEffectInsideAnotherEffect.qml new file mode 100644 index 0000000..1446f9b --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestEffectInsideAnotherEffect.qml @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "green" + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + + } + } + + Rectangle { + id: theSource + color: "red" + anchors.centerIn: parent; + width: parent.width/2 + height: parent.height/2 + } + + ShaderEffectItem { + id: effect1 + anchors.fill: theSource; + property variant source: ShaderEffectSource{ sourceItem: theSource; hideSource: true } + } + + ShaderEffectItem { + id: effect2 + anchors.fill: effect1; + property variant source: effect1 + + fragmentShader: " + varying highp vec2 qt_TexCoord0; + uniform sampler2D source; + void main(void) + { + gl_FragColor = vec4(texture2D(source, qt_TexCoord0.st).rgb, 1.0); + } + " + } + + ShaderEffectItem { + id: effect3 + x: effect2.x + y: effect2.y + width: effect2.width + height: effect2.height + + property variant source: ShaderEffectSource { sourceItem: effect2 ; hideSource: false } + + fragmentShader: + " + varying highp vec2 qt_TexCoord0; + uniform sampler2D source; + void main(void) + { + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); + } + " + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + + Text { + id: label + anchors.centerIn: parent + text: "Red rect inside green fullscreen rect." + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestFormat.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestFormat.qml new file mode 100644 index 0000000..df5e06d --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestFormat.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "gray" + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + if (theSource.format == ShaderEffectSource.Alpha) + theSource.format = ShaderEffectSource.RGB + else if (theSource.format == ShaderEffectSource.RGB) + theSource.format = ShaderEffectSource.RGBA + else if (theSource.format == ShaderEffectSource.RGBA) + theSource.format = ShaderEffectSource.Alpha + } + } + + ShaderEffectSource { + id: theSource + sourceItem: Image { source: "image.png" } + live: false + hideSource: true + } + + ShaderEffectItem { + id: effect + anchors.centerIn: parent + width: parent.width + height: parent.height + property variant source: theSource + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + Text { + id: label + anchors.centerIn: parent + text: "Source format test: " + theSource.format + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestFragmentShader.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestFragmentShader.qml new file mode 100644 index 0000000..d170358 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestFragmentShader.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "white" + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + effect.fragmentShader == effect.redFragmentShader ? effect.fragmentShader = effect.greenFragmentShader : effect.fragmentShader = effect.redFragmentShader + } + } + + ShaderEffectItem { + id: effect + anchors.fill: parent; + + property string redFragmentShader: " + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); + } + " + + property string greenFragmentShader: " + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); + } + " + + fragmentShader: redFragmentShader + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + + Text { + id: label + anchors.centerIn: parent + text: effect.fragmentShader == effect.redFragmentShader ? "Effect (display should be red)" : "Effect (display should be green)" + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestGrab.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestGrab.qml new file mode 100644 index 0000000..08e9319 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestGrab.qml @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "white" + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + console.log("Grabbed!") + theSource.grab(); + } + } + + Image { + id: theSourcImage + source: "image_opaque.png" + opacity: 0.5 + } + + ShaderEffectSource { + id: theSource + sourceItem: theSourcImage + } + + ShaderEffectItem { + id: effect + anchors.centerIn: parent + width: parent.width + height: parent.height + property variant source: theSource + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + Text { + id: label + anchors.centerIn: parent + text: "Effect with grab (opacity 0.5)" + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestHideOriginal.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestHideOriginal.qml new file mode 100644 index 0000000..1cd449f --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestHideOriginal.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "green" + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + //theSource.hideOriginal = !theSource.hideOriginal + theSource.hideSource = !theSource.hideSource + } + } + + Rectangle { + id: redRect + anchors.fill: parent; + color: "red" + } + + ShaderEffectSource { + id: theSource + sourceItem: redRect + } + + ShaderEffectItem { + id: effect + anchors.fill: parent; + property variant source: theSource + + fragmentShader: " + varying highp vec2 qt_TexCoord0; + uniform sampler2D source; + void main() { + // Empty fragmentshader, we do not write any pixels via this effect item. We only observe hideoriginal functionality. + } + " + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + + Text { + id: label + anchors.centerIn: parent + //text: theSource.hideOriginal ? "Hideoriginal true (display should be green)" : "Hideoriginal false (display should be red)" + text: theSource.hideSource ? "HideSource true (display should be green)" : "HideSource false (display should be red)" + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestHorizontalWrap.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestHorizontalWrap.qml new file mode 100644 index 0000000..ec372ca --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestHorizontalWrap.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "white" + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + theSource.wrapMode == ShaderEffectSource.RepeatHorizontally ? theSource.wrapMode = ShaderEffectSource.ClampToEdge : theSource.wrapMode = ShaderEffectSource.RepeatHorizontally + } + } + + ShaderEffectSource { + id: theSource + sourceItem: Image { source: "image_small.png" } + live: false + hideSource: true + } + + ShaderEffectItem { + id: effect + anchors.fill: parent; + property variant source: theSource + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + void main() { + highp vec2 tex = qt_TexCoord0 * 4.0; + gl_FragColor = texture2D(source, tex); + } + " + + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + + Text { + id: label + anchors.centerIn: parent + text: theSource.wrapMode == ShaderEffectSource.RepeatHorizontally ? "HorizontalWrap RepeatHorizontally" : "HorizontalWrap ClampToEdge" + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestImageFiltering.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestImageFiltering.qml new file mode 100644 index 0000000..9d990d0 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestImageFiltering.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "white" + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + theSource.smooth = !theSource.smooth + } + } + + ShaderEffectSource { + id: theSource + sourceItem: Image { source: "image.png" } + live: false + hideSource: true + } + + ShaderEffectItem { + id: effect + width: parent.width * 2.0 + height: parent.height * 2.0 + property variant source: theSource + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + + Text { + id: label + anchors.centerIn: parent + text: !theSource.smooth ? "Filtering nearest (faster)" : "Filtering linear (better quality)" + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestImageMargins.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestImageMargins.qml new file mode 100644 index 0000000..3ad2b50 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestImageMargins.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + id: imageMarginTester + anchors.fill: parent; + color: "green" + property real testMarginX: 10 + property real testMarginY: 10 + + Timer { + running: true + interval: 2000 + repeat: true + + onTriggered: { + if (imageMarginTester.testMarginX < 20) { + imageMarginTester.testMarginX = 50 + imageMarginTester.testMarginY = 120 + } + else { + imageMarginTester.testMarginX = 10 + imageMarginTester.testMarginY = 10 + } + + console.log("onTriggered...") + theSource.sourceRect = Qt.rect(-testMarginX, -testMarginY, parent.width + testMarginX*2, parent.height + testMarginY*2) + console.log("onTriggered done") + } + } + + ShaderEffectSource { + id: theSource + sourceImage: "image_opaque.png" + sourceRect: Qt.rect(-10,-10, parent.width + 2*10, parent.height + 2*10) + hideSource: true + } + + ShaderEffectItem { + id: effect + anchors.fill: parent; + property variant source: theSource + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + + Text { + id: label + anchors.centerIn: parent + text: theSource.sourceRect.width == 0 ? "No margins" : "Green margins " + imageMarginTester.testMarginX + "x" + imageMarginTester.testMarginY + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestImageMarginsWithTextureSize.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestImageMarginsWithTextureSize.qml new file mode 100644 index 0000000..453bbaf --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestImageMarginsWithTextureSize.qml @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + id: marginTester + anchors.fill: parent; + color: "green" + property real testMarginX: 10 + property real testMarginY: 10 + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + if (marginTester.testMarginX < 20) { + marginTester.testMarginX = 50 + marginTester.testMarginY = 120 + } + else { + marginTester.testMarginX = 10 + marginTester.testMarginY = 10 + } + + theSource.sourceRect = Qt.rect(-testMarginX, -testMarginY, parent.width + testMarginX*2, parent.height + testMarginY*2) + } + } + + ShaderEffectSource { + id: theSource + sourceImage: "image_opaque.png" + textureSize: Qt.size(160,160) + sourceRect: Qt.rect(-10,-10, parent.width + 2*10, parent.height + 2*10) + hideSource: true + } + + ShaderEffectItem { + id: effect + anchors.fill: parent; + property variant source: theSource + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + + Text { + id: label + anchors.centerIn: parent + text: theSource.sourceRect.width == 0 ? "No margins" : "Green margins " + marginTester.testMarginX + "x" + marginTester.testMarginY + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestImageMipmap.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestImageMipmap.qml new file mode 100644 index 0000000..a51068d --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestImageMipmap.qml @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "white" + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + if (theSource.mipmap && theSource.smooth){ + theSource.smooth = false + } else if (theSource.mipmap && !theSource.smooth){ + theSource.smooth = true + theSource.mipmap = false + } else if (!theSource.mipmap && theSource.smooth){ + theSource.smooth = false + } else if (!theSource.mipmap && !theSource.smooth){ + theSource.smooth = true + theSource.mipmap = true + } + } + } + + ShaderEffectSource { + id: theSource + sourceImage: "wallpaper.jpg" + mipmap: false + smooth: false + } + + ShaderEffectItem { + id: effect + anchors.centerIn: parent; + width: parent.width * 0.8 + height: parent.height * 0.8 + property variant source: theSource + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + + Text { + id: label + anchors.centerIn: parent + text: "Mipmap: " + theSource.mipmap + ", Smooth: " + theSource.smooth + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestItemMargins.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestItemMargins.qml new file mode 100644 index 0000000..94f7824 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestItemMargins.qml @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + id: marginTester + anchors.fill: parent; + color: "green" + property real testMarginX: 10 + property real testMarginY: 10 + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + if (marginTester.testMarginX < 20) { + marginTester.testMarginX = 50 + marginTester.testMarginY = 120 + } + else { + marginTester.testMarginX = 10 + marginTester.testMarginY = 10 + } + + theSource.sourceRect = Qt.rect(-testMarginX, -testMarginY, parent.width + testMarginX*2, parent.height + testMarginY*2) + console.log("onTriggered") + } + } + + Image { + id: redrect + source: "image_opaque.png" + } + + + ShaderEffectSource { + id: theSource + sourceItem: redrect + sourceRect: Qt.rect(-10,-10, parent.width + 2*10, parent.height + 2*10) + hideSource: true + } + + ShaderEffectItem { + id: effect + anchors.fill: parent; + property variant source: theSource + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + + Text { + id: label + anchors.centerIn: parent + text: theSource.sourceRect.width == 0 ? "No margins" : "Green margins " + marginTester.testMarginX + "x" + marginTester.testMarginY + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestItemMarginsWithTextureSize.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestItemMarginsWithTextureSize.qml new file mode 100644 index 0000000..83784c3 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestItemMarginsWithTextureSize.qml @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + id: marginTester + anchors.fill: parent; + color: "green" + property real testMarginX: 10 + property real testMarginY: 10 + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + if (marginTester.testMarginX < 20) { + marginTester.testMarginX = 50 + marginTester.testMarginY = 120 + } + else { + marginTester.testMarginX = 10 + marginTester.testMarginY = 10 + } + + theSource.sourceRect = Qt.rect(-testMarginX, -testMarginY, parent.width + testMarginX*2, parent.height + testMarginY*2) + } + } + + Image { + id: redrect + source: "image_opaque.png" + } + + ShaderEffectSource { + id: theSource + sourceItem: redrect + textureSize: Qt.size(160,160) + sourceRect: Qt.rect(-10,-10, parent.width + 2*10, parent.height + 2*10) + hideSource: true + } + + ShaderEffectItem { + id: effect + anchors.fill: parent; + property variant source: theSource + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + + Text { + id: label + anchors.centerIn: parent + text: theSource.sourceRect.width == 0 ? "No margins" : "Green margins " + marginTester.testMarginX + "x" + marginTester.testMarginY + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestLive.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestLive.qml new file mode 100644 index 0000000..6db568d --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestLive.qml @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "white" + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + theSource.live = !theSource.live + theSource.grab() // This tests grabbing screenshot from static source + } + } + + Rectangle { + id: greenRect + anchors.fill: parent; + color: theSource.live ? "green" : "red" // This works if we use grab() + property int counter: 0 + Text { + id: counterText + anchors.centerIn: parent + text: greenRect.counter + font.pixelSize: 48 + } + Timer { + running: true + interval: 100 + repeat: true + onTriggered: { + greenRect.counter++ + } + } + } + + ShaderEffectSource { + id: theSource + sourceItem: greenRect + hideSource: true + } + + ShaderEffectItem { + id: effect + anchors.fill: parent; + property variant source: theSource + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + + Text { + id: label + anchors.centerIn: parent + text: theSource.live ? "live true (color green, number changes)" : "live false (color red, same number)" + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestMeshResolution.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestMeshResolution.qml new file mode 100644 index 0000000..255df36 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestMeshResolution.qml @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "red" + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + effect.meshResolution.width == 1 ? effect.meshResolution = Qt.size(40,40) : effect.meshResolution = Qt.size(1,1) + } + } + + Rectangle { + id: thesource + anchors.centerIn: parent; + color: "green" + width: parent.width + height: parent.height + Image { + anchors.centerIn: parent; + source: "image_opaque.png" + } + } + + + ShaderEffectItem { + id: effect + anchors.fill: thesource; + property variant source: ShaderEffectSource { sourceItem: thesource } + + vertexShader: " + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + uniform highp mat4 qt_ModelViewProjectionMatrix; + varying highp vec2 qt_TexCoord0; + void main() { + qt_TexCoord0 = qt_MultiTexCoord0; + + highp vec4 shift = vec4(cos(1071. * qt_MultiTexCoord0.x + 1.0) + sin(2051. * qt_MultiTexCoord0.y + 1.0), + cos(1131. * qt_MultiTexCoord0.x + 1.0) + sin(3039. * qt_MultiTexCoord0.x + 1.0), 0, 0) * 3.0; + + if (qt_MultiTexCoord0.x < 0.01 || qt_MultiTexCoord0.x > 0.99) + shift.x = 0.; + if (qt_MultiTexCoord0.y < 0.01 || qt_MultiTexCoord0.y > 0.99) + shift.y = 0.; + + gl_Position = qt_ModelViewProjectionMatrix * (qt_Vertex + shift); + } + " + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + Text { + id: label + anchors.centerIn: parent + text: effect.meshResolution.width == 1 ? "Resolution (1,1) (image looks normal)" : "Resolution (40,40) (image looks distorted)" + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestOneSource.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestOneSource.qml new file mode 100644 index 0000000..117ae65 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestOneSource.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "black" + + Text { + id: text + anchors.centerIn: parent + font.pixelSize: 80 + text: "Shaderz!" + } + + ShaderEffectSource { + id: source + sourceItem: text + hideSource: true + } + + ShaderEffectItem { + anchors.fill: text; + + property variant source: source + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor = vec4(qt_TexCoord0.x, qt_TexCoord0.y, 1, 1) * texture2D(source, qt_TexCoord0).a; + } + " + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestOpacity.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestOpacity.qml new file mode 100644 index 0000000..00af373 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestOpacity.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "white" + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + if (effect.opacity > 0.9) + effect.opacity = 0.0 + else if (effect.opacity < 0.5) + effect.opacity = 0.5 + else if (effect.opacity < 0.9) + effect.opacity = 1.0 + } + } + + ShaderEffectSource { + id: theSource + sourceItem: Image { source: "image_opaque.png" } + live: false + hideSource: true + } + + ShaderEffectItem { + id: effect + anchors.centerIn: parent + width: parent.width + height: parent.height + property variant source: theSource + + fragmentShader: " + uniform highp float qt_Opacity; + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor = vec4(texture2D(source, qt_TexCoord0).rgb, qt_Opacity); + } + " + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + Text { + id: label + anchors.centerIn: parent + text: "Effect with opacity: " + effect.opacity + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestRotation.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestRotation.qml new file mode 100644 index 0000000..c4435fa --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestRotation.qml @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "white" + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + if (effectWrapper.rotation < 45) + effectWrapper.rotation = 45 + else if (effectWrapper.rotation < 90) + effectWrapper.rotation = 90 + else if (effectWrapper.rotation < 180) + effectWrapper.rotation = 0 + + } + } + + Item { + id: effectWrapper + anchors.fill: parent; + + ShaderEffectSource { + id: theSource + sourceItem: Image { source: "image_opaque.png" } + live: false + hideSource: true + } + + ShaderEffectItem { + id: effect + anchors.centerIn: parent + width: parent.width - 50 + height: parent.height - 50 + property variant source: theSource + } + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + Text { + id: label + anchors.centerIn: parent + text: "Effect is rotated " + effectWrapper.rotation + " degrees" + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestScale.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestScale.qml new file mode 100644 index 0000000..3488eab --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestScale.qml @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "white" + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + if (effectWrapper.scale < 0.3) + effectWrapper.scale = 0.3 + else if (effectWrapper.scale < 1.7) + effectWrapper.scale = 1.7 + else if (effectWrapper.scale < 2.0) + effectWrapper.scale = 0.1 + } + } + + Item { + id: effectWrapper + anchors.fill: parent; + scale: 0.1 + + ShaderEffectSource { + id: theSource + sourceItem: Image { source: "image_opaque.png" } + live: false + hideSource: true + } + + ShaderEffectItem { + id: effect + anchors.centerIn: parent + width: parent.width - 50 + height: parent.height - 50 + property variant source: theSource + } + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + Text { + id: label + anchors.centerIn: parent + text: "Effect is scaled " + effectWrapper.scale + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestTextureSize.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestTextureSize.qml new file mode 100644 index 0000000..7369efc --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestTextureSize.qml @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "white" + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + theSource.textureSize.width == 64 ? theSource.textureSize = Qt.size(360,640) : theSource.textureSize = Qt.size(64,64) + } + } + + ShaderEffectSource { + id: theSource + sourceItem: Image { source: "image.png" } + live: false + textureSize: Qt.size(64,64) + smooth: true + hideSource: true + } + + ShaderEffectItem { + id: effect + anchors.fill: parent; + property variant source: theSource + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + + Text { + id: label + anchors.centerIn: parent + text: "textureSize:" + theSource.textureSize.width + "x" + theSource.textureSize.height + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestTwiceOnSameSource.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestTwiceOnSameSource.qml new file mode 100644 index 0000000..8098a4d --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestTwiceOnSameSource.qml @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "black" + + Text { + id: text + anchors.centerIn: parent + font.pixelSize: 80 + text: "Shaderz!" + } + + ShaderEffectSource { + id: source + sourceItem: text + hideSource: true + } + + ShaderEffectItem { + width: parent.width + height: parent.height / 2 + blending: false + + property variant source: source + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor = vec4(0, qt_TexCoord0.y, 1, 1) * texture2D(source, qt_TexCoord0).a; + } + " + } + + ShaderEffectItem { + width: parent.width + y: parent.height / 2 + height: parent.height / 2 + + property variant source: source + + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor = vec4(qt_TexCoord0.x, 1, 0, 1) * texture2D(source, qt_TexCoord0).a; + } + " + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestTwoSources.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestTwoSources.qml new file mode 100644 index 0000000..e651cd9 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestTwoSources.qml @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "black" + + Rectangle { + id: rect; + anchors.centerIn: parent + width: 1 + height: 10 + + gradient: Gradient { + GradientStop { position: 0; color: "#ff0000" } + GradientStop { position: 0.5; color: "#00ff00" } + GradientStop { position: 1; color: "#0000ff" } + } + } + + Text { + id: text + anchors.centerIn: parent + font.pixelSize: 80 + text: "Shaderz!" + } + + ShaderEffectSource { + id: maskSource + sourceItem: text + hideSource: true + } + + ShaderEffectSource { + id: colorSource + sourceItem: rect; + hideSource: true + } + + ShaderEffectItem { + anchors.fill: text; + + property variant colorSource: colorSource + property variant maskSource: maskSource; + + fragmentShader: " + uniform lowp sampler2D maskSource; + uniform lowp sampler2D colorSource; + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor = texture2D(maskSource, qt_TexCoord0).a * texture2D(colorSource, qt_TexCoord0.yx); + } + " + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestVertexShader.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestVertexShader.qml new file mode 100644 index 0000000..4edb065 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestVertexShader.qml @@ -0,0 +1,109 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "red" + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + effect.vertexShader == effect.defaultVertexShader ? effect.vertexShader = effect.dummyVertexShader : effect.vertexShader = effect.defaultVertexShader + } + } + + ShaderEffectItem { + id: effect + anchors.fill: parent; + + property string defaultVertexShader: " + uniform highp mat4 qt_ModelViewProjectionMatrix; + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + varying highp vec2 qt_TexCoord0; + void main(void) + { + qt_TexCoord0 = qt_MultiTexCoord0; + gl_Position = qt_ModelViewProjectionMatrix * qt_Vertex; + } + " + + property string dummyVertexShader: " + uniform highp mat4 qt_ModelViewProjectionMatrix; + attribute highp vec4 qt_Vertex; + attribute highp vec2 qt_MultiTexCoord0; + varying highp vec2 qt_TexCoord0; + void main(void) + { + qt_TexCoord0 = qt_MultiTexCoord0; + gl_Position = qt_Vertex * vec4(0.0, 0.0, 0.0, 0.0001); + } + " + + vertexShader: defaultVertexShader + + fragmentShader: " + varying highp vec2 qt_TexCoord0; + void main() { + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); + } + " + + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + + Text { + id: label + anchors.centerIn: parent + text: effect.vertexShader == effect.defaultVertexShader ? "Effect (display shoud be green)" : "Effect (display shoud be red)" + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestVerticalWrap.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestVerticalWrap.qml new file mode 100644 index 0000000..b7d6db4 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestVerticalWrap.qml @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "white" + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + theSource.wrapMode == ShaderEffectSource.RepeatVertically ? theSource.wrapMode = ShaderEffectSource.ClampToEdge : theSource.wrapMode = ShaderEffectSource.RepeatVertically + } + } + + ShaderEffectSource { + id: theSource + sourceItem: Image { source: "image_small.png" } + live: false + hideSource: true + } + + ShaderEffectItem { + id: effect + anchors.fill: parent; + property variant source: theSource + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + void main() { + highp vec2 tex = qt_TexCoord0 * 4.0; + gl_FragColor = texture2D(source, tex); + } + " + + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + + Text { + id: label + anchors.centerIn: parent + text: theSource.wrapMode == ShaderEffectSource.RepeatVertically ? "Wrap RepeatVertically" : "VerticalWrap ClampToEdge" + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestWrapRepeat.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestWrapRepeat.qml new file mode 100644 index 0000000..e09673c --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/TestWrapRepeat.qml @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 +import Qt.labs.shaders 1.0 + +Rectangle { + anchors.fill: parent; + color: "white" + + Timer { + running: true + interval: 2000 + repeat: true + onTriggered: { + theSource.wrapMode == ShaderEffectSource.Repeat ? theSource.wrapMode = ShaderEffectSource.ClampToEdge : theSource.wrapMode = ShaderEffectSource.Repeat + } + } + + ShaderEffectSource { + id: theSource + sourceItem: Image { source: "image_small.png" } + live: false + hideSource: true + } + + ShaderEffectItem { + id: effect + anchors.fill: parent; + property variant source: theSource + fragmentShader: " + uniform lowp sampler2D source; + varying highp vec2 qt_TexCoord0; + void main() { + highp vec2 tex = qt_TexCoord0 * 4.0; + gl_FragColor = texture2D(source, tex); + } + " + + } + + Rectangle { + width: parent.width + height: 40 + color: "#cc000000" + + Text { + id: label + anchors.centerIn: parent + text: theSource.wrapMode == ShaderEffectSource.Repeat ? "Wrap Repeat" : "Wrap ClampToEdge" + color: "white" + font.bold: true + } + } +} diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/back.svg b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/back.svg new file mode 100755 index 0000000..3005133 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/back.svg @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) --> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" + width="30px" height="30px" viewBox="0 0 30 30" enable-background="new 0 0 30 30" xml:space="preserve"> +<rect fill="none" width="30" height="30"/> +<path fill="#FFFFFF" d="M19,8h-9V5c0-0.389-0.225-0.74-0.576-0.906C9.289,4.031,9.145,4,9,4C8.771,4,8.543,4.079,8.359,4.231 + l-6,5.001C2.132,9.422,2,9.703,2,10s0.132,0.578,0.359,0.768l6,5C8.543,15.921,8.771,16,9,16c0.145,0,0.289-0.031,0.424-0.094 + C9.775,15.741,10,15.389,10,15v-3h9c2.757,0,5,2.243,5,5s-2.243,5-5,5h-6.917c-1.104,0-2,0.896-2,2s0.896,2,2,2H19 + c4.963,0,9-4.037,9-9S23.963,8,19,8z"/> +</svg> diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/green_image_transparent.png b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/green_image_transparent.png Binary files differnew file mode 100755 index 0000000..f3024f7 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/green_image_transparent.png diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/image.png b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/image.png Binary files differnew file mode 100755 index 0000000..144c02d --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/image.png diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/image_opaque.png b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/image_opaque.png Binary files differnew file mode 100755 index 0000000..c73d389 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/image_opaque.png diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/image_small.png b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/image_small.png Binary files differnew file mode 100755 index 0000000..b226773 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/image_small.png diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/main.qml b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/main.qml new file mode 100644 index 0000000..1abf524 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/main.qml @@ -0,0 +1,236 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 + +Item { + id: main + width: 360 + height: 640 + + Rectangle { + id: background + visible: testCaseList.visible + anchors.fill: parent + gradient: Gradient { + GradientStop { position: 0.0; color: "#EEEEEE" } + GradientStop { position: 1.0; color: "#AAAAAA" } + } + } + + Loader { + id: testLoader + width: parent.width + height: parent.height + visible: !testCaseList.visible + } + + ListModel { + id: testcaseModel + ListElement { name: "TestEffectHierarchy.qml"; group: "Effect source property tests" } + ListElement { name: "TestGrab.qml"; group: "Effect source property tests" } + ListElement { name: "TestLive.qml"; group: "Effect source property tests" } + ListElement { name: "TestImageFiltering.qml"; group: "Effect source property tests" } + ListElement { name: "TestWrapRepeat.qml"; group: "Effect source property tests" } + ListElement { name: "TestHorizontalWrap.qml"; group: "Effect source property tests" } + ListElement { name: "TestVerticalWrap.qml"; group: "Effect source property tests" } + ListElement { name: "TestTextureSize.qml"; group: "Effect source property tests" } + ListElement { name: "TestItemMargins.qml"; group: "Effect source property tests" } + ListElement { name: "TestEffectInsideAnotherEffect.qml"; group: "Effect source property tests" } + ListElement { name: "TestItemMarginsWithTextureSize.qml"; group: "Effect source property tests" } + ListElement { name: "TestHideOriginal.qml"; group: "Effect source property tests" } + ListElement { name: "TestActive.qml"; group: "Effect item property tests" } + ListElement { name: "TestBlending.qml"; group: "Effect item property tests" } + ListElement { name: "TestBlendingModes.qml"; group: "Effect item property tests" } + ListElement { name: "TestOpacity.qml"; group: "Effect item property tests" } + ListElement { name: "TestFragmentShader.qml"; group: "Effect item property tests" } + ListElement { name: "TestVertexShader.qml"; group: "Effect item property tests" } + ListElement { name: "TestMeshResolution.qml"; group: "Effect item property tests" } + ListElement { name: "TestRotation.qml"; group: "Shader effect transformation tests" } + ListElement { name: "TestScale.qml"; group: "Shader effect transformation tests" } + ListElement { name: "TestBasic.qml"; group: "Scenegraph effect tests" } + ListElement { name: "TestOneSource.qml"; group: "Scenegraph effect tests" } + ListElement { name: "TestTwiceOnSameSource.qml"; group: "Scenegraph effect tests" } + ListElement { name: "TestTwoSources.qml"; group: "Scenegraph effect tests" } + } + + Component { + id: sectionHeading + Rectangle { + width: testCaseList.width + height: 35 + color: "#00000000" + + Text { + text: section + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignLeft + anchors.fill: parent + anchors.leftMargin: 5 + font.bold: true + style: Text.Raised + styleColor: "white" + } + } + } + + ListView { + id: testCaseList + + property int hideTranslation: 0 + transform: Translate { + x: testCaseList.hideTranslation + } + + anchors.fill: parent + anchors.topMargin: 10 + anchors.leftMargin: 5 + anchors.rightMargin: 5 + anchors.bottomMargin: 10 + + model: testcaseModel + spacing: 3 + + state: "testStopped" + + section.property: "group" + section.criteria: ViewSection.FullString + section.delegate: sectionHeading + + delegate: Rectangle { + width: parent.width + height: 50 + radius: 5 + border.width: 1 + border.color: "#888888" + color: delegateMouseArea.pressed ? "#AAAAFF" : "#FFFFFF" + Text { + id: delegateText; + text: " " + name + width: parent.width + height: parent.height + font.pixelSize: 16 + verticalAlignment: Text.AlignVCenter + } + Text { + id: delegateText2; + text: "> " + width: parent.width + height: parent.height + font.pixelSize: 20 + smooth: true + color: "gray" + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignRight + } + + MouseArea { + id: delegateMouseArea + anchors.fill: parent; + onClicked: { + testCaseList.state = "testRunning" + testLoader.source = name + console.log(name) + } + } + } + + states: [ + State { + name: "testRunning" + PropertyChanges { target: testCaseList; visible: false; hideTranslation: -main.width } + }, + State { + name: "testStopped" + PropertyChanges { target: testCaseList; visible: true; hideTranslation: 0 } + } + ] + + transitions: [ + Transition { + to: "testRunning" + SequentialAnimation { + NumberAnimation { properties: "hideTranslation"; easing.type: Easing.InQuad; duration: 300 } + PropertyAction { target: testCaseList; property: "visible"; value: false } + } + }, + Transition { + to: "testStopped" + SequentialAnimation { + PropertyAction { target: testCaseList; property: "visible"; value: true } + NumberAnimation { properties: "hideTranslation"; easing.type: Easing.InQuad; duration: 300 } + } + } + + ] + } + + Rectangle { + visible: true + anchors.bottom: main.bottom + anchors.left: main.left + anchors.right: main.right + height: 40 + color: "#cc000000" + Item { + anchors.top: parent.top + anchors.topMargin: 5 + anchors.left: parent.left + anchors.leftMargin: 20 + Image { + source: "back.svg" + } + } + + MouseArea { + anchors.fill: parent; + onClicked: { + if (testCaseList.visible){ + Qt.quit() + } else if (!testCaseList.state != "testStopped") { + testCaseList.state = "testStopped" + testLoader.source = "" + } + } + } + } +} + diff --git a/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/wallpaper.jpg b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/wallpaper.jpg Binary files differnew file mode 100755 index 0000000..5bc7b58 --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qml/qmlshadersplugintest/wallpaper.jpg diff --git a/tests/manual/declarative/qmlshadersplugin/qmlapplicationviewer/qmlapplicationviewer.cpp b/tests/manual/declarative/qmlshadersplugin/qmlapplicationviewer/qmlapplicationviewer.cpp new file mode 100644 index 0000000..b5b43bf --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qmlapplicationviewer/qmlapplicationviewer.cpp @@ -0,0 +1,168 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// checksum 0xdf1f version 0x10008 +#include "qmlapplicationviewer.h" + +#include <QtCore/QCoreApplication> +#include <QtCore/QDir> +#include <QtCore/QFileInfo> +#include <QtDeclarative/QDeclarativeComponent> +#include <QtDeclarative/QDeclarativeEngine> +#include <QtDeclarative/QDeclarativeContext> + +#if defined(QMLJSDEBUGGER) +#include <jsdebuggeragent.h> +#endif +#if defined(QMLOBSERVER) +#include <qdeclarativeviewobserver.h> +#endif + +#if defined(Q_OS_SYMBIAN) && defined(ORIENTATIONLOCK) +#include <eikenv.h> +#include <eikappui.h> +#include <aknenv.h> +#include <aknappui.h> +#endif // Q_OS_SYMBIAN && ORIENTATIONLOCK + +class QmlApplicationViewerPrivate +{ + QString mainQmlFile; + friend class QmlApplicationViewer; + static QString adjustPath(const QString &path); +}; + +QString QmlApplicationViewerPrivate::adjustPath(const QString &path) +{ +#ifdef Q_OS_UNIX +#ifdef Q_OS_MAC + if (!QDir::isAbsolutePath(path)) + return QCoreApplication::applicationDirPath() + + QLatin1String("/../Resources/") + path; +#else + const QString pathInShareDir = QCoreApplication::applicationDirPath() + + QLatin1String("/../share/") + + QFileInfo(QCoreApplication::applicationFilePath()).fileName() + + QLatin1Char('/') + path; + if (QFileInfo(pathInShareDir).exists()) + return pathInShareDir; +#endif +#endif + return path; +} + +QmlApplicationViewer::QmlApplicationViewer(QWidget *parent) : + QDeclarativeView(parent), + m_d(new QmlApplicationViewerPrivate) +{ + connect(engine(), SIGNAL(quit()), SLOT(close())); + setResizeMode(QDeclarativeView::SizeRootObjectToView); +#ifdef QMLJSDEBUGGER + new QmlJSDebugger::JSDebuggerAgent(engine()); +#endif +#ifdef QMLOBSERVER + new QmlJSDebugger::QDeclarativeViewObserver(this, parent); +#endif +} + +QmlApplicationViewer::~QmlApplicationViewer() +{ + delete m_d; +} + +void QmlApplicationViewer::setMainQmlFile(const QString &file) +{ + m_d->mainQmlFile = QmlApplicationViewerPrivate::adjustPath(file); + setSource(QUrl::fromLocalFile(m_d->mainQmlFile)); +} + +void QmlApplicationViewer::addImportPath(const QString &path) +{ + engine()->addImportPath(QmlApplicationViewerPrivate::adjustPath(path)); +} + +void QmlApplicationViewer::setOrientation(Orientation orientation) +{ +#ifdef Q_OS_SYMBIAN + if (orientation != Auto) { +#if defined(ORIENTATIONLOCK) + const CAknAppUiBase::TAppUiOrientation uiOrientation = + (orientation == LockPortrait) ? CAknAppUi::EAppUiOrientationPortrait + : CAknAppUi::EAppUiOrientationLandscape; + CAknAppUi* appUi = dynamic_cast<CAknAppUi*> (CEikonEnv::Static()->AppUi()); + TRAPD(error, + if (appUi) + appUi->SetOrientationL(uiOrientation); + ); +#else // ORIENTATIONLOCK + qWarning("'ORIENTATIONLOCK' needs to be defined on Symbian when locking the orientation."); +#endif // ORIENTATIONLOCK + } +#elif defined(Q_WS_MAEMO_5) + Qt::WidgetAttribute attribute; + switch (orientation) { + case LockPortrait: + attribute = Qt::WA_Maemo5PortraitOrientation; + break; + case LockLandscape: + attribute = Qt::WA_Maemo5LandscapeOrientation; + break; + case Auto: + default: + attribute = Qt::WA_Maemo5AutoOrientation; + break; + } + setAttribute(attribute, true); +#else // Q_OS_SYMBIAN + Q_UNUSED(orientation); +#endif // Q_OS_SYMBIAN +} + +void QmlApplicationViewer::show() +{ +#ifdef Q_OS_SYMBIAN + showFullScreen(); +#elif defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6) + showMaximized(); +#else + QDeclarativeView::show(); +#endif +} diff --git a/tests/manual/declarative/qmlshadersplugin/qmlapplicationviewer/qmlapplicationviewer.h b/tests/manual/declarative/qmlshadersplugin/qmlapplicationviewer/qmlapplicationviewer.h new file mode 100644 index 0000000..4d1a38c --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qmlapplicationviewer/qmlapplicationviewer.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QML Shaders plugin of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// checksum 0x39ee version 0x10008 +#ifndef QMLAPPLICATIONVIEWER_H +#define QMLAPPLICATIONVIEWER_H + +#include <QtDeclarative/QDeclarativeView> + +class QmlApplicationViewer : public QDeclarativeView +{ +public: + enum Orientation { + LockPortrait, + LockLandscape, + Auto + }; + + QmlApplicationViewer(QWidget *parent = 0); + virtual ~QmlApplicationViewer(); + + void setMainQmlFile(const QString &file); + void addImportPath(const QString &path); + void setOrientation(Orientation orientation); + void show(); + +private: + class QmlApplicationViewerPrivate *m_d; +}; + +#endif // QMLAPPLICATIONVIEWER_H diff --git a/tests/manual/declarative/qmlshadersplugin/qmlapplicationviewer/qmlapplicationviewer.pri b/tests/manual/declarative/qmlshadersplugin/qmlapplicationviewer/qmlapplicationviewer.pri new file mode 100644 index 0000000..79e6a9f --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qmlapplicationviewer/qmlapplicationviewer.pri @@ -0,0 +1,152 @@ +# checksum 0xc123 version 0x10008 +# This file should not be edited. +# Future versions of Qt Creator might offer updated versions of this file. + +QT += declarative + +SOURCES += $$PWD/qmlapplicationviewer.cpp +HEADERS += $$PWD/qmlapplicationviewer.h +INCLUDEPATH += $$PWD + +contains(DEFINES, QMLOBSERVER) { + DEFINES *= QMLJSDEBUGGER +} + +defineTest(minQtVersion) { + maj = $$1 + min = $$2 + patch = $$3 + isEqual(QT_MAJOR_VERSION, $$maj) { + isEqual(QT_MINOR_VERSION, $$min) { + isEqual(QT_PATCH_VERSION, $$patch) { + return(true) + } + greaterThan(QT_PATCH_VERSION, $$patch) { + return(true) + } + } + greaterThan(QT_MINOR_VERSION, $$min) { + return(true) + } + } + return(false) +} + +contains(DEFINES, QMLJSDEBUGGER) { + CONFIG(debug, debug|release) { + !minQtVersion(4, 7, 1) { + warning() + warning("Debugging QML requires the qmljsdebugger library that ships with Qt Creator.") + warning("This library requires Qt 4.7.1 or newer.") + warning() + + error("Qt version $$QT_VERSION too old for QmlJS Debugging. Aborting.") + } + isEmpty(QMLJSDEBUGGER_PATH) { + warning() + warning("Debugging QML requires the qmljsdebugger library that ships with Qt Creator.") + warning("Please specify its location on the qmake command line, eg") + warning(" qmake -r QMLJSDEBUGGER_PATH=$CREATORDIR/share/qtcreator/qmljsdebugger") + warning() + + error("QMLJSDEBUGGER defined, but no QMLJSDEBUGGER_PATH set on command line. Aborting.") + DEFINES -= QMLJSDEBUGGER + } else { + include($$QMLJSDEBUGGER_PATH/qmljsdebugger-lib.pri) + } + } else { + DEFINES -= QMLJSDEBUGGER + } +} +# This file should not be edited. +# Future versions of Qt Creator might offer updated versions of this file. + +defineTest(qtcAddDeployment) { +for(deploymentfolder, DEPLOYMENTFOLDERS) { + item = item$${deploymentfolder} + itemsources = $${item}.sources + $$itemsources = $$eval($${deploymentfolder}.source) + itempath = $${item}.path + $$itempath= $$eval($${deploymentfolder}.target) + export($$itemsources) + export($$itempath) + DEPLOYMENT += $$item +} + +MAINPROFILEPWD = $$PWD + +symbian { + ICON = $${TARGET}.svg + TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 + contains(DEFINES, ORIENTATIONLOCK):LIBS += -lavkon -leikcore -leiksrv -lcone + contains(DEFINES, NETWORKACCESS):TARGET.CAPABILITY += NetworkServices +} else:win32 { + !isEqual(PWD,$$OUT_PWD) { + copyCommand = @echo Copying application data... + for(deploymentfolder, DEPLOYMENTFOLDERS) { + source = $$eval($${deploymentfolder}.source) + pathSegments = $$split(source, /) + sourceAndTarget = $$MAINPROFILEPWD/$$source $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(pathSegments) + copyCommand += && $(COPY_DIR) $$replace(sourceAndTarget, /, \\) + } + copydeploymentfolders.commands = $$copyCommand + first.depends = $(first) copydeploymentfolders + export(first.depends) + export(copydeploymentfolders.commands) + QMAKE_EXTRA_TARGETS += first copydeploymentfolders + } +} else:unix { + maemo5 { + installPrefix = /opt/usr + desktopfile.path = /usr/share/applications/hildon + } else { + installPrefix = /usr/local + desktopfile.path = /usr/share/applications + !isEqual(PWD,$$OUT_PWD) { + copyCommand = @echo Copying application data... + for(deploymentfolder, DEPLOYMENTFOLDERS) { + macx { + target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target) + } else { + target = $$OUT_PWD/$$eval($${deploymentfolder}.target) + } + copyCommand += && $(MKDIR) $$target + copyCommand += && $(COPY_DIR) $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source) $$target + } + copydeploymentfolders.commands = $$copyCommand + first.depends = $(first) copydeploymentfolders + export(first.depends) + export(copydeploymentfolders.commands) + QMAKE_EXTRA_TARGETS += first copydeploymentfolders + } + } + for(deploymentfolder, DEPLOYMENTFOLDERS) { + item = item$${deploymentfolder} + itemfiles = $${item}.files + $$itemfiles = $$eval($${deploymentfolder}.source) + itempath = $${item}.path + $$itempath = $${installPrefix}/share/$${TARGET}/$$eval($${deploymentfolder}.target) + export($$itemfiles) + export($$itempath) + INSTALLS += $$item + } + icon.files = $${TARGET}.png + icon.path = /usr/share/icons/hicolor/64x64/apps + desktopfile.files = $${TARGET}.desktop + target.path = $${installPrefix}/bin + export(icon.files) + export(icon.path) + export(desktopfile.files) + export(desktopfile.path) + export(target.path) + INSTALLS += desktopfile icon target +} + +export (ICON) +export (INSTALLS) +export (DEPLOYMENT) +export (TARGET.EPOCHEAPSIZE) +export (TARGET.CAPABILITY) +export (LIBS) +export (QMAKE_EXTRA_TARGETS) +} diff --git a/tests/manual/declarative/qmlshadersplugin/qmlshadersplugin.pro b/tests/manual/declarative/qmlshadersplugin/qmlshadersplugin.pro new file mode 100644 index 0000000..98101fb --- /dev/null +++ b/tests/manual/declarative/qmlshadersplugin/qmlshadersplugin.pro @@ -0,0 +1,29 @@ +QT += declarative opengl + +# Add more folders to ship with the application, here +folder_01.source = qml/qmlshadersplugintest +folder_01.target = qml +DEPLOYMENTFOLDERS = folder_01 + +# Additional import path used to resolve Qml modules in Creator's code model +QML_IMPORT_PATH = + +# Avoid auto screen rotation +#DEFINES += ORIENTATIONLOCK + +# Needs to be defined for Symbian +#DEFINES += NETWORKACCESS + +symbian:TARGET.UID3 = 0xE40472A7 + +# Define QMLJSDEBUGGER to enable basic debugging (setting breakpoints etc) +# Define QMLOBSERVER for advanced features (requires experimental QmlInspector plugin!) +#DEFINES += QMLJSDEBUGGER +#DEFINES += QMLOBSERVER + +# The .cpp file which was generated for your project. Feel free to hack it. +SOURCES += main.cpp + +# Please do not modify the following two lines. Required for deployment. +include(qmlapplicationviewer/qmlapplicationviewer.pri) +qtcAddDeployment() |