diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-06-29 17:33:01 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2022-06-30 20:26:21 +0200 |
commit | b0fc5287b8378e0be13765e2f8dc90aa938a25fb (patch) | |
tree | c3447ed03747e44fa70a4dac2d337e0f3012e4e0 /tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp | |
parent | 80166d58a18370bd5a2c6c61d2519011cfd65721 (diff) |
Ensure that when an item resizes, its layer resizes immediately
geometryChange() notifies QQuickItemLayer::updateGeometry() to update
its internal bounds; at that moment, QQuickImagePrivate::paintedHeight
has not yet been updated, so the QQuickImage::boundingRect() override
returns the old size. It gets updated in updatePaintedGeometry(); but
until then, it's better to use QQuickItem::boundingRect() without
polymorphism, because that simply returns the item width and height.
An alternative would be to use clipRect(), as it was before
9b62f4c27ac3fb3dc563c7f4657094c14d752bac; but that is more complex now:
in case ItemObservesViewport is set, we would need to worry about
whether it's more appropriate to have the item's layer the same size
as the viewport (and update it more often during scrolling), or the
same size as the item, as it was before.
Amends 9b62f4c27ac3fb3dc563c7f4657094c14d752bac
Fixes: QTBUG-104442
Fixes: QTBUG-104536
Pick-to: 6.4 6.3
Change-Id: I51e25402d358a57cea9fd718ee8fe759b572b1a2
Reviewed-by: Igor Bugaev <freedbrt@gmail.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp')
-rw-r--r-- | tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp index 32a571ee49..6cdcd2829c 100644 --- a/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp +++ b/tests/auto/quick/qquickitemlayer/tst_qquickitemlayer.cpp @@ -6,10 +6,12 @@ #include <QtQuick/qquickitem.h> #include <QtQuick/qquickview.h> #include <QtQuick/qsgrendererinterface.h> +#include <QtQuick/private/qquickitem_p.h> #include <qopenglcontext.h> #include <qopenglfunctions.h> #include <QtQuickTestUtils/private/qmlutils_p.h> +#include <QtQuickTestUtils/private/viewtestutils_p.h> #include <QtGui/private/qguiapplication_p.h> #include <QtGui/qpa/qplatformintegration.h> @@ -60,6 +62,8 @@ private slots: void textureMirroring_data(); void textureMirroring(); + void effectSourceResizeToItem(); + private: void mirroringCheck(int mirroring, int x, bool shouldMirror, const QImage &fb); }; @@ -452,6 +456,25 @@ void tst_QQuickItemLayer::textureMirroring() mirroringCheck(mirroring, 200, true, fb); } +void tst_QQuickItemLayer::effectSourceResizeToItem() // QTBUG-104442 +{ + QQuickView window; + QVERIFY(QQuickTest::showView(window, testFileUrl("itemImageLayer.qml"))); + window.setResizeMode(QQuickView::SizeRootObjectToView); + QQuickItem *image = window.rootObject()->findChild<QQuickItem*>("image"); + QVERIFY(image); + QCOMPARE(image->size(), window.rootObject()->size()); + QQuickItemLayer *layer = QQuickItemPrivate::get(image)->layer(); + QVERIFY(layer); + auto *effectSource = layer->effectSource(); + QVERIFY(effectSource); + QCOMPARE(effectSource->size(), image->size()); + + window.resize(200, 200); // shrink it a bit + QTRY_COMPARE(image->size().toSize(), QSize(200, 200)); // wait for the window system + QCOMPARE(effectSource->size(), image->size()); +} + void tst_QQuickItemLayer::mirroringCheck(int mirroring, int x, bool shouldMirror, const QImage &fb) { int offset = 10; |