[Libreoffice-commits] online.git: loolwsd/TileDesc.hpp

2016-11-24 Thread Ashod Nakashian
 loolwsd/TileDesc.hpp |   27 ---
 1 file changed, 16 insertions(+), 11 deletions(-)

New commits:
commit c8c8407e001dc6b058488cae0578f68c59093225
Author: Ashod Nakashian 
Date:   Wed Nov 23 21:28:50 2016 -0500

loolwsd: move ver field in tile to the end

tile and tilecombine have grown organically
and gained optional fields when originally
all fields were required.

Since internally we deduplicate them, we need
to compare the required fields and not the
optional ones. By moving all optional ones
after the landmark ver, we make comparison
easier and, hopefully, less error prone.

Change-Id: I309185d3e19a45c7d59bc872e8a76acd3c511c14
Reviewed-on: https://gerrit.libreoffice.org/31182
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/TileDesc.hpp b/loolwsd/TileDesc.hpp
index 5c39e48..85bc453 100644
--- a/loolwsd/TileDesc.hpp
+++ b/loolwsd/TileDesc.hpp
@@ -120,17 +120,19 @@ public:
 << " tileposx=" << _tilePosX
 << " tileposy=" << _tilePosY
 << " tilewidth=" << _tileWidth
-<< " tileheight=" << _tileHeight
-<< " ver=" << _ver;
+<< " tileheight=" << _tileHeight;
 
-if (_imgSize > 0)
+if (_id >= 0)
 {
-oss << " imgsize=" << _imgSize;
+oss << " id=" << _id;
 }
 
-if (_id >= 0)
+// Anything after ver is optional.
+oss << " ver=" << _ver;
+
+if (_imgSize > 0)
 {
-oss << " id=" << _id;
+oss << " imgsize=" << _imgSize;
 }
 
 if (_broadcast)
@@ -162,8 +164,10 @@ public:
 pairs[name] = value;
 }
 }
+
 std::string s;
-bool broadcast = (LOOLProtocol::getTokenString(tokens, "broadcast", s) 
&& s == "yes");
+const bool broadcast = (LOOLProtocol::getTokenString(tokens, 
"broadcast", s) &&
+s == "yes");
 
 return TileDesc(pairs["part"], pairs["width"], pairs["height"],
 pairs["tileposx"], pairs["tileposy"],
@@ -304,16 +308,17 @@ public:
 
 oss << " tilewidth=" << _tileWidth
 << " tileheight=" << _tileHeight;
-if (_ver >= 0)
-{
-oss << " ver=" << _ver;
-}
 
 if (_id >= 0)
 {
 oss << " id=" << _id;
 }
 
+if (_ver >= 0)
+{
+oss << " ver=" << _ver;
+}
+
 return oss.str();
 }
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/TileDesc.hpp

2016-09-19 Thread Ashod Nakashian
 loolwsd/TileDesc.hpp |9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

New commits:
commit 454b2b71c18ace94f16dcf1f203c4d20cf9f1dce
Author: Ashod Nakashian 
Date:   Mon Sep 19 20:30:35 2016 -0400

loolwsd: don't generate imgsize in tile when 0

Change-Id: I469bdbfbb5efd8230808e6c68f58f505acef3993
Reviewed-on: https://gerrit.libreoffice.org/29069
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/TileDesc.hpp b/loolwsd/TileDesc.hpp
index e4d2c36..0258645 100644
--- a/loolwsd/TileDesc.hpp
+++ b/loolwsd/TileDesc.hpp
@@ -81,8 +81,13 @@ public:
 << " tileposy=" << _tilePosY
 << " tilewidth=" << _tileWidth
 << " tileheight=" << _tileHeight
