From 699dbb8914e718013d9ee0cbb39bdb4b6f833710 Mon Sep 17 00:00:00 2001 From: Andy Nichols Date: Wed, 10 Sep 2014 15:56:49 +0200 Subject: Ensure that markDirty is called when needed There were many cases where properties of nodes could change but since the node was not marked dirty, the scene update was never rendered. Change-Id: I7740a43d98521073056f85fe80d6c1ff213236a3 Reviewed-by: Andy Nichols --- .../scenegraph/softwarecontext/imagenode.cpp | 33 ++++++++++++++++++++-- .../scenegraph/softwarecontext/ninepatchnode.cpp | 14 +++++++++ .../scenegraph/softwarecontext/rectanglenode.cpp | 6 ++++ 3 files changed, 51 insertions(+), 2 deletions(-) (limited to 'src/plugins/scenegraph/softwarecontext') diff --git a/src/plugins/scenegraph/softwarecontext/imagenode.cpp b/src/plugins/scenegraph/softwarecontext/imagenode.cpp index 27583821ae..3146830172 100644 --- a/src/plugins/scenegraph/softwarecontext/imagenode.cpp +++ b/src/plugins/scenegraph/softwarecontext/imagenode.cpp @@ -303,22 +303,34 @@ ImageNode::ImageNode() void ImageNode::setTargetRect(const QRectF &rect) { + if (rect == m_targetRect) + return; m_targetRect = rect; + markDirty(DirtyGeometry); } void ImageNode::setInnerTargetRect(const QRectF &rect) { + if (rect == m_innerTargetRect) + return; m_innerTargetRect = rect; + markDirty(DirtyGeometry); } void ImageNode::setInnerSourceRect(const QRectF &rect) { + if (rect == m_innerSourceRect) + return; m_innerSourceRect = rect; + markDirty(DirtyGeometry); } void ImageNode::setSubSourceRect(const QRectF &rect) { + if (rect == m_subSourceRect) + return; m_subSourceRect = rect; + markDirty(DirtyGeometry); } void ImageNode::setTexture(QSGTexture *texture) @@ -326,6 +338,7 @@ void ImageNode::setTexture(QSGTexture *texture) if (m_texture != texture) { m_texture = texture; m_cachedMirroredPixmapIsDirty = true; + markDirty(DirtyMaterial); } } @@ -334,6 +347,7 @@ void ImageNode::setMirror(bool mirror) if (m_mirror != mirror) { m_mirror = mirror; m_cachedMirroredPixmapIsDirty = true; + markDirty(DirtyMaterial); } } @@ -343,17 +357,32 @@ void ImageNode::setMipmapFiltering(QSGTexture::Filtering /*filtering*/) void ImageNode::setFiltering(QSGTexture::Filtering filtering) { - m_smooth = (filtering == QSGTexture::Nearest); + bool smooth = (filtering == QSGTexture::Nearest); + if (smooth == m_smooth) + return; + + m_smooth = smooth; + markDirty(DirtyMaterial); } void ImageNode::setHorizontalWrapMode(QSGTexture::WrapMode wrapMode) { - m_tileHorizontal = (wrapMode == QSGTexture::Repeat); + bool tileHorizontal = (wrapMode == QSGTexture::Repeat); + if (tileHorizontal == m_tileHorizontal) + return; + + m_tileHorizontal = tileHorizontal; + markDirty(DirtyMaterial); } void ImageNode::setVerticalWrapMode(QSGTexture::WrapMode wrapMode) { + bool tileVertical = (wrapMode == QSGTexture::Repeat); + if (tileVertical == m_tileVertical) + return; + m_tileVertical = (wrapMode == QSGTexture::Repeat); + markDirty(DirtyMaterial); } void ImageNode::update() diff --git a/src/plugins/scenegraph/softwarecontext/ninepatchnode.cpp b/src/plugins/scenegraph/softwarecontext/ninepatchnode.cpp index ab503b7af5..ec77729388 100644 --- a/src/plugins/scenegraph/softwarecontext/ninepatchnode.cpp +++ b/src/plugins/scenegraph/softwarecontext/ninepatchnode.cpp @@ -35,21 +35,35 @@ void NinePatchNode::setTexture(QSGTexture *texture) return; } m_pixmap = pt->pixmap(); + markDirty(DirtyMaterial); } void NinePatchNode::setBounds(const QRectF &bounds) { + if (m_bounds == bounds) + return; + m_bounds = bounds; + markDirty(DirtyGeometry); } void NinePatchNode::setDevicePixelRatio(qreal ratio) { + if (m_pixelRatio == ratio) + return; + m_pixelRatio = ratio; + markDirty(DirtyGeometry); } void NinePatchNode::setPadding(qreal left, qreal top, qreal right, qreal bottom) { + QMargins margins(qRound(left), qRound(top), qRound(right), qRound(bottom)); + if (m_margins == margins) + return; + m_margins = QMargins(qRound(left), qRound(top), qRound(right), qRound(bottom)); + markDirty(DirtyGeometry); } void NinePatchNode::update() diff --git a/src/plugins/scenegraph/softwarecontext/rectanglenode.cpp b/src/plugins/scenegraph/softwarecontext/rectanglenode.cpp index c0eebb3bcd..0a4fcf8859 100644 --- a/src/plugins/scenegraph/softwarecontext/rectanglenode.cpp +++ b/src/plugins/scenegraph/softwarecontext/rectanglenode.cpp @@ -37,6 +37,7 @@ void RectangleNode::setRect(const QRectF &rect) QRect alignedRect = rect.toAlignedRect(); if (m_rect != alignedRect) { m_rect = alignedRect; + markDirty(DirtyMaterial); } } @@ -45,6 +46,7 @@ void RectangleNode::setColor(const QColor &color) if (m_color != color) { m_color = color; m_cornerPixmapIsDirty = true; + markDirty(DirtyMaterial); } } @@ -53,6 +55,7 @@ void RectangleNode::setPenColor(const QColor &color) if (m_penColor != color) { m_penColor = color; m_cornerPixmapIsDirty = true; + markDirty(DirtyMaterial); } } @@ -61,6 +64,7 @@ void RectangleNode::setPenWidth(qreal width) if (m_penWidth != width) { m_penWidth = width; m_cornerPixmapIsDirty = true; + markDirty(DirtyMaterial); } } @@ -155,6 +159,7 @@ void RectangleNode::setGradientStops(const QGradientStops &stops) m_stops = stops; } m_cornerPixmapIsDirty = true; + markDirty(DirtyMaterial); } void RectangleNode::setRadius(qreal radius) @@ -162,6 +167,7 @@ void RectangleNode::setRadius(qreal radius) if (m_radius != radius) { m_radius = radius; m_cornerPixmapIsDirty = true; + markDirty(DirtyMaterial); } } -- cgit v1.2.3