These are chat archives for openseadragon/openseadragon

2nd
Nov 2016
John Hoffer
@thejohnhoffer
Nov 02 2016 22:06
Is it possible to load a tileSource that has no opacity? The tiles aren't loaded by default.
Ian Gilman
@iangilman
Nov 02 2016 22:09
@thejohnhoffer Meaning you set the opacity to 0 when you added it? No, the tiles don't load. If you want them to load you can set the opacity to 0.00001 or whatever
Some thoughts on a possible enhancement: openseadragon/openseadragon#821
John Hoffer
@thejohnhoffer
Nov 02 2016 22:14
Okay- I'll give these two options some thought. Right now I'm looking for where in the code the decison to not load the tiles is made. I might have 10 or more of these 'preloaded' tiles secretly overlaying my actual data, so I'd be worried even small opacites could cause performance problems.
Ian Gilman
@iangilman
Nov 02 2016 22:15
Yup, I hear you
I definitely think a real preload option would be good
Probably the one where you put your image where you want it but give it an opacity of 0 and then call preload on it would be the simplest, both as API and to implement
... but I haven't really dug in to give it more thought
John Hoffer
@thejohnhoffer
Nov 02 2016 22:17
Yeah, I think that's the best.
Ian Gilman
@iangilman
Nov 02 2016 22:17
Cool
You certainly don't want to preload the entire pyramid!
John Hoffer
@thejohnhoffer
Nov 02 2016 22:20
No- I can see that would sort of defeat the purpose of having a mip map. I don't really understand the algorithm openseadragon uses to select and cache tiles based on the viewport, but I'd like to basically just tap into that as if the tile were visible.
Ian Gilman
@iangilman
Nov 02 2016 22:22
Yeah, and that should be easy to do without having to understand it... you basically just want to go through the draw process but don't actually draw the tiles at the end
(since the draw process is what figures out which tiles you need to load)
it's all in tiledimage.js
updateViewport() is the top of the process and drawTiles() is the actual drawing
John Hoffer
@thejohnhoffer
Nov 02 2016 22:28
Great- is it the case that some part of the loading process just breaks gracefully when opacity is zero or is there actually a switch being intentionally flipped? I'll be searching for it now anyway if you don't know that off the top of your head.
Ian Gilman
@iangilman
Nov 02 2016 22:29
The switch is at the very top of the process in TiledImage.draw()
...and you'll want to keep that switch there (but allow an exception for the preload case)
Keep in mind that it takes a number of cycles to load all the tiles... you might need to make use of the _fullyLoaded flag
Btw, don't let it hold you up, but be aware that there may be some upcoming changes in how the tile loading process works: https://github.com/openseadragon/openseadragon/issues/1020#issuecomment-253274720
John Hoffer
@thejohnhoffer
Nov 02 2016 22:35
Right now this seems as simple as adding a check for something like this.preLoadOnly - which can easily become a tileSource parameter that's used like opacity when creating a tiledImage
   draw: function() {
        if (this.opacity !== 0 && !this.preLoadOnly) {
            this._midDraw = true;
            updateViewport(this);
            this._midDraw = false;
        }
    }
Ian Gilman
@iangilman
Nov 02 2016 22:37
...and then checking that flag and aborting drawTiles()
It feels to me more like something you would want to be able to flip at will on the TiledImage... though I suppose you could specify it as a parameter as well
Ian Gilman
@iangilman
Nov 02 2016 22:47
...and probably just preload would be fine for the option name
for the flippable property, we'd want TiledImage.setPreload(flag)
John Hoffer
@thejohnhoffer
Nov 02 2016 22:51
Is it overkill to also have a TiledImage.getPreload function? I think I'm just planning to mirror how the API for opacity works. For me, I'll need to be able to set it when first creating the tiledImage like I've been doing with opacity.
Ian Gilman
@iangilman
Nov 02 2016 22:53
Might as well include getPreload just for completeness, though I agree it might not be needed that much