Calculate tiles-on-fly limit a bit more precisely
Change-Id: Id012a83d6ccd226d1b66e3cd48a9caeafd849fc5
This commit is contained in:
parent
ab7943edd6
commit
dce6c18fb4
3 changed files with 23 additions and 12 deletions
|
@ -1079,6 +1079,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);
|
||||
|
@ -1172,12 +1182,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;
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
|
@ -1368,13 +1368,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();
|
||||
|
|
Loading…
Reference in a new issue