[Libreoffice-commits] online.git: loolwsd/ChildProcessSession.cpp loolwsd/MasterProcessSession.cpp loolwsd/TileCache.cpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Fri Apr 15 01:05:07 UTC 2016
loolwsd/ChildProcessSession.cpp | 12 +++++++-----
loolwsd/MasterProcessSession.cpp | 37 +++++++++++++++++--------------------
loolwsd/TileCache.cpp | 16 ++++++++++------
3 files changed, 34 insertions(+), 31 deletions(-)
New commits:
commit e5595509fdf89fe6f562164d9db4eb66cc39464f
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Thu Apr 14 20:08:25 2016 -0400
loolwsd: cosmetic cleanup
Change-Id: I02f3ab1778db462376b7563e7e8b0abeebd2e8a1
Reviewed-on: https://gerrit.libreoffice.org/24098
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/ChildProcessSession.cpp b/loolwsd/ChildProcessSession.cpp
index a681221..4ea65d5 100644
--- a/loolwsd/ChildProcessSession.cpp
+++ b/loolwsd/ChildProcessSession.cpp
@@ -691,7 +691,8 @@ void ChildProcessSession::sendTile(const char* /*buffer*/, int /*length*/, Strin
Log::trace() << "paintTile at [" << tilePosX << ", " << tilePosY
<< "] rendered in " << (timestamp.elapsed()/1000.) << " ms" << Log::end;
- LibreOfficeKitTileMode mode = static_cast<LibreOfficeKitTileMode>(_loKitDocument->pClass->getTileMode(_loKitDocument));
+ const LibreOfficeKitTileMode mode =
+ static_cast<LibreOfficeKitTileMode>(_loKitDocument->pClass->getTileMode(_loKitDocument));
if (!Util::encodeBufferToPNG(pixmap.data(), width, height, output, mode))
{
sendTextFrame("error: cmd=tile kind=failure");
@@ -747,15 +748,16 @@ void ChildProcessSession::sendCombinedTiles(const char* /*buffer*/, int /*length
std::vector<Util::Rectangle> tiles;
tiles.reserve(numberOfPositions);
- for (size_t i = 0; i < numberOfPositions; i++)
+ for (size_t i = 0; i < numberOfPositions; ++i)
{
- int x, y;
-
+ int x = 0;
if (!stringToInteger(positionXtokens[i], x))
{
sendTextFrame("error: cmd=tilecombine kind=syntax");
return;
}
+
+ int y = 0;
if (!stringToInteger(positionYtokens[i], y))
{
sendTextFrame("error: cmd=tilecombine kind=syntax");
@@ -798,7 +800,7 @@ void ChildProcessSession::sendCombinedTiles(const char* /*buffer*/, int /*length
renderArea.getLeft(), renderArea.getTop(),
renderArea.getWidth(), renderArea.getHeight());
- Log::debug() << "paintTile (Multiple) called, tile at [" << renderArea.getLeft() << ", " << renderArea.getTop() << "]"
+ Log::debug() << "paintTile (combined) called, tile at [" << renderArea.getLeft() << ", " << renderArea.getTop() << "]"
<< " (" << renderArea.getWidth() << ", " << renderArea.getHeight() << ") rendered in "
<< double(timestamp.elapsed())/1000 << "ms" << Log::end;
diff --git a/loolwsd/MasterProcessSession.cpp b/loolwsd/MasterProcessSession.cpp
index f9bb7b1..280e19c 100644
--- a/loolwsd/MasterProcessSession.cpp
+++ b/loolwsd/MasterProcessSession.cpp
@@ -558,8 +558,8 @@ void MasterProcessSession::sendFontRendering(const char *buffer, int length, Str
void MasterProcessSession::sendTile(const char *buffer, int length, StringTokenizer& tokens)
{
- int part, width, height, tilePosX, tilePosY, tileWidth, tileHeight;
+ int part, width, height, tilePosX, tilePosY, tileWidth, tileHeight;
if (tokens.count() < 8 ||
!getTokenInteger(tokens[1], "part", part) ||
!getTokenInteger(tokens[2], "width", width) ||
@@ -585,7 +585,7 @@ void MasterProcessSession::sendTile(const char *buffer, int length, StringTokeni
return;
}
- std::string response = "tile: " + Poco::cat(std::string(" "), tokens.begin() + 1, tokens.end()) + "\n";
+ const std::string response = "tile: " + Poco::cat(std::string(" "), tokens.begin() + 1, tokens.end()) + "\n";
std::vector<char> output;
output.reserve(4 * width * height);
@@ -617,8 +617,6 @@ void MasterProcessSession::sendCombinedTiles(const char* /*buffer*/, int /*lengt
{
int part, pixelWidth, pixelHeight, tileWidth, tileHeight;
std::string tilePositionsX, tilePositionsY;
- std::string reqTimestamp;
-
if (tokens.count() < 8 ||
!getTokenInteger(tokens[1], "part", part) ||
!getTokenInteger(tokens[2], "width", pixelWidth) ||
@@ -632,26 +630,25 @@ void MasterProcessSession::sendCombinedTiles(const char* /*buffer*/, int /*lengt
return;
}
- if (part < 0 || pixelWidth <= 0 || pixelHeight <= 0
- || tileWidth <= 0 || tileHeight <= 0
- || tilePositionsX.empty() || tilePositionsY.empty())
+ if (part < 0 || pixelWidth <= 0 || pixelHeight <= 0 ||
+ tileWidth <= 0 || tileHeight <= 0 ||
+ tilePositionsX.empty() || tilePositionsY.empty())
{
sendTextFrame("error: cmd=tilecombine kind=invalid");
return;
}
+ std::string reqTimestamp;
if (tokens.count() > 8)
getTokenString(tokens[8], "timestamp", reqTimestamp);
- Util::Rectangle renderArea;
-
StringTokenizer positionXtokens(tilePositionsX, ",", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
StringTokenizer positionYtokens(tilePositionsY, ",", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
size_t numberOfPositions = positionYtokens.count();
// check that number of positions for X and Y is the same
- if (numberOfPositions != positionYtokens.count())
+ if (numberOfPositions != positionXtokens.count())
{
sendTextFrame("error: cmd=tilecombine kind=invalid");
return;
@@ -659,16 +656,16 @@ void MasterProcessSession::sendCombinedTiles(const char* /*buffer*/, int /*lengt
std::string forwardTileX;
std::string forwardTileY;
-
- for (size_t i = 0; i < numberOfPositions; i++)
+ for (size_t i = 0; i < numberOfPositions; ++i)
{
- int x, y;
-
+ int x = 0;
if (!stringToInteger(positionXtokens[i], x))
{
sendTextFrame("error: cmd=tilecombine kind=syntax");
return;
}
+
+ int y = 0;
if (!stringToInteger(positionYtokens[i], y))
{
sendTextFrame("error: cmd=tilecombine kind=syntax");
@@ -729,12 +726,12 @@ void MasterProcessSession::sendCombinedTiles(const char* /*buffer*/, int /*lengt
dispatchChild();
std::string forward = "tilecombine part=" + std::to_string(part) +
- " width=" + std::to_string(pixelWidth) +
- " height=" + std::to_string(pixelHeight) +
- " tileposx=" + forwardTileX +
- " tileposy=" + forwardTileY +
- " tilewidth=" + std::to_string(tileWidth) +
- " tileheight=" + std::to_string(tileHeight);
+ " width=" + std::to_string(pixelWidth) +
+ " height=" + std::to_string(pixelHeight) +
+ " tileposx=" + forwardTileX +
+ " tileposy=" + forwardTileY +
+ " tilewidth=" + std::to_string(tileWidth) +
+ " tileheight=" + std::to_string(tileHeight);
if (!reqTimestamp.empty())
forward += " timestamp=" + reqTimestamp;
diff --git a/loolwsd/TileCache.cpp b/loolwsd/TileCache.cpp
index da50309..8afe6b5 100644
--- a/loolwsd/TileCache.cpp
+++ b/loolwsd/TileCache.cpp
@@ -183,7 +183,7 @@ std::string TileCache::getTextFile(std::string fileName)
void TileCache::documentSaved()
{
- Log::trace("Persisting editing tiles.");
+ Log::debug("Persisting editing tiles.");
// first remove the invalidated tiles from the Persistent cache
for (const auto& it : _toBeRemoved)
@@ -271,6 +271,11 @@ std::unique_ptr<std::fstream> TileCache::lookupRendering(const std::string& name
void TileCache::invalidateTiles(int part, int x, int y, int width, int height)
{
+ Log::trace() << "Removing invalidated tiles: part: " << part
+ << ", x: " << x << ", y: " << y
+ << ", width: " << width
+ << ", height: " << height << Log::end;
+
// in the Editing cache, remove immediately
File editingDir(_editCacheDir);
if (editingDir.exists() && editingDir.isDirectory())
@@ -360,16 +365,15 @@ bool TileCache::parseCacheFileName(const std::string& fileName, int& part, int&
bool TileCache::intersectsTile(const std::string& fileName, int part, int x, int y, int width, int height)
{
int tilePart, tilePixelWidth, tilePixelHeight, tilePosX, tilePosY, tileWidth, tileHeight;
-
if (parseCacheFileName(fileName, tilePart, tilePixelWidth, tilePixelHeight, tilePosX, tilePosY, tileWidth, tileHeight))
{
if (part != -1 && tilePart != part)
return false;
- int left = std::max(x, tilePosX);
- int right = std::min(x + width, tilePosX + tileWidth);
- int top = std::max(y, tilePosY);
- int bottom = std::min(y + height, tilePosY + tileHeight);
+ const int left = std::max(x, tilePosX);
+ const int right = std::min(x + width, tilePosX + tileWidth);
+ const int top = std::max(y, tilePosY);
+ const int bottom = std::min(y + height, tilePosY + tileHeight);
if (left <= right && top <= bottom)
return true;
More information about the Libreoffice-commits
mailing list