tile.canvas is always true after a successful _ensureContext(tile)

_applyDelta returns early if the initial "ensureContext" of the tile
fails.

i.e.

  var ctx = this._ensureContext(tile);
  if (!ctx) // out of canvas / texture memory.
    return;

and ensureContext already calls ensureCanvas, so tile.canvas is
always true in the remainder of this function.

The "defer constructing the image & applying these deltas until the tile
is rendered via ensureCanvas." implied a sort of deliberate optimization
to wait until render time to apply the delta which doesn't actually
exist.

Also move the stray "// 'Uint8Array' delta" comment back to where it
originally came from as documentation of the type of the param, as in

commit 4140bf8741
Date:   Sat Nov 6 11:11:13 2021 +0000

    Bring back the delta application JS from the 6.4 branch.

...

 _applyDelta: function(tile, delta) {
         // 'Uint8Array' delta

...

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: If15a897c3251f28639c9f1112687e543421e457d
pull/8997/head
Caolán McNamara 2024-05-08 13:06:09 +01:00 committed by Caolán McNamara
parent e40bcccc4f
commit 399afd123f
1 changed files with 2 additions and 8 deletions

View File

@ -6738,6 +6738,8 @@ L.CanvasTileLayer = L.Layer.extend({
},
_applyDelta: function(tile, rawDelta, isKeyframe, wireMessage) {
// 'Uint8Array' rawDelta
if (this._debugDeltas)
window.app.console.log('Applying a raw ' + (isKeyframe ? 'keyframe' : 'delta') +
' of length ' + rawDelta.length +
@ -6803,14 +6805,6 @@ L.CanvasTileLayer = L.Layer.extend({
tile.rawDeltas = tmp;
}
// 'Uint8Array' delta
if (!tile.canvas)
{
// defer constructing the image & applying these deltas
// until the tile is rendered via ensureCanvas.
return;
}
// apply potentially several deltas in turn.
var i = 0;
var offset = 0;