[Libreoffice-commits] core.git: include/vcl vcl/source
Chris Sherlock (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jan 8 10:02:43 UTC 2021
include/vcl/outdev.hxx | 5 --
include/vcl/print.hxx | 5 ++
vcl/source/gdi/print.cxx | 92 ++++++++++++++++++++++++++++++++++++++
vcl/source/outdev/transparent.cxx | 92 --------------------------------------
4 files changed, 97 insertions(+), 97 deletions(-)
New commits:
commit 6bc1de9b410e118aa15bdade6ad2c3644843e21e
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
AuthorDate: Thu Dec 24 09:35:22 2020 +1100
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jan 8 11:02:09 2021 +0100
vcl: move ImplPrintTransparent() from OutputDevice to Printer
Change-Id: I6950bdca72b93b34621e0b108c2c8060c59d98d5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108247
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 6daab02f95f1..b5885f4b2de2 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1605,11 +1605,6 @@ public:
bool bDownsampleBitmaps,
const Color& rBackground = COL_TRANSPARENT );
- SAL_DLLPRIVATE void ImplPrintTransparent (
- const Bitmap& rBmp, const Bitmap& rMask,
- const Point& rDestPt, const Size& rDestSize,
- const Point& rSrcPtPixel, const Size& rSrcSizePixel );
-
SAL_DLLPRIVATE Color ImplDrawModeToColor ( const Color& rColor ) const;
diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx
index a74f1c5e6288..8ddd8bc7fbd3 100644
--- a/include/vcl/print.hxx
+++ b/include/vcl/print.hxx
@@ -184,6 +184,11 @@ private:
static VCL_DLLPRIVATE ErrCode
ImplSalPrinterErrorCodeToVCL( SalPrinterError nError );
+ SAL_DLLPRIVATE void ImplPrintTransparent (
+ const Bitmap& rBmp, const Bitmap& rMask,
+ const Point& rDestPt, const Size& rDestSize,
+ const Point& rSrcPtPixel, const Size& rSrcSizePixel );
+
private:
VCL_DLLPRIVATE void EndJob();
Printer( const Printer& rPrinter ) = delete;
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index bb99579fcafc..bbfac98a1797 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -181,6 +181,98 @@ void PrinterOptions::ReadFromConfig( bool i_bFile )
*this = aOldValues;
}
+void Printer::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask,
+ const Point& rDestPt, const Size& rDestSize,
+ const Point& rSrcPtPixel, const Size& rSrcSizePixel )
+{
+ Point aDestPt( LogicToPixel( rDestPt ) );
+ Size aDestSz( LogicToPixel( rDestSize ) );
+ tools::Rectangle aSrcRect( rSrcPtPixel, rSrcSizePixel );
+
+ aSrcRect.Justify();
+
+ if( rBmp.IsEmpty() || !aSrcRect.GetWidth() || !aSrcRect.GetHeight() || !aDestSz.Width() || !aDestSz.Height() )
+ return;
+
+ Bitmap aPaint( rBmp ), aMask( rMask );
+ BmpMirrorFlags nMirrFlags = BmpMirrorFlags::NONE;
+
+ if( aMask.GetBitCount() > 1 )
+ aMask.Convert( BmpConversion::N1BitThreshold );
+
+ // mirrored horizontically
+ if( aDestSz.Width() < 0 )
+ {
+ aDestSz.setWidth( -aDestSz.Width() );
+ aDestPt.AdjustX( -( aDestSz.Width() - 1 ) );
+ nMirrFlags |= BmpMirrorFlags::Horizontal;
+ }
+
+ // mirrored vertically
+ if( aDestSz.Height() < 0 )
+ {
+ aDestSz.setHeight( -aDestSz.Height() );
+ aDestPt.AdjustY( -( aDestSz.Height() - 1 ) );
+ nMirrFlags |= BmpMirrorFlags::Vertical;
+ }
+
+ // source cropped?
+ 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(), 1 );
+ aMask.Erase( COL_BLACK );
+ }
+
+ // do painting
+ const tools::Long nSrcWidth = aSrcRect.GetWidth(), nSrcHeight = aSrcRect.GetHeight();
+ tools::Long nX, nY; // , nWorkX, nWorkY, nWorkWidth, nWorkHeight;
+ std::unique_ptr<tools::Long[]> pMapX(new tools::Long[ nSrcWidth + 1 ]);
+ std::unique_ptr<tools::Long[]> pMapY(new tools::Long[ nSrcHeight + 1 ]);
+ const bool bOldMap = mbMap;
+
+ mbMap = false;
+
+ // create forward mapping tables
+ for( nX = 0; nX <= nSrcWidth; nX++ )
+ pMapX[ nX ] = aDestPt.X() + FRound( static_cast<double>(aDestSz.Width()) * nX / nSrcWidth );
+
+ 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);
+
+ aBandBmp.Crop(rectangle);
+ DrawBitmap(aMapPt, aMapSz, Point(), aBandBmp.GetSizePixel(), aBandBmp);
+ }
+
+ mbMap = bOldMap;
+
+}
+
bool Printer::DrawTransformBitmapExDirect(
const basegfx::B2DHomMatrix& /*aFullTransform*/,
const BitmapEx& /*rBitmapEx*/)
diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx
index 28a030963018..49c8bfa23e07 100644
--- a/vcl/source/outdev/transparent.cxx
+++ b/vcl/source/outdev/transparent.cxx
@@ -107,98 +107,6 @@ Color OutputDevice::ImplDrawModeToColor( const Color& rColor ) const
return aColor;
}
-void OutputDevice::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask,
- const Point& rDestPt, const Size& rDestSize,
- const Point& rSrcPtPixel, const Size& rSrcSizePixel )
-{
- Point aDestPt( LogicToPixel( rDestPt ) );
- Size aDestSz( LogicToPixel( rDestSize ) );
- tools::Rectangle aSrcRect( rSrcPtPixel, rSrcSizePixel );
-
- aSrcRect.Justify();
-
- if( rBmp.IsEmpty() || !aSrcRect.GetWidth() || !aSrcRect.GetHeight() || !aDestSz.Width() || !aDestSz.Height() )
- return;
-
- Bitmap aPaint( rBmp ), aMask( rMask );
- BmpMirrorFlags nMirrFlags = BmpMirrorFlags::NONE;
-
- if( aMask.GetBitCount() > 1 )
- aMask.Convert( BmpConversion::N1BitThreshold );
-
- // mirrored horizontally
- if( aDestSz.Width() < 0 )
- {
- aDestSz.setWidth( -aDestSz.Width() );
- aDestPt.AdjustX( -( aDestSz.Width() - 1 ) );
- nMirrFlags |= BmpMirrorFlags::Horizontal;
- }
-
- // mirrored vertically
- if( aDestSz.Height() < 0 )
- {
- aDestSz.setHeight( -aDestSz.Height() );
- aDestPt.AdjustY( -( aDestSz.Height() - 1 ) );
- nMirrFlags |= BmpMirrorFlags::Vertical;
- }
-
- // source cropped?
- 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(), 1 );
- aMask.Erase( COL_BLACK );
- }
-
- // do painting
- const tools::Long nSrcWidth = aSrcRect.GetWidth(), nSrcHeight = aSrcRect.GetHeight();
- tools::Long nX, nY; // , nWorkX, nWorkY, nWorkWidth, nWorkHeight;
- std::unique_ptr<tools::Long[]> pMapX(new tools::Long[ nSrcWidth + 1 ]);
- std::unique_ptr<tools::Long[]> pMapY(new tools::Long[ nSrcHeight + 1 ]);
- const bool bOldMap = mbMap;
-
- mbMap = false;
-
- // create forward mapping tables
- for( nX = 0; nX <= nSrcWidth; nX++ )
- pMapX[ nX ] = aDestPt.X() + FRound( static_cast<double>(aDestSz.Width()) * nX / nSrcWidth );
-
- 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);
-
- aBandBmp.Crop(rectangle);
- DrawBitmap(aMapPt, aMapSz, Point(), aBandBmp.GetSizePixel(), aBandBmp);
- }
-
- mbMap = bOldMap;
-
-}
-
// Caution: This method is nearly the same as
// void OutputDevice::DrawPolyPolygon( const basegfx::B2DPolyPolygon& rB2DPolyPoly )
// so when changes are made here do not forget to make changes there, too
More information about the Libreoffice-commits
mailing list