sd/source/ui/tools/SlideshowLayerRenderer.cxx |   37 ++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

New commits:
commit ba2d75a9932c9a42cc54d52645be88a7cd420466
Author:     Skyler Grey <skyler.g...@collabora.com>
AuthorDate: Thu Jan 16 16:46:52 2025 +0000
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri May 9 15:51:45 2025 +0200

    fix(slideshow): Use CoreGraphics to render on iOS
    
    Similarly to `doc_paintTile` in init.cxx, we can't use the regular
    initialization for our graphics backend on iOS. If we do so, we render
    a completely white area. Instead, we need to use CoreGraphics, which is
    the iOS library for rendering graphics
    
    Change-Id: I94cb620d422c02f8343db30eea24cecc53d928c6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185095
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sd/source/ui/tools/SlideshowLayerRenderer.cxx 
b/sd/source/ui/tools/SlideshowLayerRenderer.cxx
index 4178cc4ec690..96cdc9cb6e6e 100644
--- a/sd/source/ui/tools/SlideshowLayerRenderer.cxx
+++ b/sd/source/ui/tools/SlideshowLayerRenderer.cxx
@@ -48,6 +48,33 @@
 
 #include <drawinglayer/tools/primitive2dxmldump.hxx>
 
+#ifdef IOS
+#include <vcl/sysdata.hxx>
+namespace CoreGraphics
+{ // Namespace here because iOS redefines Point and Size
+#import <CoreGraphics/CoreGraphics.h>
+
+SystemGraphicsData getiOSGraphicsData(unsigned char* pBuffer, long width, long 
height)
+{
+    double fDPIScale = 1.0;
+
+    // Onine uses the LOK_TILEMODE_RGBA by default so flip the normal flags
+    // to kCGImageAlphaPremultipliedLast | kCGImageByteOrder32Big
+    CGContextRef pCGContext
+        = CGBitmapContextCreate(pBuffer, width, height, 8, width * 4, 
CGColorSpaceCreateDeviceRGB(),
+                                kCGImageAlphaPremultipliedLast | 
kCGImageByteOrder32Big);
+
+    CGContextTranslateCTM(pCGContext, 0, height);
+    CGContextScaleCTM(pCGContext, fDPIScale, -fDPIScale);
+
+    SystemGraphicsData aData;
+    aData.rCGContext = reinterpret_cast<CGContextRef>(pCGContext);
+
+    return aData;
+}
+}
+#endif
+
 using namespace ::com::sun::star;
 
 namespace sd
@@ -67,7 +94,13 @@ public:
     RenderContext(unsigned char* pBuffer, SdrModel& rModel, const SdrPage& 
rPage,
                   Size const& rSlideSize, const Fraction& rScale)
         : mrModel(rModel)
+#if defined(IOS)
+        , maVirtualDevice(
+              CoreGraphics::getiOSGraphicsData(pBuffer, rSlideSize.Width(), 
rSlideSize.Height()),
+              Size(1, 1), DeviceFormat::WITHOUT_ALPHA)
+#else
         , maVirtualDevice(DeviceFormat::WITHOUT_ALPHA)
+#endif
     {
         SdrOutliner& rOutliner = mrModel.GetDrawOutliner();
 
@@ -103,6 +136,10 @@ public:
         SdrOutliner& rOutliner = mrModel.GetDrawOutliner();
         rOutliner.SetControlWord(mnSavedControlBits);
         rOutliner.SetBackgroundColor(maSavedBackgroundColor);
+
+#ifdef IOS
+        
CoreGraphics::CGContextRelease(maVirtualDevice->GetSystemGfxData().rCGContext);
+#endif
     }
 };
 

Reply via email to