[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - kit/ChildSession.cpp kit/ChildSession.hpp

Jan Holesovsky kendy at collabora.com
Mon Apr 24 18:09:00 UTC 2017


 kit/ChildSession.cpp |   48 +++++++++++++++++++++++++++++++-----------------
 kit/ChildSession.hpp |   12 ++++++++++++
 2 files changed, 43 insertions(+), 17 deletions(-)

New commits:
commit 35bd504c6d3b3b71bac4cdcaf71bf994ed8d7765
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Mon Apr 24 19:19:18 2017 +0200

    inactive: Invalidate tiles when we return back to the active state.
    
    Change-Id: Ib97d6463c52ecf153d3c19ab7efc47d99b71ce9b
    Reviewed-on: https://gerrit.libreoffice.org/36906
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 373d451f..8b01a517 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -117,15 +117,24 @@ bool ChildSession::_handleInput(const char *buffer, int length)
             sendTextFrame("setpart: part=" + std::to_string(curPart));
         }
 
+        // Invalidate if we have to
+        // TODO instead just a "_invalidate" flag, we should remember / grow
+        // the rectangle to invalidate; invalidating everything is sub-optimal
+        if (_stateRecorder._invalidate)
+        {
+            std::string payload = "0, 0, " + std::to_string(INT_MAX) + ", " + std::to_string(INT_MAX) + ", " + std::to_string(curPart);
+            loKitCallback(LOK_CALLBACK_INVALIDATE_TILES, payload);
+        }
+
         for (const auto& viewPair : _stateRecorder._recordedViewEvents)
         {
-                for (const auto& eventPair : viewPair.second)
-                {
-                    const RecordedEvent& event = eventPair.second;
-                    LOG_TRC("Replaying missed view event: " <<  viewPair.first << " " << LOKitHelper::kitCallbackTypeToString(event._type)
-                                                            << ": " << event._payload);
-                    loKitCallback(event._type, event._payload);
-                }
+            for (const auto& eventPair : viewPair.second)
+            {
+                const RecordedEvent& event = eventPair.second;
+                LOG_TRC("Replaying missed view event: " <<  viewPair.first << " " << LOKitHelper::kitCallbackTypeToString(event._type)
+                                                        << ": " << event._payload);
+                loKitCallback(event._type, event._payload);
+            }
         }
 
         for (const auto& eventPair : _stateRecorder._recordedEvents)
@@ -971,16 +980,21 @@ bool ChildSession::setPage(const char* /*buffer*/, int /*length*/, const std::ve
  */
 void ChildSession::rememberEventsForInactiveUser(const int type, const std::string& payload)
 {
-    if (type == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR ||
-        type == LOK_CALLBACK_CURSOR_VISIBLE ||
-        type == LOK_CALLBACK_TEXT_SELECTION ||
-        type == LOK_CALLBACK_TEXT_SELECTION_START ||
-        type == LOK_CALLBACK_TEXT_SELECTION_END ||
-        type == LOK_CALLBACK_CELL_FORMULA ||
-        type == LOK_CALLBACK_CELL_CURSOR ||
-        type == LOK_CALLBACK_GRAPHIC_SELECTION ||
-        type == LOK_CALLBACK_DOCUMENT_SIZE_CHANGED ||
-        type == LOK_CALLBACK_INVALIDATE_HEADER)
+    if (type == LOK_CALLBACK_INVALIDATE_TILES)
+    {
+        auto lock(getLock());
+        _stateRecorder.recordInvalidate(); // TODO remember the area, not just a bool ('true' invalidates everything)
+    }
+    else if (type == LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR ||
+             type == LOK_CALLBACK_CURSOR_VISIBLE ||
+             type == LOK_CALLBACK_TEXT_SELECTION ||
+             type == LOK_CALLBACK_TEXT_SELECTION_START ||
+             type == LOK_CALLBACK_TEXT_SELECTION_END ||
+             type == LOK_CALLBACK_CELL_FORMULA ||
+             type == LOK_CALLBACK_CELL_CURSOR ||
+             type == LOK_CALLBACK_GRAPHIC_SELECTION ||
+             type == LOK_CALLBACK_DOCUMENT_SIZE_CHANGED ||
+             type == LOK_CALLBACK_INVALIDATE_HEADER)
     {
         auto lock(getLock());
         _stateRecorder.recordEvent(type, payload);
diff --git a/kit/ChildSession.hpp b/kit/ChildSession.hpp
index ce47ed4c..c0279488 100644
--- a/kit/ChildSession.hpp
+++ b/kit/ChildSession.hpp
@@ -66,13 +66,23 @@ struct RecordedEvent
     std::string _payload;
 };
 
+/// When the session is inactive, we need to record its state for a replay.
 class StateRecorder
 {
 public:
+    bool _invalidate;
     std::unordered_map<std::string, std::string> _recordedStates;
     std::unordered_map<int, std::unordered_map<int, RecordedEvent>> _recordedViewEvents;
     std::unordered_map<int, RecordedEvent> _recordedEvents;
 
+    StateRecorder() : _invalidate(false) {}
+
+    // TODO Remember the maximal area we need to invalidate - grow it step by step.
+    void recordInvalidate()
+    {
+        _invalidate = true;
+    }
+
     void recordEvent(const int type, const std::string& payload)
     {
         _recordedEvents[type] = {type, payload};
@@ -90,8 +100,10 @@ public:
 
     void clear()
     {
+        _invalidate = false;
         _recordedEvents.clear();
         _recordedViewEvents.clear();
+        _recordedStates.clear();
     }
 };
 


More information about the Libreoffice-commits mailing list