Debian Codegraph @

tests/manual/nodetypes_ng/Layers.qml

raw
1 /****************************************************************************
2 **
3 ** Copyright (C) 2017 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the demonstration applications 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
51 import QtQuick 2.0
52
53 Item {
54 Rectangle {
55 color: "lightGray"
56 anchors.fill: parent
57 anchors.margins: 10
58
59 Column {
60 anchors.fill: parent
61 spacing: 10
62
63 Row {
64 width: parent.width
65 Rectangle {
66 color: "red"
67 width: 300
68 height: 100
69 layer.enabled: true
70 Text { text: "this is in a layer, going through an offscreen render target" }
71 clip: true
72 Rectangle {
73 color: "lightGreen"
74 width: 50
75 height: 50
76 x: 275
77 y: 75
78 }
79 }
80 Rectangle {
81 color: "white"
82 width: 300
83 height: 100
84 Text { text: "this is not a layer" }
85 }
86 Rectangle {
87 color: "green"
88 width: 300
89 height: 100
90 layer.enabled: true
91 Text { text: "this is another layer" }
92 Rectangle {
93 border.width: 4
94 border.color: "black"
95 anchors.centerIn: parent
96 width: 150
97 height: 50
98 layer.enabled: true
99 Text {
100 anchors.centerIn: parent
101 text: "layer in a layer"
102 }
103 }
104 Image {
105 source: "qrc:/face-smile.png"
106 anchors.bottom: parent.bottom
107 anchors.right: parent.right
108 NumberAnimation on rotation { from: 0; to: 360; duration: 2000; loops: Animation.Infinite; }
109 }
110 }
111 }
112
113 Row {
114 width: parent.width
115 Rectangle {
116 color: "white"
117 border.color: "black"
118 border.width: 4
119 width: 300
120 height: 100
121 layer.enabled: true
122 layer.smooth: true // sets min/mag filter in the sampler to Linear
123 layer.textureSize: Qt.size(width * 2, height * 2)
124 Text { x: 10; y: 10; text: "supersampled layer\n(rendered at 2x, sampled with linear min/mag)" }
125 Rectangle {
126 width: 30
127 height: 30
128 anchors.centerIn: parent
129 color: "red"
130 NumberAnimation on rotation { from: 0; to: 360; duration: 2000; loops: Animation.Infinite; }
131 }
132 }
133 Rectangle {
134 color: "white"
135 border.color: "black"
136 border.width: 4
137 width: 300
138 height: 100
139 layer.enabled: true
140 layer.samples: 4 // 4x MSAA
141 Text { x: 10; y: 10; text: "4x MSAA layer\n(rendered into multisample texture/renderbuffer,\nthen resolved into non-msaa texture)" }
142 Rectangle {
143 width: 30
144 height: 30
145 anchors.right: parent.right
146 anchors.bottom: parent.bottom
147 anchors.margins: 10
148 color: "red"
149 NumberAnimation on rotation { from: 360; to: 0; duration: 2000; loops: Animation.Infinite; }
150 }
151 }
152 Rectangle {
153 color: "white"
154 border.color: "black"
155 border.width: 4
156 width: 300
157 height: 100
158 layer.enabled: true
159 layer.mipmap: true
160 Text { x: 10; y: 10; text: "Mipmapped layer" }
161 Rectangle {
162 width: 30
163 height: 30
164 anchors.right: parent.right
165 anchors.bottom: parent.bottom
166 anchors.margins: 10
167 color: "red"
168 NumberAnimation on rotation { from: 360; to: 0; duration: 2000; loops: Animation.Infinite; }
169 }
170 }
171 }
172 }
173 }
174 }