From 2821c8f67bd3b5a4ec5f9335f9972b53917b7c59 Mon Sep 17 00:00:00 2001 From: Antoine Vandecreme Date: Thu, 6 Oct 2016 22:18:32 +0200 Subject: [PATCH] Partialy fix edge smoothing. --- src/drawer.js | 7 ++++--- src/tiledimage.js | 2 +- src/world.js | 10 ++++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/drawer.js b/src/drawer.js index a77edd56..7029320d 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -323,13 +323,13 @@ $.Drawer.prototype = { this.sketchCanvas.height = sketchCanvasSize.y; this.sketchContext = this.sketchCanvas.getContext( "2d" ); + // FIXME: should check if any tiled image get rotated as well. // If the viewport is not currently rotated, the sketchCanvas // will have the same size as the main canvas. However, if // the viewport get rotated later on, we will need to resize it. if (this.viewport.getRotation() === 0) { var self = this; - this.viewer.addHandler('rotate', function resizeSketchCanvas() { - self.viewer.removeHandler('rotate', resizeSketchCanvas); + this.viewer.addOnceHandler('rotate', function resizeSketchCanvas() { var sketchCanvasSize = self._calculateSketchCanvasSize(); self.sketchCanvas.width = sketchCanvasSize.x; self.sketchCanvas.height = sketchCanvasSize.y; @@ -617,7 +617,8 @@ $.Drawer.prototype = { // private _calculateSketchCanvasSize: function() { var canvasSize = this._calculateCanvasSize(); - if (this.viewport.getRotation() === 0) { + if (this.viewport.getRotation() === 0 && + !this.viewer.world._hasRotatedItem()) { return canvasSize; } // If the viewport is rotated, we need a larger sketch canvas in order diff --git a/src/tiledimage.js b/src/tiledimage.js index 15ec6668..90c9222a 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -1670,7 +1670,7 @@ function drawTiles( tiledImage, lastDrawn ) { tiledImage._degrees, tiledImage.viewport.pixelFromPointNoRotate( tiledImage._getRotationPoint(true), true), - useSketch); + false); } } tiledImage._drawer.blendSketch({ diff --git a/src/world.js b/src/world.js index e68590b3..ad6285d9 100644 --- a/src/world.js +++ b/src/world.js @@ -436,6 +436,16 @@ $.extend( $.World.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.W * @property {?Object} userData - Arbitrary subscriber-defined object. */ this.raiseEvent( 'remove-item', { item: item } ); + }, + + // private + _hasRotatedItem: function() { + for (var i = 0; i < this._items.length; i++) { + if (this._items[i].getRotation() !== 0) { + return true; + } + } + return false; } });