diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-02-16 17:04:24 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-03-02 12:31:55 +0000 |
commit | 28af5be1fa824a181e560cf7d9f2b06479720c31 (patch) | |
tree | 10c83ef5513a9e858dd1f3fc68007417da8cd01a | |
parent | 87aebe39ae80c0752695b21b5b7508d220035b85 (diff) |
PathItem example: add super- and multisample example
Change-Id: Iefd1a2656161b69de73e66e0bcefc36a49f733e2
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
-rw-r--r-- | examples/quick/pathitem/content/pathitem.qml | 2 | ||||
-rw-r--r-- | examples/quick/pathitem/content/pathiteminteract.qml | 65 | ||||
-rw-r--r-- | examples/quick/pathitem/content/pathitemsampling.qml | 191 | ||||
-rw-r--r-- | examples/quick/pathitem/content/pathitemtigers.qml | 1 | ||||
-rw-r--r-- | examples/quick/pathitem/pathitem.pro | 2 | ||||
-rw-r--r-- | examples/quick/pathitem/pathitem.qrc | 2 |
6 files changed, 194 insertions, 69 deletions
diff --git a/examples/quick/pathitem/content/pathitem.qml b/examples/quick/pathitem/content/pathitem.qml index c4a86ff8b1..b82d51a13c 100644 --- a/examples/quick/pathitem/content/pathitem.qml +++ b/examples/quick/pathitem/content/pathitem.qml @@ -57,7 +57,7 @@ Item { anchors.fill: parent Component.onCompleted: { addExample("PathItem Gallery", "Simple path rendering examples", Qt.resolvedUrl("pathitemgallery.qml")) - addExample("Interactive paths", "Dynamic path examples", Qt.resolvedUrl("pathiteminteract.qml")) + addExample("Super- and multisampling", "Improving quality", Qt.resolvedUrl("pathitemsampling.qml")) addExample("Clip My Tiger!", "Clip examples, a.k.a. What Not To Do", Qt.resolvedUrl("pathitemtigers.qml")) } } diff --git a/examples/quick/pathitem/content/pathiteminteract.qml b/examples/quick/pathitem/content/pathiteminteract.qml deleted file mode 100644 index 78b3b25b55..0000000000 --- a/examples/quick/pathitem/content/pathiteminteract.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtQuick module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.9 // to get PathItem - -Rectangle { - id: root - width: 1024 - height: 768 - - property color col: "lightsteelblue" - gradient: Gradient { - GradientStop { position: 0.0; color: Qt.tint(root.col, "#20FFFFFF") } - GradientStop { position: 0.1; color: Qt.tint(root.col, "#20AAAAAA") } - GradientStop { position: 0.9; color: Qt.tint(root.col, "#20666666") } - GradientStop { position: 1.0; color: Qt.tint(root.col, "#20000000") } - } -} diff --git a/examples/quick/pathitem/content/pathitemsampling.qml b/examples/quick/pathitem/content/pathitemsampling.qml new file mode 100644 index 0000000000..15c9cbe323 --- /dev/null +++ b/examples/quick/pathitem/content/pathitemsampling.qml @@ -0,0 +1,191 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQuick module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.9 // to get PathItem + +Rectangle { + id: root + width: 1024 + height: 768 + + property color col: "lightsteelblue" + gradient: Gradient { + GradientStop { position: 0.0; color: Qt.tint(root.col, "#20FFFFFF") } + GradientStop { position: 0.1; color: Qt.tint(root.col, "#20AAAAAA") } + GradientStop { position: 0.9; color: Qt.tint(root.col, "#20666666") } + GradientStop { position: 1.0; color: Qt.tint(root.col, "#20000000") } + } + + Row { + anchors.fill: parent + anchors.margins: 20 + spacing: 40 + + Column { + spacing: 40 + + Text { + text: "Original" + } + + // A simple PathItem without anything special. + Rectangle { + color: "lightGray" + width: 400 + height: 200 + + PathItem { + x: 30 + y: 20 + width: 50 + height: 50 + scale: 2 + + VisualPath { + strokeColor: "green" + NumberAnimation on strokeWidth { from: 1; to: 20; duration: 5000 } + fillColor: "transparent" + capStyle: VisualPath.RoundCap + + Path { + startX: 40; startY: 30 + PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 } + PathLine { x: 150; y: 80 } + PathQuad { x: 160; y: 30; controlX: 200; controlY: 80 } + } + } + } + } + + Text { + text: "Supersampling (2x)" + } + + // Now let's use 2x supersampling via layers. This way the entire subtree + // is rendered into an FBO twice the size and then drawn with linear + // filtering. This allows having some level of AA even when there is no + // support for multisample framebuffers. + Rectangle { + id: supersampledItem + color: "lightGray" + width: 400 + height: 200 + + layer.enabled: true + layer.smooth: true + layer.textureSize: Qt.size(supersampledItem.width * 2, supersampledItem.height * 2) + + PathItem { + x: 30 + y: 20 + width: 50 + height: 50 + scale: 2 + + VisualPath { + strokeColor: "green" + NumberAnimation on strokeWidth { from: 1; to: 20; duration: 5000 } + fillColor: "transparent" + capStyle: VisualPath.RoundCap + + Path { + startX: 40; startY: 30 + PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 } + PathLine { x: 150; y: 80 } + PathQuad { x: 160; y: 30; controlX: 200; controlY: 80 } + } + } + } + } + } + + Column { + spacing: 40 + + Text { + text: "Multisampling (4x)" + } + + // Now let's use 4x MSAA, again via layers. This needs support for + // multisample renderbuffers and framebuffer blits. + Rectangle { + color: "lightGray" + width: 400 + height: 200 + + layer.enabled: true + layer.smooth: true + layer.samples: 4 + + PathItem { + x: 30 + y: 20 + width: 50 + height: 50 + scale: 2 + + VisualPath { + strokeColor: "green" + NumberAnimation on strokeWidth { from: 1; to: 20; duration: 5000 } + fillColor: "transparent" + capStyle: VisualPath.RoundCap + + Path { + startX: 40; startY: 30 + PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 } + PathLine { x: 150; y: 80 } + PathQuad { x: 160; y: 30; controlX: 200; controlY: 80 } + } + } + } + } + } + } +} diff --git a/examples/quick/pathitem/content/pathitemtigers.qml b/examples/quick/pathitem/content/pathitemtigers.qml index 6c8e3a19ce..36bff891c6 100644 --- a/examples/quick/pathitem/content/pathitemtigers.qml +++ b/examples/quick/pathitem/content/pathitemtigers.qml @@ -108,7 +108,6 @@ Rectangle { // instead of scissoring, this is more expensive. It may also trigger a // slower code path for PathItems, depending on the path rendering backend // in use, and may affect rendering quality as well. - // So in short: do not do this. Rectangle { id: stencilRect width: 300 diff --git a/examples/quick/pathitem/pathitem.pro b/examples/quick/pathitem/pathitem.pro index 3c12f35fd2..333b84176d 100644 --- a/examples/quick/pathitem/pathitem.pro +++ b/examples/quick/pathitem/pathitem.pro @@ -5,7 +5,7 @@ SOURCES += main.cpp RESOURCES += pathitem.qrc OTHER_FILES += content/pathitem.qml \ content/pathitemgallery.qml \ - content/pathiteminteract.qml \ + content/pathitemsampling.qml \ content/pathitemtigers.qml \ content/tiger.qml \ content/item1.qml \ diff --git a/examples/quick/pathitem/pathitem.qrc b/examples/quick/pathitem/pathitem.qrc index d67c918faf..83984b5e87 100644 --- a/examples/quick/pathitem/pathitem.qrc +++ b/examples/quick/pathitem/pathitem.qrc @@ -6,7 +6,7 @@ <file alias="images/back.png">../shared/images/back.png</file> <file alias="pathitem.qml">content/pathitem.qml</file> <file alias="pathitemgallery.qml">content/pathitemgallery.qml</file> - <file alias="pathiteminteract.qml">content/pathiteminteract.qml</file> + <file alias="pathitemsampling.qml">content/pathitemsampling.qml</file> <file alias="pathitemtigers.qml">content/pathitemtigers.qml</file> <file alias="tiger.qml">content/tiger.qml</file> <file alias="item1.qml">content/item1.qml</file> |