From 561d091005a2ab10801c0a564c7806fab1bf619a Mon Sep 17 00:00:00 2001 From: Toni Munder Date: Sun, 13 Sep 2015 19:20:34 -0700 Subject: [PATCH 1/3] Code for flickering tile --- src/tiledimage.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/tiledimage.js b/src/tiledimage.js index 4aaef1db..9e4942cc 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -675,9 +675,15 @@ function updateViewport( tiledImage ) { viewportBounds.y -= tiledImage._ySpring.current.value; // Reset tile's internal drawn state + var _hasOpaqueTile; + while ( tiledImage.lastDrawn.length > 0 ) { tile = tiledImage.lastDrawn.pop(); tile.beingDrawn = false; + + if (tile.beingDrawn === false) { + _hasOpaqueTile = false; + } } //Change bounds for rotation @@ -1151,6 +1157,7 @@ function blendTile( tiledImage, tile, x, y, level, levelOpacity, currentTime ){ if ( opacity == 1 ) { setCoverage( tiledImage.coverage, level, x, y, true ); + this._hasOpaqueTile = true; } else if ( deltaTime < blendTimeMillis ) { return true; } @@ -1299,7 +1306,7 @@ function drawTiles( tiledImage, lastDrawn ) { usedClip = true; } - if ( tiledImage.placeholderFillStyle && lastDrawn.length === 0 ) { + if ( tiledImage.placeholderFillStyle && this._hasOpaqueTile === false ) { var placeholderRect = tiledImage._drawer.viewportToDrawerRectangle(tiledImage.getBounds(true)); var fillStyle = null; From 484ae63db13c6bf0d267fa8938c222fca0034348 Mon Sep 17 00:00:00 2001 From: Toni Munder Date: Mon, 14 Sep 2015 20:45:52 -0700 Subject: [PATCH 2/3] Made some changes to flickering code --- src/tiledimage.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/tiledimage.js b/src/tiledimage.js index 9e4942cc..b87bd414 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -130,6 +130,7 @@ $.TiledImage = function( options ) { lastResetTime: 0, // Last time for which the tiledImage was reset. _midDraw: false, // Is the tiledImage currently updating the viewport? _needsDraw: true, // Does the tiledImage need to update the viewport again? + _hasOpaqueTile: false, // Do we have even one fully opaque tile? //configurable settings springStiffness: $.DEFAULT_SETTINGS.springStiffness, @@ -675,15 +676,9 @@ function updateViewport( tiledImage ) { viewportBounds.y -= tiledImage._ySpring.current.value; // Reset tile's internal drawn state - var _hasOpaqueTile; - while ( tiledImage.lastDrawn.length > 0 ) { tile = tiledImage.lastDrawn.pop(); tile.beingDrawn = false; - - if (tile.beingDrawn === false) { - _hasOpaqueTile = false; - } } //Change bounds for rotation From a2ee81d7cbd6d36e08245595dac9a757730e46d7 Mon Sep 17 00:00:00 2001 From: Toni Munder Date: Tue, 15 Sep 2015 20:52:44 -0700 Subject: [PATCH 3/3] Fixed some code --- src/tile.js | 4 ++++ src/tiledimage.js | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tile.js b/src/tile.js index 48f3503c..ad018ba7 100644 --- a/src/tile.js +++ b/src/tile.js @@ -265,6 +265,8 @@ $.Tile.prototype = /** @lends OpenSeadragon.Tile.prototype */{ return; } + context.save(); + context.globalAlpha = this.opacity; //if we are supposed to be rendering fully opaque rectangle, @@ -298,6 +300,8 @@ $.Tile.prototype = /** @lends OpenSeadragon.Tile.prototype */{ size.x * $.pixelDensityRatio, size.y * $.pixelDensityRatio ); + + context.restore(); }, /** diff --git a/src/tiledimage.js b/src/tiledimage.js index b87bd414..97172e19 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -1152,7 +1152,7 @@ function blendTile( tiledImage, tile, x, y, level, levelOpacity, currentTime ){ if ( opacity == 1 ) { setCoverage( tiledImage.coverage, level, x, y, true ); - this._hasOpaqueTile = true; + tiledImage._hasOpaqueTile = true; } else if ( deltaTime < blendTimeMillis ) { return true; } @@ -1301,7 +1301,7 @@ function drawTiles( tiledImage, lastDrawn ) { usedClip = true; } - if ( tiledImage.placeholderFillStyle && this._hasOpaqueTile === false ) { + if ( tiledImage.placeholderFillStyle && tiledImage._hasOpaqueTile === false ) { var placeholderRect = tiledImage._drawer.viewportToDrawerRectangle(tiledImage.getBounds(true)); var fillStyle = null;