[Libreoffice-commits] online.git: loolwsd/DocumentBroker.cpp

Michael Meeks michael at linux.site
Wed Sep 14 21:19:38 UTC 2016


 loolwsd/DocumentBroker.cpp |   29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

New commits:
commit 787ee1d2d2719f4fed161dd66eb7d3e21c512bd3
Author: Michael Meeks <michael at linux.site>
Date:   Wed Sep 14 22:15:43 2016 +0100

    Revert "loolwsd: don't combine tiles by row to allow for better culling"
    
    This breaks combine-tiles very significantly, viewing images
    in documents with this appears to show each tile scaling and
    rendering individually.
    
    This reverts commit 99d0ee2ac111e7199626f6c17fb7ce723dac9126.

diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index fe73d63..043218f 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -532,7 +532,8 @@ void DocumentBroker::handleTileCombinedRequest(TileCombined& tileCombined,
     Log::trace() << "TileCombined request for " << tileCombined.serialize() << Log::end;
 
     // Satisfy as many tiles from the cache.
-    std::vector<TileDesc> tiles;
+    // The rest, group by rows.
+    std::map<int, std::vector<TileDesc>> rows;
     for (auto& tile : tileCombined.getTiles())
     {
         std::unique_ptr<std::fstream> cachedTile = _tileCache->lookupTile(tile);
@@ -586,16 +587,34 @@ void DocumentBroker::handleTileCombinedRequest(TileCombined& tileCombined,
             }
         }
 
-        tiles.push_back(tile);
+        const auto tilePosY = tile.getTilePosY();
+        auto it = rows.lower_bound(tilePosY);
+        if (it != rows.end())
+        {
+            it->second.emplace_back(tile);
+        }
+        else
+        {
+            rows.emplace_hint(it, tilePosY, std::vector<TileDesc>({ tile }));
+        }
     }
 
-    for (auto& tile : tiles)
+    if (rows.empty())
     {
-        const auto tileMsg = tile.serialize("tile ");
+        // Done.
+        return;
+    }
+
+    auto& tiles = tileCombined.getTiles();
+    for (auto& row : rows)
+    {
+        tiles = row.second;
+        const auto tileMsg = tileCombined.serialize();
         Log::debug() << "TileCombined residual request for " << tileMsg << Log::end;
 
         // Forward to child to render.
-        _childProcess->getWebSocket()->sendFrame(tileMsg.data(), tileMsg.size());
+        const std::string request = "tilecombine " + tileMsg;
+        _childProcess->getWebSocket()->sendFrame(request.data(), request.size());
     }
 }
 


More information about the Libreoffice-commits mailing list