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
4
4
//! http://openseadragon.github.io
5
5
//! License: http://openseadragon.github.io/license/
6
6
90
90
91
91
/**
92
92
* @namespace OpenSeadragon
93
- * @version openseadragon 5.0.0
93
+ * @version openseadragon 5.0.1
94
94
* @classdesc The root namespace for OpenSeadragon. All utility methods
95
95
* and classes are defined on or below this namespace.
96
96
*
220
220
* For complete list of modes, please @see {@link https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation/ globalCompositeOperation}
221
221
*
222
222
* @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
224
224
* by some (especially older) browsers which do not support this canvas property.
225
225
* This property can be changed in {@link Viewer.DrawerBase.setImageSmoothingEnabled}.
226
226
*
@@ -856,10 +856,10 @@ function OpenSeadragon( options ){
856
856
* @since 1.0.0
857
857
*/
858
858
$.version = {
859
- versionStr: '5.0.0 ',
859
+ versionStr: '5.0.1 ',
860
860
major: parseInt('5', 10),
861
861
minor: parseInt('0', 10),
862
- revision: parseInt('0 ', 10)
862
+ revision: parseInt('1 ', 10)
863
863
};
864
864
865
865
@@ -10407,17 +10407,15 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
10407
10407
},
10408
10408
10409
10409
/**
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.
10412
10411
* @private
10413
10412
*/
10414
10413
_updatePixelDensityRatio: function() {
10415
10414
var previusPixelDensityRatio = $.pixelDensityRatio;
10416
10415
var currentPixelDensityRatio = $.getCurrentPixelDensityRatio();
10417
10416
if (previusPixelDensityRatio !== currentPixelDensityRatio) {
10418
10417
$.pixelDensityRatio = currentPixelDensityRatio;
10419
- this.world.resetItems();
10420
- this.forceRedraw();
10418
+ this.forceResize();
10421
10419
}
10422
10420
},
10423
10421
@@ -12289,7 +12287,6 @@ $.extend( $.Navigator.prototype, $.EventSource.prototype, $.Viewer.prototype, /*
12289
12287
},
12290
12288
12291
12289
setDisplayTransform: function(rule) {
12292
- setElementTransform(this.displayRegion, rule);
12293
12290
setElementTransform(this.canvas, rule);
12294
12291
setElementTransform(this.element, rule);
12295
12292
},
@@ -19044,9 +19041,17 @@ $.Tile.prototype = {
19044
19041
};
19045
19042
}
19046
19043
19044
+ this.elementWrapper = document.createElement('div');
19047
19045
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;
19050
19055
this._init(options);
19051
19056
};
19052
19057
@@ -19113,7 +19118,7 @@ $.Tile.prototype = {
19113
19118
* @function
19114
19119
*/
19115
19120
destroy: function() {
19116
- var element = this.element ;
19121
+ var element = this.elementWrapper ;
19117
19122
var style = this.style;
19118
19123
19119
19124
if (element.parentNode) {
@@ -19158,7 +19163,7 @@ $.Tile.prototype = {
19158
19163
* @param {Element} container
19159
19164
*/
19160
19165
drawHTML: function(container, viewport) {
19161
- var element = this.element ;
19166
+ var element = this.elementWrapper ;
19162
19167
if (element.parentNode !== container) {
19163
19168
//save the source parent for later if we need it
19164
19169
element.prevElementParent = element.parentNode;
@@ -19169,7 +19174,7 @@ $.Tile.prototype = {
19169
19174
this.style.position = "absolute";
19170
19175
// this.size is used by overlays which don't get scaled in at
19171
19176
// least one direction when this.checkResize is set to false.
19172
- this.size = $.getElementSize(element );
19177
+ this.size = $.getElementSize(this.elementWrapper );
19173
19178
}
19174
19179
var positionAndSize = this._getOverlayPositionAndSize(viewport);
19175
19180
var position = positionAndSize.position;
@@ -19186,15 +19191,15 @@ $.Tile.prototype = {
19186
19191
this.onDraw(position, size, this.element);
19187
19192
} else {
19188
19193
var style = this.style;
19189
- var innerElement = element.firstChild ;
19190
- var innerStyle = innerElement.style ;
19194
+ var innerStyle = this. element.style ;
19195
+ innerStyle.display = "block" ;
19191
19196
style.left = position.x + "px";
19192
19197
style.top = position.y + "px";
19193
19198
if (this.width !== null) {
19194
- style .width = size.x + "px";
19199
+ innerStyle .width = size.x + "px";
19195
19200
}
19196
19201
if (this.height !== null) {
19197
- style .height = size.y + "px";
19202
+ innerStyle .height = size.y + "px";
19198
19203
}
19199
19204
var transformOriginProp = $.getCssPropertyWithVendorPrefix(
19200
19205
'transformOrigin');
@@ -19219,7 +19224,7 @@ $.Tile.prototype = {
19219
19224
style[transformProp] = "";
19220
19225
}
19221
19226
}
19222
- style.display = 'block ';
19227
+ style.display = 'flex ';
19223
19228
}
19224
19229
},
19225
19230
@@ -19271,7 +19276,7 @@ $.Tile.prototype = {
19271
19276
}
19272
19277
if (this.checkResize &&
19273
19278
(this.width === null || this.height === null)) {
19274
- var eltSize = this.size = $.getElementSize(this.element );
19279
+ var eltSize = this.size = $.getElementSize(this.elementWrapper );
19275
19280
if (this.width === null) {
19276
19281
width = eltSize.x;
19277
19282
}
@@ -21155,6 +21160,8 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
21155
21160
this._renderingCanvas = null;
21156
21161
this._backupCanvasDrawer = null;
21157
21162
21163
+ this._imageSmoothingEnabled = true; // will be updated by setImageSmoothingEnabled
21164
+
21158
21165
// Add listeners for events that require modifying the scene or camera
21159
21166
this._boundToTileReady = ev => this._tileReadyHandler(ev);
21160
21167
this._boundToImageUnloaded = ev => this._imageUnloadedHandler(ev);
@@ -21198,10 +21205,7 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
21198
21205
gl.bindRenderbuffer(gl.RENDERBUFFER, null);
21199
21206
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
21200
21207
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();
21205
21209
21206
21210
// Delete all our created resources
21207
21211
gl.deleteBuffer(this._secondPass.bufferOutputPosition);
@@ -21223,6 +21227,7 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
21223
21227
// unbind our event listeners from the viewer
21224
21228
this.viewer.removeHandler("tile-ready", this._boundToTileReady);
21225
21229
this.viewer.removeHandler("image-unloaded", this._boundToImageUnloaded);
21230
+ this.viewer.removeHandler("resize", this._resizeHandler);
21226
21231
21227
21232
// set our webgl context reference to null to enable garbage collection
21228
21233
this._gl = null;
@@ -21317,9 +21322,10 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
21317
21322
*/
21318
21323
draw(tiledImages){
21319
21324
let gl = this._gl;
21325
+ const bounds = this.viewport.getBoundsNoRotateWithMargins(true);
21320
21326
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 ),
21323
21329
rotation: this.viewport.getRotation(true) * Math.PI / 180
21324
21330
};
21325
21331
@@ -21511,7 +21517,7 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
21511
21517
gl.bindBuffer(gl.ARRAY_BUFFER, this._secondPass.bufferTexturePosition);
21512
21518
gl.vertexAttribPointer(this._secondPass.aTexturePosition, 2, gl.FLOAT, false, 0, 0);
21513
21519
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);
21515
21521
21516
21522
// Draw the quad (two triangles)
21517
21523
gl.drawArrays(gl.TRIANGLES, 0, 6);
@@ -21547,11 +21553,15 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
21547
21553
21548
21554
// Public API required by all Drawer implementations
21549
21555
/**
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.
21552
21558
*/
21553
21559
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
+ }
21555
21565
}
21556
21566
21557
21567
/**
@@ -21661,6 +21671,11 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
21661
21671
21662
21672
}
21663
21673
21674
+ // private
21675
+ _textureFilter(){
21676
+ return this._imageSmoothingEnabled ? this._gl.LINEAR : this._gl.NEAREST;
21677
+ }
21678
+
21664
21679
// private
21665
21680
_setupRenderer(){
21666
21681
let gl = this._gl;
@@ -21677,7 +21692,7 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
21677
21692
gl.activeTexture(gl.TEXTURE0);
21678
21693
gl.bindTexture(gl.TEXTURE_2D, this._renderToTexture);
21679
21694
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() );
21681
21696
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
21682
21697
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
21683
21698
@@ -21876,7 +21891,7 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
21876
21891
gl.activeTexture(gl.TEXTURE0);
21877
21892
gl.bindTexture(gl.TEXTURE_2D, this._renderToTexture);
21878
21893
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() );
21880
21895
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
21881
21896
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
21882
21897
@@ -21902,8 +21917,7 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
21902
21917
21903
21918
this._gl = this._renderingCanvas.getContext('webgl');
21904
21919
21905
- //make the additional canvas elements mirror size changes to the output canvas
21906
- this.viewer.addHandler("resize", function(){
21920
+ this._resizeHandler = function(){
21907
21921
21908
21922
if(_this._outputCanvas !== _this.viewer.drawer.canvas){
21909
21923
_this._outputCanvas.style.width = _this.viewer.drawer.canvas.clientWidth + 'px';
@@ -21924,7 +21938,10 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
21924
21938
21925
21939
// important - update the size of the rendering viewport!
21926
21940
_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);
21928
21945
}
21929
21946
21930
21947
// private
@@ -22014,8 +22031,8 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
22014
22031
// Set the parameters so we can render any size image.
22015
22032
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
22016
22033
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() );
22019
22036
22020
22037
// Upload the image into the texture.
22021
22038
this._uploadImageData(tileContext);
@@ -22039,6 +22056,14 @@ function determineSubPixelRoundingRule(subPixelRoundingRules) {
22039
22056
};
22040
22057
}
22041
22058
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
+
22042
22067
// private
22043
22068
_uploadImageData(tileContext){
22044
22069
@@ -25101,6 +25126,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
25101
25126
this._clip = null;
25102
25127
}
25103
25128
25129
+ this._needsUpdate = true;
25104
25130
this._needsDraw = true;
25105
25131
/**
25106
25132
* Raised when the TiledImage's clip is changed.
0 commit comments