diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-05-10 15:29:08 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-05-10 18:54:12 +0200 |
commit | 9d5d7b021db791b309469bc946d59502d47e6bef (patch) | |
tree | de3c3271744d3405b6c4aaec284efbadf61c6027 /vcl/source | |
parent | 47b1e4fdb1d70c9812fe849e6007ca74f3e18787 (diff) |
ImplPrintTransparent is always called with an empty mask
which we can use to simplify it
Change-Id: I8fa38a9f414d8d720e31bd1f71fd722f6a95fdbc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151635
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/gdi/print.cxx | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index 95525639e493..3e92abd02487 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -94,7 +94,7 @@ void ImplUpdateJobSetupPaper( JobSetup& rJobSetup ) } } -void Printer::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask, +void Printer::ImplPrintTransparent( const Bitmap& rBmp, const Point& rDestPt, const Size& rDestSize, const Point& rSrcPtPixel, const Size& rSrcSizePixel ) { @@ -107,12 +107,9 @@ void Printer::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask, if( rBmp.IsEmpty() || !aSrcRect.GetWidth() || !aSrcRect.GetHeight() || !aDestSz.Width() || !aDestSz.Height() ) return; - Bitmap aPaint( rBmp ), aMask( rMask ); + Bitmap aPaint( rBmp ); BmpMirrorFlags nMirrFlags = BmpMirrorFlags::NONE; - if (aMask.getPixelFormat() >= vcl::PixelFormat::N8_BPP) - aMask.Convert( BmpConversion::N1BitThreshold ); - // mirrored horizontally if( aDestSz.Width() < 0 ) { @@ -133,22 +130,17 @@ void Printer::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask, if( aSrcRect != tools::Rectangle( Point(), aPaint.GetSizePixel() ) ) { aPaint.Crop( aSrcRect ); - aMask.Crop( aSrcRect ); } // destination mirrored if( nMirrFlags != BmpMirrorFlags::NONE ) { aPaint.Mirror( nMirrFlags ); - aMask.Mirror( nMirrFlags ); } // we always want to have a mask - if( aMask.IsEmpty() ) - { - aMask = Bitmap(aSrcRect.GetSize(), vcl::PixelFormat::N8_BPP, &Bitmap::GetGreyPalette(256)); - aMask.Erase( COL_BLACK ); - } + AlphaMask aAlphaMask(aSrcRect.GetSize()); + aAlphaMask.Erase( 0 ); // do painting const tools::Long nSrcWidth = aSrcRect.GetWidth(), nSrcHeight = aSrcRect.GetHeight(); @@ -166,24 +158,15 @@ void Printer::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask, for( nY = 0; nY <= nSrcHeight; nY++ ) pMapY[ nY ] = aDestPt.Y() + FRound( static_cast<double>(aDestSz.Height()) * nY / nSrcHeight ); - // walk through all rectangles of mask - const vcl::Region aWorkRgn(aMask.CreateRegion(COL_BLACK, tools::Rectangle(Point(), aMask.GetSizePixel()))); - RectangleVector aRectangles; - aWorkRgn.GetRegionRectangles(aRectangles); - - for (auto const& rectangle : aRectangles) - { - const Point aMapPt(pMapX[rectangle.Left()], pMapY[rectangle.Top()]); - const Size aMapSz( pMapX[rectangle.Right() + 1] - aMapPt.X(), // pMapX[L + W] -> L + ((R - L) + 1) -> R + 1 - pMapY[rectangle.Bottom() + 1] - aMapPt.Y()); // same for Y - Bitmap aBandBmp(aPaint); + tools::Rectangle rectangle { Point(0,0), aSrcRect.GetSize() }; + const Point aMapPt(pMapX[rectangle.Left()], pMapY[rectangle.Top()]); + const Size aMapSz( pMapX[rectangle.Right() + 1] - aMapPt.X(), // pMapX[L + W] -> L + ((R - L) + 1) -> R + 1 + pMapY[rectangle.Bottom() + 1] - aMapPt.Y()); // same for Y + Bitmap aBandBmp(aPaint); - aBandBmp.Crop(rectangle); - DrawBitmap(aMapPt, aMapSz, Point(), aBandBmp.GetSizePixel(), aBandBmp); - } + DrawBitmap(aMapPt, aMapSz, Point(), aBandBmp.GetSizePixel(), aBandBmp); mbMap = bOldMap; - } bool Printer::DrawTransformBitmapExDirect( @@ -221,7 +204,7 @@ void Printer::DrawDeviceBitmapEx( const Point& rDestPt, const Size& rDestSize, else { Bitmap aBmp( rBmpEx.GetBitmap() ); - ImplPrintTransparent( aBmp, Bitmap(), rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel ); + ImplPrintTransparent( aBmp, rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel ); } } |