[Libreoffice-commits] online.git: Branch 'feature/calc-canvas' - 2 commits - loleaflet/src
Michael Meeks (via logerrit)
logerrit at kemper.freedesktop.org
Fri Aug 21 19:44:29 UTC 2020
loleaflet/src/layer/tile/CanvasTileLayer.js | 51 +++++++++++++---------------
1 file changed, 24 insertions(+), 27 deletions(-)
New commits:
commit 1f51dc50f43a70edd30d54d67e0856d56170f3d9
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Fri Aug 21 20:43:47 2020 +0100
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Fri Aug 21 20:43:47 2020 +0100
Don't merge - grim hack try to get 1:1 pixels in canvas.
Change-Id: I8ff3f157112295e0c6ef6743de3c878329b98adb
diff --git a/loleaflet/src/layer/tile/CanvasTileLayer.js b/loleaflet/src/layer/tile/CanvasTileLayer.js
index 9f3b6e02f..94937e047 100644
--- a/loleaflet/src/layer/tile/CanvasTileLayer.js
+++ b/loleaflet/src/layer/tile/CanvasTileLayer.js
@@ -40,22 +40,15 @@ L.CanvasTilePainter = L.Class.extend({
debug: true,
},
- initialize: function (layer, enableImageSmoothing) {
+ initialize: function (layer) {
this._layer = layer;
this._canvas = this._layer._canvas;
var dpiScale = L.getDpiScaleFactor();
- if (dpiScale === 1 || dpiScale === 2) {
- enableImageSmoothing = (enableImageSmoothing === true);
- }
- else {
- enableImageSmoothing = (enableImageSmoothing === undefined || enableImageSmoothing);
- }
-
this._dpiScale = dpiScale;
this._map = this._layer._map;
- this._setupCanvas(enableImageSmoothing);
+ this._setupCanvas();
this._topLeft = undefined;
this._lastZoom = undefined;
@@ -95,15 +88,11 @@ L.CanvasTilePainter = L.Class.extend({
this.stopUpdates();
},
- setImageSmoothing: function (enable) {
- this._canvasCtx.imageSmoothingEnabled = enable;
- this._canvasCtx.msImageSmoothingEnabled = enable;
- },
-
- _setupCanvas: function (enableImageSmoothing) {
+ _setupCanvas: function () {
console.assert(this._canvas, 'no canvas element');
this._canvasCtx = this._canvas.getContext('2d', { alpha: false });
- this.setImageSmoothing(enableImageSmoothing);
+ this._canvasCtx.imageSmoothingEnabled = false;
+ this._canvasCtx.msImageSmoothingEnabled = false;
var mapSize = this._map.getPixelBounds().getSize();
this._lastSize = mapSize;
this._lastMapSize = mapSize;
@@ -132,7 +121,7 @@ L.CanvasTilePainter = L.Class.extend({
clear: function () {
this._canvasCtx.save();
- this._canvasCtx.scale(this._dpiScale, this._dpiScale);
+ this._canvasCtx.scale(1, 1);
if (this.options.debug)
this._canvasCtx.fillStyle = 'red';
else
@@ -177,7 +166,7 @@ L.CanvasTilePainter = L.Class.extend({
topLeft.y = ctx.viewBounds.min.y;
this._canvasCtx.save();
- this._canvasCtx.scale(this._dpiScale, this._dpiScale);
+ this._canvasCtx.scale(1, 1);
this._canvasCtx.translate(-topLeft.x, -topLeft.y);
// create a clip for the pane/view.
@@ -186,12 +175,11 @@ L.CanvasTilePainter = L.Class.extend({
this._canvasCtx.rect(paneBounds.min.x, paneBounds.min.y, paneSize.x + 1, paneSize.y + 1);
this._canvasCtx.clip();
- if (this._dpiScale !== 1) {
- // FIXME: avoid this scaling when possible (dpiScale = 2).
- this._canvasCtx.drawImage(tile.el, tile.coords.x, tile.coords.y, ctx.tileSize.x, ctx.tileSize.y);
- }
- else {
- this._canvasCtx.drawImage(tile.el, tile.coords.x, tile.coords.y);
+ this._canvasCtx.drawImage(tile.el, tile.coords.x, tile.coords.y);
+ if (this.options.debug)
+ {
+ this._canvasCtx.strokeStyle = 'red';
+ this._canvasCtx.strokeRect(tile.coords.x, tile.coords.y, 256, 256);
}
this._canvasCtx.restore();
}
@@ -204,7 +192,7 @@ L.CanvasTilePainter = L.Class.extend({
}
var splitPos = splitPanesContext.getSplitPos();
this._canvasCtx.save();
- this._canvasCtx.scale(this._dpiScale, this._dpiScale);
+ this._canvasCtx.scale(1, 1);
this._canvasCtx.strokeStyle = 'red';
this._canvasCtx.strokeRect(0, 0, splitPos.x, splitPos.y);
this._canvasCtx.restore();
@@ -249,6 +237,8 @@ L.CanvasTilePainter = L.Class.extend({
!splitPosChanged &&
!scaleChanged);
+ console.debug('Tile size: ' + this._layer._getTileSize());
+
if (skipUpdate)
return;
commit 1c669525a651f6dcc6eab6802809c5e89fe3c3b1
Author: Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Fri Aug 21 16:40:29 2020 +0100
Commit: Michael Meeks <michael.meeks at collabora.com>
CommitDate: Fri Aug 21 16:40:29 2020 +0100
calc tiles: more debug helpers
Change-Id: I24370b2a35fdfeca360cbaeb296cd2dd3a11e768
diff --git a/loleaflet/src/layer/tile/CanvasTileLayer.js b/loleaflet/src/layer/tile/CanvasTileLayer.js
index 5829239fa..9f3b6e02f 100644
--- a/loleaflet/src/layer/tile/CanvasTileLayer.js
+++ b/loleaflet/src/layer/tile/CanvasTileLayer.js
@@ -37,7 +37,7 @@ L.TileCoordData.parseKey = function (keyString) {
L.CanvasTilePainter = L.Class.extend({
options: {
- debug: false,
+ debug: true,
},
initialize: function (layer, enableImageSmoothing) {
@@ -133,7 +133,10 @@ L.CanvasTilePainter = L.Class.extend({
clear: function () {
this._canvasCtx.save();
this._canvasCtx.scale(this._dpiScale, this._dpiScale);
- this._canvasCtx.fillStyle = 'white';
+ if (this.options.debug)
+ this._canvasCtx.fillStyle = 'red';
+ else
+ this._canvasCtx.fillStyle = 'white';
this._canvasCtx.fillRect(0, 0, this._width, this._height);
this._canvasCtx.restore();
},
@@ -277,6 +280,10 @@ L.CanvasTilePainter = L.Class.extend({
},
_paintWholeCanvas: function () {
+
+ if (this.options.debug)
+ this.clear();
+
var zoom = this._lastZoom || Math.round(this._map.getZoom());
var part = this._lastPart || this._layer._selectedPart;
More information about the Libreoffice-commits
mailing list