From 82e1160508c3d89262a5433fdbfe07c64c599943 Mon Sep 17 00:00:00 2001 From: Aiosa <469130@mail.muni.cz> Date: Mon, 21 Oct 2024 11:00:23 +0200 Subject: [PATCH] Clean up outdated TODO comments. --- src/drawerbase.js | 11 +++++------ src/tile.js | 10 ---------- src/tilecache.js | 27 +++++++++++++-------------- src/tiledimage.js | 1 - src/webgldrawer.js | 4 ---- 5 files changed, 18 insertions(+), 35 deletions(-) diff --git a/src/drawerbase.js b/src/drawerbase.js index c811fbff..dc15c8a4 100644 --- a/src/drawerbase.js +++ b/src/drawerbase.js @@ -239,20 +239,19 @@ OpenSeadragon.DrawerBase = class DrawerBase{ * */ _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")); } - if(this.draw === $.DrawerBase.prototype.draw){ + if (this.draw === $.DrawerBase.prototype.draw) { 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")); } - if(this.destroy === $.DrawerBase.prototype.destroy){ + if (this.destroy === $.DrawerBase.prototype.destroy) { 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")); } } diff --git a/src/tile.js b/src/tile.js index 5a9c65dc..bb7e35da 100644 --- a/src/tile.js +++ b/src/tile.js @@ -488,9 +488,6 @@ $.Tile.prototype = { } 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) { this.addCache(this.cacheKey, value.data, value.type, true, false); } else { @@ -584,15 +581,10 @@ $.Tile.prototype = { * @return */ 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 const requestedRestore = this.__restore; 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 // if restore() was called last, then working cache was deleted (does not exist) const cache = this.getCache(this._wcKey); @@ -763,8 +755,6 @@ $.Tile.prototype = { if (currentMainKey === key) { if (!sameBuiltinKeys && this._caches[originalDataKey]) { // 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); } else { $.console.warn("[Tile.removeCache] trying to remove the only cache that can be used to draw the tile!", diff --git a/src/tilecache.js b/src/tilecache.js index 79ae43b9..1c370cc9 100644 --- a/src/tilecache.js +++ b/src/tilecache.js @@ -229,23 +229,25 @@ */ prepareForRendering(drawerId, supportedTypes, keepInternalCopy = true, _shareTileUpdateStamp = null) { - // Locked update of render target, - if (_shareTileUpdateStamp) { - for (let tile of this._tiles) { - if (tile.processing === _shareTileUpdateStamp) { - tile.updateRenderTarget(); + const fin = () => { + // Locked update of render target, + if (_shareTileUpdateStamp) { + for (let tile of this._tiles) { + if (tile.processing === _shareTileUpdateStamp) { + tile.updateRenderTarget(); + } } } - } - + }; // if not internal copy and we have no data, or we are ready to render, exit if (!this.loaded || supportedTypes.includes(this.type)) { + fin(); return $.Promise.resolve(this); } if (!keepInternalCopy) { - return this.transformTo(supportedTypes); + return this.transformTo(supportedTypes).then(fin); } // we can get here only if we want to render incompatible type @@ -257,6 +259,7 @@ internalCache = internalCache[drawerId]; if (internalCache) { // already done + fin(); return $.Promise.resolve(this); } else { internalCache = this[DRAWER_INTERNAL_CACHE][drawerId] = new $.SimpleCacheRecord(); @@ -269,7 +272,8 @@ internalCache.withTileReference(this._tRef); const selectedFormat = conversionPath[conversionPath.length - 1].target.value; 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; }); } @@ -530,8 +534,6 @@ const internal = this[DRAWER_INTERNAL_CACHE]; if (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); } } @@ -550,8 +552,6 @@ const internal = this[DRAWER_INTERNAL_CACHE]; if (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); } } @@ -898,7 +898,6 @@ cloneCache(options) { const theTile = options.tile; 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]; $.console.assert(cacheRecord, "[TileCache.cloneCache] attempt to clone non-existent cache %s!", cacheKey); $.console.assert(!this._cachesLoaded[options.newCacheKey], diff --git a/src/tiledimage.js b/src/tiledimage.js index 0c989e5d..e5fd7424 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -290,7 +290,6 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag */ requestInvalidate: function (viewportOnly, tStamp, restoreTiles = true) { 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); this.viewer.world.requestTileInvalidateEvent(tiles, tStamp, restoreTiles); }, diff --git a/src/webgldrawer.js b/src/webgldrawer.js index 23266347..ee21e946 100644 --- a/src/webgldrawer.js +++ b/src/webgldrawer.js @@ -854,10 +854,6 @@ const _this = this; const tex2DCompatibleLoader = (tile, data) => { 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; // create a gl Texture for this tile and bind the canvas with the image data