Clean up outdated TODO comments.

This commit is contained in:
Aiosa 2024-10-21 11:00:23 +02:00
parent d5cdf59993
commit 82e1160508
5 changed files with 18 additions and 35 deletions

View File

@ -239,20 +239,19 @@ OpenSeadragon.DrawerBase = class DrawerBase{
* *
*/ */
_checkInterfaceImplementation(){ _checkInterfaceImplementation(){
// TODO: is this necessary? why not throw just in the method itself? if (this._createDrawingElement === $.DrawerBase.prototype._createDrawingElement) {
if(this._createDrawingElement === $.DrawerBase.prototype._createDrawingElement){
throw(new Error("[drawer]._createDrawingElement must be implemented by child class")); throw(new Error("[drawer]._createDrawingElement must be implemented by child class"));
} }
if(this.draw === $.DrawerBase.prototype.draw){ if (this.draw === $.DrawerBase.prototype.draw) {
throw(new Error("[drawer].draw must be implemented by child class")); throw(new Error("[drawer].draw must be implemented by child class"));
} }
if(this.canRotate === $.DrawerBase.prototype.canRotate){ if (this.canRotate === $.DrawerBase.prototype.canRotate) {
throw(new Error("[drawer].canRotate must be implemented by child class")); throw(new Error("[drawer].canRotate must be implemented by child class"));
} }
if(this.destroy === $.DrawerBase.prototype.destroy){ if (this.destroy === $.DrawerBase.prototype.destroy) {
throw(new Error("[drawer].destroy must be implemented by child class")); throw(new Error("[drawer].destroy must be implemented by child class"));
} }
if(this.setImageSmoothingEnabled === $.DrawerBase.prototype.setImageSmoothingEnabled){ if (this.setImageSmoothingEnabled === $.DrawerBase.prototype.setImageSmoothingEnabled) {
throw(new Error("[drawer].setImageSmoothingEnabled must be implemented by child class")); throw(new Error("[drawer].setImageSmoothingEnabled must be implemented by child class"));
} }
} }

View File

@ -488,9 +488,6 @@ $.Tile.prototype = {
} }
if (value) { if (value) {
// Note: the value's data is probably not preserved - if a cacheKey cache exists, it will ignore
// data - it would have to call setData(...)
// TODO: call setData() ?
if (value.loaded) { if (value.loaded) {
this.addCache(this.cacheKey, value.data, value.type, true, false); this.addCache(this.cacheKey, value.data, value.type, true, false);
} else { } else {
@ -584,15 +581,10 @@ $.Tile.prototype = {
* @return * @return
*/ */
updateRenderTarget: function () { updateRenderTarget: function () {
// TODO we probably need to create timestamp and check if current update stamp is the one saved on the cache,
// if yes, then the update has been performed (and update all tiles asociated to the same cache at once)
// since we cannot ensure all tiles are called with the update (e.g. zombies)
// Check if we asked for restore, and make sure we set it to false since we update the whole cache state // Check if we asked for restore, and make sure we set it to false since we update the whole cache state
const requestedRestore = this.__restore; const requestedRestore = this.__restore;
this.__restore = false; this.__restore = false;
//TODO IMPLEMENT LOCKING AND IGNORE PIPELINE OUT OF THESE CALLS
// Now, if working cache exists, we set main cache to the working cache, since it has been updated // Now, if working cache exists, we set main cache to the working cache, since it has been updated
// if restore() was called last, then working cache was deleted (does not exist) // if restore() was called last, then working cache was deleted (does not exist)
const cache = this.getCache(this._wcKey); const cache = this.getCache(this._wcKey);
@ -763,8 +755,6 @@ $.Tile.prototype = {
if (currentMainKey === key) { if (currentMainKey === key) {
if (!sameBuiltinKeys && this._caches[originalDataKey]) { if (!sameBuiltinKeys && this._caches[originalDataKey]) {
// if we have original data let's revert back // if we have original data let's revert back
// TODO consider calling drawer.getDataToDraw(...)
// or even better, first ensure the data is compatible and then update...?
this._updateMainCacheKey(originalDataKey); this._updateMainCacheKey(originalDataKey);
} else { } else {
$.console.warn("[Tile.removeCache] trying to remove the only cache that can be used to draw the tile!", $.console.warn("[Tile.removeCache] trying to remove the only cache that can be used to draw the tile!",

View File

@ -229,23 +229,25 @@
*/ */
prepareForRendering(drawerId, supportedTypes, keepInternalCopy = true, _shareTileUpdateStamp = null) { prepareForRendering(drawerId, supportedTypes, keepInternalCopy = true, _shareTileUpdateStamp = null) {
// Locked update of render target, const fin = () => {
if (_shareTileUpdateStamp) { // Locked update of render target,
for (let tile of this._tiles) { if (_shareTileUpdateStamp) {
if (tile.processing === _shareTileUpdateStamp) { for (let tile of this._tiles) {
tile.updateRenderTarget(); if (tile.processing === _shareTileUpdateStamp) {
tile.updateRenderTarget();
}
} }
} }
} };
// if not internal copy and we have no data, or we are ready to render, exit // if not internal copy and we have no data, or we are ready to render, exit
if (!this.loaded || supportedTypes.includes(this.type)) { if (!this.loaded || supportedTypes.includes(this.type)) {
fin();
return $.Promise.resolve(this); return $.Promise.resolve(this);
} }
if (!keepInternalCopy) { if (!keepInternalCopy) {
return this.transformTo(supportedTypes); return this.transformTo(supportedTypes).then(fin);
} }
// we can get here only if we want to render incompatible type // we can get here only if we want to render incompatible type
@ -257,6 +259,7 @@
internalCache = internalCache[drawerId]; internalCache = internalCache[drawerId];
if (internalCache) { if (internalCache) {
// already done // already done
fin();
return $.Promise.resolve(this); return $.Promise.resolve(this);
} else { } else {
internalCache = this[DRAWER_INTERNAL_CACHE][drawerId] = new $.SimpleCacheRecord(); internalCache = this[DRAWER_INTERNAL_CACHE][drawerId] = new $.SimpleCacheRecord();
@ -269,7 +272,8 @@
internalCache.withTileReference(this._tRef); internalCache.withTileReference(this._tRef);
const selectedFormat = conversionPath[conversionPath.length - 1].target.value; const selectedFormat = conversionPath[conversionPath.length - 1].target.value;
return $.convertor.convert(this._tRef, this.data, this.type, selectedFormat).then(data => { return $.convertor.convert(this._tRef, this.data, this.type, selectedFormat).then(data => {
internalCache.setDataAs(data, selectedFormat); internalCache.setDataAs(data, selectedFormat); // synchronous, SimpleCacheRecord
fin();
return this; return this;
}); });
} }
@ -530,8 +534,6 @@
const internal = this[DRAWER_INTERNAL_CACHE]; const internal = this[DRAWER_INTERNAL_CACHE];
if (internal) { if (internal) {
for (let iCache in internal) { for (let iCache in internal) {
// TODO: if update will be greedy uncomment (see below)
//internal[iCache].withTileReference(this._tRef);
internal[iCache].setDataAs(data, type); internal[iCache].setDataAs(data, type);
} }
} }
@ -550,8 +552,6 @@
const internal = this[DRAWER_INTERNAL_CACHE]; const internal = this[DRAWER_INTERNAL_CACHE];
if (internal) { if (internal) {
for (let iCache in internal) { for (let iCache in internal) {
// TODO: if update will be greedy uncomment (see below)
//internal[iCache].withTileReference(this._tRef);
internal[iCache].setDataAs(data, type); internal[iCache].setDataAs(data, type);
} }
} }
@ -898,7 +898,6 @@
cloneCache(options) { cloneCache(options) {
const theTile = options.tile; const theTile = options.tile;
const cacheKey = options.copyTargetKey; const cacheKey = options.copyTargetKey;
//todo consider zombie drop support and custom queue for working cache items only
const cacheRecord = this._cachesLoaded[cacheKey] || this._zombiesLoaded[cacheKey]; const cacheRecord = this._cachesLoaded[cacheKey] || this._zombiesLoaded[cacheKey];
$.console.assert(cacheRecord, "[TileCache.cloneCache] attempt to clone non-existent cache %s!", cacheKey); $.console.assert(cacheRecord, "[TileCache.cloneCache] attempt to clone non-existent cache %s!", cacheKey);
$.console.assert(!this._cachesLoaded[options.newCacheKey], $.console.assert(!this._cachesLoaded[options.newCacheKey],

View File

@ -290,7 +290,6 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
*/ */
requestInvalidate: function (viewportOnly, tStamp, restoreTiles = true) { requestInvalidate: function (viewportOnly, tStamp, restoreTiles = true) {
tStamp = tStamp || $.now(); tStamp = tStamp || $.now();
// this.invalidatedAt = tStamp; //todo document, or remove by something nicer
const tiles = viewportOnly ? this._lastDrawn.map(x => x.tile) : this._tileCache.getLoadedTilesFor(this); const tiles = viewportOnly ? this._lastDrawn.map(x => x.tile) : this._tileCache.getLoadedTilesFor(this);
this.viewer.world.requestTileInvalidateEvent(tiles, tStamp, restoreTiles); this.viewer.world.requestTileInvalidateEvent(tiles, tStamp, restoreTiles);
}, },

View File

@ -854,10 +854,6 @@
const _this = this; const _this = this;
const tex2DCompatibleLoader = (tile, data) => { const tex2DCompatibleLoader = (tile, data) => {
let tiledImage = tile.tiledImage; let tiledImage = tile.tiledImage;
//todo verify we are calling conversion just right amount of time!
// e.g. no upload of cpu-existing texture
// also check textures are really getting destroyed (it is tested, but also do this with demos)
let gl = _this._gl; let gl = _this._gl;
// create a gl Texture for this tile and bind the canvas with the image data // create a gl Texture for this tile and bind the canvas with the image data