summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2017-01-06 10:48:18 -0500
committerAshod Nakashian <ashnakash@gmail.com>2017-01-23 03:23:19 +0000
commit1c27286b9d5331634c073cd3e327bd941e61bbb6 (patch)
treea80286f43ddab83e79bfc3b1c720c36e20e80fb3
parentd9cfbabc7fe13752daf02e2a8cfa38c72a30fb29 (diff)
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 <ci@libreoffice.org> Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
-rw-r--r--desktop/inc/lib/init.hxx4
-rw-r--r--desktop/source/lib/init.cxx26
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h10
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx10
4 files changed, 50 insertions, 0 deletions
diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index 302f54de5391..bfe9954c3308 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 d29a6950c301..3df7b2eda5d8 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 c7a2130315da..55cff727776c 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 447f44b09885..46ecb5f40d3f 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
};