vcl/inc/quartz/salgdi.h |    2 +-
 vcl/osx/salprn.cxx      |    2 +-
 vcl/quartz/salgdi.cxx   |   11 +++++++++--
 3 files changed, 11 insertions(+), 4 deletions(-)

New commits:
commit de3f13e2175564316eb5a62dee65e9ff8f31b460
Author:     Patrick Luby <plub...@neooffice.org>
AuthorDate: Wed Dec 7 14:24:57 2022 -0500
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Fri Dec 9 09:17:42 2022 +0000

    tdf#146842 Do not use Skia for printing
    
    Skia does not work with a native print graphics contexts. I am not sure why 
but from what I can see, the Skia implementation drawing to a bitmap buffer. 
However, in an NSPrintOperation, the print view's backing buffer is 
CGPDFContext so even if this bug could be solved by blitting the Skia bitmap 
buffer, the printed PDF would not have selectable text so always disable Skia 
for print graphics contexts.
    
    Change-Id: I214ba83b6e368af3ef51ea770b093612d04047a0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143798
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index 61ff01c12e3a..9e070c4215ce 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -454,7 +454,7 @@ class AquaSalGraphics : public SalGraphicsAutoDelegateToImpl
     rtl::Reference<CoreTextFont>            mpFont[MAX_FALLBACK];
 
 public:
-                            AquaSalGraphics();
+                            AquaSalGraphics(bool bPrinter = false);
     virtual                 ~AquaSalGraphics() override;
 
     void                    SetVirDevGraphics(SalVirtualDevice* 
pVirDev,CGLayerHolder const &rLayer, CGContextRef, int nBitDepth = 0);
diff --git a/vcl/osx/salprn.cxx b/vcl/osx/salprn.cxx
index bec30a35b562..e9101e390085 100644
--- a/vcl/osx/salprn.cxx
+++ b/vcl/osx/salprn.cxx
@@ -71,7 +71,7 @@ AquaSalInfoPrinter::AquaSalInfoPrinter( const 
SalPrinterQueueInfo& i_rQueue ) :
         [mpPrintInfo setOrientation: NSPaperOrientationPortrait];
     }
 
-    mpGraphics = new AquaSalGraphics();
+    mpGraphics = new AquaSalGraphics(true);
 
     const int nWidth = 100, nHeight = 100;
     mpContextMemory.reset(new (std::nothrow) sal_uInt8[nWidth * 4 * nHeight]);
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index 1058b7bc31e9..571e44f23e71 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -137,14 +137,21 @@ sal_IntPtr CoreTextFontFace::GetFontId() const
     return reinterpret_cast<sal_IntPtr>(mxFontDescriptor);
 }
 
-AquaSalGraphics::AquaSalGraphics()
+AquaSalGraphics::AquaSalGraphics(bool bPrinter)
     : mnRealDPIX( 0 )
     , mnRealDPIY( 0 )
 {
     SAL_INFO( "vcl.quartz", "AquaSalGraphics::AquaSalGraphics() this=" << this 
);
 
 #if HAVE_FEATURE_SKIA
-    if(SkiaHelper::isVCLSkiaEnabled())
+    // tdf#146842 Do not use Skia for printing
+    // Skia does not work with a native print graphics contexts. I am not sure
+    // why but from what I can see, the Skia implementation drawing to a bitmap
+    // buffer. However, in an NSPrintOperation, the print view's backing buffer
+    // is CGPDFContext so even if this bug could be solved by blitting the
+    // Skia bitmap buffer, the printed PDF would not have selectable text so
+    // always disable Skia for print graphics contexts.
+    if(!bPrinter && SkiaHelper::isVCLSkiaEnabled())
         mpBackend.reset(new AquaSkiaSalGraphicsImpl(*this, maShared));
 #else
     if(false)

Reply via email to