mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-29 16:46:08 +03:00
Fix demo filtering plugin: certain guards made rendering not being properly updated.
This commit is contained in:
parent
20177116e7
commit
6cbe359398
@ -186,8 +186,8 @@
|
||||
let internalCache = this[DRAWER_INTERNAL_CACHE];
|
||||
internalCache = internalCache && internalCache[drawer.getId()];
|
||||
if (keepInternalCopy && !internalCache) {
|
||||
$.console.warn("Attempt to render tile cache %s that is not prepared with drawer requesting " +
|
||||
"internal cache! This might introduce artifacts.", this);
|
||||
$.console.warn("Attempt to render %s that is not prepared with drawer requesting " +
|
||||
"internal cache! This might introduce artifacts.", this.toString());
|
||||
|
||||
this.prepareForRendering(drawer.getId(), supportedTypes, keepInternalCopy)
|
||||
.then(() => this._triggerNeedsDraw());
|
||||
@ -207,8 +207,8 @@
|
||||
}
|
||||
|
||||
if (!supportedTypes.includes(internalCache.type)) {
|
||||
$.console.warn("Attempt to render tile cache %s that is not prepared for current drawer " +
|
||||
"supported format: the preparation should've happened after tile processing has finished.", this);
|
||||
$.console.warn("Attempt to render %s that is not prepared for current drawer " +
|
||||
"supported format: the preparation should've happened after tile processing has finished.", this.toString());
|
||||
|
||||
internalCache.transformTo(supportedTypes.length > 1 ? supportedTypes : supportedTypes[0])
|
||||
.then(() => this._triggerNeedsDraw());
|
||||
@ -231,6 +231,7 @@
|
||||
|
||||
const fin = () => {
|
||||
// Locked update of render target,
|
||||
console.log("FINISH CACHE PREPARE", this._tRef);
|
||||
if (_shareTileUpdateStamp) {
|
||||
for (let tile of this._tiles) {
|
||||
if (tile.processing === _shareTileUpdateStamp) {
|
||||
@ -347,6 +348,15 @@
|
||||
this._tRef = ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cache description. Used for system messages and errors.
|
||||
* @return {string}
|
||||
*/
|
||||
toString() {
|
||||
const tile = this._tRef || (this._tiles.length && this._tiles[0]);
|
||||
return tile ? `Cache ${this.type} [used e.g. by ${tile.toString()}]` : `Orphan cache!`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set initial state, prepare for usage.
|
||||
* Must not be called on active cache, e.g. first call destroy().
|
||||
@ -850,9 +860,9 @@
|
||||
* @return {OpenSeadragon.CacheRecord | null}
|
||||
*/
|
||||
renameCache( options ) {
|
||||
let originalCache = this._cachesLoaded[options.oldCacheKey];
|
||||
const newKey = options.newCacheKey,
|
||||
oldKey = options.oldCacheKey;
|
||||
let originalCache = this._cachesLoaded[oldKey];
|
||||
|
||||
if (!originalCache) {
|
||||
originalCache = this._zombiesLoaded[oldKey];
|
||||
@ -940,12 +950,15 @@
|
||||
// We need to avoid async execution here: replace consumer instead of overwriting the data.
|
||||
const iterateTiles = [...consumer._tiles]; // unloadCacheForTile() will modify the array, use a copy
|
||||
for (let tile of iterateTiles) {
|
||||
if (tile.loaded) {
|
||||
if (tile.loaded || tile.loading) {
|
||||
this.unloadCacheForTile(tile, options.consumerKey, true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (this._cachesLoaded[options.consumerKey]) {
|
||||
console.error("The routine should've freed cache!");
|
||||
}
|
||||
// Just swap victim to become new consumer
|
||||
const resultCache = this.renameCache({
|
||||
oldCacheKey: options.victimKey,
|
||||
@ -955,8 +968,6 @@
|
||||
if (resultCache) {
|
||||
// Only one cache got working item, other caches were idle: update cache: add the new cache
|
||||
// we can add since we removed above with unloadCacheForTile()
|
||||
// Loading tiles are also accepted, since they might be in the process of finishing. However,
|
||||
// note that they are not part of the unloading process above!
|
||||
for (let tile of tiles) {
|
||||
if (tile !== options.tile && (tile.loaded || tile.loading)) {
|
||||
tile.addCache(options.consumerKey, resultCache.data, resultCache.type, true, false);
|
||||
|
@ -2118,7 +2118,10 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
||||
eventFinished = false;
|
||||
const _this = this,
|
||||
finishPromise = new $.Promise(r => {
|
||||
resolver = r;
|
||||
resolver = () => {
|
||||
console.log("TILE READY", tile);
|
||||
r();
|
||||
};
|
||||
});
|
||||
|
||||
function completionCallback() {
|
||||
@ -2169,13 +2172,16 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
||||
|
||||
if (!tileCacheCreated) {
|
||||
// Tile-loaded not called on each tile, but only on tiles with new data! Verify we share the main cache
|
||||
|
||||
// We could attempt to initialize the tile here (e.g. find another tile that has same key and if
|
||||
// we find it in different main cache, we try to share it with current tile, but this process
|
||||
// is also happening within tile cache logics (see last part of consumeCache(..)).
|
||||
const origCache = tile.getCache(tile.originalCacheKey);
|
||||
for (let t of origCache._tiles) {
|
||||
if (!t.processing && t.cacheKey !== tile.cacheKey) {
|
||||
const targetMainCache = t.getCache();
|
||||
tile.addCache(t.cacheKey, targetMainCache.data, targetMainCache.type, true, false);
|
||||
fallbackCompletion();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggered when a tile has just been loaded in memory. That means that the
|
||||
|
Loading…
Reference in New Issue
Block a user