[Libreoffice-commits] core.git: include/vcl vcl/source
Chris Sherlock (via logerrit)
logerrit at kemper.freedesktop.org
Mon Dec 28 00:54:22 UTC 2020
include/vcl/outdev.hxx | 2 +-
include/vcl/print.hxx | 2 +-
vcl/source/outdev/bitmap.cxx | 29 +++++++++++++----------------
3 files changed, 15 insertions(+), 18 deletions(-)
New commits:
commit 0c2042b34f34824e6ff8ffc78acad46be4faa7cf
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
AuthorDate: Sat Dec 26 22:05:54 2020 +1100
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Mon Dec 28 01:53:39 2020 +0100
vcl: remove OutputDevice::ScaleBitmap
Some time ago, in an attempt to remove a check on OutDevType I
refactored some code into the function ScaleBitmap(). When I look at
this more closely, I realise that I missed the point of the function.
The code I refactored actually checked if subsampled scaling could be
done. Thus, the function is inaccurate - it only scales *down* a bitmap,
and in fact scaling is already done in Bitmap.
Instead, I have now moved the function back into the code and replaced
it with a virtual function that checks if the OutputDevice derived class
can actually do bitmap subsampling (Printer is unable to do
subsampling).
Change-Id: I2e6bdbba0bf2153e0421efe6e05c05dd593a4e1e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108323
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index c11d1abc1875..052b0afb3086 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1491,7 +1491,7 @@ protected:
const Point& rSrcPtPixel, const Size& rSrcSizePixel,
BitmapEx& rBitmapEx );
- virtual void ScaleBitmap ( Bitmap &rBmp, SalTwoRect &rPosAry );
+ virtual bool CanSubsampleBitmap() const { return true; }
/** Transform and draw a bitmap directly
diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx
index 631b2f5b83fe..517a9607f1c2 100644
--- a/include/vcl/print.hxx
+++ b/include/vcl/print.hxx
@@ -203,7 +203,7 @@ protected:
virtual void ClipAndDrawGradientMetafile ( const Gradient &rGradient,
const tools::PolyPolygon &rPolyPoly ) override;
- void ScaleBitmap ( Bitmap&, SalTwoRect& ) override { };
+ bool CanSubsampleBitmap() const override { return false; }
vcl::Region ClipToDeviceBounds(vcl::Region aRegion) const override;
public:
diff --git a/vcl/source/outdev/bitmap.cxx b/vcl/source/outdev/bitmap.cxx
index 82897f01e00e..ad02fccff63d 100644
--- a/vcl/source/outdev/bitmap.cxx
+++ b/vcl/source/outdev/bitmap.cxx
@@ -159,8 +159,19 @@ void OutputDevice::DrawBitmap( const Point& rDestPt, const Size& rDestSize,
if ( aPosAry.mnSrcWidth && aPosAry.mnSrcHeight && aPosAry.mnDestWidth && aPosAry.mnDestHeight )
{
- if ( nAction == MetaActionType::BMPSCALE )
- ScaleBitmap (aBmp, aPosAry);
+ if (nAction == MetaActionType::BMPSCALE && CanSubsampleBitmap())
+ {
+ const double nScaleX = aPosAry.mnDestWidth / static_cast<double>(aPosAry.mnSrcWidth);
+ const double nScaleY = aPosAry.mnDestHeight / static_cast<double>(aPosAry.mnSrcHeight);
+
+ // If subsampling, use Bitmap::Scale() for subsampling of better quality.
+ if ( nScaleX < 1.0 || nScaleY < 1.0 )
+ {
+ aBmp.Scale(nScaleX, nScaleY);
+ aPosAry.mnSrcWidth = aPosAry.mnDestWidth;
+ aPosAry.mnSrcHeight = aPosAry.mnDestHeight;
+ }
+ }
mpGraphics->DrawBitmap( aPosAry, *aBmp.ImplGetSalBitmap(), *this );
}
@@ -1038,20 +1049,6 @@ void OutputDevice::DrawDeviceAlphaBitmapSlowPath(const Bitmap& rBitmap,
mpMetaFile = pOldMetaFile;
}
-void OutputDevice::ScaleBitmap (Bitmap &rBmp, SalTwoRect &rPosAry)
-{
- const double nScaleX = rPosAry.mnDestWidth / static_cast<double>( rPosAry.mnSrcWidth );
- const double nScaleY = rPosAry.mnDestHeight / static_cast<double>( rPosAry.mnSrcHeight );
-
- // If subsampling, use Bitmap::Scale for subsampling for better quality.
- if ( nScaleX < 1.0 || nScaleY < 1.0 )
- {
- rBmp.Scale ( nScaleX, nScaleY );
- rPosAry.mnSrcWidth = rPosAry.mnDestWidth;
- rPosAry.mnSrcHeight = rPosAry.mnDestHeight;
- }
-}
-
bool OutputDevice::DrawTransformBitmapExDirect(
const basegfx::B2DHomMatrix& aFullTransform,
const BitmapEx& rBitmapEx)
More information about the Libreoffice-commits
mailing list