sd/source/ui/tools/SlideshowLayerRenderer.cxx | 37 ++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
New commits: commit 452ad36e67cf1d330783f6e8ae239f861d3d77a4 Author: Skyler Grey <[email protected]> AuthorDate: Thu Jan 16 16:46:52 2025 +0000 Commit: Tomaž Vajngerl <[email protected]> CommitDate: Thu Mar 20 10:59:12 2025 +0100 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/+/183098 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Tomaž Vajngerl <[email protected]> diff --git a/sd/source/ui/tools/SlideshowLayerRenderer.cxx b/sd/source/ui/tools/SlideshowLayerRenderer.cxx index 20fc4a77e444..9cf7e8b5e785 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 @@ -69,7 +96,13 @@ public: const Fraction& rScale) : mrModel(rModel) , maScale(rScale) +#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(); @@ -105,6 +138,10 @@ public: SdrOutliner& rOutliner = mrModel.GetDrawOutliner(); rOutliner.SetControlWord(mnSavedControlBits); rOutliner.SetBackgroundColor(maSavedBackgroundColor); + +#ifdef IOS + CoreGraphics::CGContextRelease(maVirtualDevice->GetSystemGfxData().rCGContext); +#endif } };
