Skip to content

Commit

Permalink
tiles: do not duplicate rendering if tilecombine requested
Browse files Browse the repository at this point in the history
related to #10980

open calc and use page down to enter some initially not visible area
notice in debug tools that tiles are rendered twice

If any tile rendering is already pending - let's don't request
it again. Use shared function for that check which was used only
in one place but forgotten in hadnling the incoming tilecombine message.

Signed-off-by: Szymon Kłos <[email protected]>
Change-Id: Icc1bf97826ec8b1cb1185b6f30dc2daf6d0355ea
  • Loading branch information
eszkadev committed Feb 12, 2025
1 parent ebd2480 commit b6fae29
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
43 changes: 26 additions & 17 deletions wsd/DocumentBroker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4405,9 +4405,7 @@ void DocumentBroker::handleTileCombinedRequest(TileCombined& tileCombined, bool
{
if (!cachedTile || tooLarge)
tile.forceKeyframe();
tilesNeedsRendering.push_back(tile);
_debugRenderedTileCount++;
tileCache().subscribeToTileRendering(tile, session, now);
requestTileRendering(tile, /*forceKeyFrame*/ true, now, tilesNeedsRendering, session);
}
}
if (hasOldWireId)
Expand Down Expand Up @@ -4569,6 +4567,30 @@ void DocumentBroker::handleMediaRequest(std::string range,
}
}

bool DocumentBroker::requestTileRendering(TileDesc& tile, bool forceKeyframe,
const std::chrono::steady_clock::time_point &now,
std::vector<TileDesc>& tilesNeedsRendering,
const std::shared_ptr<ClientSession>& session)
{
bool allSamePartAndSize = true;
if (!tileCache().hasTileBeingRendered(tile, &now) || // There is no in progress rendering of the given tile
tileCache().getTileBeingRenderedVersion(tile) < tile.getVersion()) // We need a newer version
{
tile.setVersion(++_tileVersion);
if (forceKeyframe)
{
LOG_TRC("Forcing keyframe for tile was oldwid " << tile.getOldWireId());
tile.setOldWireId(0);
}
allSamePartAndSize &= tilesNeedsRendering.empty() || tile.sameTileCombineParams(tilesNeedsRendering.back());
tilesNeedsRendering.push_back(tile);
_debugRenderedTileCount++;
}

tileCache().subscribeToTileRendering(tile, session, now);
return allSamePartAndSize;
}

void DocumentBroker::sendRequestedTiles(const std::shared_ptr<ClientSession>& session)
{
ASSERT_CORRECT_THREAD();
Expand Down Expand Up @@ -4612,20 +4634,7 @@ void DocumentBroker::sendRequestedTiles(const std::shared_ptr<ClientSession>& se
else
{
// Not cached, needs rendering.
if (!tileCache().hasTileBeingRendered(tile, &now) || // There is no in progress rendering of the given tile
tileCache().getTileBeingRenderedVersion(tile) < tile.getVersion()) // We need a newer version
{
tile.setVersion(++_tileVersion);
if (!cachedTile) // forceKeyframe
{
LOG_TRC("Forcing keyframe for tile was oldwid " << tile.getOldWireId());
tile.setOldWireId(0);
}
allSamePartAndSize &= tilesNeedsRendering.empty() || tile.sameTileCombineParams(tilesNeedsRendering.back());
tilesNeedsRendering.push_back(tile);
_debugRenderedTileCount++;
}
tileCache().subscribeToTileRendering(tile, session, now);
allSamePartAndSize &= requestTileRendering(tile, !cachedTile, now, tilesNeedsRendering, session);
}
requestedTiles.pop_front();
}
Expand Down
7 changes: 7 additions & 0 deletions wsd/DocumentBroker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,13 @@ class DocumentBroker : public std::enable_shared_from_this<DocumentBroker>
#endif // !MOBILEAPP

private:
/// Checks if we really need to request tile rendering or it's in progress
/// returns true if all tiles are of the same part and size so can be grouped
inline bool requestTileRendering(TileDesc& tile, bool forceKeyFrame,
const std::chrono::steady_clock::time_point &now,
std::vector<TileDesc>& tilesNeedsRendering,
const std::shared_ptr<ClientSession>& session);

/// Get the session that can write the document for save / locking / uploading.
/// Note that if there is no loaded and writable session, the first will be returned.
std::shared_ptr<ClientSession> getWriteableSession() const;
Expand Down

0 comments on commit b6fae29

Please sign in to comment.