summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@qt.io>2019-11-12 22:10:34 +0100
committerEirik Aavitsland <eirik.aavitsland@qt.io>2019-11-14 08:14:02 +0000
commite489a325769d295ee3b3948d98f5d07814dffd97 (patch)
tree40934f17f3367c5785662e1e92946342295d0d37 /src
parentbeb0d74195ddc642524fe1f5a2d65d944527d1b5 (diff)
downloadqtsvg-e489a325769d295ee3b3948d98f5d07814dffd97.tar.gz
Re-fix scaling when rendering a specific element by id
This is a modification of 14fa4591eb34a35cf3d485fd901e3f1e2caa7770 That patch corrected the handling of the view box when rendering an entire SVG document. However, contrary to intention stated in the comment of that patch, it turns out that the new viewbox handling code path can be taken also for the case of rendering only a single element by id. Instead, we want to keep the original behavior where the element's origin bounds are transformed to fit into the user requested target bounds, allowing non-proportional scaling. Since the render-single-element case is easily and uniqely identifiable by the sourceRect parameter being non-null, just add an explicit check for that to the code path branching. Done-with: Eirik Aavitsland <eirik.aavitsland@qt.io> Fixes: QTBUG-79933 Change-Id: I64a35bbb193db22c33670b48ea165a91df8e719e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/svg/qsvgtinydocument.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/svg/qsvgtinydocument.cpp b/src/svg/qsvgtinydocument.cpp
index a2bf1c7..56960bf 100644
--- a/src/svg/qsvgtinydocument.cpp
+++ b/src/svg/qsvgtinydocument.cpp
@@ -420,7 +420,9 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect,
source = viewBox();
if (source != target && !source.isNull()) {
- if (m_implicitViewBox) {
+ if (m_implicitViewBox || !sourceRect.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).
QTransform transform;
transform.scale(target.width() / source.width(),
target.height() / source.height());