bundled/include/LibreOfficeKit/LibreOfficeKit.h | 12 +++++++++ bundled/include/LibreOfficeKit/LibreOfficeKit.hxx | 28 ++++++++++++++++++++++ ios/ios.h | 4 --- ios/ios.mm | 21 ---------------- kit/Kit.cpp | 20 +-------------- 5 files changed, 42 insertions(+), 43 deletions(-)
New commits: commit ab54f21a54e6b2b66d6ae4b45fd200fa6c7d4fa1 Author: Tor Lillqvist <t...@collabora.com> AuthorDate: Wed Oct 10 16:30:48 2018 +0300 Commit: Tor Lillqvist <t...@collabora.com> CommitDate: Wed Oct 10 16:31:38 2018 +0300 Adapt to change in core: paintTile() now takes a buffer pointer also on iOS Makes the code here a little bit simpler. diff --git a/bundled/include/LibreOfficeKit/LibreOfficeKit.h b/bundled/include/LibreOfficeKit/LibreOfficeKit.h index 0799584d3..0ae5c6ff1 100644 --- a/bundled/include/LibreOfficeKit/LibreOfficeKit.h +++ b/bundled/include/LibreOfficeKit/LibreOfficeKit.h @@ -309,6 +309,18 @@ struct _LibreOfficeKitDocumentClass /// @see lok::Document::getPartInfo(). char* (*getPartInfo) (LibreOfficeKitDocument* pThis, int nPart); +#ifdef IOS + /// @see lok::Document::paintTileToCGContext(). + void (*paintTileToCGContext) (LibreOfficeKitDocument* pThis, + void* rCGContext, + const int nCanvasWidth, + const int nCanvasHeight, + const int nTilePosX, + const int nTilePosY, + const int nTileWidth, + const int nTileHeight); +#endif // IOS + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; diff --git a/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx b/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx index 232eada69..3568c861f 100644 --- a/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/bundled/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -550,6 +550,34 @@ public: mpDoc->pClass->postWindowExtTextInputEvent(mpDoc, nWindowId, nType, pText); } +#ifdef IOS + /** + * Renders a subset of the document to a Core Graphics context. + * + * Note that the buffer size and the tile size implicitly supports + * rendering at different zoom levels, as the number of rendered pixels and + * the rendered rectangle of the document are independent. + * + * @param rCGContext the CGContextRef, cast to a void*. + * @param nCanvasHeight number of pixels in a column of pBuffer. + * @param nTilePosX logical X position of the top left corner of the rendered rectangle, in TWIPs. + * @param nTilePosY logical Y position of the top left corner of the rendered rectangle, in TWIPs. + * @param nTileWidth logical width of the rendered rectangle, in TWIPs. + * @param nTileHeight logical height of the rendered rectangle, in TWIPs. + */ + void paintTileToCGContext(void* rCGContext, + const int nCanvasWidth, + const int nCanvasHeight, + const int nTilePosX, + const int nTilePosY, + const int nTileWidth, + const int nTileHeight) + { + return mpDoc->pClass->paintTileToCGContext(mpDoc, rCGContext, nCanvasWidth, nCanvasHeight, + nTilePosX, nTilePosY, nTileWidth, nTileHeight); + } +#endif // IOS + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; diff --git a/ios/ios.h b/ios/ios.h index f613b93ff..0109b0eda 100644 --- a/ios/ios.h +++ b/ios/ios.h @@ -11,8 +11,4 @@ extern const char *lo_ios_app_getCacheDir(); extern int loolwsd_server_socket_fd; -extern unsigned char *lo_ios_app_get_cgcontext_for_buffer(unsigned char *buffer, int width, int height); - -extern void lo_ios_app_release_cgcontext_for_buffer(); - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ios/ios.mm b/ios/ios.mm index 277e807ba..b9afc0299 100644 --- a/ios/ios.mm +++ b/ios/ios.mm @@ -17,8 +17,6 @@ extern "C" { int loolwsd_server_socket_fd = -1; -static thread_local CGContextRef cgc = nullptr; - const char* lo_ios_app_getCacheDir() { static NSString *cachePath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0]; @@ -27,23 +25,4 @@ const char* lo_ios_app_getCacheDir() return result; } -extern unsigned char *lo_ios_app_get_cgcontext_for_buffer(unsigned char *buffer, int width, int height) -{ - assert(cgc == nullptr); - - cgc = CGBitmapContextCreate(buffer, width, height, 8, width*4, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipFirst | kCGImageByteOrder32Little); - - CGContextTranslateCTM(cgc, 0, height); - CGContextScaleCTM(cgc, 1, -1); - - return (unsigned char*)cgc; -} - -extern void lo_ios_app_release_cgcontext_for_buffer() -{ - assert(cgc != nullptr); - CGContextRelease(cgc); - cgc = nullptr; -} - // vim:set shiftwidth=4 softtabstop=4 expandtab: diff --git a/kit/Kit.cpp b/kit/Kit.cpp index 5d19b848c..63d9f6b24 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -967,19 +967,11 @@ public: const double area = tile.getWidth() * tile.getHeight(); Timestamp timestamp; - _loKitDocument->paintPartTile( -#ifndef IOS - pixmap.data(), -#else - lo_ios_app_get_cgcontext_for_buffer(pixmap.data(), tile.getWidth(), tile.getHeight()), -#endif + _loKitDocument->paintPartTile(pixmap.data(), tile.getPart(), tile.getWidth(), tile.getHeight(), tile.getTilePosX(), tile.getTilePosY(), tile.getTileWidth(), tile.getTileHeight()); -#ifdef IOS - lo_ios_app_release_cgcontext_for_buffer(); -#endif const Poco::Timestamp::TimeDiff elapsed = timestamp.elapsed(); LOG_TRC("paintTile at (" << tile.getPart() << ',' << tile.getTilePosX() << ',' << tile.getTilePosY() << ") " << "ver: " << tile.getVersion() << " rendered in " << (elapsed/1000.) << @@ -1075,19 +1067,11 @@ public: const double area = pixmapWidth * pixmapHeight; Timestamp timestamp; LOG_TRC("Calling paintPartTile(" << (void*)pixmap.data() << ")"); - _loKitDocument->paintPartTile( -#ifndef IOS - pixmap.data(), -#else - lo_ios_app_get_cgcontext_for_buffer(pixmap.data(), pixmapWidth, pixmapHeight), -#endif + _loKitDocument->paintPartTile(pixmap.data(), tileCombined.getPart(), pixmapWidth, pixmapHeight, renderArea.getLeft(), renderArea.getTop(), renderArea.getWidth(), renderArea.getHeight()); -#ifdef IOS - lo_ios_app_release_cgcontext_for_buffer(); -#endif Timestamp::TimeDiff elapsed = timestamp.elapsed(); LOG_DBG("paintTile (combined) at (" << renderArea.getLeft() << ", " << renderArea.getTop() << "), (" << renderArea.getWidth() << ", " << renderArea.getHeight() << ") " << _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits