summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Luby <guibmacdev@gmail.com>2024-12-19 09:16:03 -0500
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2024-12-19 23:17:04 +0100
commit6966db05a83dc1e7ca2768d811776fcace50ecc3 (patch)
tree9f0525c35a2fde32cf66338839f3ec27083e442f
parent565555025255106e48ea7ff593a57bbb1a80d7b9 (diff)
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 <guibomacdev@gmail.com> Tested-by: Jenkins (cherry picked from commit fa3dd1c3a190fcbead9d39038a30f0fd306a1baa) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178836 Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r--vcl/source/gdi/print.cxx10
-rw-r--r--vcl/source/outdev/transparent.cxx9
2 files changed, 19 insertions, 0 deletions
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