aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/nativestyle
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-11-03 17:25:50 +0100
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-11-04 09:49:53 +0100
commite71818f7700d0e9b1f40dfa8a0f154e9d01e701c (patch)
tree03458da2c21e8f4cff10230646f6849a6989b79e /src/imports/nativestyle
parente5dfa302fe227576aece1d5637251ac68ead0374 (diff)
QQuickStyleItem: use imageSize directly
There is no reason to calculate the image size over and over. Just calculate imgSize once. Change-Id: Idf49a64102de18ba535899d4a46085de79e7ca2f Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/imports/nativestyle')
-rw-r--r--src/imports/nativestyle/items/qquickstyleitem.cpp19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/imports/nativestyle/items/qquickstyleitem.cpp b/src/imports/nativestyle/items/qquickstyleitem.cpp
index 9f6ce676..38e7fd6d 100644
--- a/src/imports/nativestyle/items/qquickstyleitem.cpp
+++ b/src/imports/nativestyle/items/qquickstyleitem.cpp
@@ -284,7 +284,8 @@ void QQuickStyleItem::paintControlToImage()
m_dirty.setFlag(DirtyFlag::Image, false);
const qreal scale = window()->devicePixelRatio();
- const QSize scaledImageSize = imageSize() * scale;
+ const QSize imgSize = imageSize();
+ const QSize scaledImageSize = imgSize * scale;
if (m_paintedImage.size() != scaledImageSize) {
m_paintedImage = QImage(scaledImageSize, QImage::Format_ARGB32_Premultiplied);
@@ -300,16 +301,16 @@ void QQuickStyleItem::paintControlToImage()
if (m_debugFlags != NoDebug) {
painter.setPen(QColor(255, 0, 0, 255));
if (m_debugFlags.testFlag(ImageRect))
- painter.drawRect(QRect(QPoint(0, 0), m_paintedImage.size() / scale));
+ painter.drawRect(QRect(QPoint(0, 0), imgSize));
if (m_debugFlags.testFlag(LayoutRect)) {
const auto m = layoutMargins();
- QRect rect = QRect(QPoint(0, 0), m_paintedImage.size() / scale);
+ QRect rect = QRect(QPoint(0, 0), imgSize);
rect.adjust(m.left(), m.top(), -m.right(), -m.bottom());
painter.drawRect(rect);
}
if (m_debugFlags.testFlag(ContentRect)) {
const auto p = contentPadding();
- QRect rect = QRect(QPoint(0, 0), m_paintedImage.size() / scale);
+ QRect rect = QRect(QPoint(0, 0), imgSize);
rect.adjust(p.left(), p.top(), -p.right(), -p.bottom());
painter.drawRect(rect);
}
@@ -321,15 +322,13 @@ void QQuickStyleItem::paintControlToImage()
}
if (m_debugFlags.testFlag(NinePatchMargins)) {
const QMargins m = m_styleItemGeometry.ninePatchMargins;
- const int w = int(m_paintedImage.rect().width() / scale);
- const int h = int(m_paintedImage.rect().height() / scale);
if (m.right() != -1) {
- painter.drawLine(m.left(), 0, m.left(), h);
- painter.drawLine(w - m.right(), 0, w - m.right(), h);
+ painter.drawLine(m.left(), 0, m.left(), imgSize.height());
+ painter.drawLine(imgSize.width() - m.right(), 0, imgSize.width() - m.right(), imgSize.height());
}
if (m.bottom() != -1) {
- painter.drawLine(0, m.top(), w, m.top());
- painter.drawLine(0, h - m.bottom(), w, h - m.bottom());
+ painter.drawLine(0, m.top(), imgSize.width(), m.top());
+ painter.drawLine(0, imgSize.height() - m.bottom(), imgSize.width(), imgSize.height() - m.bottom());
}
}
}