summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kit/Kit.cpp8
-rw-r--r--wsd/DocumentBroker.cpp19
-rw-r--r--wsd/TileDesc.hpp50
3 files changed, 41 insertions, 36 deletions
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.