desktop/inc/lib/init.hxx | 4 ++++ desktop/source/lib/init.cxx | 26 ++++++++++++++++++++++++++ include/LibreOfficeKit/LibreOfficeKit.h | 10 ++++++++++ include/LibreOfficeKit/LibreOfficeKit.hxx | 10 ++++++++++ 4 files changed, 50 insertions(+)
New commits: commit 1c27286b9d5331634c073cd3e327bd941e61bbb6 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Fri Jan 6 10:48:18 2017 -0500 Lok: support for batch API calls Mouse and keyboard operations typically come in batches, and often each results in tile invalidations and/or layout modifications. Processing each input event on its own, then processing the resulting output event is very costly and unecessary when we know there is more of the same. The new API adds support for batching such related input events by disabling the output events generated by Core until the batch is done. The client can then process the resulting events, which will be compressed and deduplicated. Change-Id: Id381dab807186d010021a8778ee440074a739920 Reviewed-on: https://gerrit.libreoffice.org/33402 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx index 302f54d..bfe9954 100644 --- a/desktop/inc/lib/init.hxx +++ b/desktop/inc/lib/init.hxx @@ -41,6 +41,10 @@ namespace desktop { void setEventLatch(const bool bEventLatch) { m_bEventLatch = bEventLatch; + if (!IsActive()) + { + Start(); + } } bool isEventLatchOn() const { return m_bEventLatch; } diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index d29a695..3df7b2e 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -537,6 +537,8 @@ static unsigned char* doc_renderFont(LibreOfficeKitDocument* pThis, int* pFontWidth, int* pFontHeight); static char* doc_getPartHash(LibreOfficeKitDocument* pThis, int nPart); +static void doc_beginBatch(LibreOfficeKitDocument* pThis); +static void doc_endBatch(LibreOfficeKitDocument* pThis); LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent) : mxComponent(xComponent) @@ -583,6 +585,8 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone m_pDocumentClass->renderFont = doc_renderFont; m_pDocumentClass->getPartHash = doc_getPartHash; + m_pDocumentClass->beginBatch = doc_beginBatch; + m_pDocumentClass->endBatch = doc_endBatch; gDocumentClass = m_pDocumentClass; } @@ -2707,6 +2711,28 @@ unsigned char* doc_renderFont(LibreOfficeKitDocument* /*pThis*/, return nullptr; } +static void doc_beginBatch(LibreOfficeKitDocument* pThis) +{ + SolarMutexGuard aGuard; + + LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis); + for (const auto& pair : pDocument->mpCallbackFlushHandlers) + { + pair.second->setEventLatch(true); + } +} + +static void doc_endBatch(LibreOfficeKitDocument* pThis) +{ + SolarMutexGuard aGuard; + + LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis); + for (const auto& pair : pDocument->mpCallbackFlushHandlers) + { + pair.second->setEventLatch(false); + } +} + static char* lo_getError (LibreOfficeKit *pThis) { SolarMutexGuard aGuard; diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index c7a2130..55cff72 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -250,6 +250,16 @@ struct _LibreOfficeKitDocumentClass int* pArray, size_t nSize); + /// Starts a batch of operations. + /// Events are emmitted only after ending the batch. + /// @see lok::Document::endBatch(); + void (*beginBatch) (LibreOfficeKitDocument* pThis); + + /// Ends a batch of operations. + /// @see lok::Document::beginBatch(); + void (*endBatch) (LibreOfficeKitDocument* pThis); + + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index 447f44b..46ecb5f 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -452,6 +452,16 @@ public: return mpDoc->pClass->getViewIds(mpDoc, pArray, nSize); } + inline void beginBatch() + { + mpDoc->pClass->beginBatch(mpDoc); + } + + inline void endBatch() + { + mpDoc->pClass->endBatch(mpDoc); + } + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits