diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2014-10-02 00:21:30 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2014-10-02 00:23:34 +0100 |
commit | a131feddd07bcb75112b1f80a16b8733458338e4 (patch) | |
tree | 639cfb26dac28e7d9d04da2851f4d41771b1cae4 /libreofficekit | |
parent | 87fad21582fceb200e3630e9ec10a873f7d7a3ed (diff) |
LOK: Excercise tiled-rendering harder in the test-bench.
Change-Id: I13a93991050cc25d06f2836d85ec1d0a0bc574f1
Diffstat (limited to 'libreofficekit')
-rw-r--r-- | libreofficekit/qa/tilebench/tilebench.cxx | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/libreofficekit/qa/tilebench/tilebench.cxx b/libreofficekit/qa/tilebench/tilebench.cxx index 80d5c1654db7..edb6889a46c6 100644 --- a/libreofficekit/qa/tilebench/tilebench.cxx +++ b/libreofficekit/qa/tilebench/tilebench.cxx @@ -13,6 +13,9 @@ #include <vector> #include <osl/time.h> + +#define LOK_USE_UNSTABLE_API + #include <LibreOfficeKit/LibreOfficeKitInit.h> #include <LibreOfficeKit/LibreOfficeKit.hxx> @@ -66,6 +69,85 @@ int main( int argc, char* argv[] ) Document *pDocument(pOffice->documentLoad(argv[2])); aTimes.push_back(TimeRecord()); + aTimes.push_back(TimeRecord("getparts")); + int nParts = pDocument->getParts(); + aTimes.push_back(TimeRecord()); + + aTimes.push_back(TimeRecord("get size of parts")); + for (int nPart = 0; nPart < nParts; nPart++) + { + char* pName = pDocument->getPartName(nPart); + pDocument->setPart(nPart); + long nWidth = 0, nHeight = 0; + pDocument->getDocumentSize(&nWidth, &nHeight); + fprintf (stderr, " '%s' -> %ld, %ld\n", pName, nWidth, nHeight); + free (pName); + } + aTimes.push_back(TimeRecord()); + + unsigned char pPixels[256*256*4]; + for (int nPart = 0; nPart < nParts; nPart++) + { + { + char* pName = pDocument->getPartName(nPart); + fprintf (stderr, "render '%s'\n", pName); + free (pName); + } + pDocument->setPart(nPart); + long nWidth = 0, nHeight = 0; + pDocument->getDocumentSize(&nWidth, &nHeight); + + { // whole document + aTimes.push_back(TimeRecord("render whole document")); + int nRowStride = 256; + pDocument->paintTile(pPixels, 256, 256, &nRowStride, + 0, 0, nWidth, nHeight); // not square + aTimes.push_back(TimeRecord()); + } + + { // 1:1 + aTimes.push_back(TimeRecord("render sub-region at 1:1")); + int nTiles = 0; + int nSplit = nWidth / 4; + for (int nX = 0; nX < 4; nX++) + { + for (int nY = 0; nY < nHeight / nSplit; nY++) + { + int nRowStride = 256; + int nTilePosX = nX * nSplit; + int nTilePosY = nY * nSplit; + pDocument->paintTile(pPixels, 256, 256, &nRowStride, + nTilePosX, nTilePosY, 256, 256); + nTiles++; + fprintf (stderr, " rendered tile %d at %d, %d\n", + nTiles, nTilePosX, nTilePosY); + } + } + aTimes.push_back(TimeRecord()); + } + + { // scaled + aTimes.push_back(TimeRecord("render sub-regions at scale")); + int nTiles = 0; + int nSplit = nWidth / 4; + for (int nX = 0; nX < 4; nX++) + { + for (int nY = 0; nY < nHeight / nSplit; nY++) + { + int nRowStride = 256; + int nTilePosX = nX * nSplit; + int nTilePosY = nY * nSplit; + pDocument->paintTile(pPixels, 256, 256, &nRowStride, + nTilePosX, nTilePosY, nSplit, nSplit); + nTiles++; + fprintf (stderr, " rendered tile %d at %d, %d\n", + nTiles, nTilePosX, nTilePosY); + } + } + aTimes.push_back(TimeRecord()); + } + } + aTimes.push_back(TimeRecord("destroy document")); delete pDocument; aTimes.push_back(TimeRecord()); |