summaryrefslogtreecommitdiff
path: root/loleaflet
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2020-09-08 16:18:31 +0100
committerJan Holesovsky <kendy@collabora.com>2020-09-17 15:03:01 +0200
commitd1971d3a7ddd1973c415b9cbe202f39a0b39faee (patch)
tree9c205a6891577a3b06fbf5b60da555cbe415f014 /loleaflet
parent5367d18d3d152ee7bdc5415aea2dcaca18e40438 (diff)
calc canvas: avoid repeated setTransform; build the right offset.
Change-Id: Iab153b25fa38f27742a052ad0892e3d55c2c04cc
Diffstat (limited to 'loleaflet')
-rw-r--r--loleaflet/src/layer/tile/CanvasTileLayer.js18
1 files changed, 6 insertions, 12 deletions
diff --git a/loleaflet/src/layer/tile/CanvasTileLayer.js b/loleaflet/src/layer/tile/CanvasTileLayer.js
index a4b83aed9..2b8eb00db 100644
--- a/loleaflet/src/layer/tile/CanvasTileLayer.js
+++ b/loleaflet/src/layer/tile/CanvasTileLayer.js
@@ -93,6 +93,7 @@ L.CanvasTilePainter = L.Class.extend({
this._lastSize = mapSize;
this._lastMapSize = mapSize;
this._setCanvasSize(mapSize.x, mapSize.y);
+ this._canvasCtx.setTransform(1,0,0,1,0,0);
},
_setCanvasSize: function (widthCSSPx, heightCSSPx) {
@@ -129,7 +130,6 @@ L.CanvasTilePainter = L.Class.extend({
},
clear: function () {
- this._canvasCtx.setTransform(1,0,0,1,0,0);
if (this._layer._debug)
this._canvasCtx.fillStyle = 'rgba(255, 0, 0, 0.5)';
else
@@ -171,15 +171,9 @@ L.CanvasTilePainter = L.Class.extend({
if (!paneBounds.intersects(tileBounds))
continue;
- var topLeft = paneBounds.getTopLeft();
- if (topLeft.x)
- topLeft.x = viewBounds.min.x;
- if (topLeft.y)
- topLeft.y = viewBounds.min.y;
-
- this._canvasCtx.setTransform(1,0,
- 0,1,
- -topLeft.x, -topLeft.y);
+ var offset = paneBounds.getTopLeft(); // allocates
+ offset.x = Math.min(offset.x, viewBounds.min.x);
+ offset.y = Math.min(offset.y, viewBounds.min.y);
// intersect - to avoid state thrash through clipping
var crop = new L.Bounds(tileBounds.min, tileBounds.max);
@@ -195,7 +189,8 @@ L.CanvasTilePainter = L.Class.extend({
crop.min.x - tileBounds.min.x,
crop.min.y - tileBounds.min.y,
cropWidth, cropHeight,
- crop.min.x, crop.min.y,
+ crop.min.x - offset.x,
+ crop.min.y - offset.y,
cropWidth, cropHeight);
if (this._layer._debug)
{
@@ -211,7 +206,6 @@ L.CanvasTilePainter = L.Class.extend({
return;
}
var splitPos = this._layer._cssPixelsToCore(splitPanesContext.getSplitPos());
- this._canvasCtx.setTransform(1,0,0,1,0,0);
this._canvasCtx.strokeStyle = 'red';
this._canvasCtx.strokeRect(0, 0, splitPos.x, splitPos.y);
},