summaryrefslogtreecommitdiff
path: root/src/svg/qsvgtinydocument.cpp
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-01-14 03:00:08 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-01-14 03:00:08 +0100
commit97c5949d1376293220283ab1bc7b64f4eadafdcb (patch)
treec8d98124275c0fbc4fc51fa678647f90ab0c6edd /src/svg/qsvgtinydocument.cpp
parent9db51feb3a59682ab73c75700c63db5a5ed7f163 (diff)
parent2f58f925cc16946a474f066c739c4682246afa0f (diff)
downloadqtsvg-97c5949d1376293220283ab1bc7b64f4eadafdcb.tar.gz
Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: I535fa2bbee58d1cd15e1c25f0ac6321d502518fb
Diffstat (limited to 'src/svg/qsvgtinydocument.cpp')
-rw-r--r--src/svg/qsvgtinydocument.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/svg/qsvgtinydocument.cpp b/src/svg/qsvgtinydocument.cpp
index 56960bf..173baaa 100644
--- a/src/svg/qsvgtinydocument.cpp
+++ b/src/svg/qsvgtinydocument.cpp
@@ -420,9 +420,10 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
source = viewBox();
if (source != target && !source.isNull()) {
- if (m_implicitViewBox || !sourceRect.isNull()) {
+ if (m_implicitViewBox || !sourceRect.isNull() || !targetRect.isNull()) {
// Code path used when no view box is set, or when an explicit source size is given which
- // overrides it (which is the case when we're rendering only a specific element by id).
+ // overrides it (which is the case when we're rendering only a specific element by id),
+ // or when user has given explicit target bounds that overrides viebox aspect ratio
QTransform transform;
transform.scale(target.width() / source.width(),
target.height() / source.height());
@@ -441,15 +442,14 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
viewBoxSize.scale(target.width(), target.height(), Qt::KeepAspectRatio);
// Center the view box in the view port
- p->translate((target.width() - viewBoxSize.width()) / 2,
- (target.height() - viewBoxSize.height()) / 2);
+ p->translate(target.x() + (target.width() - viewBoxSize.width()) / 2,
+ target.y() + (target.height() - viewBoxSize.height()) / 2);
p->scale(viewBoxSize.width() / source.width(),
viewBoxSize.height() / source.height());
// Apply the view box translation if specified.
- p->translate(target.x() - source.x(),
- target.y() - source.y());
+ p->translate(-source.x(), -source.y());
}
}
}