diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2016-12-19 13:54:58 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2017-01-10 14:47:30 +0000 |
commit | aa24b8938bb03e688633e544dddeca5aff91940e (patch) | |
tree | 9f430add0d4ba2ccd3e7b17037d947185fe97c2e /tests/manual | |
parent | 79831caa0533ad5f48322568557622596b85ed0f (diff) |
Stencil clipping for NVPR
Fix also the fill rule interpretation on NVPR - it was the opposite of
what QPainter was doing.
Change-Id: I23ff3b20e3b066d4b4e07aaa68b7da1e09d9127d
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'tests/manual')
-rw-r--r-- | tests/manual/pathitem/main.cpp | 11 | ||||
-rw-r--r-- | tests/manual/pathitem/pathitemtest.qml | 74 |
2 files changed, 82 insertions, 3 deletions
diff --git a/tests/manual/pathitem/main.cpp b/tests/manual/pathitem/main.cpp index 62ef4385d6..35f0c9eb84 100644 --- a/tests/manual/pathitem/main.cpp +++ b/tests/manual/pathitem/main.cpp @@ -49,11 +49,16 @@ int main(int argc, char **argv) QQuickView view; - if (app.arguments().contains(QStringLiteral("--multisample"))) { - QSurfaceFormat fmt; + QSurfaceFormat fmt; + fmt.setDepthBufferSize(24); + fmt.setStencilBufferSize(8); + if (app.arguments().contains(QStringLiteral("--multisample"))) fmt.setSamples(4); - view.setFormat(fmt); + if (app.arguments().contains(QStringLiteral("--coreprofile"))) { + fmt.setVersion(4, 3); + fmt.setProfile(QSurfaceFormat::CoreProfile); } + view.setFormat(fmt); view.setResizeMode(QQuickView::SizeRootObjectToView); view.resize(1024, 768); diff --git a/tests/manual/pathitem/pathitemtest.qml b/tests/manual/pathitem/pathitemtest.qml index cf8a3deece..8b4ae74fae 100644 --- a/tests/manual/pathitem/pathitemtest.qml +++ b/tests/manual/pathitem/pathitemtest.qml @@ -279,6 +279,80 @@ Rectangle { } } } + + Rectangle { + border.color: "purple" + color: "transparent" + width: 200 + height: 200 + Rectangle { + anchors.centerIn: parent + // have a size smaller than 150x150 + width: 100 + height: 100 + // and enable clipping. Normally this goes via scissoring, unless + // some transform triggers the stencil-based path. Ensure this via rotation. + clip: true + NumberAnimation on rotation { + from: 0; to: 360; duration: 5000; loops: Animation.Infinite + } + + PathItem { + width: 150 + height: 150 + + fillColor: "blue" + strokeColor: "red" + strokeWidth: 4 + + path: Path { + startX: 10; startY: 10 + PathLine { x: 140; y: 140 } + PathLine { x: 10; y: 140 } + PathLine { x: 10; y: 10 } + } + } + } + } + + // stencil clip test #2, something more complicated: + Rectangle { + border.color: "purple" + color: "transparent" + width: 150 + height: 150 + Rectangle { + anchors.centerIn: parent + width: 60 + height: 60 + clip: true + NumberAnimation on rotation { + from: 0; to: 360; duration: 5000; loops: Animation.Infinite + } + PathItem { + id: clippedStar + width: 100 + height: 100 + strokeColor: "blue" + fillColor: "lightGray" + strokeWidth: 2 + path: Path { + PathMove { x: 90; y: 50 } + PathLine { x: 50 + 40 * Math.cos(0.8 * 1 * Math.PI); y: 50 + 40 * Math.sin(0.8 * 1 * Math.PI) } + PathLine { x: 50 + 40 * Math.cos(0.8 * 2 * Math.PI); y: 50 + 40 * Math.sin(0.8 * 2 * Math.PI) } + PathLine { x: 50 + 40 * Math.cos(0.8 * 3 * Math.PI); y: 50 + 40 * Math.sin(0.8 * 3 * Math.PI) } + PathLine { x: 50 + 40 * Math.cos(0.8 * 4 * Math.PI); y: 50 + 40 * Math.sin(0.8 * 4 * Math.PI) } + PathLine { x: 90; y: 50 } + } + } + Timer { + interval: 1000 + onTriggered: clippedStar.fillRule = (clippedStar.fillRule === PathItem.OddEvenFill ? PathItem.WindingFill : PathItem.OddEvenFill) + repeat: true + running: true + } + } + } } } |