[Libreoffice-commits] core.git: Branch 'feature/calctiledrendering3' - 4 commits - desktop/source include/sal libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk libreofficekit/Module_libreofficekit.mk libreofficekit/qa svx/source
Andrzej Hunt
andrzej.hunt at collabora.com
Fri Jul 11 00:13:26 PDT 2014
desktop/source/lib/init.cxx | 3
include/sal/log-areas.dox | 5
libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk | 56 ++++++
libreofficekit/Module_libreofficekit.mk | 4
libreofficekit/qa/unit/tiledrendering.cxx | 111 ++++++++++++
svx/source/svdraw/svdpagv.cxx | 2
6 files changed, 181 insertions(+)
New commits:
commit c9a5886c031d0fc9c770cc190e409b5232124ac0
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jul 11 09:13:21 2014 +0200
LOK: some logging for tiled rendering.
Change-Id: I5779eec97507b1996cda89174a6e6c55cdd57baf
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 520d7ca..7b6197a 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -471,6 +471,9 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
const int nTilePosX, const int nTilePosY,
const int nTileWidth, const int nTileHeight)
{
+ SAL_INFO( "lok.tiledrendering", "paintTile: painting [" << nTileWidth << "x" << nTileHeight <<
+ "]@(" << nTilePosX << ", " << nTilePosY << ") to [" <<
+ nCanvasWidth << "x" << nCanvasHeight << "]px" );
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
::vcl::ITiledRenderable* pDoc = dynamic_cast< ::vcl::ITiledRenderable* >( pDocument->mxComponent.get() );
commit cd2f057dec236cdccd6f91a1eb366166e28e2f5f
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jul 11 09:12:58 2014 +0200
Add LOK and tiledrendering log areas.
Change-Id: I885acc9b4a52835fa256c2ecd1b8da917b4f7ba7
diff --git a/include/sal/log-areas.dox b/include/sal/log-areas.dox
index 1627ad2..44a56d8 100644
--- a/include/sal/log-areas.dox
+++ b/include/sal/log-areas.dox
@@ -235,6 +235,11 @@ certain functionality.
@li @c jfw.level1
@li @c jfw.level2
+ at section LibreOfficeKit
+
+ at li @c lok
+ at li @c lok.tiledrendering
+
@section l10ntools
@li @c l10ntools
commit d3678012fed0bcbf35cf349ccc362758d6623446
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jul 11 09:12:27 2014 +0200
Add LOK tiled rendering divided-tile unit test.
I.e. we render the same area as one larger tile, and then
as 4 sub-tiles (which, when put together, should be identical
to the larger tile). However currently only the top-left sub-tile
actually matches the larger tile, so we have to disable the test
for the remaining sub-tiles.
Change-Id: If1130022b43898e20fefff3e9f592102da3e413a
diff --git a/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk b/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk
new file mode 100644
index 0000000..3c41c0a
--- /dev/null
+++ b/libreofficekit/CppunitTest_libreofficekit_tiledrendering.mk
@@ -0,0 +1,56 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+#*************************************************************************
+
+$(eval $(call gb_CppunitTest_CppunitTest,libreofficekit_tiledrendering))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,libreofficekit_tiledrendering, \
+ libreofficekit/qa/unit/tiledrendering \
+))
+
+$(eval $(call gb_CppunitTest_use_external,libreofficekit_tiledrendering,boost_headers))
+
+# We need all these libraries / etc. due for CppunitTest to work, even though
+# our test specifically tests LOK only functionality which would otherwise not
+# require any normal LO api/libraries.
+$(eval $(call gb_CppunitTest_use_libraries,libreofficekit_tiledrendering, \
+ test \
+ cppu \
+ sal \
+ vcl \
+ $(gb_UWINAPI) \
+))
+
+
+# unotest \
+
+ifeq ($(OS),LINUX)
+$(eval $(call gb_CppunitTest_add_libs,libreofficekit_tiledrendering,\
+ -lm \
+ -ldl \
+ -lpthread \
+))
+endif
+
+$(eval $(call gb_CppunitTest_use_sdk_api,libreofficekit_tiledrendering))
+
+$(eval $(call gb_CppunitTest_use_static_libraries,libreofficekit_tiledrendering,\
+ libreofficekit \
+))
+
+$(eval $(call gb_CppunitTest_use_ure,libreofficekit_tiledrendering))
+#$(eval $(call gb_CppunitTest_use_vcl,libreofficekit_tiledrendering))
+
+# Depend on ~everything, as tiled rendering can use most parts of LO.
+$(eval $(call gb_CppunitTest_use_rdb,libreofficekit_tiledrendering,services))
+
+$(eval $(call gb_CppunitTest_use_configuration,libreofficekit_tiledrendering))
+
+# vim: set noet sw=4 ts=4:
diff --git a/libreofficekit/Module_libreofficekit.mk b/libreofficekit/Module_libreofficekit.mk
index 55136a4..8fef777 100644
--- a/libreofficekit/Module_libreofficekit.mk
+++ b/libreofficekit/Module_libreofficekit.mk
@@ -16,6 +16,10 @@ $(eval $(call gb_Module_add_targets,libreofficekit,\
Library_libreofficekitgtk \
))
+$(eval $(call gb_Module_add_check_targets,libreofficekit,\
+ CppunitTest_libreofficekit_tiledrendering \
+))
+
ifneq ($(ENABLE_GTK),)
$(eval $(call gb_Module_add_targets,libreofficekit,\
Executable_gtktiledviewer \
diff --git a/libreofficekit/qa/unit/tiledrendering.cxx b/libreofficekit/qa/unit/tiledrendering.cxx
new file mode 100644
index 0000000..1cc93f7
--- /dev/null
+++ b/libreofficekit/qa/unit/tiledrendering.cxx
@@ -0,0 +1,111 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <boost/scoped_array.hpp>
+#include <boost/scoped_ptr.hpp>
+#include <cppunit/TestFixture.h>
+#include <cppunit/plugin/TestPlugIn.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cstdlib>
+#include <string>
+
+#include <sal/types.h>
+
+#define LOK_USE_UNSTABLE_API
+#include <LibreOfficeKit/LibreOfficeKit.hxx>
+
+using namespace ::boost;
+using namespace ::lok;
+using namespace ::std;
+
+// We specifically don't use the usual BootStrapFixture, as LOK does
+// all it's own setup and bootstrapping, and should be useable in a
+// raw C++ program.
+class TiledRenderingTest : public ::CppUnit::TestFixture
+{
+public:
+ TiledRenderingTest() {}
+
+ void testOverlay();
+
+ CPPUNIT_TEST_SUITE(TiledRenderingTest);
+ CPPUNIT_TEST(testOverlay);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+void TiledRenderingTest::testOverlay()
+{
+ const string sSrcRoot = getenv( "SRC_ROOT" );
+ const string sLOPath = sSrcRoot + "/instdir/program";
+ const string sDocPath = sSrcRoot + "/odk/examples/java/DocumentHandling/test/test1.odt";
+
+ scoped_ptr< Office > pOffice( lok_cpp_init(
+ sLOPath.c_str() ) );
+ scoped_ptr< Document> pDocument( pOffice->documentLoad(
+ sDocPath.c_str() ) );
+
+ // We render one large tile, then subdivide it into 4 and render those parts, and finally
+ // iterate over each smaller tile and check whether their contents match the large
+ // tile.
+ const int nTotalWidthPix = 512;
+ const int nTotalHeightPix = 512;
+ int nRowStride;
+
+ long nTotalWidthDoc;
+ long nTotalHeightDoc;
+ // pDocument->getDocumentSize( &nTotalWidthDoc, &nTotalHeightDoc );
+ // TODO: make sure we select an actually interesting part of the document
+ // for this comparison, i.e. ideally an image and lots of text, in order
+ // to test as many edge cases as possible.
+ // Alternatively we could rewrite this to actually grab the document size
+ // and iterate over it (subdividing into an arbitrary number of tiles rather
+ // than our less sophisticated test of just 4 sub-tiles).
+ nTotalWidthDoc = 8000;
+ nTotalHeightDoc = 9000;
+
+ scoped_array< unsigned char > pLarge( new unsigned char[ 4*nTotalWidthPix*nTotalHeightPix ] );
+ pDocument->paintTile( pLarge.get(), nTotalWidthPix, nTotalHeightPix, &nRowStride,
+ 0, 0,
+ nTotalWidthDoc, nTotalHeightDoc );
+ scoped_array< unsigned char > pSmall[4];
+ for ( int i = 0; i < 4; i++ )
+ {
+ pSmall[i].reset( new unsigned char[ 4*(nTotalWidthPix/2)*(nTotalHeightPix/2) ] );
+ pDocument->paintTile( pSmall[i].get(), nTotalWidthPix / 2, nTotalHeightPix / 2, &nRowStride,
+ // Tile 0/2: left. Tile 1/3: right. Tile 0/1: top. Tile 2/3: bottom
+ ((i%2 == 0) ? 0 : nTotalWidthDoc / 2), ((i < 2 ) ? 0 : nTotalHeightDoc / 2),
+ nTotalWidthDoc / 2, nTotalHeightDoc / 2);
+ }
+
+ // Iterate over each pixel of the sub-tile, and compare that pixel for every
+ // tile with the equivalent super-tile pixel.
+ for ( int i = 0; i < 4*nTotalWidthPix / 2 * nTotalHeightPix / 2; i++ )
+ {
+ int xSmall = i % (4*nTotalWidthPix/2);
+ int ySmall = i / (4*nTotalWidthPix/2);
+ // Iterate over our array of tiles
+ // However for now we only bother with the top-left
+ // tile as the other ones don't match yet...
+ for ( int x = 0; x < 1; x++ )
+ {
+ for ( int y = 0; y < 1; y++ )
+ {
+ int xLarge = (x * (4 * nTotalWidthPix / 2)) + xSmall;
+ int yLarge = (y * (nTotalHeightPix / 2)) + ySmall;
+ CPPUNIT_ASSERT( pSmall[2*y+x][i] == pLarge[yLarge*4*nTotalWidthPix + xLarge] );
+ }
+ }
+ }
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(TiledRenderingTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 0ca75c6a3ff6dc97de79cdcff39ac264ea4af6f8
Author: Andrzej Hunt <andrzej.hunt at collabora.com>
Date: Fri Jul 11 09:07:06 2014 +0200
DON'T MERGE: the viewport doesn't get set otherwise?
When writing the tiled rendering test, asserts were firing because the
redraw area wasn't set on the page -- however I don't understand
things well enought yet to know whether or not this is the correct
solution.. (Especially as this happened only for certain tile configurations.)
Change-Id: I187d639b00d0748e7cc9fd6cc33d555f02f9a081
diff --git a/svx/source/svdraw/svdpagv.cxx b/svx/source/svdraw/svdpagv.cxx
index addcc38..40e0809 100644
--- a/svx/source/svdraw/svdpagv.cxx
+++ b/svx/source/svdraw/svdpagv.cxx
@@ -328,6 +328,8 @@ void SdrPageView::DrawLayer(SdrLayerID nID, OutputDevice* pGivenTarget, sdr::con
if(pKnownTarget)
{
+ // This is where it gets lost.
+ pKnownTarget->GetPaintWindow().SetRedrawRegion(Region(rRect));
// paint known target
pKnownTarget->RedrawLayer(&nID, pRedirector);
}
More information about the Libreoffice-commits
mailing list