Skip to content
Snippets Groups Projects
Commit e420c891 authored by Ashod Nakashian's avatar Ashod Nakashian Committed by Andras Timar
Browse files

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: default avatarAshod Nakashian <ashnakash@gmail.com>
Tested-by: default avatarAshod Nakashian <ashnakash@gmail.com>
(cherry picked from commit a2ef70c7)
parent cd47726b
No related branches found
Tags 1.9.5
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment