diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2020-10-27 16:27:01 +0100 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2020-10-28 11:51:19 +0100 |
commit | 7c48cf655580e118ee7faf21a9f346bd68292e26 (patch) | |
tree | 88216a0c76cf2093fe10e34b94b4c5de09517d03 | |
parent | 938f853ddcb1a7a86da703336a0a67ccd69aca54 (diff) |
nativestyle: only draw the control if the control is visible
Check if the control is visible before taking the time to
draw the image.
Change-Id: Icb64b85355e1341279a95e9035ae18d91c14d6a8
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r-- | src/imports/nativestyle/items/qquickstyleitem.cpp | 16 | ||||
-rw-r--r-- | src/imports/nativestyle/items/qquickstyleitem.h | 1 |
2 files changed, 16 insertions, 1 deletions
diff --git a/src/imports/nativestyle/items/qquickstyleitem.cpp b/src/imports/nativestyle/items/qquickstyleitem.cpp index bf3d9129..b5005a8b 100644 --- a/src/imports/nativestyle/items/qquickstyleitem.cpp +++ b/src/imports/nativestyle/items/qquickstyleitem.cpp @@ -220,6 +220,20 @@ void QQuickStyleItem::geometryChange(const QRectF &newGeometry, const QRectF &ol markGeometryDirty(); } +void QQuickStyleItem::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &data) +{ + QQuickItem::itemChange(change, data); + + switch (change) { + case QQuickItem::ItemVisibleHasChanged: + if (data.boolValue) + markImageDirty(); + break; + default: + break; + } +} + void QQuickStyleItem::updateGeometry() { qqc2DebugHeading("GEOMETRY"); @@ -321,7 +335,7 @@ void QQuickStyleItem::updatePolish() QScopedValueRollback<bool> guard(m_polishing, true); const bool dirtyGeometry = m_dirty & DirtyFlag::Geometry; - const bool dirtyImage = (m_dirty & DirtyFlag::Image) || (!m_useNinePatchImage && dirtyGeometry); + const bool dirtyImage = isVisible() && ((m_dirty & DirtyFlag::Image) || (!m_useNinePatchImage && dirtyGeometry)); if (dirtyGeometry) updateGeometry(); diff --git a/src/imports/nativestyle/items/qquickstyleitem.h b/src/imports/nativestyle/items/qquickstyleitem.h index 94d8a8ef..237744fd 100644 --- a/src/imports/nativestyle/items/qquickstyleitem.h +++ b/src/imports/nativestyle/items/qquickstyleitem.h @@ -234,6 +234,7 @@ protected: void componentComplete() override; QSGNode *updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *updatePaintNodeData) override; void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override; + void itemChange(ItemChange change, const ItemChangeData &data) override; void updatePolish() override; virtual void connectToControl(); |