From 51591ae750df644738bba4e1c8a2bb81d183a572 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Fri, 28 Sep 2018 14:15:56 +0200 Subject: More hacking on the tilebench part of the UnitTest app On iOS, don't attempt to write the tile dump ppm file to /tmp, but use the app-specific directory so that it can be copied for inspection using iTunes. (Of course, even better would be to simply paint it to the app's view. Later) Change-Id: I8dd60d04adc61de6594099f5c358a9b6220522da Reviewed-on: https://gerrit.libreoffice.org/61255 Reviewed-by: Tor Lillqvist Tested-by: Tor Lillqvist --- libreofficekit/qa/tilebench/tilebench.cxx | 32 +++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'libreofficekit') diff --git a/libreofficekit/qa/tilebench/tilebench.cxx b/libreofficekit/qa/tilebench/tilebench.cxx index d4148dfaa797..ee325c429267 100644 --- a/libreofficekit/qa/tilebench/tilebench.cxx +++ b/libreofficekit/qa/tilebench/tilebench.cxx @@ -64,7 +64,15 @@ static std::vector< TimeRecord > aTimes; static void dumpTile(const int nWidth, const int nHeight, const int mode, const unsigned char* pBufferU) { auto pBuffer = reinterpret_cast(pBufferU); +#ifndef IOS std::ofstream ofs("/tmp/dump_tile.ppm"); +#else + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSString *documentsDirectory = [paths objectAtIndex:0]; + static int counter = 0; + NSString *path = [NSString stringWithFormat:@"%@/dump_tile_%d.ppm", documentsDirectory, counter++]; + std::ofstream ofs([path UTF8String]); +#endif ofs << "P6\n" << nWidth << " " << nHeight << "\n" @@ -101,6 +109,7 @@ static void dumpTile(const int nWidth, const int nHeight, const int mode, const } } } + ofs.close(); } static void testTile( Document *pDocument, int max_parts, @@ -156,8 +165,15 @@ static void testTile( Document *pDocument, int max_parts, { // whole part; meaningful only for non-writer documents. aTimes.emplace_back("render whole part"); +#ifndef IOS pDocument->paintTile(pPixels, nTilePixelWidth, nTilePixelHeight, nWidth/2, 2000, 1000, 1000); // not square +#else + pDocument->paintTile(lo_ios_app_get_cgcontext_for_buffer(pPixels, nTilePixelWidth, nTilePixelHeight), + nTilePixelWidth, nTilePixelHeight, + nWidth/2, 2000, 1000, 1000); // not square + lo_ios_app_release_cgcontext_for_buffer(); +#endif aTimes.emplace_back(); if (dump) dumpTile(nTilePixelWidth, nTilePixelHeight, mode, pPixels); @@ -177,9 +193,15 @@ static void testTile( Document *pDocument, int max_parts, nY = nHeight; break; } - +#ifndef IOS pDocument->paintTile(pPixels, nTilePixelWidth, nTilePixelHeight, nX, nY, nTilePixelWidth, nTilePixelHeight); +#else + pDocument->paintTile(lo_ios_app_get_cgcontext_for_buffer(pPixels, nTilePixelWidth, nTilePixelHeight), + nTilePixelWidth, nTilePixelHeight, + nX, nY, nTilePixelWidth, nTilePixelHeight); + lo_ios_app_release_cgcontext_for_buffer(); +#endif nTiles++; fprintf (stderr, " rendered 1:1 tile %d at %d, %d\n", nTiles, nX, nY); @@ -203,9 +225,15 @@ static void testTile( Document *pDocument, int max_parts, nY = nHeight; break; } - +#ifndef IOS pDocument->paintTile(pPixels, nTilePixelWidth, nTilePixelHeight, nX, nY, nTileTwipWidth, nTileTwipHeight); +#else + pDocument->paintTile(lo_ios_app_get_cgcontext_for_buffer(pPixels, nTilePixelWidth, nTilePixelHeight), + nTilePixelWidth, nTilePixelHeight, + nX, nY, nTileTwipWidth, nTileTwipHeight); + lo_ios_app_release_cgcontext_for_buffer(); +#endif nTiles++; fprintf (stderr, " rendered scaled tile %d at %d, %d\n", nTiles, nX, nY); -- cgit