[Libreoffice-commits] online.git: loolwsd/TileCache.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Tue Oct 25 01:01:47 UTC 2016
loolwsd/TileCache.cpp | 35 ++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)
New commits:
commit a2ef70c71ce48e81864de6d20382e8ef156bf64d
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Mon Oct 24 19:57:37 2016 -0400
loolwsd: mark all tiles but the first to have come from the cache
While this has some overhead, it makes debugging of tile
rendering easier.
Change-Id: I0430015f41fd044e4be1099a5d61a23c0ef88176
Reviewed-on: https://gerrit.libreoffice.org/30245
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/TileCache.cpp b/loolwsd/TileCache.cpp
index 5decc9e..e8ebdd1 100644
--- a/loolwsd/TileCache.cpp
+++ b/loolwsd/TileCache.cpp
@@ -167,20 +167,37 @@ void TileCache::saveTileAndNotify(const TileDesc& tile, const char *data, const
{
std::string response = tile.serialize("tile:");
Log::debug("Sending tile message to subscribers: " + response);
- response += '\n';
- std::vector<char> output;
- output.reserve(static_cast<size_t>(4) * tile.getWidth() * tile.getHeight());
- output.resize(response.size());
+ std::vector<char> output(256 + size);
+ output.resize(response.size() + 1 + size);
+
std::memcpy(output.data(), response.data(), response.size());
+ output[response.size()] = '\n';
+ std::memcpy(output.data() + response.size() + 1, data, size);
- const auto pos = output.size();
- output.resize(pos + size);
- std::memcpy(output.data() + pos, data, size);
+ // Send to first subscriber as-is (without cache marker).
+ auto firstSubscriber = tileBeingRendered->_subscribers[0].lock();
+ if (firstSubscriber)
+ {
+ try
+ {
+ firstSubscriber->sendBinaryFrame(output.data(), output.size());
+ }
+ catch (const std::exception& ex)
+ {
+ Log::warn("Failed to send tile to " + firstSubscriber->getName() + ": " + ex.what());
+ }
+ }
+
+ // All others must get served from the cache.
+ response += " renderid=cached\n";
+ output.resize(response.size() + size);
+ std::memcpy(output.data(), response.data(), response.size());
+ std::memcpy(output.data() + response.size(), data, size);
- for (const auto& i: tileBeingRendered->_subscribers)
+ for (size_t i = 1; i < tileBeingRendered->_subscribers.size(); ++i)
{
- auto subscriber = i.lock();
+ auto subscriber = tileBeingRendered->_subscribers[i].lock();
if (subscriber)
{
try
More information about the Libreoffice-commits
mailing list