mirror of
https://github.com/openseadragon/openseadragon.git
synced 2025-03-14 04:56:19 +03:00
Add back overlapFraction logic for webgl drawer.
This commit is contained in:
parent
6b4c0f873a
commit
17f13885c7
@ -872,10 +872,18 @@
|
||||
}
|
||||
|
||||
_setupTextureHandlers() {
|
||||
const _this = this;
|
||||
const tex2DCompatibleLoader = (tile, data) => {
|
||||
let tiledImage = tile.tiledImage;
|
||||
let gl = _this._gl;
|
||||
let gl = this._gl;
|
||||
|
||||
let sourceWidthFraction, sourceHeightFraction;
|
||||
if (tile.sourceBounds) {
|
||||
sourceWidthFraction = Math.min(tile.sourceBounds.width, data.width) / data.width;
|
||||
sourceHeightFraction = Math.min(tile.sourceBounds.height, data.height) / data.height;
|
||||
} else {
|
||||
sourceWidthFraction = 1;
|
||||
sourceHeightFraction = 1;
|
||||
}
|
||||
|
||||
// create a gl Texture for this tile and bind the canvas with the image data
|
||||
let texture = gl.createTexture();
|
||||
@ -884,16 +892,18 @@
|
||||
if( overlap > 0){
|
||||
// calculate the normalized position of the rect to actually draw
|
||||
// discarding overlap.
|
||||
let overlapFraction = _this._calculateOverlapFraction(tile, tiledImage);
|
||||
let overlapFraction = this._calculateOverlapFraction(tile, tiledImage);
|
||||
|
||||
let left = tile.x === 0 ? 0 : overlapFraction.x;
|
||||
let top = tile.y === 0 ? 0 : overlapFraction.y;
|
||||
let right = tile.isRightMost ? 1 : 1 - overlapFraction.x;
|
||||
let bottom = tile.isBottomMost ? 1 : 1 - overlapFraction.y;
|
||||
position = _this._makeQuadVertexBuffer(left, right, top, bottom);
|
||||
let left = (tile.x === 0 ? 0 : overlapFraction.x) * sourceWidthFraction;
|
||||
let top = (tile.y === 0 ? 0 : overlapFraction.y) * sourceHeightFraction;
|
||||
let right = (tile.isRightMost ? 1 : 1 - overlapFraction.x) * sourceWidthFraction;
|
||||
let bottom = (tile.isBottomMost ? 1 : 1 - overlapFraction.y) * sourceHeightFraction;
|
||||
position = this._makeQuadVertexBuffer(left, right, top, bottom);
|
||||
} else if (sourceWidthFraction === 1 && sourceHeightFraction === 1) {
|
||||
// no overlap and no padding: this texture can use the unit quad as its position data
|
||||
position = this._unitQuad;
|
||||
} else {
|
||||
// no overlap: this texture can use the unit quad as its position data
|
||||
position = _this._unitQuad;
|
||||
position = this._makeQuadVertexBuffer(0, sourceWidthFraction, 0, sourceHeightFraction);
|
||||
}
|
||||
|
||||
gl.activeTexture(gl.TEXTURE0);
|
||||
@ -901,8 +911,8 @@
|
||||
// Set the parameters so we can render any size image.
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, _this._textureFilter());
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, _this._textureFilter());
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, this._textureFilter());
|
||||
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, this._textureFilter());
|
||||
|
||||
try{
|
||||
// This depends on gl.TEXTURE_2D being bound to the texture
|
||||
|
Loading…
x
Reference in New Issue
Block a user