1/**************************************************************************** 2** 3** Copyright (C) 2016 The Qt Company Ltd. 4** Contact: https://www.qt.io/licensing/ 5** 6** This file is part of the QtQuick module of the Qt Toolkit. 7** 8** $QT_BEGIN_LICENSE:BSD$ 9** Commercial License Usage 10** Licensees holding valid commercial Qt licenses may use this file in 11** accordance with the commercial license agreement provided with the 12** Software or, alternatively, in accordance with the terms contained in 13** a written agreement between you and The Qt Company. For licensing terms 14** and conditions see https://www.qt.io/terms-conditions. For further 15** information use the contact form at https://www.qt.io/contact-us. 16** 17** BSD License Usage 18** Alternatively, you may use this file under the terms of the BSD license 19** as follows: 20** 21** "Redistribution and use in source and binary forms, with or without 22** modification, are permitted provided that the following conditions are 23** met: 24** * Redistributions of source code must retain the above copyright 25** notice, this list of conditions and the following disclaimer. 26** * Redistributions in binary form must reproduce the above copyright 27** notice, this list of conditions and the following disclaimer in 28** the documentation and/or other materials provided with the 29** distribution. 30** * Neither the name of The Qt Company Ltd nor the names of its 31** contributors may be used to endorse or promote products derived 32** from this software without specific prior written permission. 33** 34** 35** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 36** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 37** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 38** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 39** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 40** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 41** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 42** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 43** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 44** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 45** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 46** 47** $QT_END_LICENSE$ 48** 49****************************************************************************/ 50 51import QtQuick 2.9 52import QtQuick.Shapes 1.0 53 54Rectangle { 55 id: root 56 width: 1024 57 height: 768 58 59 property color col: "lightsteelblue" 60 gradient: Gradient { 61 GradientStop { position: 0.0; color: Qt.tint(root.col, "#20FFFFFF") } 62 GradientStop { position: 0.1; color: Qt.tint(root.col, "#20AAAAAA") } 63 GradientStop { position: 0.9; color: Qt.tint(root.col, "#20666666") } 64 GradientStop { position: 1.0; color: Qt.tint(root.col, "#20000000") } 65 } 66 67 Row { 68 anchors.fill: parent 69 anchors.margins: 20 70 spacing: 40 71 72 Column { 73 spacing: 40 74 75 Text { 76 text: "Original" 77 } 78 79 // A simple Shape without anything special. 80 Rectangle { 81 color: "lightGray" 82 width: 400 83 height: 200 84 85 Shape { 86 x: 30 87 y: 20 88 width: 50 89 height: 50 90 scale: 2 91 92 ShapePath { 93 strokeColor: "green" 94 NumberAnimation on strokeWidth { from: 1; to: 20; duration: 5000 } 95 fillColor: "transparent" 96 capStyle: ShapePath.RoundCap 97 98 startX: 40; startY: 30 99 PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 } 100 PathLine { x: 150; y: 80 } 101 PathQuad { x: 160; y: 30; controlX: 200; controlY: 80 } 102 } 103 } 104 } 105 106 Text { 107 text: "Supersampling (2x)" 108 } 109 110 // Now let's use 2x supersampling via layers. This way the entire subtree 111 // is rendered into an FBO twice the size and then drawn with linear 112 // filtering. This allows having some level of AA even when there is no 113 // support for multisample framebuffers. 114 Rectangle { 115 id: supersampledItem 116 color: "lightGray" 117 width: 400 118 height: 200 119 120 layer.enabled: true 121 layer.smooth: true 122 layer.textureSize: Qt.size(supersampledItem.width * 2, supersampledItem.height * 2) 123 124 Shape { 125 x: 30 126 y: 20 127 width: 50 128 height: 50 129 scale: 2 130 131 ShapePath { 132 strokeColor: "green" 133 NumberAnimation on strokeWidth { from: 1; to: 20; duration: 5000 } 134 fillColor: "transparent" 135 capStyle: ShapePath.RoundCap 136 137 startX: 40; startY: 30 138 PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 } 139 PathLine { x: 150; y: 80 } 140 PathQuad { x: 160; y: 30; controlX: 200; controlY: 80 } 141 } 142 } 143 } 144 } 145 146 Column { 147 spacing: 40 148 149 Text { 150 text: "Multisampling (4x)" 151 } 152 153 // Now let's use 4x MSAA, again via layers. This needs support for 154 // multisample renderbuffers and framebuffer blits. 155 Rectangle { 156 color: "lightGray" 157 width: 400 158 height: 200 159 160 layer.enabled: true 161 layer.smooth: true 162 layer.samples: 4 163 164 Shape { 165 x: 30 166 y: 20 167 width: 50 168 height: 50 169 scale: 2 170 171 ShapePath { 172 strokeColor: "green" 173 NumberAnimation on strokeWidth { from: 1; to: 20; duration: 5000 } 174 fillColor: "transparent" 175 capStyle: ShapePath.RoundCap 176 177 startX: 40; startY: 30 178 PathQuad { x: 50; y: 80; controlX: 0; controlY: 80 } 179 PathLine { x: 150; y: 80 } 180 PathQuad { x: 160; y: 30; controlX: 200; controlY: 80 } 181 } 182 } 183 } 184 } 185 } 186} 187