diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2020-02-01 03:04:04 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2020-02-01 03:04:04 +0100 |
commit | 85092b76d328ac1cc7c40d39f77f6d2c7bae9391 (patch) | |
tree | 1bfbf22de93244298a6ebec31cfdf7f529405066 /src/svg/qsvgtinydocument.cpp | |
parent | 1693b5d0091ea0bf4dfc4b12797b65a7384da367 (diff) | |
parent | 84bc219fb1e9f586c1f7ac2c10172c4da2605f96 (diff) | |
download | qtsvg-85092b76d328ac1cc7c40d39f77f6d2c7bae9391.tar.gz |
Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: I4007f29077ec6a6ff34c7af730e6192cfd6202ba
Diffstat (limited to 'src/svg/qsvgtinydocument.cpp')
-rw-r--r-- | src/svg/qsvgtinydocument.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/svg/qsvgtinydocument.cpp b/src/svg/qsvgtinydocument.cpp index eb6b6b0..b4b9526 100644 --- a/src/svg/qsvgtinydocument.cpp +++ b/src/svg/qsvgtinydocument.cpp @@ -336,6 +336,11 @@ void QSvgTinyDocument::setHeight(int len, bool percent) m_heightPercent = percent; } +void QSvgTinyDocument::setPreserveAspectRatio(bool on) +{ + m_preserveAspectRatio = on; +} + void QSvgTinyDocument::setViewBox(const QRectF &rect) { m_viewBox = rect; @@ -421,10 +426,10 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, source = viewBox(); if (source != target && !source.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), - // or when user has given explicit target bounds that overrides viebox aspect ratio +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) + if (m_implicitViewBox || !preserveAspectRatio()) { + // Code path used when no view box is set, or IgnoreAspectRatio requested +#endif QTransform transform; transform.scale(target.width() / source.width(), target.height() / source.height()); @@ -433,10 +438,10 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, target.y() - c2.y()); p->scale(target.width() / source.width(), target.height() / source.height()); +#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) } else { - // Code path used when a view box is specified and we're not rendering a specific element by id - // but the entire document. This attempts to emulate the default values of the <preserveAspectRatio> - // tag that's implicitly defined when <viewbox> is used. + // Code path used when KeepAspectRatio is requested. This attempts to emulate the default values + // of the <preserveAspectRatio tag that's implicitly defined when <viewbox> is used. // Scale the view box into the view port (target) by preserve the aspect ratio. QSizeF viewBoxSize = source.size(); @@ -452,6 +457,7 @@ void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, // Apply the view box translation if specified. p->translate(-source.x(), -source.y()); } +#endif } } |