mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-01-30 22:51:41 +03:00
Small bugfixes, rename some properties. Add more redraw calls.
This commit is contained in:
parent
47419a090a
commit
e2c633a23b
@ -37,7 +37,7 @@
|
||||
/**
|
||||
* @typedef BaseDrawerOptions
|
||||
* @memberOf OpenSeadragon
|
||||
* @property {boolean} [detachedCache=false] specify whether the drawer should use
|
||||
* @property {boolean} [usePrivateCache=false] specify whether the drawer should use
|
||||
* detached (=internal) cache object in case it has to perform type conversion
|
||||
*/
|
||||
|
||||
@ -96,7 +96,7 @@ OpenSeadragon.DrawerBase = class DrawerBase{
|
||||
*/
|
||||
get defaultOptions() {
|
||||
return {
|
||||
detachedCache: false
|
||||
usePrivateCache: false
|
||||
};
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ OpenSeadragon.DrawerBase = class DrawerBase{
|
||||
$.console.warn("Attempt to draw tile %s when not cached!", tile);
|
||||
return null;
|
||||
}
|
||||
return cache.getDataForRendering(this.getSupportedDataFormats(), this.options.detachedCache);
|
||||
return cache.getDataForRendering(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2660,11 +2660,13 @@ function OpenSeadragon( options ){
|
||||
}
|
||||
|
||||
if (i >= tileList.length) {
|
||||
viewer.forceRedraw();
|
||||
clearInterval(interval);
|
||||
return;
|
||||
}
|
||||
const tiledImage = tile.tiledImage;
|
||||
if (tiledImage.invalidatedAt > tStamp) {
|
||||
viewer.forceRedraw();
|
||||
clearInterval(interval);
|
||||
return;
|
||||
}
|
||||
|
@ -472,9 +472,11 @@ $.Tile.prototype = {
|
||||
* Get the original data data for this tile
|
||||
* @param {string} type data type to require
|
||||
* @param {boolean} [copy=this.loaded] whether to force copy retrieval
|
||||
* note that if you do not copy the data and save the data to a different cache,
|
||||
* its destruction will also delete this original data which will likely cause issues
|
||||
* @return {*|undefined} data in the desired type, or undefined if a conversion is ongoing
|
||||
*/
|
||||
getOriginalData: function(type, copy = false) {
|
||||
getOriginalData: function(type, copy = true) {
|
||||
if (!this.tiledImage) {
|
||||
return null; //async can access outside its lifetime
|
||||
}
|
||||
|
@ -167,19 +167,20 @@
|
||||
*
|
||||
* When drawers access data, they can choose to access this data as internal copy
|
||||
*
|
||||
* @param {Array<string>} supportedTypes required data (or one of) type(s)
|
||||
* @param {boolean} keepInternalCopy if true, the cache keeps internally the drawer data
|
||||
* @param {OpenSeadragon.DrawerBase} drawer
|
||||
* until 'setData' is called
|
||||
* @returns {any|undefined} desired data if available, undefined if conversion must be done
|
||||
*/
|
||||
getDataForRendering(supportedTypes, keepInternalCopy = true) {
|
||||
getDataForRendering(drawer) {
|
||||
const supportedTypes = drawer.getSupportedDataFormats(),
|
||||
keepInternalCopy = drawer.options.usePrivateCache;
|
||||
if (this.loaded && supportedTypes.includes(this.type)) {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
let internalCache = this[DRAWER_INTERNAL_CACHE];
|
||||
if (keepInternalCopy && !internalCache) {
|
||||
this.prepareForRendering(supportedTypes, keepInternalCopy);
|
||||
this.prepareForRendering(supportedTypes, keepInternalCopy).then(() => this._triggerNeedsDraw);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -191,6 +192,7 @@
|
||||
|
||||
// Cache in the process of loading, no-op
|
||||
if (!internalCache.loaded) {
|
||||
this._triggerNeedsDraw();
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -204,6 +206,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Should not be called if cache type is already among supported types
|
||||
* @private
|
||||
* @param supportedTypes
|
||||
* @param keepInternalCopy
|
||||
@ -215,6 +218,10 @@
|
||||
return $.Promise.resolve(this);
|
||||
}
|
||||
|
||||
if (!keepInternalCopy) {
|
||||
return this.transformTo(supportedTypes);
|
||||
}
|
||||
|
||||
// we can get here only if we want to render incompatible type
|
||||
let internalCache = this[DRAWER_INTERNAL_CACHE] = new $.SimpleCacheRecord();
|
||||
const conversionPath = $.convertor.getConversionPath(this.type, supportedTypes);
|
||||
@ -423,7 +430,7 @@
|
||||
|
||||
_triggerNeedsDraw() {
|
||||
if (this._tiles.length > 0) {
|
||||
this._tiles[0].tiledImage.redraw();
|
||||
this._tiles[0].tiledImage.viewer.forceRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -302,7 +302,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
||||
return;
|
||||
}
|
||||
|
||||
const tiles = this.tileCache.getLoadedTilesFor(this);
|
||||
const tiles = this._tileCache.getLoadedTilesFor(this);
|
||||
$.invalidateTilesLater(tiles, tStamp, this.viewer);
|
||||
},
|
||||
|
||||
@ -2149,7 +2149,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
||||
resolver(tile);
|
||||
} else if (!requiredTypes.includes(cache.type)) {
|
||||
//initiate conversion as soon as possible if incompatible with the drawer
|
||||
cache.prepareForRendering(requiredTypes, _this._drawer.options.detachedCache).then(cacheRef => {
|
||||
cache.prepareForRendering(requiredTypes, _this._drawer.options.usePrivateCache).then(cacheRef => {
|
||||
if (!cacheRef) {
|
||||
return cache.transformTo(requiredTypes);
|
||||
}
|
||||
|
@ -1001,7 +1001,7 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
isMouseNavEnabled: function () {
|
||||
return this.innerTracker.isTracking();
|
||||
return this.innerTracker.tracking;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -109,7 +109,7 @@
|
||||
get defaultOptions() {
|
||||
return {
|
||||
// use detached cache: our type conversion will not collide (and does not have to preserve CPU data ref)
|
||||
detachedCache: true
|
||||
usePrivateCache: true
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,12 @@ const switcher = new DrawerSwitcher();
|
||||
switcher.addDrawerOption("drawer");
|
||||
$("#title-drawer").html(switcher.activeName("drawer"));
|
||||
switcher.render("#title-banner");
|
||||
|
||||
const sources = {
|
||||
'Highsmith': "https://openseadragon.github.io/example-images/highsmith/highsmith.dzi",
|
||||
'Rainbow Grid': "../../data/testpattern.dzi",
|
||||
'Leaves': "../../data/iiif_2_0_sizes/info.json",
|
||||
"Duomo":"https://openseadragon.github.io/example-images/duomo/duomo.dzi",
|
||||
}
|
||||
const url = new URL(window.location);
|
||||
const targetSource = url.searchParams.get("image") || Object.values(sources)[0];
|
||||
const viewer = window.viewer = new OpenSeadragon({
|
||||
@ -142,12 +147,6 @@ const viewer = window.viewer = new OpenSeadragon({
|
||||
drawer: switcher.activeImplementation("drawer"),
|
||||
});
|
||||
|
||||
const sources = {
|
||||
'Highsmith': "https://openseadragon.github.io/example-images/highsmith/highsmith.dzi",
|
||||
'Rainbow Grid': "../../data/testpattern.dzi",
|
||||
'Leaves': "../../data/iiif_2_0_sizes/info.json",
|
||||
"Duomo":"https://openseadragon.github.io/example-images/duomo/duomo.dzi",
|
||||
}
|
||||
$("#image-select")
|
||||
.html(Object.entries(sources).map(([k, v]) =>
|
||||
`<option value="${v}" ${targetSource === v ? "selected" : ""}>${k}</option>`).join("\n"))
|
||||
@ -772,3 +771,17 @@ function updateFilters() {
|
||||
});
|
||||
}
|
||||
|
||||
window.debugCache = function () {
|
||||
for (let cacheKey in viewer.tileCache._cachesLoaded) {
|
||||
let cache = viewer.tileCache._cachesLoaded[cacheKey];
|
||||
if (!cache.loaded) {
|
||||
console.log(cacheKey, "skipping...");
|
||||
}
|
||||
if (cache.type === "context2d") {
|
||||
console.log(cacheKey, cache.data.canvas.width, cache.data.canvas.height);
|
||||
} else {
|
||||
console.log(cacheKey, cache.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@
|
||||
|
||||
if (processors.length === 0) {
|
||||
//restore the original data
|
||||
const context = await tile.getOriginalData('context2d', false);
|
||||
const context = await tile.getOriginalData('context2d', true);
|
||||
tile.setData(context, 'context2d');
|
||||
tile._filterIncrement = self.filterIncrement;
|
||||
return;
|
||||
@ -117,7 +117,6 @@
|
||||
}
|
||||
instance.filterIncrement++;
|
||||
instance.viewer.world.invalidateItems();
|
||||
instance.viewer.forceRedraw();
|
||||
}
|
||||
|
||||
function getFiltersProcessors(instance, item) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user