[Libreoffice-commits] online.git: Branch 'feature/latency' - wsd/ClientSession.hpp wsd/DocumentBroker.cpp
Tamás Zolnai
tamas.zolnai at collabora.com
Thu Jul 5 12:40:58 UTC 2018
wsd/ClientSession.hpp | 4 ++++
wsd/DocumentBroker.cpp | 13 +++++++++++--
2 files changed, 15 insertions(+), 2 deletions(-)
New commits:
commit 7acf86c53008e00d09229e777c97e8d73d61c6fc
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date: Thu Jul 5 14:40:28 2018 +0200
Calculate TilesOnFly limit based on visible area
Use 10 as a minimum value.
Change-Id: I9442a427fd25e1a7a32c3d1d06aa34d2c4ca2472
diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp
index 5b3e62bc3..92589ea6b 100644
--- a/wsd/ClientSession.hpp
+++ b/wsd/ClientSession.hpp
@@ -114,6 +114,10 @@ public:
void clearTilesOnFly();
size_t getTilesOnFlyCount() const { return _tilesOnFly.size(); }
+ Util::Rectangle getVisibleArea() const { return _clientVisibleArea; }
+ int getTileWidthInTwips() const { return _tileWidthTwips; }
+ int getTileHeightInTwips() const { return _tileHeightTwips; }
+
private:
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 9b176501d..0028d8749 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -41,7 +41,7 @@
#include <sys/types.h>
#include <sys/wait.h>
-#define TILES_ON_FLY_UPPER_LIMIT 25
+#define TILES_ON_FLY_MIN_UPPER_LIMIT 10u
using namespace LOOLProtocol;
@@ -1366,13 +1366,22 @@ void DocumentBroker::sendRequestedTiles(const std::shared_ptr<ClientSession>& se
{
std::unique_lock<std::mutex> lock(_mutex);
+ // How many tiles we have on the visible area, set the upper limit accordingly
+ const unsigned tilesFitOnWidth = static_cast<int>(std::ceil(static_cast<float>(session->getVisibleArea().getWidth()) /
+ static_cast<float>(session->getTileWidthInTwips())));
+ const unsigned tilesFitOnHieght = static_cast<int>(std::ceil(static_cast<float>(session->getVisibleArea().getHeight()) /
+ static_cast<float>(session->getTileHeightInTwips())));
+ const unsigned tilesInVisArea = tilesFitOnWidth * tilesFitOnHieght;
+
+ const unsigned tilesInFlyUpperLimit = std::max(TILES_ON_FLY_MIN_UPPER_LIMIT, tilesInVisArea);
+
// All tiles were processed on client side what we sent last time, so we can send a new banch of tiles
// which was invalidated / requested in the meantime
boost::optional<std::list<TileDesc>>& requestedTiles = session->getRequestedTiles();
if(requestedTiles != boost::none && !requestedTiles.get().empty())
{
std::vector<TileDesc> tilesNeedsRendering;
- while(session->getTilesOnFlyCount() < TILES_ON_FLY_UPPER_LIMIT && !requestedTiles.get().empty())
+ while(session->getTilesOnFlyCount() < tilesInFlyUpperLimit && !requestedTiles.get().empty())
{
TileDesc& tile = *(requestedTiles.get().begin());
session->addTileOnFly(tile);
More information about the Libreoffice-commits
mailing list