diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2016-10-24 19:57:37 -0400 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2016-10-25 15:00:02 +0200 |
commit | e420c891a2f00a06156ba1878c0afaf1609542b4 (patch) | |
tree | ede4be084c721f9781948e8bde6b392fa38909be | |
parent | cd47726bfac7f05ef7aa9a929ad9a156ad3086f5 (diff) |
loolwsd: mark all tiles but the first to have come from the cache1.9.5
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@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
(cherry picked from commit a2ef70c71ce48e81864de6d20382e8ef156bf64d)
-rw-r--r-- | loolwsd/TileCache.cpp | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/loolwsd/TileCache.cpp b/loolwsd/TileCache.cpp index 5decc9e86..e8ebdd1ee 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 |