[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4-0' - test/TileCacheTests.cpp wsd/ClientSession.cpp wsd/DocumentBroker.cpp wsd/DocumentBroker.hpp wsd/TileCache.cpp wsd/TileCache.hpp
Mert Tumer (via logerrit)
logerrit at kemper.freedesktop.org
Sat Oct 19 18:14:51 UTC 2019
test/TileCacheTests.cpp | 2 +-
wsd/ClientSession.cpp | 2 +-
wsd/DocumentBroker.cpp | 4 ++--
wsd/DocumentBroker.hpp | 2 +-
wsd/TileCache.cpp | 23 +++++++++++++----------
wsd/TileCache.hpp | 8 ++++----
6 files changed, 22 insertions(+), 19 deletions(-)
New commits:
commit ed4d93df1bfddfd73719af74cfafbbeefef90e02
Author: Mert Tumer <mert.tumer at collabora.com>
AuthorDate: Wed Oct 16 16:50:09 2019 +0300
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Sat Oct 19 20:14:31 2019 +0200
Include normalizedViewId to TileCache
Change-Id: Ibabc38a796cd99fb9d0efbf0ef14bf3d82c87b47
Reviewed-on: https://gerrit.libreoffice.org/81048
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/test/TileCacheTests.cpp b/test/TileCacheTests.cpp
index b6dda807f..fd453d995 100644
--- a/test/TileCacheTests.cpp
+++ b/test/TileCacheTests.cpp
@@ -211,7 +211,7 @@ void TileCacheTests::testSimple()
CPPUNIT_ASSERT_MESSAGE("cached tile corrupted", data == tileData);
// Invalidate Tiles
- tc.invalidateTiles("invalidatetiles: EMPTY");
+ tc.invalidateTiles("invalidatetiles: EMPTY", nviewid);
// No Cache
file = tc.lookupTile(tile);
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 86a79754e..112eb511e 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -1299,7 +1299,7 @@ void ClientSession::dumpState(std::ostream& os)
void ClientSession::handleTileInvalidation(const std::string& message,
const std::shared_ptr<DocumentBroker>& docBroker)
{
- docBroker->invalidateTiles(message);
+ docBroker->invalidateTiles(message, getHash());
// Skip requesting new tiles if we don't have client visible area data yet.
if(!_clientVisibleArea.hasSurface() ||
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 3119a14c1..fd4120611 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1363,10 +1363,10 @@ bool DocumentBroker::handleInput(const std::vector<char>& payload)
return true;
}
-void DocumentBroker::invalidateTiles(const std::string& tiles)
+void DocumentBroker::invalidateTiles(const std::string& tiles, int normalizedViewId)
{
// Remove from cache.
- _tileCache->invalidateTiles(tiles);
+ _tileCache->invalidateTiles(tiles, normalizedViewId);
}
void DocumentBroker::handleTileRequest(TileDesc& tile,
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 24a5e1ac9..858e80658 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -305,7 +305,7 @@ public:
_cursorHeight = h;
}
- void invalidateTiles(const std::string& tiles);
+ void invalidateTiles(const std::string& tiles, int normalizedViewId);
void handleTileRequest(TileDesc& tile,
const std::shared_ptr<ClientSession>& session);
void handleDialogRequest(const std::string& dialogCmd);
diff --git a/wsd/TileCache.cpp b/wsd/TileCache.cpp
index b46d16044..e38fdad57 100644
--- a/wsd/TileCache.cpp
+++ b/wsd/TileCache.cpp
@@ -353,7 +353,7 @@ std::unique_ptr<std::fstream> TileCache::lookupCachedFile(const std::string& nam
return nullptr;
}
-void TileCache::invalidateTiles(int part, int x, int y, int width, int height)
+void TileCache::invalidateTiles(int part, int x, int y, int width, int height, int nViewId)
{
LOG_TRC("Removing invalidated tiles: part: " << part <<
", x: " << x << ", y: " << y <<
@@ -369,7 +369,7 @@ void TileCache::invalidateTiles(int part, int x, int y, int width, int height)
for (auto tileIterator = DirectoryIterator(dir); tileIterator != DirectoryIterator(); ++tileIterator)
{
const std::string fileName = tileIterator.path().getFileName();
- if (intersectsTile(fileName, part, x, y, width, height))
+ if (intersectsTile(fileName, part, x, y, width, height, nViewId))
{
LOG_DBG("Removing tile: " << tileIterator.path().toString());
FileUtil::removeFile(tileIterator.path());
@@ -378,11 +378,11 @@ void TileCache::invalidateTiles(int part, int x, int y, int width, int height)
}
}
-void TileCache::invalidateTiles(const std::string& tiles)
+void TileCache::invalidateTiles(const std::string& tiles, int normalizedViewId)
{
std::pair<int, Util::Rectangle> result = TileCache::parseInvalidateMsg(tiles);
Util::Rectangle& invalidateRect = result.second;
- invalidateTiles(result.first, invalidateRect.getLeft(), invalidateRect.getTop(), invalidateRect.getWidth(), invalidateRect.getHeight());
+ invalidateTiles(result.first, invalidateRect.getLeft(), invalidateRect.getTop(), invalidateRect.getWidth(), invalidateRect.getHeight(), normalizedViewId);
}
std::pair<int, Util::Rectangle> TileCache::parseInvalidateMsg(const std::string& tiles)
@@ -433,25 +433,28 @@ void TileCache::removeFile(const std::string& fileName)
std::string TileCache::cacheFileName(const TileDesc& tile)
{
std::ostringstream oss;
- oss << tile.getPart() << '_' << tile.getWidth() << 'x' << tile.getHeight() << '.'
+ oss << tile.getNormalizedViewId() << '_' << tile.getPart() << '_' << tile.getWidth() << 'x' << tile.getHeight() << '.'
<< tile.getTilePosX() << ',' << tile.getTilePosY() << '.'
<< tile.getTileWidth() << 'x' << tile.getTileHeight() << ".png";
return oss.str();
}
-bool TileCache::parseCacheFileName(const std::string& fileName, int& part, int& width, int& height, int& tilePosX, int& tilePosY, int& tileWidth, int& tileHeight)
+bool TileCache::parseCacheFileName(const std::string& fileName, int& part, int& width, int& height, int& tilePosX, int& tilePosY, int& tileWidth, int& tileHeight, int& nViewId)
{
- return std::sscanf(fileName.c_str(), "%d_%dx%d.%d,%d.%dx%d.png", &part, &width, &height, &tilePosX, &tilePosY, &tileWidth, &tileHeight) == 7;
+ return std::sscanf(fileName.c_str(), "%d_%d_%dx%d.%d,%d.%dx%d.png", &nViewId, &part, &width, &height, &tilePosX, &tilePosY, &tileWidth, &tileHeight) == 8;
}
-bool TileCache::intersectsTile(const std::string& fileName, int part, int x, int y, int width, int height)
+bool TileCache::intersectsTile(const std::string& fileName, int part, int x, int y, int width, int height, int normalizedViewId)
{
- int tilePart, tilePixelWidth, tilePixelHeight, tilePosX, tilePosY, tileWidth, tileHeight;
- if (parseCacheFileName(fileName, tilePart, tilePixelWidth, tilePixelHeight, tilePosX, tilePosY, tileWidth, tileHeight))
+ int tilePart, tilePixelWidth, tilePixelHeight, tilePosX, tilePosY, tileWidth, tileHeight, nViewId;
+ if (parseCacheFileName(fileName, tilePart, tilePixelWidth, tilePixelHeight, tilePosX, tilePosY, tileWidth, tileHeight, nViewId))
{
if (part != -1 && tilePart != part)
return false;
+ if (nViewId != normalizedViewId)
+ return false;
+
const int left = std::max(x, tilePosX);
const int right = std::min(x + width, tilePosX + tileWidth);
const int top = std::max(y, tilePosY);
diff --git a/wsd/TileCache.hpp b/wsd/TileCache.hpp
index db922691d..5614412cf 100644
--- a/wsd/TileCache.hpp
+++ b/wsd/TileCache.hpp
@@ -76,7 +76,7 @@ public:
std::unique_ptr<std::fstream> lookupCachedFile(const std::string& name, const std::string& dir);
// The tiles parameter is an invalidatetiles: message as sent by the child process
- void invalidateTiles(const std::string& tiles);
+ void invalidateTiles(const std::string& tiles, int normalizedViewId);
/// Parse invalidateTiles message to a part number and a rectangle of the invalidated area
static std::pair<int, Util::Rectangle> parseInvalidateMsg(const std::string& tiles);
@@ -96,16 +96,16 @@ public:
private:
- void invalidateTiles(int part, int x, int y, int width, int height);
+ void invalidateTiles(int part, int x, int y, int width, int height, int normalizedViewId);
// Removes the given file from the cache
void removeFile(const std::string& fileName);
static std::string cacheFileName(const TileDesc& tile);
- static bool parseCacheFileName(const std::string& fileName, int& part, int& width, int& height, int& tilePosX, int& tilePosY, int& tileWidth, int& tileHeight);
+ static bool parseCacheFileName(const std::string& fileName, int& part, int& width, int& height, int& tilePosX, int& tilePosY, int& tileWidth, int& tileHeight, int& nViewid);
/// Extract location from fileName, and check if it intersects with [x, y, width, height].
- static bool intersectsTile(const std::string& fileName, int part, int x, int y, int width, int height);
+ static bool intersectsTile(const std::string& fileName, int part, int x, int y, int width, int height, int nViewId);
/// Load the timestamp from modtime.txt.
Poco::Timestamp getLastModified();
More information about the Libreoffice-commits
mailing list