desktop/inc/lib/init.hxx | 84 +++++++++++++++++++++++- desktop/qa/desktop_lib/test_desktop_lib.cxx | 95 ++++++++++++++-------------- desktop/source/lib/init.cxx | 52 +++++++++++++++ include/LibreOfficeKit/LibreOfficeKit.h | 13 +++ include/LibreOfficeKit/LibreOfficeKit.hxx | 21 ++++++ 5 files changed, 215 insertions(+), 50 deletions(-)
New commits: commit 81d866a78d33dfc483b004b0cfc783a3d9005592 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sun May 8 12:02:54 2016 -0400 LOK: drop identical invalidation notifications And drop duplicate GRAPHIC_SELECTION notifications. (cherry picked from commit 7cdfe080432f69c2247cc7ff28316b653bd654ff) Change-Id: I0c372efa9a58620e24cea219d82479cdc9dff359 Reviewed-on: https://gerrit.libreoffice.org/24771 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx index 933b9e6..c0a4462 100644 --- a/desktop/inc/lib/init.hxx +++ b/desktop/inc/lib/init.hxx @@ -43,6 +43,7 @@ namespace desktop { m_states.emplace(LOK_CALLBACK_TEXT_SELECTION_START, "NIL"); m_states.emplace(LOK_CALLBACK_TEXT_SELECTION_END, "NIL"); m_states.emplace(LOK_CALLBACK_TEXT_SELECTION, "NIL"); + m_states.emplace(LOK_CALLBACK_GRAPHIC_SELECTION, "NIL"); m_states.emplace(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, "NIL"); m_states.emplace(LOK_CALLBACK_STATE_CHANGED, "NIL"); m_states.emplace(LOK_CALLBACK_MOUSE_POINTER, "NIL"); @@ -85,7 +86,6 @@ namespace desktop { return; } - const std::string payload(data ? data : "(nil)"); std::unique_lock<std::mutex> lock(m_mutex); @@ -124,13 +124,14 @@ namespace desktop { case LOK_CALLBACK_TEXT_SELECTION_START: case LOK_CALLBACK_TEXT_SELECTION_END: case LOK_CALLBACK_TEXT_SELECTION: + case LOK_CALLBACK_GRAPHIC_SELECTION: case LOK_CALLBACK_MOUSE_POINTER: case LOK_CALLBACK_CELL_CURSOR: case LOK_CALLBACK_CELL_FORMULA: case LOK_CALLBACK_CURSOR_VISIBLE: case LOK_CALLBACK_SET_PART: case LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE: - removeAllButLast(type); + removeAllButLast(type, false); break; // These come with rects, so drop earlier @@ -139,10 +140,15 @@ namespace desktop { case LOK_CALLBACK_INVALIDATE_TILES: if (payload.empty()) { - // Invalidating everything means previous + // Invalidating everything means previously // invalidated tiles can be dropped. - removeAllButLast(type); + removeAllButLast(type, false); + } + else + { + removeAllButLast(type, true); } + break; } @@ -171,23 +177,26 @@ namespace desktop { } } - void removeAllButLast(const int type) + void removeAllButLast(const int type, const bool identical) { int i = m_queue.size() - 1; + std::string payload; for (; i >= 0; --i) { if (m_queue[i].first == type) { - //SAL_WARN("idle", "Found [" + std::to_string(type) + "] at " + std::to_string(i)); + payload = m_queue[i].second; + //SAL_WARN("idle", "Found [" + std::to_string(type) + "] at " + std::to_string(i) + ": [" + payload + "]."); break; } } for (--i; i >= 0; --i) { - if (m_queue[i].first == type) + if (m_queue[i].first == type && + (!identical || m_queue[i].second == payload)) { - //SAL_WARN("idle", "Removing [" + std::to_string(type) + "] at " + std::to_string(i)); + //SAL_WARN("idle", "Removing [" + std::to_string(type) + "] at " + std::to_string(i) + ": " + m_queue[i].second + "]."); m_queue.erase(m_queue.begin() + i); } } diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index f20835d..905325d 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -1279,7 +1279,7 @@ void DesktopLOKTest::testNotificationCompression() handler->queue(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, ""); // 0 handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15 25 15 10"); // Superseeded. handler->queue(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, ""); // Should be dropped. - handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15 25 15 10"); // 1 + handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15 25 15 10"); // Superseeded. handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15 25 15 10"); // Should be dropped. handler->queue(LOK_CALLBACK_TEXT_SELECTION, ""); // Superseeded. handler->queue(LOK_CALLBACK_STATE_CHANGED, ""); // 2 @@ -1308,15 +1308,12 @@ void DesktopLOKTest::testNotificationCompression() Scheduler::ProcessEventsToIdle(); - CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(14), notifs.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(13), notifs.size()); size_t i = 0; CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, (int)std::get<0>(notifs[i])); CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[i++])); - CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_TILES, (int)std::get<0>(notifs[i])); - CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[i++])); - CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_STATE_CHANGED, (int)std::get<0>(notifs[i])); CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[i++])); commit e394a8eab65c65e5ce377950ccaad8964ca6bdc3 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sat May 7 16:31:38 2016 -0400 LOK: SAL_WARN for each removed event is unnecessary Change-Id: If5e4c7b8751ae4eeb278475fb00118e32c6bb565 Reviewed-on: https://gerrit.libreoffice.org/24730 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx index 3f962ba..933b9e6 100644 --- a/desktop/inc/lib/init.hxx +++ b/desktop/inc/lib/init.hxx @@ -178,7 +178,7 @@ namespace desktop { { if (m_queue[i].first == type) { - SAL_WARN("idle", "Found [" + std::to_string(type) + "] at " + std::to_string(i)); + //SAL_WARN("idle", "Found [" + std::to_string(type) + "] at " + std::to_string(i)); break; } } @@ -187,7 +187,7 @@ namespace desktop { { if (m_queue[i].first == type) { - SAL_WARN("idle", "Removing [" + std::to_string(type) + "] at " + std::to_string(i)); + //SAL_WARN("idle", "Removing [" + std::to_string(type) + "] at " + std::to_string(i)); m_queue.erase(m_queue.begin() + i); } } commit 755827016d0fffaffd155806c378b5d972ac9016 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Fri May 6 11:01:42 2016 -0400 Don't change part on text documents to paint tiles Change-Id: Icb5fb46cbc9d2f72c814cf9f1f166382493d403f Reviewed-on: https://gerrit.libreoffice.org/24702 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> (cherry picked from commit aadab5f4a72e38ccc8bbe9b7811d2cdcaa00124c) diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index ed48935..460157b 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1052,15 +1052,21 @@ void doc_paintPartTile(LibreOfficeKitDocument* pThis, pDocument->mpCallbackFlushHandler->setPartTilePainting(true); try { - const int nOrigPart = doc_getPart(pThis); - if (nPart != nOrigPart) + // Text documents have a single coordinate system; don't change part. + int nOrigPart = 0; + const bool isText = (doc_getDocumentType(pThis) == LOK_DOCTYPE_TEXT); + if (!isText) { - doc_setPart(pThis, nPart); + nOrigPart = doc_getPart(pThis); + if (nPart != nOrigPart) + { + doc_setPart(pThis, nPart); + } } doc_paintTile(pThis, pBuffer, nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight); - if (nPart != nOrigPart) + if (!isText && nPart != nOrigPart) { doc_setPart(pThis, nOrigPart); } commit 70e8e788beb122b5779693ecece8f65e27192256 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Fri May 6 08:16:00 2016 -0400 Allow painting for arbitrary part Painting should not cause any state changes, but to paint a tile on a different part than the current has to change the document, which sends notifications to all clients. A new API, paintPartTile, allows for painting tiles on any part without sending change of part notifications. Furthermore, because we block notifications during this operation, no tile invalidation is issued due to changing of the part. One issue remains in the cases when the LO Core resets the cursor position internally and we resume editing after painting, the cursor might be at the top of the page. This needs fixing separately. Change-Id: If19bd1c90ecad4d5ed5e8d09513741b7994fa6e5 Reviewed-on: https://gerrit.libreoffice.org/24698 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx index 315f566..3f962ba 100644 --- a/desktop/inc/lib/init.hxx +++ b/desktop/inc/lib/init.hxx @@ -33,7 +33,8 @@ namespace desktop { explicit CallbackFlushHandler(LibreOfficeKitCallback pCallback, void* pData) : Idle( "lokit timer callback" ), m_pCallback(pCallback), - m_pData(pData) + m_pData(pData), + m_bPartTilePainting(false) { SetPriority(SchedulerPriority::POST_PAINT); @@ -78,6 +79,13 @@ namespace desktop { void queue(const int type, const char* data) { + if (m_bPartTilePainting) + { + // We drop notifications when this is set. + return; + } + + const std::string payload(data ? data : "(nil)"); std::unique_lock<std::mutex> lock(m_mutex); @@ -145,6 +153,9 @@ namespace desktop { } } + void setPartTilePainting(const bool bPartPainting) { m_bPartTilePainting = bPartPainting; } + bool isPartTilePainting() const { return m_bPartTilePainting; } + private: void flush() { @@ -187,6 +198,7 @@ namespace desktop { std::map<int, std::string> m_states; LibreOfficeKitCallback m_pCallback; void *m_pData; + bool m_bPartTilePainting; std::mutex m_mutex; }; diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 554a4f4..ed48935 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -310,6 +310,12 @@ void doc_paintTile(LibreOfficeKitDocument* pThis, const int nCanvasWidth, const int nCanvasHeight, const int nTilePosX, const int nTilePosY, const int nTileWidth, const int nTileHeight); +void doc_paintPartTile(LibreOfficeKitDocument* pThis, + unsigned char* pBuffer, + const int nPart, + const int nCanvasWidth, const int nCanvasHeight, + const int nTilePosX, const int nTilePosY, + const int nTileWidth, const int nTileHeight); static int doc_getTileMode(LibreOfficeKitDocument* pThis); static void doc_getDocumentSize(LibreOfficeKitDocument* pThis, long* pWidth, @@ -388,6 +394,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone m_pDocumentClass->getPartName = doc_getPartName; m_pDocumentClass->setPartMode = doc_setPartMode; m_pDocumentClass->paintTile = doc_paintTile; + m_pDocumentClass->paintPartTile = doc_paintPartTile; m_pDocumentClass->getTileMode = doc_getTileMode; m_pDocumentClass->getDocumentSize = doc_getDocumentSize; m_pDocumentClass->initializeForRendering = doc_initializeForRendering; @@ -1027,6 +1034,45 @@ void doc_paintTile(LibreOfficeKitDocument* pThis, #endif } + +void doc_paintPartTile(LibreOfficeKitDocument* pThis, + unsigned char* pBuffer, + const int nPart, + const int nCanvasWidth, const int nCanvasHeight, + const int nTilePosX, const int nTilePosY, + const int nTileWidth, const int nTileHeight) +{ + SAL_INFO( "lok.tiledrendering", "paintPartTile: painting @ " << nPart << " [" + << nTileWidth << "x" << nTileHeight << "]@(" + << nTilePosX << ", " << nTilePosY << ") to [" + << nCanvasWidth << "x" << nCanvasHeight << "]px" ); + + // Disable callbacks while we are painting. + LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis); + pDocument->mpCallbackFlushHandler->setPartTilePainting(true); + try + { + const int nOrigPart = doc_getPart(pThis); + if (nPart != nOrigPart) + { + doc_setPart(pThis, nPart); + } + + doc_paintTile(pThis, pBuffer, nCanvasWidth, nCanvasHeight, nTilePosX, nTilePosY, nTileWidth, nTileHeight); + + if (nPart != nOrigPart) + { + doc_setPart(pThis, nOrigPart); + } + } + catch (const std::exception& exception) + { + // Nothing to do but restore the PartTilePainting flag. + } + + pDocument->mpCallbackFlushHandler->setPartTilePainting(false); +} + static int doc_getTileMode(LibreOfficeKitDocument* /*pThis*/) { return LOK_TILEMODE_BGRA; diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index 1281a21..110d4d5 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -228,6 +228,19 @@ struct _LibreOfficeKitDocumentClass /// @see lok::Document::getPartHash(). char* (*getPartHash) (LibreOfficeKitDocument* pThis, int nPart); + + /// Paints a tile from a specific part. + /// @see lok::Document::paintTile(). + void (*paintPartTile) (LibreOfficeKitDocument* pThis, + unsigned char* pBuffer, + const int nPart, + const int nCanvasWidth, + const int nCanvasHeight, + const int nTilePosX, + const int nTilePosY, + const int nTileWidth, + const int nTileHeight); + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index 3e3a0e1..7969ed5 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -414,6 +414,27 @@ public: return mpDoc->pClass->renderFont(mpDoc, pFontName, pFontWidth, pFontHeight); } + /** + * Renders a subset of the document's part to a pre-allocated buffer. + * + * @param nPart the part number of the document of which the tile is painted. + * @see paintTile. + */ + inline void paintPartTile(unsigned char* pBuffer, + const int nPart, + const int nCanvasWidth, + const int nCanvasHeight, + const int nTilePosX, + const int nTilePosY, + const int nTileWidth, + const int nTileHeight) + { + return mpDoc->pClass->paintPartTile(mpDoc, pBuffer, nPart, + nCanvasWidth, nCanvasHeight, + nTilePosX, nTilePosY, + nTileWidth, nTileHeight); + } + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; commit bc990b011a928ab55b42361415c6eeb5cb9d172c Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sat Apr 30 14:29:37 2016 -0400 Some LOK notifications are dropped if they are superseeded by later ones Change-Id: I323e46a2a6c60b200b182b89199945f99a7f384a Reviewed-on: https://gerrit.libreoffice.org/24567 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> (cherry picked from commit cf98799fff7ae999bd62cec6486c986bf44000cc) diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx index 66811e4..315f566 100644 --- a/desktop/inc/lib/init.hxx +++ b/desktop/inc/lib/init.hxx @@ -109,6 +109,35 @@ namespace desktop { m_queue.emplace_back(type, payload); + // These are safe to use the latest state and ignore previous + // ones (if any) since the last overrides previous ones. + switch (type) + { + case LOK_CALLBACK_TEXT_SELECTION_START: + case LOK_CALLBACK_TEXT_SELECTION_END: + case LOK_CALLBACK_TEXT_SELECTION: + case LOK_CALLBACK_MOUSE_POINTER: + case LOK_CALLBACK_CELL_CURSOR: + case LOK_CALLBACK_CELL_FORMULA: + case LOK_CALLBACK_CURSOR_VISIBLE: + case LOK_CALLBACK_SET_PART: + case LOK_CALLBACK_STATUS_INDICATOR_SET_VALUE: + removeAllButLast(type); + break; + + // These come with rects, so drop earlier + // only when the latter includes former ones. + case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR: + case LOK_CALLBACK_INVALIDATE_TILES: + if (payload.empty()) + { + // Invalidating everything means previous + // invalidated tiles can be dropped. + removeAllButLast(type); + } + break; + } + lock.unlock(); if (!IsActive()) { @@ -131,6 +160,28 @@ namespace desktop { } } + void removeAllButLast(const int type) + { + int i = m_queue.size() - 1; + for (; i >= 0; --i) + { + if (m_queue[i].first == type) + { + SAL_WARN("idle", "Found [" + std::to_string(type) + "] at " + std::to_string(i)); + break; + } + } + + for (--i; i >= 0; --i) + { + if (m_queue[i].first == type) + { + SAL_WARN("idle", "Removing [" + std::to_string(type) + "] at " + std::to_string(i)); + m_queue.erase(m_queue.begin() + i); + } + } + } + private: std::vector<std::pair<int, std::string>> m_queue; std::map<int, std::string> m_states; diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 7f1d97b..f20835d 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -1277,95 +1277,81 @@ void DesktopLOKTest::testNotificationCompression() std::unique_ptr<CallbackFlushHandler> handler(new CallbackFlushHandler(callbackCompressionTest, ¬ifs)); handler->queue(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, ""); // 0 - handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15 25 15 10"); // 1 + handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15 25 15 10"); // Superseeded. handler->queue(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, ""); // Should be dropped. - handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15 25 15 10"); // 2 + handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15 25 15 10"); // 1 handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15 25 15 10"); // Should be dropped. - handler->queue(LOK_CALLBACK_TEXT_SELECTION, ""); // 3 + handler->queue(LOK_CALLBACK_TEXT_SELECTION, ""); // Superseeded. + handler->queue(LOK_CALLBACK_STATE_CHANGED, ""); // 2 + handler->queue(LOK_CALLBACK_STATE_CHANGED, ".uno:Bold"); // 3 handler->queue(LOK_CALLBACK_STATE_CHANGED, ""); // 4 - handler->queue(LOK_CALLBACK_STATE_CHANGED, ".uno:Bold"); // 5 - handler->queue(LOK_CALLBACK_STATE_CHANGED, ""); // 6 - handler->queue(LOK_CALLBACK_MOUSE_POINTER, "text"); // 7 - handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15 25 15 10"); // 8 + handler->queue(LOK_CALLBACK_MOUSE_POINTER, "text"); // 5 + handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15 25 15 10"); // 6 handler->queue(LOK_CALLBACK_INVALIDATE_TILES, "15 25 15 10"); // Should be dropped. handler->queue(LOK_CALLBACK_MOUSE_POINTER, "text"); // Should be dropped. - handler->queue(LOK_CALLBACK_TEXT_SELECTION_START, "15 25 15 10"); // 9 - handler->queue(LOK_CALLBACK_TEXT_SELECTION_END, "15 25 15 10"); // 10 - handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15 25 15 10"); // 11 + handler->queue(LOK_CALLBACK_TEXT_SELECTION_START, "15 25 15 10"); // Superseeded. + handler->queue(LOK_CALLBACK_TEXT_SELECTION_END, "15 25 15 10"); // Superseeded. + handler->queue(LOK_CALLBACK_TEXT_SELECTION, "15 25 15 10"); // Superseedd. handler->queue(LOK_CALLBACK_TEXT_SELECTION_START, "15 25 15 10"); // Should be dropped. handler->queue(LOK_CALLBACK_TEXT_SELECTION_END, "15 25 15 10"); // Should be dropped. - handler->queue(LOK_CALLBACK_TEXT_SELECTION, ""); // 12 - handler->queue(LOK_CALLBACK_TEXT_SELECTION_START, "15 25 15 10"); // 13 - handler->queue(LOK_CALLBACK_TEXT_SELECTION_END, "15 25 15 10"); // 14 - handler->queue(LOK_CALLBACK_CELL_CURSOR, "15 25 15 10"); // 15 - handler->queue(LOK_CALLBACK_CURSOR_VISIBLE, ""); // 16 + handler->queue(LOK_CALLBACK_TEXT_SELECTION, ""); // 7 + handler->queue(LOK_CALLBACK_TEXT_SELECTION_START, "15 25 15 10"); // 8 + handler->queue(LOK_CALLBACK_TEXT_SELECTION_END, "15 25 15 10"); // 9 + handler->queue(LOK_CALLBACK_CELL_CURSOR, "15 25 15 10"); // 10 + handler->queue(LOK_CALLBACK_CURSOR_VISIBLE, ""); // 11 handler->queue(LOK_CALLBACK_CELL_CURSOR, "15 25 15 10"); // Should be dropped. - handler->queue(LOK_CALLBACK_CELL_FORMULA, "blah"); // 17 - handler->queue(LOK_CALLBACK_SET_PART, "1"); // 18 + handler->queue(LOK_CALLBACK_CELL_FORMULA, "blah"); // 12 + handler->queue(LOK_CALLBACK_SET_PART, "1"); // 13 handler->queue(LOK_CALLBACK_CURSOR_VISIBLE, ""); // Should be dropped. handler->queue(LOK_CALLBACK_CELL_FORMULA, "blah"); // Should be dropped. handler->queue(LOK_CALLBACK_SET_PART, "1"); // Should be dropped. Scheduler::ProcessEventsToIdle(); - CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(19), notifs.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(14), notifs.size()); - CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, (int)std::get<0>(notifs[0])); - CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[0])); + size_t i = 0; + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, (int)std::get<0>(notifs[i])); + CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[i++])); - CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION, (int)std::get<0>(notifs[1])); - CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[1])); + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_TILES, (int)std::get<0>(notifs[i])); + CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[i++])); - CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_TILES, (int)std::get<0>(notifs[2])); - CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[2])); + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_STATE_CHANGED, (int)std::get<0>(notifs[i])); + CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[i++])); - CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION, (int)std::get<0>(notifs[3])); - CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[3])); + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_STATE_CHANGED, (int)std::get<0>(notifs[i])); + CPPUNIT_ASSERT_EQUAL(std::string(".uno:Bold"), std::get<1>(notifs[i++])); - CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_STATE_CHANGED, (int)std::get<0>(notifs[4])); - CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[4])); + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_STATE_CHANGED, (int)std::get<0>(notifs[i])); + CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[i++])); - CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_STATE_CHANGED, (int)std::get<0>(notifs[5])); - CPPUNIT_ASSERT_EQUAL(std::string(".uno:Bold"), std::get<1>(notifs[5])); + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_MOUSE_POINTER, (int)std::get<0>(notifs[i])); + CPPUNIT_ASSERT_EQUAL(std::string("text"), std::get<1>(notifs[i++])); - CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_STATE_CHANGED, (int)std::get<0>(notifs[6])); - CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[6])); + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_TILES, (int)std::get<0>(notifs[i])); + CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[i++])); - CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_MOUSE_POINTER, (int)std::get<0>(notifs[7])); - CPPUNIT_ASSERT_EQUAL(std::string("text"), std::get<1>(notifs[7])); + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION, (int)std::get<0>(notifs[i])); + CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[i++])); - CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_TILES, (int)std::get<0>(notifs[8])); - CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[8])); + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION_START, (int)std::get<0>(notifs[i])); + CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[i++])); - CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION_START, (int)std::get<0>(notifs[9])); - CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[9])); + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION_END, (int)std::get<0>(notifs[i])); + CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[i++])); - CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION_END, (int)std::get<0>(notifs[10])); - CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[10])); + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_CELL_CURSOR, (int)std::get<0>(notifs[i])); + CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[i++])); - CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION, (int)std::get<0>(notifs[11])); - CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[11])); + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_CURSOR_VISIBLE, (int)std::get<0>(notifs[i])); + CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[i++])); - CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION, (int)std::get<0>(notifs[12])); - CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[12])); + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_CELL_FORMULA, (int)std::get<0>(notifs[i])); + CPPUNIT_ASSERT_EQUAL(std::string("blah"), std::get<1>(notifs[i++])); - CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION_START, (int)std::get<0>(notifs[13])); - CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[13])); - - CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION_END, (int)std::get<0>(notifs[14])); - CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[14])); - - CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_CELL_CURSOR, (int)std::get<0>(notifs[15])); - CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[15])); - - CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_CURSOR_VISIBLE, (int)std::get<0>(notifs[16])); - CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[16])); - - CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_CELL_FORMULA, (int)std::get<0>(notifs[17])); - CPPUNIT_ASSERT_EQUAL(std::string("blah"), std::get<1>(notifs[17])); - - CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_SET_PART, (int)std::get<0>(notifs[18])); - CPPUNIT_ASSERT_EQUAL(std::string("1"), std::get<1>(notifs[18])); + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_SET_PART, (int)std::get<0>(notifs[i])); + CPPUNIT_ASSERT_EQUAL(std::string("1"), std::get<1>(notifs[i++])); } CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); commit fda7a716a782f95f89d8b2b980e0b67058d7fec8 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sat Apr 30 12:48:52 2016 -0400 std::tuple -> std::pair Change-Id: I2f11436a5c9691c2a0aac3655bc2c543d1c3d684 Reviewed-on: https://gerrit.libreoffice.org/24566 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> (cherry picked from commit 8a6dab5da851f38a8ecef633e06e3cb2ac5e7849) diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx index 6206f05..66811e4 100644 --- a/desktop/inc/lib/init.hxx +++ b/desktop/inc/lib/init.hxx @@ -94,7 +94,7 @@ namespace desktop { } if (type == LOK_CALLBACK_INVALIDATE_TILES && - !m_queue.empty() && std::get<0>(m_queue.back()) == type && std::get<1>(m_queue.back()) == payload) + !m_queue.empty() && m_queue.back().first == type && m_queue.back().second == payload) { // Supress duplicate invalidation only when they are in sequence. return; @@ -124,7 +124,7 @@ namespace desktop { std::unique_lock<std::mutex> lock(m_mutex); for (auto& pair : m_queue) { - m_pCallback(std::get<0>(pair), std::get<1>(pair).c_str(), m_pData); + m_pCallback(pair.first, pair.second.c_str(), m_pData); } m_queue.clear(); @@ -132,7 +132,7 @@ namespace desktop { } private: - std::vector<std::tuple<int, std::string>> m_queue; + std::vector<std::pair<int, std::string>> m_queue; std::map<int, std::string> m_states; LibreOfficeKitCallback m_pCallback; void *m_pData; commit 840e979757d7d9d7104f54269271c617b9b8d473 Author: Ashod Nakashian <ashod.nakash...@collabora.co.uk> Date: Sat Apr 30 10:55:23 2016 -0400 More LOK callback notification compression SET_PART, CELL_CURSOR, CELL_FORMULA, and CURSOR_VISIBLE are now deduplicated. Change-Id: I4c17307c6f8b7c68bdfe55b4e90da4d34c55d085 Reviewed-on: https://gerrit.libreoffice.org/24565 Reviewed-by: Ashod Nakashian <ashnak...@gmail.com> Tested-by: Ashod Nakashian <ashnak...@gmail.com> (cherry picked from commit a9771e1f4d0d2602713983ab1f3e743784e9ae72) diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx index 7cf81e3..6206f05 100644 --- a/desktop/inc/lib/init.hxx +++ b/desktop/inc/lib/init.hxx @@ -45,6 +45,10 @@ namespace desktop { m_states.emplace(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, "NIL"); m_states.emplace(LOK_CALLBACK_STATE_CHANGED, "NIL"); m_states.emplace(LOK_CALLBACK_MOUSE_POINTER, "NIL"); + m_states.emplace(LOK_CALLBACK_CELL_CURSOR, "NIL"); + m_states.emplace(LOK_CALLBACK_CELL_FORMULA, "NIL"); + m_states.emplace(LOK_CALLBACK_CURSOR_VISIBLE, "NIL"); + m_states.emplace(LOK_CALLBACK_SET_PART, "NIL"); Start(); } diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 6beb0e7..7f1d97b 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -1297,10 +1297,18 @@ void DesktopLOKTest::testNotificationCompression() handler->queue(LOK_CALLBACK_TEXT_SELECTION, ""); // 12 handler->queue(LOK_CALLBACK_TEXT_SELECTION_START, "15 25 15 10"); // 13 handler->queue(LOK_CALLBACK_TEXT_SELECTION_END, "15 25 15 10"); // 14 + handler->queue(LOK_CALLBACK_CELL_CURSOR, "15 25 15 10"); // 15 + handler->queue(LOK_CALLBACK_CURSOR_VISIBLE, ""); // 16 + handler->queue(LOK_CALLBACK_CELL_CURSOR, "15 25 15 10"); // Should be dropped. + handler->queue(LOK_CALLBACK_CELL_FORMULA, "blah"); // 17 + handler->queue(LOK_CALLBACK_SET_PART, "1"); // 18 + handler->queue(LOK_CALLBACK_CURSOR_VISIBLE, ""); // Should be dropped. + handler->queue(LOK_CALLBACK_CELL_FORMULA, "blah"); // Should be dropped. + handler->queue(LOK_CALLBACK_SET_PART, "1"); // Should be dropped. Scheduler::ProcessEventsToIdle(); - CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(15), notifs.size()); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(19), notifs.size()); CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, (int)std::get<0>(notifs[0])); CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[0])); @@ -1346,6 +1354,18 @@ void DesktopLOKTest::testNotificationCompression() CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_TEXT_SELECTION_END, (int)std::get<0>(notifs[14])); CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[14])); + + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_CELL_CURSOR, (int)std::get<0>(notifs[15])); + CPPUNIT_ASSERT_EQUAL(std::string("15 25 15 10"), std::get<1>(notifs[15])); + + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_CURSOR_VISIBLE, (int)std::get<0>(notifs[16])); + CPPUNIT_ASSERT_EQUAL(std::string(""), std::get<1>(notifs[16])); + + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_CELL_FORMULA, (int)std::get<0>(notifs[17])); + CPPUNIT_ASSERT_EQUAL(std::string("blah"), std::get<1>(notifs[17])); + + CPPUNIT_ASSERT_EQUAL((int)LOK_CALLBACK_SET_PART, (int)std::get<0>(notifs[18])); + CPPUNIT_ASSERT_EQUAL(std::string("1"), std::get<1>(notifs[18])); } CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits