From 18a2ca50ab092e27a3464fca8d515cb7791c7d5a Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" Date: Sat, 13 Apr 2019 17:23:20 +0200 Subject: [PATCH] SvgItem, IconItem: drop "smooth" property override, update node on change Summary: QQuickItem already has a "smooth" property, which was shadowed by the custom ones with the same name. As the property was not part of public symbols, but instead is dynamically looked up without the class name part of the property, we just remove the custom versions and instead switch all custom code to use the inherited property. While doing that the code is also fixed to properly update the textureNodes to the current value of the "smooth" property. As well as not set the filtering only on the texture, when it is passed to a texturenode which will set its own filtering state to the texture right before the bind call and thus wipe any previous direct setting of the filter mode on the texture. This also changed the default to smooth=true for SvgItem, though effectively smooth was always true, as the texturenode was hardcoded to get a QSGTexture::Linear filtering (which, as said above, is forced onto its texture, no matter what was otherwise set before). Reviewers: #plasma, davidedmundson, mart Reviewed By: #plasma, davidedmundson Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D20510 --- src/declarativeimports/core/iconitem.cpp | 21 +++------------------ src/declarativeimports/core/iconitem.h | 9 --------- src/declarativeimports/core/svgitem.cpp | 21 ++------------------- src/declarativeimports/core/svgitem.h | 10 ---------- 4 files changed, 5 insertions(+), 56 deletions(-) diff --git a/src/declarativeimports/core/iconitem.cpp b/src/declarativeimports/core/iconitem.cpp index 5a862485f..2beaccdd3 100644 --- a/src/declarativeimports/core/iconitem.cpp +++ b/src/declarativeimports/core/iconitem.cpp @@ -39,7 +39,6 @@ IconItem::IconItem(QQuickItem *parent) : QQuickItem(parent), m_svgIcon(nullptr), m_status(Plasma::Svg::Normal), - m_smooth(true), m_active(false), m_animated(true), m_usesPlasmaTheme(true), @@ -320,20 +319,6 @@ void IconItem::setActive(bool active) emit activeChanged(); } -void IconItem::setSmooth(const bool smooth) -{ - if (smooth == m_smooth) { - return; - } - m_smooth = smooth; - update(); -} - -bool IconItem::smooth() const -{ - return m_smooth; -} - bool IconItem::isAnimated() const { return m_animated; @@ -492,9 +477,9 @@ QSGNode* IconItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *update delete oldNode; QSGTexture *source = window()->createTextureFromImage(m_oldIconPixmap.toImage(), QQuickWindow::TextureCanUseAtlas); - source->setFiltering(m_smooth ? QSGTexture::Linear : QSGTexture::Nearest); + source->setFiltering(smooth() ? QSGTexture::Linear : QSGTexture::Nearest); QSGTexture *target = window()->createTextureFromImage(m_iconPixmap.toImage(), QQuickWindow::TextureCanUseAtlas); - target->setFiltering(m_smooth ? QSGTexture::Linear : QSGTexture::Nearest); + target->setFiltering(smooth() ? QSGTexture::Linear : QSGTexture::Nearest); animatingNode = new FadingNode(source, target); m_sizeChanged = true; m_textureChanged = false; @@ -516,11 +501,11 @@ QSGNode* IconItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *update if (!textureNode || m_textureChanged) { delete oldNode; textureNode = new ManagedTextureNode; - textureNode->setFiltering(m_smooth ? QSGTexture::Linear : QSGTexture::Nearest); textureNode->setTexture(QSharedPointer(window()->createTextureFromImage(m_iconPixmap.toImage(), QQuickWindow::TextureCanUseAtlas))); m_sizeChanged = true; m_textureChanged = false; } + textureNode->setFiltering(smooth() ? QSGTexture::Linear : QSGTexture::Nearest); if (m_sizeChanged) { const QSize newSize = paintedSize(); diff --git a/src/declarativeimports/core/iconitem.h b/src/declarativeimports/core/iconitem.h index 984e30b7d..9c0dc233d 100644 --- a/src/declarativeimports/core/iconitem.h +++ b/src/declarativeimports/core/iconitem.h @@ -66,12 +66,6 @@ class IconItem : public QQuickItem */ Q_PROPERTY(QStringList overlays READ overlays WRITE setOverlays NOTIFY overlaysChanged) - /** - * See QQuickItem::smooth - */ - //KF6 Remove, this just shadows QQuickItem::smooth - Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged) - /** * Apply a visual indication that this icon is active. * Typically used to indicate that it is hovered @@ -141,9 +135,6 @@ public: bool isActive() const; void setActive(bool active); - void setSmooth(const bool smooth); - bool smooth() const; - bool isAnimated() const; void setAnimated(bool animated); diff --git a/src/declarativeimports/core/svgitem.cpp b/src/declarativeimports/core/svgitem.cpp index 919d6aeb3..4c2d29729 100644 --- a/src/declarativeimports/core/svgitem.cpp +++ b/src/declarativeimports/core/svgitem.cpp @@ -36,7 +36,6 @@ namespace Plasma SvgItem::SvgItem(QQuickItem *parent) : QQuickItem(parent), - m_smooth(false), m_textureChanged(false) { setFlag(QQuickItem::ItemHasContents, true); @@ -115,20 +114,6 @@ Plasma::Svg *SvgItem::svg() const return m_svg.data(); } -void SvgItem::setSmooth(const bool smooth) -{ - if (smooth == m_smooth) { - return; - } - m_smooth = smooth; - emit smoothChanged(); -} - -bool SvgItem::smooth() const -{ - return m_smooth; -} - QSGNode *SvgItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) { Q_UNUSED(updatePaintNodeData); @@ -146,7 +131,6 @@ QSGNode *SvgItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updateP ManagedTextureNode *textureNode = static_cast(oldNode); if (!textureNode) { textureNode = new ManagedTextureNode; - textureNode->setFiltering(QSGTexture::Linear); m_textureChanged = true; } @@ -164,15 +148,14 @@ QSGNode *SvgItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updateP } QSharedPointer texture(window()->createTextureFromImage(m_image, QQuickWindow::TextureCanUseAtlas)); - if (m_smooth) { - texture->setFiltering(QSGTexture::Linear); - } textureNode->setTexture(texture); m_textureChanged = false; textureNode->setRect(0, 0, width(), height()); } + textureNode->setFiltering(smooth() ? QSGTexture::Linear : QSGTexture::Nearest); + return textureNode; } diff --git a/src/declarativeimports/core/svgitem.h b/src/declarativeimports/core/svgitem.h index 53e753dad..a51a821b9 100644 --- a/src/declarativeimports/core/svgitem.h +++ b/src/declarativeimports/core/svgitem.h @@ -60,11 +60,6 @@ class SvgItem : public QQuickItem */ Q_PROPERTY(QSizeF naturalSize READ naturalSize NOTIFY naturalSizeChanged) - /** - * If true enable antialiasing in paint: default off, better quality but less performance. - */ - Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged) - public: /// @cond INTERNAL_DOCS @@ -77,9 +72,6 @@ public: void setSvg(Plasma::Svg *svg); Plasma::Svg *svg() const; - void setSmooth(const bool smooth); - bool smooth() const; - QSizeF naturalSize() const; QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData) override; @@ -89,7 +81,6 @@ Q_SIGNALS: void elementIdChanged(); void svgChanged(); void naturalSizeChanged(); - void smoothChanged(); protected Q_SLOTS: /// @cond INTERNAL_DOCS @@ -104,7 +95,6 @@ private: QPointer m_svg; QString m_elementID; - bool m_smooth; bool m_textureChanged; QImage m_image; };