summaryrefslogtreecommitdiff
path: root/libreofficekit/qa/tilebench
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2018-09-28 14:15:56 +0200
committerTor Lillqvist <tml@collabora.com>2018-10-02 19:46:31 +0200
commit51591ae750df644738bba4e1c8a2bb81d183a572 (patch)
treec6b234439c41f2d2a06b74a38b6eb015cdfae882 /libreofficekit/qa/tilebench
parent0895c26b7761215e92eef7b3fbf384982ac01eeb (diff)
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 <tml@collabora.com> Tested-by: Tor Lillqvist <tml@collabora.com>
Diffstat (limited to 'libreofficekit/qa/tilebench')
-rw-r--r--libreofficekit/qa/tilebench/tilebench.cxx32
1 files changed, 30 insertions, 2 deletions
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<const char *>(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);