From b8c9163ac8ddfcc3035e95013a34fa0fe2315c80 Mon Sep 17 00:00:00 2001 From: Ashod Nakashian Date: Sun, 27 Nov 2016 21:28:21 -0500 Subject: [PATCH] loolwsd: combine tiles strictly in the same row only Change-Id: I1d2ba647deac8da749e7cf7b56a1c9a19fe840f8 Reviewed-on: https://gerrit.libreoffice.org/31299 Reviewed-by: Ashod Nakashian Tested-by: Ashod Nakashian --- test/TileQueueTests.cpp | 17 ++++++++++------- wsd/DocumentBroker.cpp | 24 +++++++++++++++--------- wsd/TileDesc.hpp | 3 +-- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/test/TileQueueTests.cpp b/test/TileQueueTests.cpp index dea692baa..049146869 100644 --- a/test/TileQueueTests.cpp +++ b/test/TileQueueTests.cpp @@ -109,24 +109,27 @@ void TileQueueTests::testTileCombinedRendering() const std::string resHor = "tilecombine part=0 width=256 height=256 tileposx=0,3840 tileposy=0,0 imgsize=0,0 tilewidth=3840 tileheight=3840"; const TileQueue::Payload payloadHor(resHor.data(), resHor.data() + resHor.size()); - const std::string resVer = "tilecombine part=0 width=256 height=256 tileposx=0,0 tileposy=0,3840 imgsize=0,0 tilewidth=3840 tileheight=3840"; - const TileQueue::Payload payloadVer(resVer.data(), resVer.data() + resVer.size()); - const std::string resFull = "tilecombine part=0 width=256 height=256 tileposx=0,3840,0 tileposy=0,0,3840 imgsize=0,0,0 tilewidth=3840 tileheight=3840"; + const std::string resVer1 = "tile part=0 width=256 height=256 tileposx=0 tileposy=0 tilewidth=3840 tileheight=3840 ver=-1"; + const TileQueue::Payload payloadVer1(resVer1.data(), resVer1.data() + resVer1.size()); + const std::string resVer2 = "tile part=0 width=256 height=256 tileposx=0 tileposy=3840 tilewidth=3840 tileheight=3840 ver=-1"; + const TileQueue::Payload payloadVer2(resVer2.data(), resVer2.data() + resVer2.size()); + const std::string resFull = "tilecombine part=0 width=256 height=256 tileposx=0,3840 tileposy=0,0 imgsize=0,0 tilewidth=3840 tileheight=3840"; const TileQueue::Payload payloadFull(resFull.data(), resFull.data() + resFull.size()); TileQueue queue; - // Horizontal. + // Horizontal - combine both. queue.put(req1); queue.put(req2); CPPUNIT_ASSERT_EQUAL(payloadHor, queue.get()); - // Vertical. + // Vertical - not combined. queue.put(req1); queue.put(req3); - CPPUNIT_ASSERT_EQUAL(payloadVer, queue.get()); + CPPUNIT_ASSERT_EQUAL(payloadVer1, queue.get()); + CPPUNIT_ASSERT_EQUAL(payloadVer2, queue.get()); - // Vertical. + // Vertical - combine first row only. queue.put(req1); queue.put(req2); queue.put(req3); diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 886cf98c2..ed5b7260b 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -591,18 +591,24 @@ size_t DocumentBroker::removeSession(const std::string& id) { Util::assertIsLocked(_mutex); - auto it = _sessions.find(id); - if (it != _sessions.end()) + try { - _sessions.erase(it); + Admin::instance().rmDoc(_docKey, id); - // Let the child know the client has disconnected. - const std::string msg("child-" + id + " disconnect"); - _childProcess->sendTextFrame(msg); + auto it = _sessions.find(id); + if (it != _sessions.end()) + { + _sessions.erase(it); + + // Let the child know the client has disconnected. + const std::string msg("child-" + id + " disconnect"); + _childProcess->sendTextFrame(msg); + } + } + catch (const std::exception& ex) + { + LOG_ERR("Error while removing session [" << id << "]: " << ex.what()); } - - // Lets remove this session from the admin console too - Admin::instance().rmDoc(_docKey, id); return _sessions.size(); } diff --git a/wsd/TileDesc.hpp b/wsd/TileDesc.hpp index 765341d0c..3e124080c 100644 --- a/wsd/TileDesc.hpp +++ b/wsd/TileDesc.hpp @@ -104,8 +104,7 @@ public: return false; } - return other.getTilePosY() + other.getTileHeight() >= getTilePosY() && - other.getTilePosY() <= getTilePosY() + getTileHeight(); + return other.getTilePosY() == getTilePosY(); } /// Serialize this instance into a string.