Change coverage methods on TiledImage to be member methods.

This commit is contained in:
Jirka 2022-03-30 13:27:23 +02:00
parent 7f784835a7
commit 38e91f1fa5

View File

@ -1176,7 +1176,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
// Stop the loop if lower-res tiles would all be covered by // Stop the loop if lower-res tiles would all be covered by
// already drawn tiles // already drawn tiles
if ($.TiledImage._providesCoverage(this.coverage, level)) { if (this._providesCoverage(this.coverage, level)) {
break; break;
} }
} }
@ -1287,8 +1287,8 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
}); });
} }
$.TiledImage._resetCoverage(this.coverage, level); this._resetCoverage(this.coverage, level);
$.TiledImage._resetCoverage(this.loadingCoverage, level); this._resetCoverage(this.loadingCoverage, level);
//OK, a new drawing so do your calculations //OK, a new drawing so do your calculations
var cornerTiles = this._getCornerTiles(level, topLeftBound, bottomRightBound); var cornerTiles = this._getCornerTiles(level, topLeftBound, bottomRightBound);
@ -1392,18 +1392,18 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
}); });
} }
$.TiledImage._setCoverage( this.coverage, level, x, y, false ); this._setCoverage( this.coverage, level, x, y, false );
var loadingCoverage = tile.loaded || tile.loading || $.TiledImage._isCovered(this.loadingCoverage, level, x, y); var loadingCoverage = tile.loaded || tile.loading || this._isCovered(this.loadingCoverage, level, x, y);
$.TiledImage._setCoverage(this.loadingCoverage, level, x, y, loadingCoverage); this._setCoverage(this.loadingCoverage, level, x, y, loadingCoverage);
if ( !tile.exists ) { if ( !tile.exists ) {
return best; return best;
} }
if ( haveDrawn && !drawTile ) { if ( haveDrawn && !drawTile ) {
if ( $.TiledImage._isCovered( this.coverage, level, x, y ) ) { if ( this._isCovered( this.coverage, level, x, y ) ) {
$.TiledImage._setCoverage( this.coverage, level, x, y, true ); this._setCoverage( this.coverage, level, x, y, true );
} else { } else {
drawTile = true; drawTile = true;
} }
@ -1789,7 +1789,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
this.lastDrawn.push( tile ); this.lastDrawn.push( tile );
if ( opacity === 1 ) { if ( opacity === 1 ) {
$.TiledImage._setCoverage( this.coverage, level, x, y, true ); this._setCoverage( this.coverage, level, x, y, true );
this._hasOpaqueTile = true; this._hasOpaqueTile = true;
} else if ( deltaTime < blendTimeMillis ) { } else if ( deltaTime < blendTimeMillis ) {
return true; return true;
@ -2080,8 +2080,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
} }
} }
} }
} },
});
/** /**
* @private * @private
@ -2100,7 +2099,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
* @param {Number} y - The Y position of the tile. * @param {Number} y - The Y position of the tile.
* @returns {Boolean} * @returns {Boolean}
*/ */
$.TiledImage._providesCoverage = function( coverage, level, x, y ) { _providesCoverage: function( coverage, level, x, y ) {
var rows, var rows,
cols, cols,
i, j; i, j;
@ -2130,7 +2129,7 @@ $.TiledImage._providesCoverage = function( coverage, level, x, y ) {
coverage[ level ][ x ][ y ] === undefined || coverage[ level ][ x ][ y ] === undefined ||
coverage[ level ][ x ][ y ] === true coverage[ level ][ x ][ y ] === true
); );
}; },
/** /**
* @private * @private
@ -2145,7 +2144,7 @@ $.TiledImage._providesCoverage = function( coverage, level, x, y ) {
* @param {Number} y - The Y position of the tile. * @param {Number} y - The Y position of the tile.
* @returns {Boolean} * @returns {Boolean}
*/ */
$.TiledImage._isCovered = function( coverage, level, x, y ) { _isCovered: function( coverage, level, x, y ) {
if ( x === undefined || y === undefined ) { if ( x === undefined || y === undefined ) {
return this._providesCoverage( coverage, level + 1 ); return this._providesCoverage( coverage, level + 1 );
} else { } else {
@ -2156,7 +2155,7 @@ $.TiledImage._isCovered = function( coverage, level, x, y ) {
this._providesCoverage( coverage, level + 1, 2 * x + 1, 2 * y + 1 ) this._providesCoverage( coverage, level + 1, 2 * x + 1, 2 * y + 1 )
); );
} }
}; },
/** /**
* @private * @private
@ -2169,7 +2168,7 @@ $.TiledImage._isCovered = function( coverage, level, x, y ) {
* @param {Number} y - The Y position of the tile. * @param {Number} y - The Y position of the tile.
* @param {Boolean} covers - Whether the tile provides coverage. * @param {Boolean} covers - Whether the tile provides coverage.
*/ */
$.TiledImage._setCoverage = function( coverage, level, x, y, covers ) { _setCoverage: function( coverage, level, x, y, covers ) {
if ( !coverage[ level ] ) { if ( !coverage[ level ] ) {
$.console.warn( $.console.warn(
"Setting coverage for a tile before its level's coverage has been reset: %s", "Setting coverage for a tile before its level's coverage has been reset: %s",
@ -2183,7 +2182,7 @@ $.TiledImage._setCoverage = function( coverage, level, x, y, covers ) {
} }
coverage[ level ][ x ][ y ] = covers; coverage[ level ][ x ][ y ] = covers;
}; },
/** /**
* @private * @private
@ -2195,9 +2194,11 @@ $.TiledImage._setCoverage = function( coverage, level, x, y, covers ) {
* @param {Object} coverage - A '3d' dictionary [level][x][y] --> Boolean. * @param {Object} coverage - A '3d' dictionary [level][x][y] --> Boolean.
* @param {Number} level - The resolution level of tiles to completely reset. * @param {Number} level - The resolution level of tiles to completely reset.
*/ */
$.TiledImage._resetCoverage = function( coverage, level ) { _resetCoverage: function( coverage, level ) {
coverage[ level ] = {}; coverage[ level ] = {};
}; }
});
/** /**
* @private * @private