[Libreoffice-commits] online.git: 2 commits - loolwsd/DocumentBroker.cpp loolwsd/DocumentBroker.hpp loolwsd/PrisonerSession.cpp loolwsd/protocol.txt loolwsd/TileCache.cpp loolwsd/TileDesc.hpp
Michael Meeks
michael.meeks at collabora.com
Thu Sep 1 20:19:26 UTC 2016
loolwsd/DocumentBroker.cpp | 17 ++++++++++-------
loolwsd/DocumentBroker.hpp | 6 +++++-
loolwsd/PrisonerSession.cpp | 10 +++++++---
loolwsd/TileCache.cpp | 4 +++-
loolwsd/TileDesc.hpp | 7 +++++++
loolwsd/protocol.txt | 4 +++-
6 files changed, 35 insertions(+), 13 deletions(-)
New commits:
commit 6bce292c4410ba61f41bd015cee00176238140af
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Thu Sep 1 21:17:56 2016 +0100
Send intermediate tiles back even when we they are older.
Should improve interactivity and avoid jerky feedback.
diff --git a/loolwsd/TileCache.cpp b/loolwsd/TileCache.cpp
index 9b76a15..0f6936a 100644
--- a/loolwsd/TileCache.cpp
+++ b/loolwsd/TileCache.cpp
@@ -140,17 +140,19 @@ std::unique_ptr<std::fstream> TileCache::lookupTile(const TileDesc& tile)
return nullptr;
}
-void TileCache::saveTileAndNotify(const TileDesc& tile, const char *data, const size_t size, const bool priority)
+void TileCache::saveTileAndNotify(const TileDesc& tile, const char *data, const size_t size, const bool /* priority */)
{
std::unique_lock<std::mutex> lock(_tilesBeingRenderedMutex);
std::shared_ptr<TileBeingRendered> tileBeingRendered = findTileBeingRendered(tile);
+#if 0
if (!priority && tileBeingRendered && tileBeingRendered->getVersion() != tile.getVersion())
{
Log::trace() << "Skipping unexpected tile ver: " << tile.getVersion()
<< ", waiting for ver " << tileBeingRendered->getVersion() << Log::end;
return;
}
+#endif
// Save to disk.
const auto cachedName = (tileBeingRendered ? tileBeingRendered->getCacheName()
commit 8182dd8c54ca83407e666c429d25f199e5ccc570
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Thu Sep 1 21:15:13 2016 +0100
Assign priority based on intersection with the cursor.
Should help to reduce visual tearing when cursor spans a tile join.
diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index a89b9d3..043218f 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -111,6 +111,8 @@ DocumentBroker::DocumentBroker(const Poco::URI& uriPublic,
_lastEditableSession(false),
_cursorPosX(0),
_cursorPosY(0),
+ _cursorWidth(0),
+ _cursorHeight(0),
_isLoaded(false),
_isModified(false),
_isEditLockHeld(false),
@@ -572,8 +574,8 @@ void DocumentBroker::handleTileCombinedRequest(TileCombined& tileCombined,
continue;
}
else
- if (_cursorPosX >= tile.getTilePosX() && _cursorPosX <= tile.getTilePosX() + tile.getTileWidth() &&
- _cursorPosY >= tile.getTilePosY() && _cursorPosY <= tile.getTilePosY() + tile.getTileHeight())
+ if (tile.intersectsWithRect(_cursorPosX, _cursorPosY,
+ _cursorWidth, _cursorHeight))
{
// If this tile is right under the cursor, give it priority.
const auto req = tile.serialize("tile");
@@ -628,11 +630,12 @@ void DocumentBroker::handleTileResponse(const std::vector<char>& payload)
if (firstLine.size() < static_cast<std::string::size_type>(length) - 1)
{
// If the tile right under the cursor, give it priority.
- const auto priority = (_cursorPosX >= tile.getTilePosX() &&
- _cursorPosX <= tile.getTilePosX() + tile.getTileWidth() &&
- _cursorPosY >= tile.getTilePosY() &&
- _cursorPosY <= tile.getTilePosY() + tile.getTileHeight());
- tileCache().saveTileAndNotify(tile, buffer + firstLine.size() + 1, length - firstLine.size() - 1, priority);
+ const bool priority = tile.intersectsWithRect(
+ _cursorPosX, _cursorPosY,
+ _cursorWidth, _cursorHeight);
+ tileCache().saveTileAndNotify(
+ tile, buffer + firstLine.size() + 1,
+ length - firstLine.size() - 1, priority);
}
else
{
diff --git a/loolwsd/DocumentBroker.hpp b/loolwsd/DocumentBroker.hpp
index 54ca138..fd28ed8 100644
--- a/loolwsd/DocumentBroker.hpp
+++ b/loolwsd/DocumentBroker.hpp
@@ -203,10 +203,12 @@ public:
size_t removeSession(const std::string& id);
/// Invalidate the cursor position.
- void invalidateCursor(const int x, const int y)
+ void invalidateCursor(int x, int y, int w, int h)
{
_cursorPosX = x;
_cursorPosY = y;
+ _cursorWidth = w;
+ _cursorHeight = h;
}
void handleTileRequest(TileDesc& tile,
@@ -252,6 +254,8 @@ private:
std::atomic<bool> _lastEditableSession;
int _cursorPosX;
int _cursorPosY;
+ int _cursorWidth;
+ int _cursorHeight;
bool _isLoaded;
bool _isModified;
mutable std::mutex _mutex;
diff --git a/loolwsd/PrisonerSession.cpp b/loolwsd/PrisonerSession.cpp
index ba3c344..35ce139 100644
--- a/loolwsd/PrisonerSession.cpp
+++ b/loolwsd/PrisonerSession.cpp
@@ -228,13 +228,17 @@ bool PrisonerSession::_handleInput(const char *buffer, int length)
{
assert(firstLine.size() == static_cast<std::string::size_type>(length));
StringTokenizer firstLineTokens(firstLine, " ", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
- int x = 0;
- int y = 0;
+ int x = 0, y = 0, w = 0, h = 0;
if (firstLineTokens.count() > 2 &&
stringToInteger(firstLineTokens[1], x) &&
stringToInteger(firstLineTokens[2], y))
{
- _docBroker->invalidateCursor(x, y);
+ if (firstLineTokens.count() > 3)
+ {
+ stringToInteger(firstLineTokens[3], w);
+ stringToInteger(firstLineTokens[4], h);
+ }
+ _docBroker->invalidateCursor(x, y, w, h);
}
else
{
diff --git a/loolwsd/TileDesc.hpp b/loolwsd/TileDesc.hpp
index 9d5f82c..e4d2c36 100644
--- a/loolwsd/TileDesc.hpp
+++ b/loolwsd/TileDesc.hpp
@@ -60,6 +60,13 @@ public:
void setVersion(const int ver) { _ver = ver; }
int getImgSize() const { return _imgSize; }
void setImgSize(const int imgSize) { _imgSize = imgSize; }
+ bool intersectsWithRect(int x, int y, int w, int h) const
+ {
+ return x + w >= getTilePosX() &&
+ x <= getTilePosX() + getTileWidth() &&
+ y + h >= getTilePosY() &&
+ y <= getTilePosY() + getTileHeight();
+ }
/// Serialize this instance into a string.
/// Optionally prepend a prefix.
diff --git a/loolwsd/protocol.txt b/loolwsd/protocol.txt
index 332d088..3639484 100644
--- a/loolwsd/protocol.txt
+++ b/loolwsd/protocol.txt
@@ -294,7 +294,9 @@ the client, consisting of the FOO_BAR part in lowercase, without
underscore, followed by a colon, space and the callback payload. For
instance:
-invalidatecursor:
+invalidatecursor: <payload>
+
+The payload contains a rectangle describing the cursor position.
invalidatetiles: <payload>
More information about the Libreoffice-commits
mailing list