diff options
author | Michael Brasser <mbrasser@ford.com> | 2016-03-21 21:31:03 -0500 |
---|---|---|
committer | Michael Brasser <michael.brasser@live.com> | 2016-05-06 18:25:43 +0000 |
commit | 69b7ba225007d68e113ee425ad58ce7e186a92c2 (patch) | |
tree | 72d4723b85085d901c785ae933294c83c6119ccf /tests/auto/quick | |
parent | 8997e00269d8748a366d84d234dba555fc9548ce (diff) |
Introduce BorderImageMesh.
BorderImageMesh provides an optimized way to use BorderImage-type
images with ShaderEffect.
[ChangeLog][QtQuick][ShaderEffect] Add new mesh type BorderImageMesh.
BorderImageMesh provides an optimized way to use BorderImage-type
images with ShaderEffect.
Change-Id: I73bdc8318a0facba6edc2634b5f4614996b39c1b
Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'tests/auto/quick')
-rw-r--r-- | tests/auto/quick/qquickborderimage/data/mesh.qml | 22 | ||||
-rw-r--r-- | tests/auto/quick/qquickborderimage/data/nonmesh.qml | 11 | ||||
-rw-r--r-- | tests/auto/quick/qquickborderimage/qquickborderimage.pro | 1 | ||||
-rw-r--r-- | tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp | 17 | ||||
-rw-r--r-- | tests/auto/quick/scenegraph/scenegraph.pro | 1 | ||||
-rw-r--r-- | tests/auto/quick/scenegraph/tst_scenegraph.cpp | 41 | ||||
-rw-r--r-- | tests/auto/quick/shared/visualtestutil.cpp | 35 | ||||
-rw-r--r-- | tests/auto/quick/shared/visualtestutil.h | 2 |
8 files changed, 92 insertions, 38 deletions
diff --git a/tests/auto/quick/qquickborderimage/data/mesh.qml b/tests/auto/quick/qquickborderimage/data/mesh.qml new file mode 100644 index 0000000000..203bf25867 --- /dev/null +++ b/tests/auto/quick/qquickborderimage/data/mesh.qml @@ -0,0 +1,22 @@ +import QtQuick 2.8 + +Item { + width: 300 + height: 300 + Image { + id: image + source: "colors.png" + visible: false + } + ShaderEffect { + anchors.fill: parent + property variant source: image + mesh: BorderImageMesh { + border.left: 30 + border.right: 30 + border.top: 30 + border.bottom: 30 + size: image.sourceSize + } + } +} diff --git a/tests/auto/quick/qquickborderimage/data/nonmesh.qml b/tests/auto/quick/qquickborderimage/data/nonmesh.qml new file mode 100644 index 0000000000..7a1830a942 --- /dev/null +++ b/tests/auto/quick/qquickborderimage/data/nonmesh.qml @@ -0,0 +1,11 @@ +import QtQuick 2.8 + +BorderImage { + width: 300 + height: 300 + source: "colors.png" + border.left: 30 + border.right: 30 + border.top: 30 + border.bottom: 30 +} diff --git a/tests/auto/quick/qquickborderimage/qquickborderimage.pro b/tests/auto/quick/qquickborderimage/qquickborderimage.pro index 3e16063559..ba6c01737a 100644 --- a/tests/auto/quick/qquickborderimage/qquickborderimage.pro +++ b/tests/auto/quick/qquickborderimage/qquickborderimage.pro @@ -7,6 +7,7 @@ SOURCES += tst_qquickborderimage.cpp \ ../../shared/testhttpserver.cpp include (../../shared/util.pri) +include (../shared/util.pri) TESTDATA = data/* diff --git a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp index c11ae1e8c9..e1435e739f 100644 --- a/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp +++ b/tests/auto/quick/qquickborderimage/tst_qquickborderimage.cpp @@ -44,6 +44,7 @@ #include "../../shared/testhttpserver.h" #include "../../shared/util.h" +#include "../shared/visualtestutil.h" Q_DECLARE_METATYPE(QQuickImageBase::Status) @@ -75,6 +76,7 @@ private slots: void statusChanges_data(); void sourceSizeChanges(); void progressAndStatusChanges(); + void borderImageMesh(); private: QQmlEngine engine; @@ -575,6 +577,21 @@ void tst_qquickborderimage::progressAndStatusChanges() delete obj; } +void tst_qquickborderimage::borderImageMesh() +{ + QQuickView *window = new QQuickView; + + window->setSource(testFileUrl("nonmesh.qml")); + window->show(); + QTest::qWaitForWindowExposed(window); + QImage nonmesh = window->grabWindow(); + + window->setSource(testFileUrl("mesh.qml")); + QImage mesh = window->grabWindow(); + + QVERIFY(QQuickVisualTestUtil::compareImages(mesh, nonmesh)); +} + QTEST_MAIN(tst_qquickborderimage) #include "tst_qquickborderimage.moc" diff --git a/tests/auto/quick/scenegraph/scenegraph.pro b/tests/auto/quick/scenegraph/scenegraph.pro index 320228bd08..40ff7750cc 100644 --- a/tests/auto/quick/scenegraph/scenegraph.pro +++ b/tests/auto/quick/scenegraph/scenegraph.pro @@ -3,6 +3,7 @@ TARGET = tst_scenegraph SOURCES += tst_scenegraph.cpp include (../../shared/util.pri) +include (../shared/util.pri) macx:CONFIG -= app_bundle diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp index 1cca56a876..28e2010906 100644 --- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp +++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp @@ -39,6 +39,9 @@ #include <private/qsgcontext_p.h> #include <private/qsgrenderloop_p.h> +#include "../shared/visualtestutil.h" + +using namespace QQuickVisualTestUtil; class PerPixelRect : public QQuickItem { @@ -188,44 +191,6 @@ bool containsSomethingOtherThanWhite(const QImage &image) return false; } -// When running on native Nvidia graphics cards on linux, the -// distance field glyph pixels have a measurable, but not visible -// pixel error. Use a custom compare function to avoid -// -// This was GT-216 with the ubuntu "nvidia-319" driver package. -// llvmpipe does not show the same issue. -// -bool compareImages(const QImage &ia, const QImage &ib) -{ - if (ia.size() != ib.size()) - qDebug() << "images are of different size" << ia.size() << ib.size(); - Q_ASSERT(ia.size() == ib.size()); - Q_ASSERT(ia.format() == ib.format()); - - int w = ia.width(); - int h = ia.height(); - const int tolerance = 5; - for (int y=0; y<h; ++y) { - const uint *as= (const uint *) ia.constScanLine(y); - const uint *bs= (const uint *) ib.constScanLine(y); - for (int x=0; x<w; ++x) { - uint a = as[x]; - uint b = bs[x]; - - // No tolerance for error in the alpha. - if ((a & 0xff000000) != (b & 0xff000000)) - return false; - if (qAbs(qRed(a) - qRed(b)) > tolerance) - return false; - if (qAbs(qRed(a) - qRed(b)) > tolerance) - return false; - if (qAbs(qRed(a) - qRed(b)) > tolerance) - return false; - } - } - return true; -} - void tst_SceneGraph::manyWindows_data() { QTest::addColumn<QString>("file"); diff --git a/tests/auto/quick/shared/visualtestutil.cpp b/tests/auto/quick/shared/visualtestutil.cpp index 3e18c83ee2..eabfe5368b 100644 --- a/tests/auto/quick/shared/visualtestutil.cpp +++ b/tests/auto/quick/shared/visualtestutil.cpp @@ -61,3 +61,38 @@ void QQuickVisualTestUtil::dumpTree(QQuickItem *parent, int depth) } } +// A custom compare function to avoid issues such as: +// When running on native Nvidia graphics cards on linux, the +// distance field glyph pixels have a measurable, but not visible +// pixel error. This was GT-216 with the ubuntu "nvidia-319" driver package. +// llvmpipe does not show the same issue. +bool QQuickVisualTestUtil::compareImages(const QImage &ia, const QImage &ib) +{ + if (ia.size() != ib.size()) + qDebug() << "images are of different size" << ia.size() << ib.size(); + Q_ASSERT(ia.size() == ib.size()); + Q_ASSERT(ia.format() == ib.format()); + + int w = ia.width(); + int h = ia.height(); + const int tolerance = 5; + for (int y=0; y<h; ++y) { + const uint *as= (const uint *) ia.constScanLine(y); + const uint *bs= (const uint *) ib.constScanLine(y); + for (int x=0; x<w; ++x) { + uint a = as[x]; + uint b = bs[x]; + + // No tolerance for error in the alpha. + if ((a & 0xff000000) != (b & 0xff000000)) + return false; + if (qAbs(qRed(a) - qRed(b)) > tolerance) + return false; + if (qAbs(qRed(a) - qRed(b)) > tolerance) + return false; + if (qAbs(qRed(a) - qRed(b)) > tolerance) + return false; + } + } + return true; +} diff --git a/tests/auto/quick/shared/visualtestutil.h b/tests/auto/quick/shared/visualtestutil.h index 2b377a4bab..2daf86cd83 100644 --- a/tests/auto/quick/shared/visualtestutil.h +++ b/tests/auto/quick/shared/visualtestutil.h @@ -96,6 +96,8 @@ namespace QQuickVisualTestUtil items << qobject_cast<QQuickItem*>(findItem<T>(parent, objectName, indexes[i])); return items; } + + bool compareImages(const QImage &ia, const QImage &ib); } #define QQUICK_VERIFY_POLISH(item) \ |