QQuickText: apply updateSize() optimization for item change listeners

QQuickTextPrivate::updateSize() emits implicitWidthChanged() and
implicitHeightChanged() to see if anything is connected to the signals
and therefore calls getImplicitWidth() or getImplicitHeight(), which
again call updateSize() recursively. This way it can detect the
recursion and avoid doing the size calculation multiple times.

The problem with emitting the change notifier signals directly is that
item change listeners (QQuickItemChangeListener) do not get notified.
Item change listeners are commonly used by Qt Quick Layouts and Qt
Quick Controls 2. By calling QQuickItemPrivate::implicitWidthChanged()
and implicitHeightChanged() the item change listeners are also called
in addition to emitting the change notifier signals.

Results from qmlbench delegates_buttoncontrol2.qml run with the very
latest dev-branch of qtquickcontrols2:

Before:

    Average: 130.2  frames; using  samples; MedianAll=130; StdDev=1.92354, CoV=0.0147737

After:

    Average: 139.4  frames; using  samples; MedianAll=140; StdDev=0.894427, CoV=0.00641626

Task-number: QTBUG-59746
Change-Id: I4461cdf8ddc25f80a38756a1e2b5e3d7d1e84791
Reviewed-by: Robin Burchell <robin.burchell@crimson.no>
This commit is contained in:
J-P Nurmi 2017-04-12 09:51:25 +02:00
parent 1a3dd2031a
commit 3390cc0274
1 changed files with 2 additions and 2 deletions

View File

@ -359,8 +359,8 @@ void QQuickTextPrivate::updateSize()
}
if (!requireImplicitSize) {
emit q->implicitWidthChanged();
emit q->implicitHeightChanged();
implicitWidthChanged();
implicitHeightChanged();
// if the implicitWidth is used, then updateSize() has already been called (recursively)
if (requireImplicitSize)
return;