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 <vmiklos@collabora.com>
This commit is contained in:
committed by
Miklos Vajna
parent
e695245b62
commit
ba2d75a993
@@ -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
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user