diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2020-09-19 21:47:34 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2020-09-21 09:57:16 +0200 |
commit | 224526c9678be37b4ac4258b1f01c7df473c50bc (patch) | |
tree | 504f583a003df10bed24accfb7f54d5910290c12 /loleaflet | |
parent | 95fbcdebed842b4fcd3712ccd7fa80b70f4f35fb (diff) |
calc grid: render during canvas 'clear' if we can.
Also re-render as soon as we have grid positions.
Change-Id: I57095683e662991badcb3a58832c81ebb3bc460d
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/103043
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'loleaflet')
-rw-r--r-- | loleaflet/src/layer/tile/CanvasTileLayer.js | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/loleaflet/src/layer/tile/CanvasTileLayer.js b/loleaflet/src/layer/tile/CanvasTileLayer.js index 15d813939..285fa11c3 100644 --- a/loleaflet/src/layer/tile/CanvasTileLayer.js +++ b/loleaflet/src/layer/tile/CanvasTileLayer.js @@ -130,12 +130,22 @@ L.CanvasTilePainter = L.Class.extend({ } }, - clear: function () { - if (this._layer._debug) - this._canvasCtx.fillStyle = 'rgba(255, 0, 0, 0.5)'; + clear: function (ctx) { + // First render the background / sheet grid if we can + if (this.renderBackground) + { + if (!ctx) + ctx = this._paintContext(); + this.renderBackground(this._canvasCtx, ctx); + } else - this._canvasCtx.fillStyle = 'white'; - this._canvasCtx.fillRect(0, 0, this._pixWidth, this._pixHeight); + { + if (this._layer._debug) + this._canvasCtx.fillStyle = 'rgba(255, 0, 0, 0.5)'; + else + this._canvasCtx.fillStyle = 'white'; + this._canvasCtx.fillRect(0, 0, this._pixWidth, this._pixHeight); + } }, // Details of tile areas to render @@ -265,11 +275,13 @@ L.CanvasTilePainter = L.Class.extend({ if (skipUpdate) return; + var ctx; if (resizeCanvas || scaleChanged) { this._setCanvasSize(newSize.x, newSize.y); } else if (mapSizeChanged && topLeftChanged) { - this.clear(); + ctx = this._paintContext(); + this.clear(ctx); } if (mapSizeChanged) @@ -282,24 +294,22 @@ L.CanvasTilePainter = L.Class.extend({ this._lastPart = part; this._topLeft = newTopLeft; - this._paintWholeCanvas(); + this._paintWholeCanvas(ctx); if (this._layer._debug) this._drawSplits(); }, - _paintWholeCanvas: function () { + _paintWholeCanvas: function(ctx) { var zoom = this._lastZoom || Math.round(this._map.getZoom()); var part = this._lastPart || this._layer._selectedPart; // Calculate all this here intead of doing it per tile. - var ctx = this._paintContext(); - - // First render the background / sheet grid if we can - if (this.renderBackground) - this.renderBackground(this._canvasCtx, ctx); + if (!ctx) + ctx = this._paintContext(); + this.clear(ctx); var tileRanges = ctx.paneBoundsList.map(this._layer._pxBoundsToTileRange, this._layer); for (var rangeIdx = 0; rangeIdx < tileRanges.length; ++rangeIdx) { @@ -451,6 +461,7 @@ L.CanvasTileLayer = L.TileLayer.extend({ } canvas.closePath(); }; + this._painter.clear(); }, hasSplitPanesSupport: function () { |