Kaydet (Commit) 51591ae7 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

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/61255Reviewed-by: 's avatarTor Lillqvist <tml@collabora.com>
Tested-by: 's avatarTor Lillqvist <tml@collabora.com>
üst 0895c26b
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>UIFileSharingEnabled</key>
<true/>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string> <string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
......
...@@ -29,9 +29,35 @@ extern "C" { ...@@ -29,9 +29,35 @@ extern "C" {
} }
#include <premac.h> #include <premac.h>
#import <CoreGraphics/CoreGraphics.h>
#import "ViewController.h" #import "ViewController.h"
#include <postmac.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);
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 () @interface ViewController ()
@end @end
......
...@@ -64,7 +64,15 @@ static std::vector< TimeRecord > aTimes; ...@@ -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) static void dumpTile(const int nWidth, const int nHeight, const int mode, const unsigned char* pBufferU)
{ {
auto pBuffer = reinterpret_cast<const char *>(pBufferU); auto pBuffer = reinterpret_cast<const char *>(pBufferU);
#ifndef IOS
std::ofstream ofs("/tmp/dump_tile.ppm"); 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" ofs << "P6\n"
<< nWidth << " " << nWidth << " "
<< nHeight << "\n" << nHeight << "\n"
...@@ -101,6 +109,7 @@ static void dumpTile(const int nWidth, const int nHeight, const int mode, const ...@@ -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, static void testTile( Document *pDocument, int max_parts,
...@@ -156,8 +165,15 @@ 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. // whole part; meaningful only for non-writer documents.
aTimes.emplace_back("render whole part"); aTimes.emplace_back("render whole part");
#ifndef IOS
pDocument->paintTile(pPixels, nTilePixelWidth, nTilePixelHeight, pDocument->paintTile(pPixels, nTilePixelWidth, nTilePixelHeight,
nWidth/2, 2000, 1000, 1000); // not square 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(); aTimes.emplace_back();
if (dump) if (dump)
dumpTile(nTilePixelWidth, nTilePixelHeight, mode, pPixels); dumpTile(nTilePixelWidth, nTilePixelHeight, mode, pPixels);
...@@ -177,9 +193,15 @@ static void testTile( Document *pDocument, int max_parts, ...@@ -177,9 +193,15 @@ static void testTile( Document *pDocument, int max_parts,
nY = nHeight; nY = nHeight;
break; break;
} }
#ifndef IOS
pDocument->paintTile(pPixels, nTilePixelWidth, nTilePixelHeight, pDocument->paintTile(pPixels, nTilePixelWidth, nTilePixelHeight,
nX, nY, 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++; nTiles++;
fprintf (stderr, " rendered 1:1 tile %d at %d, %d\n", fprintf (stderr, " rendered 1:1 tile %d at %d, %d\n",
nTiles, nX, nY); nTiles, nX, nY);
...@@ -203,9 +225,15 @@ static void testTile( Document *pDocument, int max_parts, ...@@ -203,9 +225,15 @@ static void testTile( Document *pDocument, int max_parts,
nY = nHeight; nY = nHeight;
break; break;
} }
#ifndef IOS
pDocument->paintTile(pPixels, nTilePixelWidth, nTilePixelHeight, pDocument->paintTile(pPixels, nTilePixelWidth, nTilePixelHeight,
nX, nY, nTileTwipWidth, nTileTwipHeight); 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++; nTiles++;
fprintf (stderr, " rendered scaled tile %d at %d, %d\n", fprintf (stderr, " rendered scaled tile %d at %d, %d\n",
nTiles, nX, nY); nTiles, nX, nY);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment