mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-02-23 18:23:13 +03:00
Fixed: internal cache not allways calling destructor, refresh handler was not called on internal cache. Polish code. Improve filtering demo.
This commit is contained in:
parent
a9b50a8fdb
commit
52ef8156c0
@ -300,7 +300,7 @@
|
|||||||
* @property {Number} [rotationIncrement=90]
|
* @property {Number} [rotationIncrement=90]
|
||||||
* The number of degrees to rotate right or left when the rotate buttons or keyboard shortcuts are activated.
|
* The number of degrees to rotate right or left when the rotate buttons or keyboard shortcuts are activated.
|
||||||
*
|
*
|
||||||
* @property {Number} [maxTilesPerFrame=1]
|
* @property {Number} [maxTilesPerFrame=10]
|
||||||
* The number of tiles loaded per frame. As the frame rate of the client's machine is usually high (e.g., 50 fps),
|
* The number of tiles loaded per frame. As the frame rate of the client's machine is usually high (e.g., 50 fps),
|
||||||
* one tile per frame should be a good choice. However, for large screens or lower frame rates, the number of
|
* one tile per frame should be a good choice. However, for large screens or lower frame rates, the number of
|
||||||
* loaded tiles per frame can be adjusted here. Reasonable values might be 2 or 3 tiles per frame.
|
* loaded tiles per frame can be adjusted here. Reasonable values might be 2 or 3 tiles per frame.
|
||||||
@ -1329,7 +1329,7 @@ function OpenSeadragon( options ){
|
|||||||
preserveImageSizeOnResize: false, // requires autoResize=true
|
preserveImageSizeOnResize: false, // requires autoResize=true
|
||||||
minScrollDeltaTime: 50,
|
minScrollDeltaTime: 50,
|
||||||
rotationIncrement: 90,
|
rotationIncrement: 90,
|
||||||
maxTilesPerFrame: 1,
|
maxTilesPerFrame: 10,
|
||||||
|
|
||||||
//DEFAULT CONTROL SETTINGS
|
//DEFAULT CONTROL SETTINGS
|
||||||
showSequenceControl: true, //SEQUENCE
|
showSequenceControl: true, //SEQUENCE
|
||||||
@ -2651,7 +2651,7 @@ function OpenSeadragon( options ){
|
|||||||
|
|
||||||
|
|
||||||
//@private, runs non-invasive update of all tiles given in the list
|
//@private, runs non-invasive update of all tiles given in the list
|
||||||
invalidateTilesLater: function(tileList, tStamp, viewer, batch = 999) {
|
invalidateTilesLater: function(tileList, tStamp, viewer, batch = $.DEFAULT_SETTINGS.maxTilesPerFrame) {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
let interval = setInterval(() => {
|
let interval = setInterval(() => {
|
||||||
let tile = tileList[i];
|
let tile = tileList[i];
|
||||||
@ -2660,13 +2660,11 @@ function OpenSeadragon( options ){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (i >= tileList.length) {
|
if (i >= tileList.length) {
|
||||||
console.log(":::::::::::::::::::::::::::::end");
|
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const tiledImage = tile.tiledImage;
|
const tiledImage = tile.tiledImage;
|
||||||
if (tiledImage.invalidatedAt > tStamp) {
|
if (tiledImage.invalidatedAt > tStamp) {
|
||||||
console.log(":::::::::::::::::::::::::::::end");
|
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2674,7 +2672,6 @@ function OpenSeadragon( options ){
|
|||||||
for (; i < tileList.length; i++) {
|
for (; i < tileList.length; i++) {
|
||||||
const tile = tileList[i];
|
const tile = tileList[i];
|
||||||
if (!tile.loaded) {
|
if (!tile.loaded) {
|
||||||
console.log("skipping tile: not loaded", tile);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2692,7 +2689,7 @@ function OpenSeadragon( options ){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 5); //how to select the delay...?? todo: just try out
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
//@private, runs tile update event
|
//@private, runs tile update event
|
||||||
@ -2704,7 +2701,6 @@ function OpenSeadragon( options ){
|
|||||||
tile: tile,
|
tile: tile,
|
||||||
tiledImage: image,
|
tiledImage: image,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
//TODO IF NOT CACHE ERRO
|
|
||||||
const newCache = tile.getCache();
|
const newCache = tile.getCache();
|
||||||
if (newCache) {
|
if (newCache) {
|
||||||
newCache._updateStamp = tStamp;
|
newCache._updateStamp = tStamp;
|
||||||
|
@ -195,7 +195,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!supportedTypes.includes(internalCache.type)) {
|
if (!supportedTypes.includes(internalCache.type)) {
|
||||||
internalCache.transformTo(supportedTypes.length > 1 ? supportedTypes : supportedTypes[0]);
|
internalCache.transformTo(supportedTypes.length > 1 ? supportedTypes : supportedTypes[0])
|
||||||
|
.then(() => this._triggerNeedsDraw);
|
||||||
return undefined; // type is NOT compatible
|
return undefined; // type is NOT compatible
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,8 +422,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
_triggerNeedsDraw() {
|
_triggerNeedsDraw() {
|
||||||
for (let tile of this._tiles) {
|
if (this._tiles.length > 0) {
|
||||||
tile.tiledImage.redraw();
|
this._tiles[0].tiledImage.redraw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -617,7 +618,7 @@
|
|||||||
*/
|
*/
|
||||||
setDataAs(data, type) {
|
setDataAs(data, type) {
|
||||||
// no check for state, users must ensure compatibility manually
|
// no check for state, users must ensure compatibility manually
|
||||||
$.convertor.destroy(this._data, this._data);
|
$.convertor.destroy(this._data, this._type);
|
||||||
this._type = type;
|
this._type = type;
|
||||||
this._data = data;
|
this._data = data;
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
|
@ -301,9 +301,8 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
|||||||
if (viewportOnly) {
|
if (viewportOnly) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//else update all tiles at some point, but by priority of access time
|
|
||||||
const tiles = this.tileCache.getLoadedTilesFor(this);
|
const tiles = this.tileCache.getLoadedTilesFor(this);
|
||||||
tiles.sort((a, b) => a.lastTouchTime - b.lastTouchTime);
|
|
||||||
$.invalidateTilesLater(tiles, tStamp, this.viewer);
|
$.invalidateTilesLater(tiles, tStamp, this.viewer);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -2042,6 +2041,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
|
|||||||
_loadTile: function(tile, time ) {
|
_loadTile: function(tile, time ) {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
tile.loading = true;
|
tile.loading = true;
|
||||||
|
tile.tiledImage = this;
|
||||||
this._imageLoader.addJob({
|
this._imageLoader.addJob({
|
||||||
src: tile.getUrl(),
|
src: tile.getUrl(),
|
||||||
tile: tile,
|
tile: tile,
|
||||||
|
@ -370,23 +370,6 @@ $.Viewer = function( options ) {
|
|||||||
|
|
||||||
THIS[ _this.hash ].forceRedraw = true;
|
THIS[ _this.hash ].forceRedraw = true;
|
||||||
|
|
||||||
//if we are not throttling
|
|
||||||
if (_this.imageLoader.canAcceptNewJob()) {
|
|
||||||
//todo small hack, we could make this builtin speedup more sophisticated, breaks tests --> commented out
|
|
||||||
const item = event.item;
|
|
||||||
const origOpacity = item.opacity;
|
|
||||||
const origMaxTiles = item.maxTilesPerFrame;
|
|
||||||
//update tiles
|
|
||||||
item.opacity = 0; //prevent draw
|
|
||||||
item.maxTilesPerFrame = 50; //todo based on image size and also number of images!
|
|
||||||
|
|
||||||
//TODO check if the method is used correctly
|
|
||||||
item._updateLevelsForViewport();
|
|
||||||
item._needsDraw = true; //we did not draw
|
|
||||||
item.opacity = origOpacity;
|
|
||||||
item.maxTilesPerFrame = origMaxTiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_this._updateRequestId) {
|
if (!_this._updateRequestId) {
|
||||||
_this._updateRequestId = scheduleUpdate( _this, updateMulti );
|
_this._updateRequestId = scheduleUpdate( _this, updateMulti );
|
||||||
}
|
}
|
||||||
@ -543,7 +526,6 @@ $.Viewer = function( options ) {
|
|||||||
|
|
||||||
// Open initial tilesources
|
// Open initial tilesources
|
||||||
if (this.tileSources) {
|
if (this.tileSources) {
|
||||||
console.log(this);
|
|
||||||
this.open( this.tileSources );
|
this.open( this.tileSources );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -963,7 +945,6 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
|
|||||||
redrawImmediately: true,
|
redrawImmediately: true,
|
||||||
drawerOptions: null
|
drawerOptions: null
|
||||||
};
|
};
|
||||||
console.debug("RESUEST DRAWER ", options.mainDrawer);
|
|
||||||
options = $.extend(true, defaultOpts, options);
|
options = $.extend(true, defaultOpts, options);
|
||||||
const mainDrawer = options.mainDrawer;
|
const mainDrawer = options.mainDrawer;
|
||||||
const redrawImmediately = options.redrawImmediately;
|
const redrawImmediately = options.redrawImmediately;
|
||||||
|
@ -242,15 +242,10 @@ $.extend( $.World.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.W
|
|||||||
const updatedAt = $.now();
|
const updatedAt = $.now();
|
||||||
$.__updated = updatedAt;
|
$.__updated = updatedAt;
|
||||||
for ( let i = 0; i < this._items.length; i++ ) {
|
for ( let i = 0; i < this._items.length; i++ ) {
|
||||||
console.log("Refreshing ", this._items[i].lastDrawn);
|
|
||||||
|
|
||||||
this._items[i].invalidate(true, updatedAt);
|
this._items[i].invalidate(true, updatedAt);
|
||||||
}
|
}
|
||||||
|
|
||||||
//update all tiles at some point, but by priority of access time
|
|
||||||
const tiles = this.viewer.tileCache.getLoadedTilesFor(true);
|
const tiles = this.viewer.tileCache.getLoadedTilesFor(true);
|
||||||
tiles.sort((a, b) => a.lastTouchTime - b.lastTouchTime);
|
|
||||||
console.log("Refreshing with late update: ", tiles);
|
|
||||||
$.invalidateTilesLater(tiles, updatedAt, this.viewer);
|
$.invalidateTilesLater(tiles, updatedAt, this.viewer);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -132,14 +132,31 @@ switcher.addDrawerOption("drawer");
|
|||||||
$("#title-drawer").html(switcher.activeName("drawer"));
|
$("#title-drawer").html(switcher.activeName("drawer"));
|
||||||
switcher.render("#title-banner");
|
switcher.render("#title-banner");
|
||||||
|
|
||||||
|
const url = new URL(window.location);
|
||||||
|
const targetSource = url.searchParams.get("image") || Object.values(sources)[0];
|
||||||
const viewer = window.viewer = new OpenSeadragon({
|
const viewer = window.viewer = new OpenSeadragon({
|
||||||
id: 'openseadragon',
|
id: 'openseadragon',
|
||||||
prefixUrl: '/build/openseadragon/images/',
|
prefixUrl: '/build/openseadragon/images/',
|
||||||
tileSources: 'https://openseadragon.github.io/example-images/highsmith/highsmith.dzi',
|
tileSources: targetSource,
|
||||||
crossOriginPolicy: 'Anonymous',
|
crossOriginPolicy: 'Anonymous',
|
||||||
drawer: switcher.activeImplementation("drawer"),
|
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"))
|
||||||
|
.on('change', e => {
|
||||||
|
url.searchParams.set('image', e.target.value);
|
||||||
|
window.history.pushState(null, '', url.toString());
|
||||||
|
viewer.addTiledImage({tileSource: e.target.value, index: 0, replace: true});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Prevent Caman from caching the canvas because without this:
|
// Prevent Caman from caching the canvas because without this:
|
||||||
// 1. We have a memory leak
|
// 1. We have a memory leak
|
||||||
|
@ -46,6 +46,9 @@
|
|||||||
<div id="openseadragon"></div>
|
<div id="openseadragon"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="wdzt-cell-layout column-2">
|
<div class="wdzt-cell-layout column-2">
|
||||||
|
<select id="image-select">
|
||||||
|
</select>
|
||||||
|
|
||||||
<h3>Available filters</h3>
|
<h3>Available filters</h3>
|
||||||
<ul id="available">
|
<ul id="available">
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user