aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickrectangle.cpp
diff options
context:
space:
mode:
authorRobin Burchell <robin.burchell@crimson.no>2017-04-25 00:03:22 +0200
committerRobin Burchell <robin.burchell@crimson.no>2017-04-28 17:46:49 +0000
commit9709d04ba7787c853a1ddbeed0347eab27c0924f (patch)
tree9c2e796acad520e7e4db47a5113439b7f1b53e26 /src/quick/items/qquickrectangle.cpp
parenta28b6107f82fefe2b4e0a5f553b6dae5e3186168 (diff)
QQuickRectangle: Optimize setGradient
Similarly to the QQuickPen optimization, we can avoid a signal connection by using the parent pointer of the QQuickGradient. This improves qmlbench's delegates_rect_gradient.qml by ~6% for me: Before: 300.6 frames; using samples; MedianAll=301; StdDev=4.61519, CoV=0.01535 After: 320.4 frames; using samples; MedianAll=321; StdDev=1.94936, CoV=0.00608414 Again, hopefully, the resulting lessening in allocations and improvement in performance will help stabilize the benchmark a little on some systems, as well as the improvement to performance and memory use. Change-Id: Id8e0399f5a4a0ef55d7fc9b8f100af229f389ddd Reviewed-by: Gunnar Sletta <gunnar@crimson.no> Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'src/quick/items/qquickrectangle.cpp')
-rw-r--r--src/quick/items/qquickrectangle.cpp19
1 files changed, 2 insertions, 17 deletions
diff --git a/src/quick/items/qquickrectangle.cpp b/src/quick/items/qquickrectangle.cpp
index 7d8e4de1c0..27086c889b 100644
--- a/src/quick/items/qquickrectangle.cpp
+++ b/src/quick/items/qquickrectangle.cpp
@@ -1,5 +1,6 @@
/****************************************************************************
**
+** Copyright (C) 2017 Crimson AS <info@crimson.no>
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
@@ -269,11 +270,9 @@ QGradientStops QQuickGradient::gradientStops() const
void QQuickGradient::doUpdate()
{
- emit updated();
+ static_cast<QQuickItem*>(parent())->update();
}
-int QQuickRectanglePrivate::doUpdateSlotIdx = -1;
-
/*!
\qmltype Rectangle
\instantiates QQuickRectangle
@@ -327,11 +326,6 @@ QQuickRectangle::QQuickRectangle(QQuickItem *parent)
setFlag(ItemHasContents);
}
-void QQuickRectangle::doUpdate()
-{
- update();
-}
-
/*!
\qmlproperty bool QtQuick::Rectangle::antialiasing
@@ -396,16 +390,7 @@ void QQuickRectangle::setGradient(QQuickGradient *gradient)
Q_D(QQuickRectangle);
if (d->gradient == gradient)
return;
- static int updatedSignalIdx = -1;
- if (updatedSignalIdx < 0)
- updatedSignalIdx = QMetaMethod::fromSignal(&QQuickGradient::updated).methodIndex();
- if (d->doUpdateSlotIdx < 0)
- d->doUpdateSlotIdx = QQuickRectangle::staticMetaObject.indexOfSlot("doUpdate()");
- if (d->gradient)
- QMetaObject::disconnect(d->gradient, updatedSignalIdx, this, d->doUpdateSlotIdx);
d->gradient = gradient;
- if (d->gradient)
- QMetaObject::connect(d->gradient, updatedSignalIdx, this, d->doUpdateSlotIdx);
update();
}