vcl/source/gdi/print.cxx | 10 ++++++++++ vcl/source/outdev/transparent.cxx | 9 +++++++++ 2 files changed, 19 insertions(+)
New commits: commit fa3dd1c3a190fcbead9d39038a30f0fd306a1baa Author: Patrick Luby <guibmac...@gmail.com> AuthorDate: Thu Dec 19 09:16:03 2024 -0500 Commit: Patrick Luby <guibomac...@gmail.com> CommitDate: Thu Dec 19 19:56:48 2024 +0100 tdf#164354 skip unnecessary transparency removal when printing On macOS, there are no known problems drawing semi-transparent shapes, fill, text, and bitmaps so only remove transparency when reduce transparency and no transparency print settings are both true. The fix not only eliminates the sometimes lengthy wait for the native print dialog to appear, but in cases like tdf#164354 the fix reduces the size of the PDF file generated by the macOS print subsystem by more than 90%. The fix was copied from the following NeoOffice source code files which are licensed under the Mozilla Public License, v. 2.0: - https://github.com/neooffice/NeoOffice/blob/NeoOffice-2022_7/vcl/source/gdi/print.cxx - https://github.com/neooffice/NeoOffice/blob/NeoOffice-2022_7/vcl/source/gdi/print2.cxx Change-Id: I54263a24201a0195fc86df6dc50580e2d6a61c70 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178818 Reviewed-by: Patrick Luby <guibomac...@gmail.com> Tested-by: Jenkins diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index f0308a5ec686..8cc67e7d5e68 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -192,6 +192,15 @@ void Printer::DrawDeviceBitmapEx( const Point& rDestPt, const Size& rDestSize, const Point& rSrcPtPixel, const Size& rSrcSizePixel, BitmapEx& rBmpEx ) { +#ifdef MACOSX + // tdf#164354 draw alpha bitmaps directly to print graphics on macOS + // On macOS, there are no known problems drawing semi-transparent + // bitmaps so just draw the alpha bitmap directly without any blending. + AlphaMask aAlpha = rBmpEx.GetAlphaMask(); + aAlpha.Invert(); + DrawDeviceAlphaBitmap( rBmpEx.GetBitmap(), aAlpha, rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel ); + aAlpha.Invert(); +#else if( rBmpEx.IsAlpha() ) { // #107169# For true alpha bitmaps, no longer masking the @@ -206,6 +215,7 @@ void Printer::DrawDeviceBitmapEx( const Point& rDestPt, const Size& rDestSize, const Bitmap& aBmp( rBmpEx.GetBitmap() ); ImplPrintTransparent( aBmp, rDestPt, rDestSize, rSrcPtPixel, rSrcSizePixel ); } +#endif } void Printer::EmulateDrawTransparent ( const tools::PolyPolygon& rPolyPoly, diff --git a/vcl/source/outdev/transparent.cxx b/vcl/source/outdev/transparent.cxx index a1e965f3a177..8c4051087c3e 100644 --- a/vcl/source/outdev/transparent.cxx +++ b/vcl/source/outdev/transparent.cxx @@ -1296,7 +1296,16 @@ bool OutputDevice::RemoveTransparenciesFromMetaFile( const GDIMetaFile& rInMtf, rOutMtf.Clear(); +#ifdef MACOSX + // tdf#164354 skip unnecessary transparency removal + // On macOS, there are no known problems drawing semi-transparent + // shapes, fill, text, and bitmaps so only do this sometimes very + // expensive step when both reduce transparency and no + // transparency are true. + if(bReduceTransparency && !bTransparencyAutoMode) +#else if(!bReduceTransparency || bTransparencyAutoMode) +#endif bTransparent = rInMtf.HasTransparentActions(); // #i10613# Determine set of connected components containing transparent objects. These are