vcl/source/gdi/metaact.cxx | 75 +++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 32 deletions(-)
New commits: commit d277de1eac9ddc00eff3e5801ab29d8e8a9a3af7 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Thu Mar 17 19:56:27 2022 +0000 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Fri Mar 18 12:15:57 2022 +0100 ofz#45675 Timeout Change-Id: Icd893d6e0361f9ffe2c88b20b08eaef32919d01a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131718 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/vcl/source/gdi/metaact.cxx b/vcl/source/gdi/metaact.cxx index 00c979f8f378..cc724b7fb2fa 100644 --- a/vcl/source/gdi/metaact.cxx +++ b/vcl/source/gdi/metaact.cxx @@ -837,8 +837,49 @@ MetaBmpScaleAction::MetaBmpScaleAction( const Point& rPt, const Size& rSz, maSz ( rSz ) {} +static bool AllowScale(const Size& rSource, const Size& rDest) +{ + if (utl::ConfigManager::IsFuzzing()) + { + constexpr int nMaxScaleWhenFuzzing = 1024; + + auto nSourceHeight = rSource.Height(); + auto nDestHeight = rDest.Height(); + if (nSourceHeight && nDestHeight > nSourceHeight && nDestHeight / nSourceHeight > nMaxScaleWhenFuzzing) + { + SAL_WARN("vcl", "skipping large vertical scaling: " << nSourceHeight << " to " << nDestHeight); + return false; + } + + if (nDestHeight && nSourceHeight > nDestHeight && nSourceHeight / nDestHeight > nMaxScaleWhenFuzzing) + { + SAL_WARN("vcl", "skipping large vertical scaling: " << nSourceHeight << " to " << nDestHeight); + return false; + } + + auto nSourceWidth = rSource.Width(); + auto nDestWidth = rDest.Width(); + if (nSourceWidth && nDestWidth > nSourceWidth && nDestWidth / nSourceWidth > nMaxScaleWhenFuzzing) + { + SAL_WARN("vcl", "skipping large horizontal scaling: " << nSourceWidth << " to " << nDestWidth); + return false; + } + + if (nDestWidth && nSourceWidth > nDestWidth && nSourceWidth / nDestWidth > nMaxScaleWhenFuzzing) + { + SAL_WARN("vcl", "skipping large horizontal scaling: " << nSourceWidth << " to " << nDestWidth); + return false; + } + } + + return true; +} + void MetaBmpScaleAction::Execute( OutputDevice* pOut ) { + if (!AllowScale(maBmp.GetSizePixel(), maSz)) + return; + pOut->DrawBitmap( maPt, maSz, maBmp ); } @@ -951,38 +992,8 @@ MetaBmpExScaleAction::MetaBmpExScaleAction( const Point& rPt, const Size& rSz, void MetaBmpExScaleAction::Execute( OutputDevice* pOut ) { - if (utl::ConfigManager::IsFuzzing()) - { - constexpr int nMaxScaleWhenFuzzing = 1024; - - auto nSourceHeight = maBmpEx.GetSizePixel().Height(); - auto nDestHeight = maSz.Height(); - if (nSourceHeight && nDestHeight > nSourceHeight && nDestHeight / nSourceHeight > nMaxScaleWhenFuzzing) - { - SAL_WARN("vcl", "skipping large vertical scaling: " << nSourceHeight << " to " << nDestHeight); - return; - } - - if (nDestHeight && nSourceHeight > nDestHeight && nSourceHeight / nDestHeight > nMaxScaleWhenFuzzing) - { - SAL_WARN("vcl", "skipping large vertical scaling: " << nSourceHeight << " to " << nDestHeight); - return; - } - - auto nSourceWidth = maBmpEx.GetSizePixel().Width(); - auto nDestWidth = maSz.Width(); - if (nSourceWidth && nDestWidth > nSourceWidth && nDestWidth / nSourceWidth > nMaxScaleWhenFuzzing) - { - SAL_WARN("vcl", "skipping large horizontal scaling: " << nSourceWidth << " to " << nDestWidth); - return; - } - - if (nDestWidth && nSourceWidth > nDestWidth && nSourceWidth / nDestWidth > nMaxScaleWhenFuzzing) - { - SAL_WARN("vcl", "skipping large horizontal scaling: " << nSourceWidth << " to " << nDestWidth); - return; - } - } + if (!AllowScale(maBmpEx.GetSizePixel(), maSz)) + return; pOut->DrawBitmapEx( maPt, maSz, maBmpEx ); }