aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Burchell <robin.burchell@crimson.no>2017-04-24 23:54:21 +0200
committerRobin Burchell <robin.burchell@crimson.no>2017-04-28 17:46:46 +0000
commita28b6107f82fefe2b4e0a5f553b6dae5e3186168 (patch)
treeef166adf1246e4add626dbd71e1a98e247fcc923
parentb0cc12406ca853c0395f71436b3ef653eb383e97 (diff)
QQuickRectangle: Use parenting on QQuickPen to speed up pen changes
We know that signal connections are slow, so let's not use them. QObject has a parent pointer sitting there that looks nice and ripe, so: let's set the parent pointer ourselves, and call update() via QQuickPen. This improves delegates_rect_border.qml on my mbp by ~5%: Before: 394.6 frames; using samples; MedianAll=395; StdDev=2.30217, CoV=0.00583419 After: 417.4 frames; using samples; MedianAll=417; StdDev=1.67332, CoV=0.00400891 ... and should additionally decrease memory (no more signal connection). Hopefully, the decrease in allocation and increase in performance might also help with stability, since some systems seem a little flappy with this one. Change-Id: I885654d606bc77d2949b9db81217426cf367b081 Reviewed-by: Gunnar Sletta <gunnar@crimson.no> Reviewed-by: Michael Brasser <michael.brasser@live.com>
-rw-r--r--src/quick/items/qquickrectangle.cpp10
-rw-r--r--src/quick/items/qquickrectangle_p_p.h1
2 files changed, 4 insertions, 7 deletions
diff --git a/src/quick/items/qquickrectangle.cpp b/src/quick/items/qquickrectangle.cpp
index cbf0cdad64..7d8e4de1c0 100644
--- a/src/quick/items/qquickrectangle.cpp
+++ b/src/quick/items/qquickrectangle.cpp
@@ -90,6 +90,7 @@ void QQuickPen::setWidth(qreal w)
m_width = w;
m_valid = m_color.alpha() && (qRound(m_width) >= 1 || (!m_aligned && m_width > 0));
+ static_cast<QQuickItem*>(parent())->update();
emit penChanged();
}
@@ -102,6 +103,7 @@ void QQuickPen::setColor(const QColor &c)
{
m_color = c;
m_valid = m_color.alpha() && (qRound(m_width) >= 1 || (!m_aligned && m_width > 0));
+ static_cast<QQuickItem*>(parent())->update();
emit penChanged();
}
@@ -116,6 +118,7 @@ void QQuickPen::setPixelAligned(bool aligned)
return;
m_aligned = aligned;
m_valid = m_color.alpha() && (qRound(m_width) >= 1 || (!m_aligned && m_width > 0));
+ static_cast<QQuickItem*>(parent())->update();
emit penChanged();
}
@@ -358,12 +361,7 @@ QQuickPen *QQuickRectangle::border()
Q_D(QQuickRectangle);
if (!d->pen) {
d->pen = new QQuickPen;
- static int penChangedSignalIdx = -1;
- if (penChangedSignalIdx < 0)
- penChangedSignalIdx = QMetaMethod::fromSignal(&QQuickPen::penChanged).methodIndex();
- if (d->doUpdateSlotIdx < 0)
- d->doUpdateSlotIdx = QQuickRectangle::staticMetaObject.indexOfSlot("doUpdate()");
- QMetaObject::connect(d->pen, penChangedSignalIdx, this, d->doUpdateSlotIdx);
+ QQml_setParent_noEvent(d->pen, this);
}
return d->pen;
}
diff --git a/src/quick/items/qquickrectangle_p_p.h b/src/quick/items/qquickrectangle_p_p.h
index b7cd91bd73..3c1aaf7661 100644
--- a/src/quick/items/qquickrectangle_p_p.h
+++ b/src/quick/items/qquickrectangle_p_p.h
@@ -70,7 +70,6 @@ public:
~QQuickRectanglePrivate()
{
- delete pen;
}
QColor color;