[Libreoffice-commits] online.git: common/Rectangle.hpp wsd/ClientSession.cpp wsd/DocumentBroker.cpp
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Nov 14 08:08:13 UTC 2018
common/Rectangle.hpp | 36 ++++++++++++++++++++++++++++++++++--
wsd/ClientSession.cpp | 20 ++++++++++----------
wsd/DocumentBroker.cpp | 8 ++++----
3 files changed, 48 insertions(+), 16 deletions(-)
New commits:
commit 63bf882f73fdb1526a9d330fc333a67b2e2b05b4
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Nov 14 09:07:47 2018 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Nov 14 09:07:54 2018 +0100
Rectangle: make members private
diff --git a/common/Rectangle.hpp b/common/Rectangle.hpp
index 6089f863d..8ed2f3626 100644
--- a/common/Rectangle.hpp
+++ b/common/Rectangle.hpp
@@ -18,11 +18,13 @@ namespace Util
/// Holds the position and size of a rectangle.
struct Rectangle
{
+private:
int _x1;
int _y1;
int _x2;
int _y2;
+public:
Rectangle()
: _x1(std::numeric_limits<int>::max())
, _y1(std::numeric_limits<int>::max())
@@ -49,16 +51,46 @@ struct Rectangle
_y2 = rectangle._y2;
}
- int getLeft()
+ void setLeft(int x1)
+ {
+ _x1 = x1;
+ }
+
+ int getLeft() const
{
return _x1;
}
- int getTop()
+ void setRight(int x2)
+ {
+ _x2 = x2;
+ }
+
+ int getRight() const
+ {
+ return _x2;
+ }
+
+ void setTop(int y1)
+ {
+ _y1 = y1;
+ }
+
+ int getTop() const
{
return _y1;
}
+ void setBottom(int y2)
+ {
+ _y2 = y2;
+ }
+
+ int getBottom() const
+ {
+ return _y2;
+ }
+
int getWidth()
{
return _x2 - _x1;
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index f6625470c..20819f83c 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -1140,10 +1140,10 @@ size_t ClientSession::countIdenticalTilesOnFly(const TileDesc& tile) const
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;
+ normalizedVisArea.setLeft(std::max(_clientVisibleArea.getLeft(), 0));
+ normalizedVisArea.setTop(std::max(_clientVisibleArea.getTop(), 0));
+ normalizedVisArea.setRight(_clientVisibleArea.getRight());
+ normalizedVisArea.setBottom(_clientVisibleArea.getBottom());
return normalizedVisArea;
}
@@ -1259,11 +1259,11 @@ void ClientSession::handleTileInvalidation(const std::string& message,
if(part == _clientSelectedPart || _isTextDocument)
{
// Iterate through visible tiles
- for(int i = std::ceil(normalizedVisArea._y1 / _tileHeightTwips);
- i <= std::ceil(normalizedVisArea._y2 / _tileHeightTwips); ++i)
+ for(int i = std::ceil(normalizedVisArea.getTop() / _tileHeightTwips);
+ i <= std::ceil(normalizedVisArea.getBottom() / _tileHeightTwips); ++i)
{
- for(int j = std::ceil(normalizedVisArea._x1 / _tileWidthTwips);
- j <= std::ceil(normalizedVisArea._x2 / _tileWidthTwips); ++j)
+ for(int j = std::ceil(normalizedVisArea.getLeft() / _tileWidthTwips);
+ j <= std::ceil(normalizedVisArea.getRight() / _tileWidthTwips); ++j)
{
// Find tiles affected by invalidation
Util::Rectangle tileRect (j * _tileWidthTwips, i * _tileHeightTwips, _tileWidthTwips, _tileHeightTwips);
@@ -1309,8 +1309,8 @@ void ClientSession::traceTileBySend(const TileDesc& tile, bool deduplicated)
{
// Track only tile inside the visible area
if(_clientVisibleArea.hasSurface() &&
- tile.getTilePosX() >= _clientVisibleArea._x1 && tile.getTilePosX() <= _clientVisibleArea._x2 &&
- tile.getTilePosY() >= _clientVisibleArea._y1 && tile.getTilePosY() <= _clientVisibleArea._y2)
+ tile.getTilePosX() >= _clientVisibleArea.getLeft() && tile.getTilePosX() <= _clientVisibleArea.getRight() &&
+ tile.getTilePosY() >= _clientVisibleArea.getTop() && tile.getTilePosY() <= _clientVisibleArea.getBottom())
{
_oldWireIds.insert(std::pair<std::string, TileWireId>(tileID, tile.getWireId()));
}
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index fd8fdd4ca..c14e5a111 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1440,10 +1440,10 @@ void DocumentBroker::sendRequestedTiles(const std::shared_ptr<ClientSession>& se
if (normalizedVisArea.hasSurface() && session->getTileWidthInTwips() != 0 && session->getTileHeightInTwips() != 0)
{
- 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 tilesFitOnWidth = std::ceil(normalizedVisArea.getRight() / session->getTileWidthInTwips()) -
+ std::ceil(normalizedVisArea.getLeft() / session->getTileWidthInTwips()) + 1;
+ const int tilesFitOnHeight = std::ceil(normalizedVisArea.getBottom() / session->getTileHeightInTwips()) -
+ std::ceil(normalizedVisArea.getTop() / session->getTileHeightInTwips()) + 1;
const int tilesInVisArea = tilesFitOnWidth * tilesFitOnHeight;
tilesOnFlyUpperLimit = std::max(TILES_ON_FLY_MIN_UPPER_LIMIT, tilesInVisArea * 1.1f);
More information about the Libreoffice-commits
mailing list