diff options
author | Tor Lillqvist <tml@collabora.com> | 2018-10-10 16:17:18 +0300 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2018-10-30 17:00:47 +0000 |
commit | 06c1fc413db0470ff8661b675796aeef891a00a5 (patch) | |
tree | fddab774c83c102a68a8a57a8562df658a43c922 /desktop | |
parent | ffe690740d9da9dfabdea37d3fdb1a6050b4818b (diff) |
Move the iOS CGBitmapContextCreate() call to doc_paintTile()
Thus it now actually takes a buffer pointer also on iOS, like on Linux
and Android. Less confusing, more uniform.
Change-Id: I81084806d37b9aac9f2b2bc03d0c262e991eec81
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/lib/init.cxx | 59 |
1 files changed, 51 insertions, 8 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 4a93cf37eb1c..70f415b58498 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -20,6 +20,7 @@ #include <unicode/ucnv.h> #include <premac.h> #import <Foundation/Foundation.h> +#import <CoreGraphics/CoreGraphics.h> #include <postmac.h> #endif @@ -580,6 +581,13 @@ static void doc_paintTile(LibreOfficeKitDocument* pThis, const int nCanvasWidth, const int nCanvasHeight, const int nTilePosX, const int nTilePosY, const int nTileWidth, const int nTileHeight); +#ifdef IOS +static void doc_paintTileToCGContext(LibreOfficeKitDocument* pThis, + void* rCGContext, + const int nCanvasWidth, const int nCanvasHeight, + const int nTilePosX, const int nTilePosY, + const int nTileWidth, const int nTileHeight); +#endif static void doc_paintPartTile(LibreOfficeKitDocument* pThis, unsigned char* pBuffer, const int nPart, @@ -2099,17 +2107,14 @@ static void doc_paintTile(LibreOfficeKitDocument* pThis, #if defined(UNX) && !defined(MACOSX) && !defined(ENABLE_HEADLESS) #if defined(IOS) - SystemGraphicsData aData; - aData.rCGContext = reinterpret_cast<CGContextRef>(pBuffer); - // the Size argument is irrelevant, I hope - ScopedVclPtrInstance<VirtualDevice> pDevice(&aData, Size(1, 1), DeviceFormat::DEFAULT); + CGContextRef cgc = CGBitmapContextCreate(pBuffer, nCanvasWidth, nCanvasHeight, 8, nCanvasWidth*4, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipFirst | kCGImageByteOrder32Little); - pDevice->SetBackground(Wallpaper(COL_TRANSPARENT)); + CGContextTranslateCTM(cgc, 0, nCanvasHeight); + CGContextScaleCTM(cgc, 1, -1); - pDevice->SetOutputSizePixel(Size(nCanvasWidth, nCanvasHeight)); + doc_paintTileToCGContext(pThis, (void*) cgc, nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight); - pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight, - nTilePosX, nTilePosY, nTileWidth, nTileHeight); + CGContextRelease(cgc); #else ScopedVclPtrInstance< VirtualDevice > pDevice(nullptr, Size(1, 1), DeviceFormat::DEFAULT) ; @@ -2131,6 +2136,44 @@ static void doc_paintTile(LibreOfficeKitDocument* pThis, #endif } +#ifdef IOS + +static void doc_paintTileToCGContext(LibreOfficeKitDocument* pThis, + void* rCGContext, + const int nCanvasWidth, const int nCanvasHeight, + const int nTilePosX, const int nTilePosY, + const int nTileWidth, const int nTileHeight) +{ + SolarMutexGuard aGuard; + if (gImpl) + gImpl->maLastExceptionMsg.clear(); + + SAL_INFO( "lok.tiledrendering", "paintTileToCGContext: painting [" << nTileWidth << "x" << nTileHeight << + "]@(" << nTilePosX << ", " << nTilePosY << ") to [" << + nCanvasWidth << "x" << nCanvasHeight << "]px" ); + + ITiledRenderable* pDoc = getTiledRenderable(pThis); + if (!pDoc) + { + gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering"; + return; + } + + SystemGraphicsData aData; + aData.rCGContext = reinterpret_cast<CGContextRef>(rCGContext); + // the Size argument is irrelevant, I hope + ScopedVclPtrInstance<VirtualDevice> pDevice(&aData, Size(1, 1), DeviceFormat::DEFAULT); + + pDevice->SetBackground(Wallpaper(COL_TRANSPARENT)); + + pDevice->SetOutputSizePixel(Size(nCanvasWidth, nCanvasHeight)); + + pDoc->paintTile(*pDevice.get(), nCanvasWidth, nCanvasHeight, + nTilePosX, nTilePosY, nTileWidth, nTileHeight); + +} + +#endif static void doc_paintPartTile(LibreOfficeKitDocument* pThis, unsigned char* pBuffer, |