aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-04-25 17:55:40 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-05-02 11:31:44 +0000
commit717b57a9aae4c6d45cbcf91d390e42af56ab8061 (patch)
tree714d8244b74a41552d3dd4d409060fa6ad6c9733
parentf9686bc68696ad1e99a0587f15d05300d003d990 (diff)
Fix Hidpi BorderImage in software renderer
We have to correct for the fact that sub-rects of images in QPainter are in source coordinates. Change-Id: I457527b4ff7c1df5f6b662c3ed4d690e05efb4fb Task-number: QTBUG-40366 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp
index aa83709b72..74426c5c4d 100644
--- a/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgsoftwareinternalimagenode.cpp
@@ -68,6 +68,9 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin
QMargins sourceMargins = normalizedMargins(sourceMarginsIn);
QMargins targetMargins = normalizedMargins(targetMarginsIn);
+ const qreal sourceDpr = pixmap.devicePixelRatioF();
+ sourceMargins *= sourceDpr;
+
// source center
const int sourceCenterTop = sourceRect.top() + sourceMargins.top();
const int sourceCenterLeft = sourceRect.left() + sourceMargins.left();
@@ -89,9 +92,9 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin
int columns = 3;
int rows = 3;
if (rules.horizontal != Qt::StretchTile && sourceCenterWidth != 0)
- columns = qMax(3, 2 + qCeil(targetCenterWidth / qreal(sourceCenterWidth)));
+ columns = qMax(3, 2 + qCeil((targetCenterWidth * sourceDpr) / qreal(sourceCenterWidth)));
if (rules.vertical != Qt::StretchTile && sourceCenterHeight != 0)
- rows = qMax(3, 2 + qCeil(targetCenterHeight / qreal(sourceCenterHeight)));
+ rows = qMax(3, 2 + qCeil((targetCenterHeight * sourceDpr) / qreal(sourceCenterHeight)));
xTarget.resize(columns + 1);
yTarget.resize(rows + 1);
@@ -121,7 +124,7 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin
dx = targetCenterWidth;
break;
case Qt::RepeatTile:
- dx = sourceCenterWidth;
+ dx = sourceCenterWidth / sourceDpr;
break;
case Qt::RoundTile:
dx = targetCenterWidth / qreal(columns - 2);
@@ -136,7 +139,7 @@ void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargin
dy = targetCenterHeight;
break;
case Qt::RepeatTile:
- dy = sourceCenterHeight;
+ dy = sourceCenterHeight / sourceDpr;
break;
case Qt::RoundTile:
dy = targetCenterHeight / qreal(rows - 2);