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];
|
let internalCache = this[DRAWER_INTERNAL_CACHE];
|
||||||
internalCache = internalCache && internalCache[drawer.getId()];
|
internalCache = internalCache && internalCache[drawer.getId()];
|
||||||
if (keepInternalCopy && !internalCache) {
|
if (keepInternalCopy && !internalCache) {
|
||||||
$.console.warn("Attempt to render tile cache %s that is not prepared with drawer requesting " +
|
$.console.warn("Attempt to render %s that is not prepared with drawer requesting " +
|
||||||
"internal cache! This might introduce artifacts.", this);
|
"internal cache! This might introduce artifacts.", this.toString());
|
||||||
|
|
||||||
this.prepareForRendering(drawer.getId(), supportedTypes, keepInternalCopy)
|
this.prepareForRendering(drawer.getId(), supportedTypes, keepInternalCopy)
|
||||||
.then(() => this._triggerNeedsDraw());
|
.then(() => this._triggerNeedsDraw());
|
||||||
@ -207,8 +207,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!supportedTypes.includes(internalCache.type)) {
|
if (!supportedTypes.includes(internalCache.type)) {
|
||||||
$.console.warn("Attempt to render tile cache %s that is not prepared for current drawer " +
|
$.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);
|
"supported format: the preparation should've happened after tile processing has finished.", this.toString());
|
||||||
|
|
||||||
internalCache.transformTo(supportedTypes.length > 1 ? supportedTypes : supportedTypes[0])
|
internalCache.transformTo(supportedTypes.length > 1 ? supportedTypes : supportedTypes[0])
|
||||||
.then(() => this._triggerNeedsDraw());
|
.then(() => this._triggerNeedsDraw());
|
||||||
@ -231,6 +231,7 @@
|
|||||||
|
|
||||||
const fin = () => {
|
const fin = () => {
|
||||||
// Locked update of render target,
|
// Locked update of render target,
|
||||||
|
console.log("FINISH CACHE PREPARE", this._tRef);
|
||||||
if (_shareTileUpdateStamp) {
|
if (_shareTileUpdateStamp) {
|
||||||
for (let tile of this._tiles) {
|
for (let tile of this._tiles) {
|
||||||
if (tile.processing === _shareTileUpdateStamp) {
|
if (tile.processing === _shareTileUpdateStamp) {
|
||||||
@ -347,6 +348,15 @@
|
|||||||
this._tRef = ref;
|
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.
|
* Set initial state, prepare for usage.
|
||||||
* Must not be called on active cache, e.g. first call destroy().
|
* Must not be called on active cache, e.g. first call destroy().
|
||||||
@ -850,9 +860,9 @@
|
|||||||
* @return {OpenSeadragon.CacheRecord | null}
|
* @return {OpenSeadragon.CacheRecord | null}
|
||||||
*/
|
*/
|
||||||
renameCache( options ) {
|
renameCache( options ) {
|
||||||
let originalCache = this._cachesLoaded[options.oldCacheKey];
|
|
||||||
const newKey = options.newCacheKey,
|
const newKey = options.newCacheKey,
|
||||||
oldKey = options.oldCacheKey;
|
oldKey = options.oldCacheKey;
|
||||||
|
let originalCache = this._cachesLoaded[oldKey];
|
||||||
|
|
||||||
if (!originalCache) {
|
if (!originalCache) {
|
||||||
originalCache = this._zombiesLoaded[oldKey];
|
originalCache = this._zombiesLoaded[oldKey];
|
||||||
@ -940,12 +950,15 @@
|
|||||||
// We need to avoid async execution here: replace consumer instead of overwriting the data.
|
// 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
|
const iterateTiles = [...consumer._tiles]; // unloadCacheForTile() will modify the array, use a copy
|
||||||
for (let tile of iterateTiles) {
|
for (let tile of iterateTiles) {
|
||||||
if (tile.loaded) {
|
if (tile.loaded || tile.loading) {
|
||||||
this.unloadCacheForTile(tile, options.consumerKey, true);
|
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
|
// Just swap victim to become new consumer
|
||||||
const resultCache = this.renameCache({
|
const resultCache = this.renameCache({
|
||||||
oldCacheKey: options.victimKey,
|
oldCacheKey: options.victimKey,
|
||||||
@ -955,8 +968,6 @@
|
|||||||
if (resultCache) {
|
if (resultCache) {
|
||||||
// Only one cache got working item, other caches were idle: update cache: add the new cache
|
// 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()
|
// 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) {
|
for (let tile of tiles) {
|
||||||
if (tile !== options.tile && (tile.loaded || tile.loading)) {
|
if (tile !== options.tile && (tile.loaded || tile.loading)) {
|
||||||
tile.addCache(options.consumerKey, resultCache.data, resultCache.type, true, false);
|
tile.addCache(options.consumerKey, resultCache.data, resultCache.type, true, false);
|
||||||
|
@ -2118,7 +2118,10 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
|||||||
eventFinished = false;
|
eventFinished = false;
|
||||||
const _this = this,
|
const _this = this,
|
||||||
finishPromise = new $.Promise(r => {
|
finishPromise = new $.Promise(r => {
|
||||||
resolver = r;
|
resolver = () => {
|
||||||
|
console.log("TILE READY", tile);
|
||||||
|
r();
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
function completionCallback() {
|
function completionCallback() {
|
||||||
@ -2169,12 +2172,15 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
|||||||
|
|
||||||
if (!tileCacheCreated) {
|
if (!tileCacheCreated) {
|
||||||
// Tile-loaded not called on each tile, but only on tiles with new data! Verify we share the main cache
|
// Tile-loaded not called on each tile, but only on tiles with new data! Verify we share the main cache
|
||||||
|
const origCache = tile.getCache(tile.originalCacheKey);
|
||||||
// We could attempt to initialize the tile here (e.g. find another tile that has same key and if
|
for (let t of origCache._tiles) {
|
||||||
// we find it in different main cache, we try to share it with current tile, but this process
|
if (!t.processing && t.cacheKey !== tile.cacheKey) {
|
||||||
// is also happening within tile cache logics (see last part of consumeCache(..)).
|
const targetMainCache = t.getCache();
|
||||||
fallbackCompletion();
|
tile.addCache(t.cacheKey, targetMainCache.data, targetMainCache.type, true, false);
|
||||||
return;
|
fallbackCompletion();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user