Skip to content

Commit 88af74a

Browse files
authored
Merge pull request #312 from bgilbert/osd
examples/deepzoom: update OpenSeadragon to 5.0.1
2 parents 602ddd8 + dd70770 commit 88af74a

File tree

1 file changed

+66
-40
lines changed

1 file changed

+66
-40
lines changed

examples/deepzoom/static/openseadragon.js

Lines changed: 66 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
//! openseadragon 5.0.0
2-
//! Built on 2024-08-14
3-
//! Git commit: v5.0.0-0-f28b7fc1
1+
//! openseadragon 5.0.1
2+
//! Built on 2024-12-09
3+
//! Git commit: v5.0.1-0-480de92d
44
//! http://openseadragon.github.io
55
//! License: http://openseadragon.github.io/license/
66

@@ -90,7 +90,7 @@
9090

9191
/**
9292
* @namespace OpenSeadragon
93-
* @version openseadragon 5.0.0
93+
* @version openseadragon 5.0.1
9494
* @classdesc The root namespace for OpenSeadragon. All utility methods
9595
* and classes are defined on or below this namespace.
9696
*
@@ -220,7 +220,7 @@
220220
* For complete list of modes, please @see {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation/ globalCompositeOperation}
221221
*
222222
* @property {Boolean} [imageSmoothingEnabled=true]
223-
* Image smoothing for canvas rendering (only if the canvas drawer is used). Note: Ignored
223+
* Image smoothing for rendering (only if the canvas or webgl drawer is used). Note: Ignored
224224
* by some (especially older) browsers which do not support this canvas property.
225225
* This property can be changed in {@link Viewer.DrawerBase.setImageSmoothingEnabled}.
226226
*
@@ -856,10 +856,10 @@ function OpenSeadragon( options ){
856856
* @since 1.0.0
857857
*/
858858
$.version = {
859-
versionStr: '5.0.0',
859+
versionStr: '5.0.1',
860860
major: parseInt('5', 10),
861861
minor: parseInt('0', 10),
862-
revision: parseInt('0', 10)
862+
revision: parseInt('1', 10)
863863
};
864864

865865

@@ -10407,17 +10407,15 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
1040710407
},
1040810408

1040910409
/**
10410-
* Update pixel density ratio, clears all tiles and triggers updates for
10411-
* all items if the ratio has changed.
10410+
* Update pixel density ratio and forces a resize operation.
1041210411
* @private
1041310412
*/
1041410413
_updatePixelDensityRatio: function() {
1041510414
var previusPixelDensityRatio = $.pixelDensityRatio;
1041610415
var currentPixelDensityRatio = $.getCurrentPixelDensityRatio();
1041710416
if (previusPixelDensityRatio !== currentPixelDensityRatio) {
1041810417
$.pixelDensityRatio = currentPixelDensityRatio;
10419-
this.world.resetItems();
10420-
this.forceRedraw();
10418+
this.forceResize();
1042110419
}
1042210420
},
1042310421

@@ -12289,7 +12287,6 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /*
1228912287
},
1229012288

1229112289
setDisplayTransform: function(rule) {
12292-
setElementTransform(this.displayRegion, rule);
1229312290
setElementTransform(this.canvas, rule);
1229412291
setElementTransform(this.element, rule);
1229512292
},
@@ -19044,9 +19041,17 @@ $.Tile.prototype = {
1904419041
};
1904519042
}
1904619043

19044+
this.elementWrapper = document.createElement('div');
1904719045
this.element = options.element;
19048-
this.element.innerHTML = "<div>" + this.element.innerHTML + "</div>";
19049-
this.style = options.element.style;
19046+
this.elementWrapper.appendChild(this.element);
19047+
19048+
if (this.element.id) {
19049+
this.elementWrapper.id = "overlay-wrapper-" + this.element.id;
19050+
} else {
19051+
this.elementWrapper.id = "overlay-wrapper";
19052+
}
19053+
19054+
this.style = this.elementWrapper.style;
1905019055
this._init(options);
1905119056
};
1905219057

@@ -19113,7 +19118,7 @@ $.Tile.prototype = {
1911319118
* @function
1911419119
*/
1911519120
destroy: function() {
19116-
var element = this.element;
19121+
var element = this.elementWrapper;
1911719122
var style = this.style;
1911819123

1911919124
if (element.parentNode) {
@@ -19158,7 +19163,7 @@ $.Tile.prototype = {
1915819163
* @param {Element} container
1915919164
*/
1916019165
drawHTML: function(container, viewport) {
19161-
var element = this.element;
19166+
var element = this.elementWrapper;
1916219167
if (element.parentNode !== container) {
1916319168
//save the source parent for later if we need it
1916419169
element.prevElementParent = element.parentNode;
@@ -19169,7 +19174,7 @@ $.Tile.prototype = {
1916919174
this.style.position = "absolute";
1917019175
// this.size is used by overlays which don't get scaled in at
1917119176
// least one direction when this.checkResize is set to false.
19172-
this.size = $.getElementSize(element);
19177+
this.size = $.getElementSize(this.elementWrapper);
1917319178
}
1917419179
var positionAndSize = this._getOverlayPositionAndSize(viewport);
1917519180
var position = positionAndSize.position;
@@ -19186,15 +19191,15 @@ $.Tile.prototype = {
1918619191
this.onDraw(position, size, this.element);
1918719192
} else {
1918819193
var style = this.style;
19189-
var innerElement = element.firstChild;
19190-
var innerStyle = innerElement.style;
19194+
var innerStyle = this.element.style;
19195+
innerStyle.display = "block";
1919119196
style.left = position.x + "px";
1919219197
style.top = position.y + "px";
1919319198
if (this.width !== null) {
19194-
style.width = size.x + "px";
19199+
innerStyle.width = size.x + "px";
1919519200
}
1919619201
if (this.height !== null) {
19197-
style.height = size.y + "px";
19202+
innerStyle.height = size.y + "px";
1919819203
}
1919919204
var transformOriginProp = $.getCssPropertyWithVendorPrefix(
1920019205
'transformOrigin');
@@ -19219,7 +19224,7 @@ $.Tile.prototype = {
1921919224
style[transformProp] = "";
1922019225
}
1922119226
}
19222-
style.display = 'block';
19227+
style.display = 'flex';
1922319228
}
1922419229
},
1922519230

@@ -19271,7 +19276,7 @@ $.Tile.prototype = {
1927119276
}
1927219277
if (this.checkResize &&
1927319278
(this.width === null || this.height === null)) {
19274-
var eltSize = this.size = $.getElementSize(this.element);
19279+
var eltSize = this.size = $.getElementSize(this.elementWrapper);
1927519280
if (this.width === null) {
1927619281
width = eltSize.x;
1927719282
}
@@ -21155,6 +21160,8 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
2115521160
this._renderingCanvas = null;
2115621161
this._backupCanvasDrawer = null;
2115721162

21163+
this._imageSmoothingEnabled = true; // will be updated by setImageSmoothingEnabled
21164+
2115821165
// Add listeners for events that require modifying the scene or camera
2115921166
this._boundToTileReady = ev => this._tileReadyHandler(ev);
2116021167
this._boundToImageUnloaded = ev => this._imageUnloadedHandler(ev);
@@ -21198,10 +21205,7 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
2119821205
gl.bindRenderbuffer(gl.RENDERBUFFER, null);
2119921206
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
2120021207

21201-
let canvases = Array.from(this._TextureMap.keys());
21202-
canvases.forEach(canvas => {
21203-
this._cleanupImageData(canvas); // deletes texture, removes from _TextureMap
21204-
});
21208+
this._unloadTextures();
2120521209

2120621210
// Delete all our created resources
2120721211
gl.deleteBuffer(this._secondPass.bufferOutputPosition);
@@ -21223,6 +21227,7 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
2122321227
// unbind our event listeners from the viewer
2122421228
this.viewer.removeHandler("tile-ready", this._boundToTileReady);
2122521229
this.viewer.removeHandler("image-unloaded", this._boundToImageUnloaded);
21230+
this.viewer.removeHandler("resize", this._resizeHandler);
2122621231

2122721232
// set our webgl context reference to null to enable garbage collection
2122821233
this._gl = null;
@@ -21317,9 +21322,10 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
2131721322
*/
2131821323
draw(tiledImages){
2131921324
let gl = this._gl;
21325+
const bounds = this.viewport.getBoundsNoRotateWithMargins(true);
2132021326
let view = {
21321-
bounds: this.viewport.getBoundsNoRotate(true),
21322-
center: this.viewport.getCenter(true),
21327+
bounds: bounds,
21328+
center: new OpenSeadragon.Point(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2),
2132321329
rotation: this.viewport.getRotation(true) * Math.PI / 180
2132421330
};
2132521331

@@ -21511,7 +21517,7 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
2151121517
gl.bindBuffer(gl.ARRAY_BUFFER, this._secondPass.bufferTexturePosition);
2151221518
gl.vertexAttribPointer(this._secondPass.aTexturePosition, 2, gl.FLOAT, false, 0, 0);
2151321519
gl.bindBuffer(gl.ARRAY_BUFFER, this._secondPass.bufferOutputPosition);
21514-
gl.vertexAttribPointer(this._firstPass.aOutputPosition, 2, gl.FLOAT, false, 0, 0);
21520+
gl.vertexAttribPointer(this._secondPass.aOutputPosition, 2, gl.FLOAT, false, 0, 0);
2151521521

2151621522
// Draw the quad (two triangles)
2151721523
gl.drawArrays(gl.TRIANGLES, 0, 6);
@@ -21547,11 +21553,15 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
2154721553

2154821554
// Public API required by all Drawer implementations
2154921555
/**
21550-
* Required by DrawerBase, but has no effect on WebGLDrawer.
21551-
* @param {Boolean} enabled
21556+
* Sets whether image smoothing is enabled or disabled
21557+
* @param {Boolean} enabled If true, uses gl.LINEAR as the TEXTURE_MIN_FILTER and TEXTURE_MAX_FILTER, otherwise gl.NEAREST.
2155221558
*/
2155321559
setImageSmoothingEnabled(enabled){
21554-
// noop - this property does not impact WebGLDrawer
21560+
if( this._imageSmoothingEnabled !== enabled ){
21561+
this._imageSmoothingEnabled = enabled;
21562+
this._unloadTextures();
21563+
this.viewer.world.draw();
21564+
}
2155521565
}
2155621566

2155721567
/**
@@ -21661,6 +21671,11 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
2166121671

2166221672
}
2166321673

21674+
// private
21675+
_textureFilter(){
21676+
return this._imageSmoothingEnabled ? this._gl.LINEAR : this._gl.NEAREST;
21677+
}
21678+
2166421679
// private
2166521680
_setupRenderer(){
2166621681
let gl = this._gl;
@@ -21677,7 +21692,7 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
2167721692
gl.activeTexture(gl.TEXTURE0);
2167821693
gl.bindTexture(gl.TEXTURE_2D, this._renderToTexture);
2167921694
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, this._renderingCanvas.width, this._renderingCanvas.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
21680-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
21695+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, this._textureFilter());
2168121696
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
2168221697
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
2168321698

@@ -21876,7 +21891,7 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
2187621891
gl.activeTexture(gl.TEXTURE0);
2187721892
gl.bindTexture(gl.TEXTURE_2D, this._renderToTexture);
2187821893
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, w, h, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
21879-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
21894+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, this._textureFilter());
2188021895
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
2188121896
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
2188221897

@@ -21902,8 +21917,7 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
2190221917

2190321918
this._gl = this._renderingCanvas.getContext('webgl');
2190421919

21905-
//make the additional canvas elements mirror size changes to the output canvas
21906-
this.viewer.addHandler("resize", function(){
21920+
this._resizeHandler = function(){
2190721921

2190821922
if(_this._outputCanvas !== _this.viewer.drawer.canvas){
2190921923
_this._outputCanvas.style.width = _this.viewer.drawer.canvas.clientWidth + 'px';
@@ -21924,7 +21938,10 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
2192421938

2192521939
// important - update the size of the rendering viewport!
2192621940
_this._resizeRenderer();
21927-
});
21941+
};
21942+
21943+
//make the additional canvas elements mirror size changes to the output canvas
21944+
this.viewer.addHandler("resize", this._resizeHandler);
2192821945
}
2192921946

2193021947
// private
@@ -22014,8 +22031,8 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
2201422031
// Set the parameters so we can render any size image.
2201522032
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
2201622033
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
22017-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
22018-
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
22034+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, this._textureFilter());
22035+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, this._textureFilter());
2201922036

2202022037
// Upload the image into the texture.
2202122038
this._uploadImageData(tileContext);
@@ -22039,6 +22056,14 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
2203922056
};
2204022057
}
2204122058

22059+
// private
22060+
_unloadTextures(){
22061+
let canvases = Array.from(this._TextureMap.keys());
22062+
canvases.forEach(canvas => {
22063+
this._cleanupImageData(canvas); // deletes texture, removes from _TextureMap
22064+
});
22065+
}
22066+
2204222067
// private
2204322068
_uploadImageData(tileContext){
2204422069

@@ -25101,6 +25126,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
2510125126
this._clip = null;
2510225127
}
2510325128

25129+
this._needsUpdate = true;
2510425130
this._needsDraw = true;
2510525131
/**
2510625132
* Raised when the TiledImage's clip is changed.

0 commit comments

Comments
 (0)