diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-10-12 14:24:44 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-10-15 13:41:23 +0200 |
commit | 6a8bc53131309817e773eef84b83664441ee24bd (patch) | |
tree | 07c534242b95267e9d7459cef7da5808feb822ba /desktop | |
parent | abb8d6e97029b1e344de04db31e3f616360e52aa (diff) |
delay, collect and compress LOK invalidations for Writer views
Due the to way views are updated on any document change, invalidations
are at least O(n^2), and since LOK may use a number of views and
for each view the entire document is considered to be the view area,
this can lead to a huge number of invalidations that are mostly
the same repeated rectangles.
Change-Id: I63682958d2fc388344641dcd19fa1d2b39054b51
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123618
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/inc/lib/init.hxx | 3 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 12 |
2 files changed, 14 insertions, 1 deletions
diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx index 74e0ebb2eb3a..0c9bddea9e45 100644 --- a/desktop/inc/lib/init.hxx +++ b/desktop/inc/lib/init.hxx @@ -97,6 +97,8 @@ namespace desktop { void addViewStates(int viewId); void removeViewStates(int viewId); + void setViewId( int viewId ) { m_viewId = viewId; } + // SfxLockCallbackInterface virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) override; virtual void libreOfficeKitViewCallback(int nType, const char* pPayload, int nViewId) override; @@ -177,6 +179,7 @@ namespace desktop { std::map<int, std::string> m_states; std::unordered_map<int, std::unordered_map<int, std::string>> m_viewStates; LibreOfficeKitDocument* m_pDocument; + int m_viewId = -1; // view id of the associated SfxViewShell LibreOfficeKitCallback m_pCallback; void *m_pData; int m_nDisableCallbacks; diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 61ab75fc45d2..2f490ce2b5af 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -2045,6 +2045,14 @@ void CallbackFlushHandler::Invoke() if (!m_pCallback) return; + // Get any pending invalidate tile events. This will call our callbacks, + // so it must be done before taking the mutex. + if(SfxViewShell* viewShell = SfxViewShell::GetFirst( false, + [this](const SfxViewShell* shell) { return shell->GetViewShellId().get() == m_viewId; } )) + { + viewShell->flushPendingLOKInvalidateTiles(); + } + std::scoped_lock<std::mutex> lock(m_mutex); SAL_INFO("lok", "Flushing " << m_queue1.size() << " elements."); @@ -3456,7 +3464,7 @@ static void doc_paintPartTile(LibreOfficeKitDocument* pThis, { if (pViewShell->getPart() == nPart) { - nViewId = static_cast<sal_Int32>(pViewShell->GetViewShellId()); + nViewId = pViewShell->GetViewShellId().get(); doc_setView(pThis, nViewId); break; } @@ -3589,6 +3597,7 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis, if (SfxViewShell* pViewShell = SfxViewShell::Current()) { + pDocument->mpCallbackFlushHandlers[nView]->setViewId(pViewShell->GetViewShellId().get()); pViewShell->setLibreOfficeKitViewCallback(pDocument->mpCallbackFlushHandlers[nView].get()); } } @@ -3597,6 +3606,7 @@ static void doc_registerCallback(LibreOfficeKitDocument* pThis, if (SfxViewShell* pViewShell = SfxViewShell::Current()) { pViewShell->setLibreOfficeKitViewCallback(nullptr); + pDocument->mpCallbackFlushHandlers[nView]->setViewId(-1); } } } |