loleaflet/src/layer/tile/GridLayer.js | 79 +++++++++++++++------------------- loleaflet/src/layer/tile/TileLayer.js | 27 +---------- wsd/ClientSession.cpp | 4 - wsd/DocumentBroker.cpp | 23 +++++++++ 4 files changed, 64 insertions(+), 69 deletions(-)
New commits: commit 6db06fc11b93bd25818a72ec49aa5e3cf61ea821 Author: Tamás Zolnai <[email protected]> Date: Tue Jun 12 16:36:14 2018 +0200 Send clientvisisblearea message immediately to the server by update Change-Id: Ia8522c4443a453f10a8c600dd9c124f4fd4bacb3 diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js index 2eec5ea9f..ec3a4dc6e 100644 --- a/loleaflet/src/layer/tile/GridLayer.js +++ b/loleaflet/src/layer/tile/GridLayer.js @@ -573,6 +573,7 @@ L.GridLayer = L.Layer.extend({ this._level.el.appendChild(fragment); } this._invalidateClientVisibleArea(); + this._sendClientVisibleArea(); }, _updateOnChangePart: function () { @@ -732,6 +733,20 @@ L.GridLayer = L.Layer.extend({ this._clientVisibleArea = true; }, + _sendClientVisibleArea: function () { + if (this._clientVisibleArea) { + // Visible area is dirty, update it on the server. + var visibleTopLeft = this._latLngToTwips(this._map.getBounds().getNorthWest()); + var visibleBottomRight = this._latLngToTwips(this._map.getBounds().getSouthEast()); + var visibleArea = new L.Bounds(visibleTopLeft, visibleBottomRight); + var size = new L.Point(visibleArea.getSize().x, visibleArea.getSize().y); + var payload = 'clientvisiblearea x=' + Math.round(visibleTopLeft.x) + ' y=' + Math.round(visibleTopLeft.y) + + ' width=' + Math.round(size.x) + ' height=' + Math.round(size.y); + this._map._socket.sendMessage(payload); + this._clientVisibleArea = false; + } + }, + _isValidTile: function (coords) { if (coords.x < 0 || coords.y < 0) { return false; diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 906f1098a..1dcdf8df6 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -2265,21 +2265,6 @@ L.TileLayer = L.GridLayer.extend({ 'tiletwipheight=' + this._tileHeightTwips; }, - _sendClientVisibleArea: function () { - if (this._clientVisibleArea) { - // Visible area is dirty, update it on the server. - var visibleTopLeft = this._latLngToTwips(this._map.getBounds().getNorthWest()); - var visibleBottomRight = this._latLngToTwips(this._map.getBounds().getSouthEast()); - var visibleArea = new L.Bounds(visibleTopLeft, visibleBottomRight); - var size = new L.Point(visibleArea.getSize().x, visibleArea.getSize().y); - var payload = 'clientvisiblearea x=' + Math.round(visibleTopLeft.x) + ' y=' + Math.round(visibleTopLeft.y) + - ' width=' + Math.round(size.x) + ' height=' + Math.round(size.y); - this._map._socket.sendMessage(payload); - this._clientVisibleArea = false; - } - }, - - _debugGetTimeArray: function() { return {count: 0, ms: 0, best: Number.MAX_SAFE_INTEGER, worst: 0, date: 0}; }, commit ca915290984e396f26f87a107bab1c15b4efc5fa Author: Tamás Zolnai <[email protected]> Date: Tue Jun 12 16:35:25 2018 +0200 Always drop invalidate tile from cache Change-Id: I2a4bdbdd413759459cc2d77af90d8ab1ba83e6f7 diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp index ba2330540..4d1c5c0e5 100644 --- a/wsd/ClientSession.cpp +++ b/wsd/ClientSession.cpp @@ -1065,6 +1065,8 @@ void ClientSession::dumpState(std::ostream& os) void ClientSession::handleTileInvalidation(const std::string& message, const std::shared_ptr<DocumentBroker>& docBroker) { + docBroker->invalidateTiles(message); + // Skip requesting new tiles if we don't have client visible area data yet. if(!_clientVisibleArea.hasSurface() || _tileWidthPixel == 0 || _tileHeightPixel == 0 || @@ -1073,8 +1075,6 @@ void ClientSession::handleTileInvalidation(const std::string& message, return; } - - docBroker->invalidateTiles(message); std::pair<int, Util::Rectangle> result = TileCache::parseInvalidateMsg(message); int part = result.first; Util::Rectangle& invalidateRect = result.second; commit 30c33ed78d4a58a7512fab5cc70f4da285744fef Author: Tamás Zolnai <[email protected]> Date: Tue Jun 12 14:51:38 2018 +0200 We might need to rerequest tile rendering when we are at sending them Change-Id: I0551e51c5f5023931dad13435b4ac3517fc48931 diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 3058a4ce6..6947eb7f3 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -1306,7 +1306,7 @@ void DocumentBroker::handleTileCombinedRequest(TileCombined& tileCombined, } } - // Send rendering request + // Send rendering request, prerender before we actually send the tiles if (!tilesNeedsRendering.empty()) { std::cerr << "tilesNeedsRendering.size(): " << tilesNeedsRendering.size() << std::endl; @@ -1376,6 +1376,7 @@ void DocumentBroker::sendRequestedTiles(const std::shared_ptr<ClientSession>& se // Satisfy as many tiles from the cache. std::cerr << "requestedTiles.size(): " << requestedTiles.get().getTiles().size() << std::endl; + std::vector<TileDesc> tilesNeedsRendering; for (auto& tile : requestedTiles.get().getTiles()) { std::cerr << "alma: "<< std::endl; @@ -1409,11 +1410,29 @@ void DocumentBroker::sendRequestedTiles(const std::shared_ptr<ClientSession>& se else { std::cerr << "not cachedTile: "<< std::endl; - // Not cached, needs rendering. Rendering request was already sent + // Not cached, needs rendering. + if(tile.getVersion() == -1) // Rendering of this tile was not requested yet + { + tile.setVersion(++_tileVersion); + tilesNeedsRendering.push_back(tile); + _debugRenderedTileCount++; + } tileCache().subscribeToTileRendering(tile, session); std::cerr << "not cachedTile2: "<< std::endl; } } + + // Send rendering request for those tiles which were not prerendered + if (!tilesNeedsRendering.empty()) + { + TileCombined newTileCombined = TileCombined::create(tilesNeedsRendering); + + // Forward to child to render. + const std::string req = newTileCombined.serialize("tilecombine"); + LOG_DBG("Some of the tiles were not prerendered. Sending residual tilecombine: " << req); + LOG_DBG("Sending residual tilecombine: " << req); + _childProcess->sendTextFrame(req); + } requestedTiles = boost::none; } } commit 2d29be76ff13756f6c9c4beb02376f3a0d52f2ff Author: Tamás Zolnai <[email protected]> Date: Mon Jun 11 16:40:16 2018 +0200 Code deduplication related to sending client visible area Change-Id: Iee9ea30041b7b086eefa373e403ce5b2f224fe7a diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 6aec6514b..906f1098a 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -1477,17 +1477,7 @@ L.TileLayer = L.GridLayer.extend({ this._clientZoom = null; } - if (this._clientVisibleArea) { - // Visible area is dirty, update it on the server. - var visibleTopLeft = this._latLngToTwips(this._map.getBounds().getNorthWest()); - var visibleBottomRight = this._latLngToTwips(this._map.getBounds().getSouthEast()); - var visibleArea = new L.Bounds(visibleTopLeft, visibleBottomRight); - var size = new L.Point(visibleArea.getSize().x, visibleArea.getSize().y); - var payload = 'clientvisiblearea x=' + Math.round(visibleTopLeft.x) + ' y=' + Math.round(visibleTopLeft.y) + - ' width=' + Math.round(size.x) + ' height=' + Math.round(size.y); - this._map._socket.sendMessage(payload); - this._clientVisibleArea = false; - } + this._sendClientVisibleArea(); this._map._socket.sendMessage('mouse type=' + type + ' x=' + x + ' y=' + y + ' count=' + count + @@ -1519,17 +1509,9 @@ L.TileLayer = L.GridLayer.extend({ this._map._socket.sendMessage('clientzoom ' + this._clientZoom); this._clientZoom = null; } - if (this._clientVisibleArea) { - // Visible area is dirty, update it on the server. - var visibleTopLeft = this._latLngToTwips(this._map.getBounds().getNorthWest()); - var visibleBottomRight = this._latLngToTwips(this._map.getBounds().getSouthEast()); - var visibleArea = new L.Bounds(visibleTopLeft, visibleBottomRight); - var size = new L.Point(visibleArea.getSize().x, visibleArea.getSize().y); - var payload = 'clientvisiblearea x=' + Math.round(visibleTopLeft.x) + ' y=' + Math.round(visibleTopLeft.y) + - ' width=' + Math.round(size.x) + ' height=' + Math.round(size.y); - this._map._socket.sendMessage(payload); - this._clientVisibleArea = false; - } + + this._sendClientVisibleArea(); + this._map._socket.sendMessage('key type=' + type + ' char=' + charcode + ' key=' + keycode); }, @@ -2283,6 +2265,20 @@ L.TileLayer = L.GridLayer.extend({ 'tiletwipheight=' + this._tileHeightTwips; }, + _sendClientVisibleArea: function () { + if (this._clientVisibleArea) { + // Visible area is dirty, update it on the server. + var visibleTopLeft = this._latLngToTwips(this._map.getBounds().getNorthWest()); + var visibleBottomRight = this._latLngToTwips(this._map.getBounds().getSouthEast()); + var visibleArea = new L.Bounds(visibleTopLeft, visibleBottomRight); + var size = new L.Point(visibleArea.getSize().x, visibleArea.getSize().y); + var payload = 'clientvisiblearea x=' + Math.round(visibleTopLeft.x) + ' y=' + Math.round(visibleTopLeft.y) + + ' width=' + Math.round(size.x) + ' height=' + Math.round(size.y); + this._map._socket.sendMessage(payload); + this._clientVisibleArea = false; + } + }, + _debugGetTimeArray: function() { return {count: 0, ms: 0, best: Number.MAX_SAFE_INTEGER, worst: 0, date: 0}; commit aa46b4a73d36a77111f763617b16cf8e6e67fb4c Author: Tamás Zolnai <[email protected]> Date: Mon Jun 11 16:26:09 2018 +0200 Reduce code deduplication We can request tilecombine even if client needs actually one tile only. Change-Id: Id897f219885be4cb93635d727d4ee871a4b55cb7 diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js index c61c6bb05..2eec5ea9f 100644 --- a/loleaflet/src/layer/tile/GridLayer.js +++ b/loleaflet/src/layer/tile/GridLayer.js @@ -940,53 +940,33 @@ L.GridLayer = L.Layer.extend({ var twips, msg; for (var r = 0; r < rectangles.length; ++r) { rectQueue = rectangles[r]; - - if (rectQueue.length === 1) { - // only one tile here - coords = rectQueue[0]; - key = this._tileCoordsToKey(coords); - + var tilePositionsX = ''; + var tilePositionsY = ''; + for (i = 0; i < rectQueue.length; i++) { + coords = rectQueue[i]; twips = this._coordsToTwips(coords); - msg = 'tile ' + - 'part=' + coords.part + ' ' + - 'width=' + this._tileWidthPx + ' ' + - 'height=' + this._tileHeightPx + ' ' + - 'tileposx=' + twips.x + ' ' + - 'tileposy=' + twips.y + ' ' + - 'tilewidth=' + this._tileWidthTwips + ' ' + - 'tileheight=' + this._tileHeightTwips; - this._map._socket.sendMessage(msg, key); - } - else { - // more tiles, use tilecombine - var tilePositionsX = ''; - var tilePositionsY = ''; - for (i = 0; i < rectQueue.length; i++) { - coords = rectQueue[i]; - twips = this._coordsToTwips(coords); - - if (tilePositionsX !== '') { - tilePositionsX += ','; - } - tilePositionsX += twips.x; - if (tilePositionsY !== '') { - tilePositionsY += ','; - } - tilePositionsY += twips.y; + if (tilePositionsX !== '') { + tilePositionsX += ','; } + tilePositionsX += twips.x; - twips = this._coordsToTwips(coords); - msg = 'tilecombine ' + - 'part=' + coords.part + ' ' + - 'width=' + this._tileWidthPx + ' ' + - 'height=' + this._tileHeightPx + ' ' + - 'tileposx=' + tilePositionsX + ' ' + - 'tileposy=' + tilePositionsY + ' ' + - 'tilewidth=' + this._tileWidthTwips + ' ' + - 'tileheight=' + this._tileHeightTwips; - this._map._socket.sendMessage(msg, ''); + if (tilePositionsY !== '') { + tilePositionsY += ','; + } + tilePositionsY += twips.y; } + + twips = this._coordsToTwips(coords); + msg = 'tilecombine ' + + 'part=' + coords.part + ' ' + + 'width=' + this._tileWidthPx + ' ' + + 'height=' + this._tileHeightPx + ' ' + + 'tileposx=' + tilePositionsX + ' ' + + 'tileposy=' + tilePositionsY + ' ' + + 'tilewidth=' + this._tileWidthTwips + ' ' + + 'tileheight=' + this._tileHeightTwips; + this._map._socket.sendMessage(msg, ''); } }, _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