-<< " ver=" << _ver
-<< " imgsize=" << _imgSize;
+<< " ver=" << _ver;
+
+if (_imgSize > 0)
+{
+oss << " imgsize=" << _imgSize;
+}
+
 if (_id >= 0)
 {
 oss << " id=" << _id;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: loolwsd/TileDesc.hpp

2016-05-22 Thread Ashod Nakashian
 loolwsd/TileDesc.hpp |   31 +--
 1 file changed, 25 insertions(+), 6 deletions(-)

New commits:
commit 55df9b85e17dccb809903f1520d1dceadde7ba8c
Author: Ashod Nakashian 
Date:   Sun May 22 14:21:05 2016 -0400

loolwsd: support versioning in tile requests

Usage and rationale to follow.

Change-Id: Ife4c12481e87f1b4b23d8ba6a6da66797b2be2a5
Reviewed-on: https://gerrit.libreoffice.org/25340
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/TileDesc.hpp b/loolwsd/TileDesc.hpp
index e723cf7..8759678 100644
--- a/loolwsd/TileDesc.hpp
+++ b/loolwsd/TileDesc.hpp
@@ -24,7 +24,7 @@
 class TileDesc
 {
 public:
-TileDesc(int part, int width, int height, int tilePosX, int tilePosY, int 
tileWidth, int tileHeight, int imgSize = 0, int id = -1) :
+TileDesc(int part, int width, int height, int tilePosX, int tilePosY, int 
tileWidth, int tileHeight, int ver = -1, int imgSize = 0, int id = -1) :
 _part(part),
 _width(width),
 _height(height),
@@ -32,6 +32,7 @@ public:
 _tilePosY(tilePosY),
 _tileWidth(tileWidth),
 _tileHeight(tileHeight),
+_ver(ver),
 _imgSize(imgSize),
 _id(id)
 {
@@ -55,6 +56,8 @@ public:
 int getTilePosY() const { return _tilePosY; }
 int getTileWidth() const { return _tileWidth; }
 int getTileHeight() const { return _tileHeight; }
+int getVersion() const { return _ver; }
+void setVersion(const int ver) { _ver = ver; }
 int getImgSize() const { return _imgSize; }
 void setImgSize(const int imgSize) { _imgSize = imgSize; }
 
@@ -71,6 +74,7 @@ public:
 << " tileposy=" << _tilePosY
 << " tilewidth=" << _tileWidth
 << " tileheight=" << _tileHeight
+<< " ver=" << _ver
 << " imgsize=" << _imgSize;
 if (_id >= 0)
 {
@@ -89,8 +93,9 @@ public:
 std::map pairs;
 
 // Optional.
-pairs["id"] = -1;
+pairs["ver"] = -1;
 pairs["imgsize"] = 0;
+pairs["id"] = -1;
 
 for (size_t i = 0; i < tokens.count(); ++i)
 {
@@ -105,6 +110,7 @@ public:
 return TileDesc(pairs["part"], pairs["width"], pairs["height"],
 pairs["tileposx"], pairs["tileposy"],
 pairs["tilewidth"], pairs["tileheight"],
+pairs["ver"],
 pairs["imgsize"], pairs["id"]);
 }
 
@@ -126,7 +132,8 @@ private:
 int _tilePosY;
 int _tileWidth;
 int _tileHeight;
-int _imgSize; //< Used for responses.
+int _ver;   //< Versioning support.
+int _imgSize;   //< Used for responses.
 int _id;
 };
 
@@ -135,12 +142,14 @@ class TileCombined
 private:
 TileCombined(int part, int width, int height,
  const std::string& tilePositionsX, const std::string& 
tilePositionsY,
- int tileWidth, int tileHeight, const std::string& imgSizes = 
"", int id = -1) :
+ int tileWidth, int tileHeight, int ver = -1,
+ const std::string& imgSizes = "", int id = -1) :
 _part(part),
 _width(width),
 _height(height),
 _tileWidth(tileWidth),
 _tileHeight(tileHeight),
+_ver(ver),
 _id(id)
 {
 if (_part < 0 ||
@@ -184,7 +193,7 @@ private:
 throw BadArgumentException("Invalid tilecombine descriptor.");
 }
 
-_tiles.emplace_back(_part, _width, _height, x, y, _tileWidth, 
_tileHeight, size);
+_tiles.emplace_back(_part, _width, _height, x, y, _tileWidth, 
_tileHeight, ver, size, id);
 }
 }
 
@@ -195,6 +204,8 @@ public:
 int getHeight() const { return _height; }
 int getTileWidth() const { return _tileWidth; }
 int getTileHeight() const { return _tileHeight; }
+int getVersion() const { return _ver; }
+void setVersion(const int ver) { _ver = ver; }
 
 const std::vector& getTiles() const { return _tiles; }
 std::vector& getTiles() { return _tiles; }
@@ -234,6 +245,11 @@ public:
 
 oss << " tilewidth=" << _tileWidth
 << " tileheight=" << _tileHeight;
+if (_ver >= 0)
+{
+oss << " ver=" << _ver;
+}
+
 if (_id >= 0)
 {
 oss << " id=" << _id;
@@ -250,7 +266,8 @@ public:
 // assume all values to be int.
 std::map pairs;
 
-// id is optional.
+// Optional.
+pairs["ver"] = -1;
 pairs["id"] = -1;
 
 std::string tilePositionsX;
@@ -288,6 +305,7 @@ public:
 return TileCombined(pairs["part"], pairs["width"], pairs["height"],
 tilePositionsX, tilePositionsY,
 pairs["tilewidth"], pairs["tileheight"],
+   

[Libreoffice-commits] online.git: loolwsd/TileDesc.hpp

2016-05-22 Thread Ashod Nakashian
 loolwsd/TileDesc.hpp |   45 -
 1 file changed, 36 insertions(+), 9 deletions(-)

New commits:
commit f5bf8aa64aa6b89b0fb5f50a7f1fac6dbf6070d1
Author: Ashod Nakashian 
Date:   Sun May 22 11:35:41 2016 -0400

loolwsd: support for imgsize field in tile and tilecombine messages

When sending back response of tile or tilecombine type the
payload of the PNG image is implicitly the remainder of
the WS message. While this works fine for single-tile cases
it prevents us from combining tile responses into one to
reduce latency and overheads.

Change-Id: Iefeeed7e1a46be322c973ccf74f2bdb668d7cf30
Reviewed-on: https://gerrit.libreoffice.org/25338
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/TileDesc.hpp b/loolwsd/TileDesc.hpp
index e4eeff8..e723cf7 100644
--- a/loolwsd/TileDesc.hpp
+++ b/loolwsd/TileDesc.hpp
@@ -24,7 +24,7 @@
 class TileDesc
 {
 public:
-TileDesc(int part, int width, int height, int tilePosX, int tilePosY, int 
tileWidth, int tileHeight, int id = -1) :
+TileDesc(int part, int width, int height, int tilePosX, int tilePosY, int 
tileWidth, int tileHeight, int imgSize = 0, int id = -1) :
 _part(part),
 _width(width),
 _height(height),
@@ -32,6 +32,7 @@ public:
 _tilePosY(tilePosY),
 _tileWidth(tileWidth),
 _tileHeight(tileHeight),
+_imgSize(imgSize),
 _id(id)
 {
 if (_part < 0 ||
@@ -40,7 +41,8 @@ public:
 _tilePosX < 0 ||
 _tilePosY < 0 ||
 _tileWidth <= 0 ||
-_tileHeight <= 0)
+_tileHeight <= 0 ||
+_imgSize < 0)
 {
 throw BadArgumentException("Invalid tile descriptor.");
 }
@@ -53,6 +55,8 @@ public:
 int getTilePosY() const { return _tilePosY; }
 int getTileWidth() const { return _tileWidth; }
 int getTileHeight() const { return _tileHeight; }
+int getImgSize() const { return _imgSize; }
+void setImgSize(const int imgSize) { _imgSize = imgSize; }
 
 /// Serialize this instance into a string.
 /// Optionally prepend a prefix.
@@ -66,7 +70,8 @@ public:
 << " tileposx=" << _tilePosX
 << " tileposy=" << _tilePosY
 << " tilewidth=" << _tileWidth
-<< " tileheight=" << _tileHeight;
+<< " tileheight=" << _tileHeight
+<< " imgsize=" << _imgSize;
 if (_id >= 0)
 {
 oss << " id=" << _id;
@@ -83,8 +88,9 @@ public:
 // assume all values to be int.
 std::map pairs;
 
-// id is optional.
+// Optional.
 pairs["id"] = -1;
+pairs["imgsize"] = 0;
 
 for (size_t i = 0; i < tokens.count(); ++i)
 {
@@ -99,7 +105,7 @@ public:
 return TileDesc(pairs["part"], pairs["width"], pairs["height"],
 pairs["tileposx"], pairs["tileposy"],
 pairs["tilewidth"], pairs["tileheight"],
-pairs["id"]);
+pairs["imgsize"], pairs["id"]);
 }
 
 /// Deserialize a TileDesc from a string format.
@@ -120,6 +126,7 @@ private:
 int _tilePosY;
 int _tileWidth;
 int _tileHeight;
+int _imgSize; //< Used for responses.
 int _id;
 };
 
@@ -128,7 +135,7 @@ class TileCombined
 private:
 TileCombined(int part, int width, int height,
  const std::string& tilePositionsX, const std::string& 
tilePositionsY,
- int tileWidth, int tileHeight, int id = -1) :
+ int tileWidth, int tileHeight, const std::string& imgSizes = 
"", int id = -1) :
 _part(part),
 _width(width),
 _height(height),
@@ -147,11 +154,12 @@ private:
 
 Poco::StringTokenizer positionXtokens(tilePositionsX, ",", 
Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
 Poco::StringTokenizer positionYtokens(tilePositionsY, ",", 
Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
+Poco::StringTokenizer sizeTokens(imgSizes, ",", 
Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
 
 const auto numberOfPositions = positionYtokens.count();
 
 // check that number of positions for X and Y is the same
-if (numberOfPositions != positionXtokens.count())
+if (numberOfPositions != positionXtokens.count() || (!imgSizes.empty() 
&& numberOfPositions != sizeTokens.count()))
 {
 throw BadArgumentException("Invalid tilecombine descriptor. Uneven 
number of tiles.");
 }
@@ -170,7 +178,13 @@ private:
 throw BadArgumentException("Invalid tilecombine descriptor.");
 }
 
-_tiles.emplace_back(_part, _width, _height, x, y, _tileWidth, 

[Libreoffice-commits] online.git: loolwsd/TileDesc.hpp

2016-05-22 Thread Ashod Nakashian
 loolwsd/TileDesc.hpp |  161 +++
 1 file changed, 161 insertions(+)

New commits:
commit 126060fd7f205925dd6130bcb17d09349ec2ce07
Author: Ashod Nakashian 
Date:   Sun May 22 11:31:36 2016 -0400

loolwsd: TileCombined class to parse, serialize, represent tilecombine

Change-Id: I00457fc0f2cd9d987972a1d5b9a17c204d42984c
Reviewed-on: https://gerrit.libreoffice.org/25337
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/TileDesc.hpp b/loolwsd/TileDesc.hpp
index 73ba75e..e4eeff8 100644
--- a/loolwsd/TileDesc.hpp
+++ b/loolwsd/TileDesc.hpp
@@ -123,6 +123,167 @@ private:
 int _id;
 };
 
+class TileCombined
+{
+private:
+TileCombined(int part, int width, int height,
+ const std::string& tilePositionsX, const std::string& 
tilePositionsY,
+ int tileWidth, int tileHeight, int id = -1) :
+_part(part),
+_width(width),
+_height(height),
+_tileWidth(tileWidth),
+_tileHeight(tileHeight),
+_id(id)
+{
+if (_part < 0 ||
+_width <= 0 ||
+_height <= 0 ||
+_tileWidth <= 0 ||
+_tileHeight <= 0)
+{
+throw BadArgumentException("Invalid tilecombine descriptor.");
+}
+
+Poco::StringTokenizer positionXtokens(tilePositionsX, ",", 
Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
+Poco::StringTokenizer positionYtokens(tilePositionsY, ",", 
Poco::StringTokenizer::TOK_IGNORE_EMPTY | Poco::StringTokenizer::TOK_TRIM);
+
+const auto numberOfPositions = positionYtokens.count();
+
+// check that number of positions for X and Y is the same
+if (numberOfPositions != positionXtokens.count())
+{
+throw BadArgumentException("Invalid tilecombine descriptor. Uneven 
number of tiles.");
+}
+
+for (size_t i = 0; i < numberOfPositions; ++i)
+{
+int x = 0;
+if (!LOOLProtocol::stringToInteger(positionXtokens[i], x))
+{
+throw BadArgumentException("Invalid tilecombine descriptor.");
+}
+
+int y = 0;
+if (!LOOLProtocol::stringToInteger(positionYtokens[i], y))
+{
+throw BadArgumentException("Invalid tilecombine descriptor.");
+}
+
+_tiles.emplace_back(_part, _width, _height, x, y, _tileWidth, 
_tileHeight);
+}
+}
+
+public:
+
+int getPart() const { return _part; }
+int getWidth() const { return _width; }
+int getHeight() const { return _height; }
+int getTileWidth() const { return _tileWidth; }
+int getTileHeight() const { return _tileHeight; }
+
+const std::vector& getTiles() const { return _tiles; }
+std::vector& getTiles() { return _tiles; }
+
+/// Serialize this instance into a string.
+/// Optionally prepend a prefix.
+std::string serialize(const std::string& prefix = "") const
+{
+std::ostringstream oss;
+oss << prefix
+<< " part=" << _part
+<< " width=" << _width
+<< " height=" << _height
+<< " tileposx=";
+for (const auto& tile : _tiles)
+{
+oss << tile.getTilePosX() << ',';
+}
+
+oss.seekp(-1, std::ios_base::cur); // Remove last comma.
+
+oss << " tileposy=";
+for (const auto& tile : _tiles)
+{
+oss << tile.getTilePosY() << ',';
+}
+
+oss.seekp(-1, std::ios_base::cur); // Remove last comma.
+
+oss << " tilewidth=" << _tileWidth
+<< " tileheight=" << _tileHeight;
+if (_id >= 0)
+{
+oss << " id=" << _id;
+}
+
+return oss.str();
+}
+
+/// Deserialize a TileDesc from a tokenized string.
+static
+TileCombined parse(const Poco::StringTokenizer& tokens)
+{
+// We don't expect undocumented fields and
+// assume all values to be int.
+std::map pairs;
+
+// id is optional.
+pairs["id"] = -1;
+
+std::string tilePositionsX;
+std::string tilePositionsY;
+for (size_t i = 0; i < tokens.count(); ++i)
+{
+std::string name;
+std::string value;
+if (LOOLProtocol::parseNameValuePair(tokens[i], name, value))
+{
+if (name == "tileposx")
+{
+tilePositionsX = value;
+}
+else if (name == "tileposy")
+{
+tilePositionsY = value;
+}
+else
+{
+int v = 0;
+if (LOOLProtocol::stringToInteger(value, v))
+{
+

[Libreoffice-commits] online.git: loolwsd/TileDesc.hpp

2016-05-21 Thread Ashod Nakashian
 loolwsd/TileDesc.hpp |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 56ae463bea80154010045e6bbdb96d1783c946d2
Author: Ashod Nakashian 
Date:   Sat May 21 10:40:16 2016 -0400

loolwsd: minor TileDesc comment fix

Change-Id: I35b11797151a26a1c420afa5296c67ca54a5bdc9
Reviewed-on: https://gerrit.libreoffice.org/25264
Reviewed-by: Ashod Nakashian 
Tested-by: Ashod Nakashian 

diff --git a/loolwsd/TileDesc.hpp b/loolwsd/TileDesc.hpp
index c8ee2d8..73ba75e 100644
--- a/loolwsd/TileDesc.hpp
+++ b/loolwsd/TileDesc.hpp
@@ -79,7 +79,7 @@ public:
 static
 TileDesc parse(const Poco::StringTokenizer& tokens)
 {
-// We don't expect undocument fields and
+// We don't expect undocumented fields and
 // assume all values to be int.
 std::map pairs;
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits