Added the code required to implement virtual images and computed tiles.
The important parts are the call to "this.cacheTile" and the "rendered" handling.
The "rendered" handling makes it possible to modify a tile after it has been loaded.
The starting point is the method "fixTile" (drawer.js), this makes it possible to modify a tile.
For performance reasons it always generates a canvas context, no DOM image.
So the extra "rendered" if-statement is required to detect this.
There is no performance problem, because the image would have been converted to a canvas context anyway.
The "cacheTile" method is used by one or more invisible instances of OpenSeadragon to collect tiles.
These are then processed and accumulated to build the virtual image.
They are stored within the TILE_CACHE and the tileMatrix of the visible instance of OpenSeadragon.
This visible instance is the one which displays the virtual image.
Some changes were required in drawer.js (loadTile) to support this.
The following code is required to force appropriate painting and updating for the virtual image:
//
updateDrawer: function ( drawer, tile, target ) {
try {
var newtile = drawer.tilesMatrix[tile.level][tile.x][tile.y];
newtile.image = target;
newtile.loading = false;
newtile.loaded = true;
drawer.updateAgain = true;
drawer.lastDrawn.push( newtile );
} catch ( ex ) {
console.log( ex );
}
},
And that method must be called for the viewer and the navigator:
mi.updateDrawer( osdMain.drawer, tile, target );
mi.updateDrawer( osdMain.navigator.drawer, tile, target );
Added fixTile. This makes it possible to modify a tile after it has been loaded.
Besides that, modified some logging statements to make them more compatible.
Previously, when showNavigator was set to true when creating the
viewer, the navigator would unnecessarily load and parse the tile
source, even though a fully parsed object already exists.
We were setting drawer.updateAgain to the result of each blendTile(),
which meant it was keeping only the last result. Instead we should have
been only setting it to true if blendTile returned true, but never
setting it to false. Fixed.
Very old versions of Firefox - e.g. Firefox 7 - have
window.requestAnimationFrame but not cancelAnimationFrame. This is a
very old release so the easiest fix is simply to check for both of the
functions which we intend to call and fall back on traditional behaviour
if both aren't present.