vcl/source/gdi/print.cxx | 10 ++++++++++ vcl/source/outdev/transparent.cxx | 9 +++++++++ 2 files changed, 19 insertions(+)
New commits: commit 797ab1fa1f9bf97fd2560d6c2feeafd04b735351 Author: Patrick Luby <guibmac...@gmail.com> AuthorDate: Thu Dec 19 09:16:03 2024 -0500 Commit: Adolfo Jayme Barrientos <fit...@ubuntu.com> CommitDate: Tue Dec 24 12:14:07 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 (cherry picked from commit fa3dd1c3a190fcbead9d39038a30f0fd306a1baa) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178837 Reviewed-by: Adolfo Jayme Barrientos <fit...@ubuntu.com> diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index 3b4fd7c9c8db..b277b4186e78 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, 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 1c8b116408b5..313a99619aeb 100644 --- a/vcl/source/outdev/transparent.cxx +++ b/vcl/source/outdev/transparent.cxx @@ -1307,7 +1307,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