mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 05:06:09 +03:00
Introduce getTileBounds method for tiledImage
This wraps the implementation in tileSource but provides support for wrapping. It does not support getting the source bounds. Using this function instead of the tileSource version allows the viewport clipping optimization to work with wrapping.
This commit is contained in:
parent
58a90f7c39
commit
4b13cf32fd
@ -392,6 +392,23 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
|||||||
return bounds.rotate(this.getRotation(current), this._getRotationPoint(current));
|
return bounds.rotate(this.getRotation(current), this._getRotationPoint(current));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @function
|
||||||
|
* @param {Number} level
|
||||||
|
* @param {Number} x
|
||||||
|
* @param {Number} y
|
||||||
|
* @returns {OpenSeadragon.Rect} Where this tile fits (in normalized coordinates).
|
||||||
|
*/
|
||||||
|
getTileBounds: function( level, x, y ) {
|
||||||
|
var numTiles = this.source.getNumTiles(level);
|
||||||
|
var xMod = ( numTiles.x + ( x % numTiles.x ) ) % numTiles.x;
|
||||||
|
var yMod = ( numTiles.y + ( y % numTiles.y ) ) % numTiles.y;
|
||||||
|
var bounds = this.source.getTileBounds(level, xMod, yMod);
|
||||||
|
bounds.x += (x - xMod) / numTiles.x;
|
||||||
|
bounds.y += (this._worldHeightCurrent / this._worldWidthCurrent) * ((y - yMod) / numTiles.y);
|
||||||
|
return bounds;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {OpenSeadragon.Point} This TiledImage's content size, in original pixels.
|
* @returns {OpenSeadragon.Point} This TiledImage's content size, in original pixels.
|
||||||
*/
|
*/
|
||||||
@ -1258,15 +1275,10 @@ function updateLevel(tiledImage, haveDrawn, drawLevel, level, levelOpacity,
|
|||||||
for (var x = topLeftTile.x; x <= bottomRightTile.x; x++) {
|
for (var x = topLeftTile.x; x <= bottomRightTile.x; x++) {
|
||||||
for (var y = topLeftTile.y; y <= bottomRightTile.y; y++) {
|
for (var y = topLeftTile.y; y <= bottomRightTile.y; y++) {
|
||||||
|
|
||||||
// Optimisation disabled with wrapping because getTileBounds does not
|
if (drawArea.intersection(tiledImage.getTileBounds(level, x, y)) === null) {
|
||||||
// work correctly with x and y outside of the number of tiles
|
|
||||||
if (!tiledImage.wrapHorizontal && !tiledImage.wrapVertical) {
|
|
||||||
var tileBounds = tiledImage.source.getTileBounds(level, x, y);
|
|
||||||
if (drawArea.intersection(tileBounds) === null) {
|
|
||||||
// This tile is outside of the viewport, no need to draw it
|
// This tile is outside of the viewport, no need to draw it
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
best = updateTile(
|
best = updateTile(
|
||||||
tiledImage,
|
tiledImage,
|
||||||
@ -1450,7 +1462,7 @@ function getTile(
|
|||||||
if ( !tilesMatrix[ level ][ x ][ y ] ) {
|
if ( !tilesMatrix[ level ][ x ][ y ] ) {
|
||||||
xMod = ( numTiles.x + ( x % numTiles.x ) ) % numTiles.x;
|
xMod = ( numTiles.x + ( x % numTiles.x ) ) % numTiles.x;
|
||||||
yMod = ( numTiles.y + ( y % numTiles.y ) ) % numTiles.y;
|
yMod = ( numTiles.y + ( y % numTiles.y ) ) % numTiles.y;
|
||||||
bounds = tileSource.getTileBounds( level, xMod, yMod );
|
bounds = tiledImage.getTileBounds( level, x, y );
|
||||||
sourceBounds = tileSource.getTileBounds( level, xMod, yMod, true );
|
sourceBounds = tileSource.getTileBounds( level, xMod, yMod, true );
|
||||||
exists = tileSource.tileExists( level, xMod, yMod );
|
exists = tileSource.tileExists( level, xMod, yMod );
|
||||||
url = tileSource.getTileUrl( level, xMod, yMod );
|
url = tileSource.getTileUrl( level, xMod, yMod );
|
||||||
@ -1469,9 +1481,6 @@ function getTile(
|
|||||||
context2D = tileSource.getContext2D ?
|
context2D = tileSource.getContext2D ?
|
||||||
tileSource.getContext2D(level, xMod, yMod) : undefined;
|
tileSource.getContext2D(level, xMod, yMod) : undefined;
|
||||||
|
|
||||||
bounds.x += ( x - xMod ) / numTiles.x;
|
|
||||||
bounds.y += (worldHeight / worldWidth) * (( y - yMod ) / numTiles.y);
|
|
||||||
|
|
||||||
tile = new $.Tile(
|
tile = new $.Tile(
|
||||||
level,
|
level,
|
||||||
x,
|
x,
|
||||||
|
Loading…
Reference in New Issue
Block a user