summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-06-05 11:03:51 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-06-07 13:23:29 +0000
commita95930282e60050d592d2688a5203f385e90e196 (patch)
tree74c94f163df151f2f32022139effdc6324333bf8
parente6fb3b4ea00044f300249f777004aad10aaa6835 (diff)
QFusionStyle: de-pessimize arrow painting
Instead of holding three QPointF's in a QPolygonF, which will allocate them on the heap, use QVarLengthArray<>, which will allocate them on the stack instead. Task-numbber: QTBUG-112200 Change-Id: If078e5a9a5cb82fd03b511e28cceb88bd42996f8 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit d6ce0bad67c6961dc87469db7ac81144a52e875f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/widgets/styles/qfusionstyle.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp
index 0ae27a9bb8..fd0458b49e 100644
--- a/src/widgets/styles/qfusionstyle.cpp
+++ b/src/widgets/styles/qfusionstyle.cpp
@@ -240,8 +240,7 @@ static void qt_fusion_draw_arrow(Qt::ArrowType type, QPainter *painter, const QS
arrowRect.moveTo((rect.width() - arrowRect.width()) / 2.0,
(rect.height() - arrowRect.height()) / 2.0);
- QPolygonF triangle;
- triangle.reserve(3);
+ QVarLengthArray<QPointF, 3> triangle;
switch (type) {
case Qt::DownArrow:
triangle << arrowRect.topLeft() << arrowRect.topRight() << QPointF(arrowRect.center().x(), arrowRect.bottom());
@@ -260,7 +259,7 @@ static void qt_fusion_draw_arrow(Qt::ArrowType type, QPainter *painter, const QS
cachePainter.setPen(Qt::NoPen);
cachePainter.setBrush(color);
cachePainter.setRenderHint(QPainter::Antialiasing);
- cachePainter.drawPolygon(triangle);
+ cachePainter.drawPolygon(triangle.data(), int(triangle.size()));
QPixmapCache::insert(cacheKey, cachePixmap);
}