[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - wsd/ClientSession.cpp wsd/ClientSession.hpp wsd/DocumentBroker.cpp
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Sep 7 11:16:45 UTC 2018
wsd/ClientSession.cpp | 18 ++++++++++++------
wsd/ClientSession.hpp | 3 +++
wsd/DocumentBroker.cpp | 14 ++++++++------
3 files changed, 23 insertions(+), 12 deletions(-)
New commits:
commit ac47dfed72a549b5e15e00b5cef5e76ffd4b6277
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Thu Aug 30 17:40:42 2018 +0200
Commit: Jan Holesovsky <kendy at collabora.com>
CommitDate: Fri Sep 7 13:16:28 2018 +0200
Calculate tiles-on-fly limit a bit more precisely
Change-Id: Id012a83d6ccd226d1b66e3cd48a9caeafd849fc5
(cherry picked from commit dce6c18fb4848a27c2e50faed4e6585b0b7bfdcd)
Reviewed-on: https://gerrit.libreoffice.org/59836
Reviewed-by: Jan Holesovsky <kendy at collabora.com>
Tested-by: Jan Holesovsky <kendy at collabora.com>
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 00fd8373d..6461851d9 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -1076,6 +1076,16 @@ void ClientSession::removeOutdatedTilesOnFly()
}
}
+Util::Rectangle ClientSession::getNormalizedVisibleArea() const
+{
+ Util::Rectangle normalizedVisArea;
+ normalizedVisArea._x1 = std::max(_clientVisibleArea._x1, 0);
+ normalizedVisArea._y1 = std::max(_clientVisibleArea._y1, 0);
+ normalizedVisArea._x2 = _clientVisibleArea._x2;
+ normalizedVisArea._y2 = _clientVisibleArea._y2;
+ return normalizedVisArea;
+}
+
void ClientSession::onDisconnect()
{
LOG_INF(getName() << " Disconnected, current number of connections: " << LOOLWSD::NumConnections);
@@ -1169,12 +1179,8 @@ void ClientSession::handleTileInvalidation(const std::string& message,
return;
}
- // Visible area can have negativ value as position, but we have tiles only in the positiv range
- Util::Rectangle normalizedVisArea;
- normalizedVisArea._x1 = std::max(_clientVisibleArea._x1, 0);
- normalizedVisArea._y1 = std::max(_clientVisibleArea._y1, 0);
- normalizedVisArea._x2 = _clientVisibleArea._x2;
- normalizedVisArea._y2 = _clientVisibleArea._y2;
+ // Visible area can have negativ value as position, but we have tiles only in the positive range
+ Util::Rectangle normalizedVisArea = getNormalizedVisibleArea();
std::pair<int, Util::Rectangle> result = TileCache::parseInvalidateMsg(message);
int part = result.first;
diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp
index 397f7b670..67664ee35 100644
--- a/wsd/ClientSession.hpp
+++ b/wsd/ClientSession.hpp
@@ -130,6 +130,9 @@ public:
void removeOutdatedTilesOnFly();
Util::Rectangle getVisibleArea() const { return _clientVisibleArea; }
+ /// Visible area can have negative value as position, but we have tiles only in the positive range
+ Util::Rectangle getNormalizedVisibleArea() const;
+
int getTileWidthInTwips() const { return _tileWidthTwips; }
int getTileHeightInTwips() const { return _tileHeightTwips; }
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 9f9e63304..367445e84 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1391,13 +1391,15 @@ 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 float tilesFitOnWidth = static_cast<float>(session->getVisibleArea().getWidth()) /
- static_cast<float>(session->getTileWidthInTwips());
- const float tilesFitOnHeight = static_cast<float>(session->getVisibleArea().getHeight()) /
- static_cast<float>(session->getTileHeightInTwips());
- const float tilesInVisArea = tilesFitOnWidth * tilesFitOnHeight;
+ Util::Rectangle normalizedVisArea = session->getNormalizedVisibleArea();
- const float tilesOnFlyUpperLimit = std::max(TILES_ON_FLY_MIN_UPPER_LIMIT, tilesInVisArea * 1.20f);
+ const int tilesFitOnWidth = std::ceil(normalizedVisArea._x2 / session->getTileWidthInTwips()) -
+ std::ceil(normalizedVisArea._x1 / session->getTileWidthInTwips()) + 1;
+ const int tilesFitOnHeight = std::ceil(normalizedVisArea._y2 / session->getTileHeightInTwips()) -
+ std::ceil(normalizedVisArea._y1 / session->getTileHeightInTwips()) + 1;
+ const int tilesInVisArea = tilesFitOnWidth * tilesFitOnHeight;
+
+ const float tilesOnFlyUpperLimit = std::max(TILES_ON_FLY_MIN_UPPER_LIMIT, tilesInVisArea * 1.5f);
// Update client's tilesBeingRendered list
session->removeOutdatedTileSubscriptions();
More information about the Libreoffice-commits
mailing list