summaryrefslogtreecommitdiff
path: root/ios
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2018-10-10 16:17:18 +0300
committerTor Lillqvist <tml@collabora.com>2018-10-10 16:25:20 +0300
commit1d279e9c9123d50788cefb186663ef3842aaa8c2 (patch)
tree2a9449cb1894ca63201919963b3ba893421d119d /ios
parentd143e211b1416665d77cd1914dd7f6a6b0b4f72a (diff)
Move the iOS CGBitmapContextCreate() call do doc_paintTile()
Thus it now actually takes a buffer pointer also on iOS, like on Linux and Android. Less confusing, more uniform. Add a separate iOS-specific paintTileToCGContext() method to LibreOfficeKitDocumentClass that takes a CGContextRef. Adapt callers correspondingly. (The LibreOfficeLight code in particular needs the paintTileToCGContext().) Change-Id: I81084806d37b9aac9f2b2bc03d0c262e991eec81
Diffstat (limited to 'ios')
-rw-r--r--ios/LibreOfficeLight/LibreOfficeLight.xcodeproj/project.pbxproj5
-rw-r--r--ios/LibreOfficeLight/LibreOfficeLight/LOKit/Document.swift24
-rw-r--r--ios/UnitTest/UnitTest/ViewController.mm25
3 files changed, 17 insertions, 37 deletions
diff --git a/ios/LibreOfficeLight/LibreOfficeLight.xcodeproj/project.pbxproj b/ios/LibreOfficeLight/LibreOfficeLight.xcodeproj/project.pbxproj
index 42a71811d3f2..819a419620b5 100644
--- a/ios/LibreOfficeLight/LibreOfficeLight.xcodeproj/project.pbxproj
+++ b/ios/LibreOfficeLight/LibreOfficeLight.xcodeproj/project.pbxproj
@@ -549,6 +549,10 @@
ENABLE_TESTABILITY = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "LibreOfficeLight/LibreOfficeLight-Prefix.pch";
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "IOS=1",
+ );
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
HEADER_SEARCH_PATHS = (
"$(inherited)",
@@ -583,6 +587,7 @@
ENABLE_TESTABILITY = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "LibreOfficeLight/LibreOfficeLight-Prefix.pch";
+ GCC_PREPROCESSOR_DEFINITIONS = "IOS=1";
HEADER_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/../../include",
diff --git a/ios/LibreOfficeLight/LibreOfficeLight/LOKit/Document.swift b/ios/LibreOfficeLight/LibreOfficeLight/LOKit/Document.swift
index 79e28d674595..218d203f61be 100644
--- a/ios/LibreOfficeLight/LibreOfficeLight/LOKit/Document.swift
+++ b/ios/LibreOfficeLight/LibreOfficeLight/LOKit/Document.swift
@@ -124,7 +124,7 @@ open class Document
* rendering at different zoom levels, as the number of rendered pixels and
* the rendered rectangle of the document are independent.
*
- * @param pBuffer pointer to the buffer, its size is determined by nCanvasWidth and nCanvasHeight.
+ * @param rCGContext Core Graphics context, cast to a UnsafeMutableRawPointer
* @param nCanvasWidth number of pixels in a row of pBuffer.
* @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.
@@ -132,7 +132,7 @@ open class Document
* @param nTileWidth logical width of the rendered rectangle, in TWIPs.
* @param nTileHeight logical height of the rendered rectangle, in TWIPs.
*/
- public func paintTile( pBuffer: UnsafeMutablePointer<UInt8>,
+ public func paintTileToCGContext( rCGContext: UnsafeMutableRawPointer,
canvasWidth: Int32,
canvasHeight: Int32,
tilePosX: Int32,
@@ -141,8 +141,8 @@ open class Document
tileHeight: Int32)
{
print("paintTile canvasWidth=\(canvasWidth) canvasHeight=\(canvasHeight) tilePosX=\(tilePosX) tilePosY=\(tilePosY) tileWidth=\(tileWidth) tileHeight=\(tileHeight) ")
- return docClass.paintTile(pDoc, pBuffer, canvasWidth, canvasHeight,
- tilePosX, tilePosY, tileWidth, tileHeight);
+ return docClass.paintTileToCGContext(pDoc, rCGContext, canvasWidth, canvasHeight,
+ tilePosX, tilePosY, tileWidth, tileHeight);
}
/**
@@ -562,16 +562,16 @@ public extension Document
{
let ctx = UIGraphicsGetCurrentContext()
//print(ctx!)
- let ptr = unsafeBitCast(ctx, to: UnsafeMutablePointer<UInt8>.self)
+ let ptr = unsafeBitCast(ctx, to: UnsafeMutableRawPointer.self)
//print(ptr)
- self.paintTile(pBuffer:ptr,
- canvasWidth: Int32(canvasSize.width),
- canvasHeight: Int32(canvasSize.height),
- tilePosX: Int32(tileRect.minX),
- tilePosY: Int32(tileRect.minY),
- tileWidth: Int32(tileRect.size.width),
- tileHeight: Int32(tileRect.size.height))
+ self.paintTileToCGContext(rCGContext:ptr,
+ canvasWidth: Int32(canvasSize.width),
+ canvasHeight: Int32(canvasSize.height),
+ tilePosX: Int32(tileRect.minX),
+ tilePosY: Int32(tileRect.minY),
+ tileWidth: Int32(tileRect.size.width),
+ tileHeight: Int32(tileRect.size.height))
}
public func paintTileToImage(canvasSize: CGSize,
diff --git a/ios/UnitTest/UnitTest/ViewController.mm b/ios/UnitTest/UnitTest/ViewController.mm
index c79c003547c8..fa002f107f27 100644
--- a/ios/UnitTest/UnitTest/ViewController.mm
+++ b/ios/UnitTest/UnitTest/ViewController.mm
@@ -33,31 +33,6 @@ extern "C" {
#import "ViewController.h"
#include <postmac.h>
-// This is from online's Mobile app (as it is called at the moment);
-// should of course be factored out to some common place. Here in
-// core?
-
-static thread_local CGContextRef cgc = nullptr;
-
-static 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;
-}
-
-static void lo_ios_app_release_cgcontext_for_buffer()
-{
- assert(cgc != nullptr);
- CGContextRelease(cgc);
- cgc = nullptr;
-}
-
@interface ViewController ()
@end