[Libreoffice-commits] online.git: 2 commits - kit/Kit.cpp wsd/DocumentBroker.cpp wsd/TileDesc.hpp
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Apr 23 01:01:35 UTC 2019
kit/Kit.cpp | 13 ++++++------
wsd/DocumentBroker.cpp | 19 +++++++-----------
wsd/TileDesc.hpp | 50 ++++++++++++++++++++++++++++---------------------
3 files changed, 44 insertions(+), 38 deletions(-)
New commits:
commit c7ac68e8e31d2cf2179c12c817a09ad24c0cc22a
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sat Apr 20 14:58:48 2019 -0400
Commit: Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Tue Apr 23 03:01:30 2019 +0200
wsd: tile serializer now supports adding a suffix
Moves appending tokens into the serializer and
avoids making extra copies of itself.
Change-Id: I62d374e69d9c4a55643ea20cb5f8c2b9c75c88c5
Reviewed-on: https://gerrit.libreoffice.org/71022
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 76dddab46..d098cd773 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -121,9 +121,9 @@ static std::string ObfuscatedFileId;
#endif
#if ENABLE_DEBUG
-# define ADD_DEBUG_RENDERID(s) ((s)+ " renderid=" + Util::UniqueId())
+# define ADD_DEBUG_RENDERID (" renderid=" + Util::UniqueId() + '\n')
#else
-# define ADD_DEBUG_RENDERID(s) (s)
+# define ADD_DEBUG_RENDERID ("\n")
#endif
#if !MOBILEAPP
@@ -1098,9 +1098,9 @@ public:
std::string tileMsg;
if (combined)
- tileMsg = ADD_DEBUG_RENDERID(tileCombined.serialize("tilecombine:")) + "\n";
+ tileMsg = tileCombined.serialize("tilecombine:", ADD_DEBUG_RENDERID);
else
- tileMsg = ADD_DEBUG_RENDERID(tiles[0].serialize("tile:")) + "\n";
+ tileMsg = tiles[0].serialize("tile:", ADD_DEBUG_RENDERID);
LOG_TRC("Sending back painted tiles for " << tileMsg << " of size " << output.size() << " bytes) for: " << tileMsg);
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 8524725ff..53d3e2dbe 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -48,6 +48,12 @@ using namespace LOOLProtocol;
using Poco::JSON::Object;
+#if ENABLE_DEBUG
+# define ADD_DEBUG_RENDERID (" renderid=cached\n")
+#else
+# define ADD_DEBUG_RENDERID ("\n")
+#endif
+
void ChildProcess::setDocumentBroker(const std::shared_ptr<DocumentBroker>& docBroker)
{
assert(docBroker && "Invalid DocumentBroker instance.");
@@ -1335,11 +1341,7 @@ void DocumentBroker::handleTileRequest(TileDesc& tile,
TileCache::Tile cachedTile = _tileCache->lookupTile(tile);
if (cachedTile)
{
-#if ENABLE_DEBUG
- const std::string response = tile.serialize("tile:") + " renderid=cached\n";
-#else
- const std::string response = tile.serialize("tile:") + '\n';
-#endif
+ const std::string response = tile.serialize("tile:", ADD_DEBUG_RENDERID);
session->sendTile(response, cachedTile);
return;
}
@@ -1452,7 +1454,6 @@ void DocumentBroker::sendRequestedTiles(const std::shared_ptr<ClientSession>& se
float tilesOnFlyUpperLimit = 0;
if (normalizedVisArea.hasSurface() && session->getTileWidthInTwips() != 0 && session->getTileHeightInTwips() != 0)
{
-
const int tilesFitOnWidth = std::ceil(normalizedVisArea.getRight() / session->getTileWidthInTwips()) -
std::ceil(normalizedVisArea.getLeft() / session->getTileWidthInTwips()) + 1;
const int tilesFitOnHeight = std::ceil(normalizedVisArea.getBottom() / session->getTileHeightInTwips()) -
@@ -1500,11 +1501,7 @@ void DocumentBroker::sendRequestedTiles(const std::shared_ptr<ClientSession>& se
if (cachedTile)
{
//TODO: Combine the response to reduce latency.
-#if ENABLE_DEBUG
- const std::string response = tile.serialize("tile:") + " renderid=cached\n";
-#else
- const std::string response = tile.serialize("tile:") + "\n";
-#endif
+ const std::string response = tile.serialize("tile:", ADD_DEBUG_RENDERID);
session->sendTile(response, cachedTile);
}
else
diff --git a/wsd/TileDesc.hpp b/wsd/TileDesc.hpp
index abb922b3f..77fb46b26 100644
--- a/wsd/TileDesc.hpp
+++ b/wsd/TileDesc.hpp
@@ -29,20 +29,21 @@ typedef uint64_t TileBinaryHash;
class TileDesc
{
public:
- TileDesc(int part, int width, int height, int tilePosX, int tilePosY, int tileWidth, int tileHeight, int ver, int imgSize, int id, bool broadcast) :
- _part(part),
- _width(width),
- _height(height),
- _tilePosX(tilePosX),
- _tilePosY(tilePosY),
- _tileWidth(tileWidth),
- _tileHeight(tileHeight),
- _ver(ver),
- _imgSize(imgSize),
- _id(id),
- _broadcast(broadcast),
- _oldWireId(0),
- _wireId(0)
+ TileDesc(int part, int width, int height, int tilePosX, int tilePosY, int tileWidth,
+ int tileHeight, int ver, int imgSize, int id, bool broadcast)
+ : _part(part)
+ , _width(width)
+ , _height(height)
+ , _tilePosX(tilePosX)
+ , _tilePosY(tilePosY)
+ , _tileWidth(tileWidth)
+ , _tileHeight(tileHeight)
+ , _ver(ver)
+ , _imgSize(imgSize)
+ , _id(id)
+ , _broadcast(broadcast)
+ , _oldWireId(0)
+ , _wireId(0)
{
if (_part < 0 ||
_width <= 0 ||
@@ -138,7 +139,8 @@ public:
/// Serialize this instance into a string.
/// Optionally prepend a prefix.
- std::string serialize(const std::string& prefix = "") const
+ std::string serialize(const std::string& prefix = std::string(),
+ const std::string& suffix = std::string()) const
{
std::ostringstream oss;
oss << prefix
@@ -170,6 +172,7 @@ public:
oss << " broadcast=yes";
}
+ oss << suffix;
return oss.str();
}
@@ -351,7 +354,8 @@ public:
/// Serialize this instance into a string.
/// Optionally prepend a prefix.
- std::string serialize(const std::string& prefix = "") const
+ std::string serialize(const std::string& prefix = std::string(),
+ const std::string& suffix = std::string()) const
{
std::ostringstream oss;
oss << prefix
@@ -397,15 +401,19 @@ public:
oss.seekp(-1, std::ios_base::cur); // Ditto
oss << " wid=";
+
+ bool comma = false;
for (const auto& tile : _tiles)
{
- oss << tile.getWireId() << ',';
+ if (comma)
+ oss << ',';
+
+ oss << tile.getWireId();
+ comma = true;
}
- oss.seekp(-1, std::ios_base::cur); // See beow.
- // Make sure we don't return a potential trailing comma that
- // we have seeked back over but not overwritten after all.
- return oss.str().substr(0, oss.tellp());
+ oss << suffix;
+ return oss.str();
}
/// Deserialize a TileDesc from a tokenized string.
commit c053dc38b2b1c8da9685fbeabb88e63d5669593d
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sat Apr 20 14:10:38 2019 -0400
Commit: Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Tue Apr 23 03:01:17 2019 +0200
wsd: set vector size when constructing
Change-Id: I68718554017b47b6df1c6bf3b997483d4c753136
Reviewed-on: https://gerrit.libreoffice.org/71021
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 281853b42..76dddab46 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -29,8 +29,10 @@
#include <climits>
#include <condition_variable>
#include <cstdlib>
+#include <cstring>
#include <iostream>
#include <memory>
+#include <string>
#include <sstream>
#include <thread>
@@ -1102,8 +1104,7 @@ public:
LOG_TRC("Sending back painted tiles for " << tileMsg << " of size " << output.size() << " bytes) for: " << tileMsg);
- std::shared_ptr<std::vector<char>> response = std::make_shared<std::vector<char>>();
- response->resize(tileMsg.size() + output.size());
+ std::shared_ptr<std::vector<char>> response = std::make_shared<std::vector<char>>(tileMsg.size() + output.size());
std::copy(tileMsg.begin(), tileMsg.end(), response->begin());
std::copy(output.begin(), output.end(), response->begin() + tileMsg.size());
More information about the Libreoffice-commits
mailing list