diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-11-24 17:26:32 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-11-25 09:13:35 +0100 |
commit | 2d18f5e3fb0ea44b538db9ccea3c87a16693e6b2 (patch) | |
tree | 81f9ff5ba2f8454b154ec44ec73e7f2f72c3118d /sw | |
parent | 7e21086c2903d19ec0981d09d63d8f7c4e078242 (diff) |
sw tiled rendering: fix paint->invalidation loop when paint is started by vcl
SwViewShell::PaintTile() already calls
comphelper::LibreOfficeKit::setTiledPainting(), so by the time it would
rearch SwViewShell::Paint(), callbacks (e.g. invalidations) are ignored
during paint.
Do the same for SwEditWin::Paint(), where we processed invalidations
during paint, potentially leading to paint->invalidation loops.
Conflicts:
sw/qa/extras/tiledrendering/tiledrendering.cxx
sw/source/uibase/docvw/edtwin2.cxx
Change-Id: I8280f5c2571beeae6c0f2986d275dde3c2d33161
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106543
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/qa/extras/tiledrendering/data/table-paint-invalidate.odt | bin | 0 -> 9067 bytes | |||
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 33 | ||||
-rw-r--r-- | sw/source/uibase/docvw/edtwin2.cxx | 11 |
3 files changed, 44 insertions, 0 deletions
diff --git a/sw/qa/extras/tiledrendering/data/table-paint-invalidate.odt b/sw/qa/extras/tiledrendering/data/table-paint-invalidate.odt Binary files differnew file mode 100644 index 000000000000..b42c5cc51588 --- /dev/null +++ b/sw/qa/extras/tiledrendering/data/table-paint-invalidate.odt diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 1f48de38d086..2f52c97efec1 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -131,6 +131,7 @@ public: void testDropDownFormFieldButtonNoSelection(); void testDropDownFormFieldButtonNoItem(); void testSpellOnlineRenderParameter(); + void testTablePaintInvalidate(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -200,6 +201,7 @@ public: CPPUNIT_TEST(testDropDownFormFieldButtonNoSelection); CPPUNIT_TEST(testDropDownFormFieldButtonNoItem); CPPUNIT_TEST(testSpellOnlineRenderParameter); + CPPUNIT_TEST(testTablePaintInvalidate); CPPUNIT_TEST_SUITE_END(); private: @@ -2760,6 +2762,37 @@ void SwTiledRenderingTest::testSpellOnlineRenderParameter() CPPUNIT_ASSERT_EQUAL(!bSet, pOpt->IsOnlineSpell()); } +void SwTiledRenderingTest::testTablePaintInvalidate() +{ + // Load a document with a table in it. + SwXTextDocument* pXTextDocument = createDoc("table-paint-invalidate.odt"); + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + pWrtShell->GetSfxViewShell()->registerLibreOfficeKitViewCallback(&SwTiledRenderingTest::callback, this); + // Enter the table. + pWrtShell->Down(/*bSelect=*/false); + Scheduler::ProcessEventsToIdle(); + m_nInvalidations = 0; + + // Paint a tile. + size_t nCanvasWidth = 256; + size_t nCanvasHeight = 256; + std::vector<unsigned char> aPixmap(nCanvasWidth * nCanvasHeight * 4, 0); + ScopedVclPtrInstance<VirtualDevice> pDevice(DeviceFormat::DEFAULT); + pDevice->SetBackground(Wallpaper(COL_TRANSPARENT)); + pDevice->SetOutputSizePixelScaleOffsetAndBuffer(Size(nCanvasWidth, nCanvasHeight), + Fraction(1.0), Point(), aPixmap.data()); + pXTextDocument->paintTile(*pDevice, nCanvasWidth, nCanvasHeight, m_aInvalidation.getX(), + m_aInvalidation.getY(), /*nTileWidth=*/1000, + /*nTileHeight=*/1000); + Scheduler::ProcessEventsToIdle(); + + // Without the accompanying fix in place, this test would have failed with + // - Expected: 0 + // - Actual : 5 + // i.e. paint generated an invalidation, which caused a loop. + CPPUNIT_ASSERT_EQUAL(0, m_nInvalidations); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/uibase/docvw/edtwin2.cxx b/sw/source/uibase/docvw/edtwin2.cxx index 872352db5e3d..9fd50d6bd10f 100644 --- a/sw/source/uibase/docvw/edtwin2.cxx +++ b/sw/source/uibase/docvw/edtwin2.cxx @@ -64,6 +64,7 @@ #include <IDocumentMarkAccess.hxx> #include <txtfrm.hxx> #include <ndtxt.hxx> +#include <comphelper/lok.hxx> static OUString lcl_GetRedlineHelp( const SwRangeRedline& rRedl, bool bBalloon ) { @@ -438,7 +439,17 @@ void SwEditWin::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle else { pWrtShell->setOutputToWindow(true); + bool bTiledPainting = false; + if (comphelper::LibreOfficeKit::isActive()) + { + bTiledPainting = comphelper::LibreOfficeKit::isTiledPainting(); + comphelper::LibreOfficeKit::setTiledPainting(true); + } pWrtShell->Paint(rRenderContext, rRect); + if (comphelper::LibreOfficeKit::isActive()) + { + comphelper::LibreOfficeKit::setTiledPainting(bTiledPainting); + } pWrtShell->setOutputToWindow(false); } |