4 ms·
>We're in Daylight Saving time. EDT. Or just "ET" or "Eastern", which are good year-round. Point taken. :) >Doesn't this mean that crossing a panel boundary m
by chromakode 12y ago
>We're in Daylight Saving time. EDT. Or just "ET" or "Eastern", which are good year-round.
Point taken. :)
>Doesn't this mean that crossing a panel boundary means we need to pop up the stack?
Aha! Yes, now that I'm looking closely, I think that is possible, since the logic that handles crossing outside of the current "pos" pixel boundary is re-entrant.
However, I note that the line numbers in your trace are alternating. This looks suspiciously like an oscillation between the "need to zoom out and find a new pos" and "need to zoom in and set pos" states. It just occurred to me that since these conditionals compare floating point positions directly, it might be possible for a precision error to cause such a loop.
This exercise has made me realize a benefit to the mess of carrying code that happens further down, when wrapping around the 4 panels that are actively being displayed. That code will in principle operate past the point where a recursive implementation will stack trace, FWIW. According to StackOverflow [1], that'll be around 25K/50K nestings in Chrome/Firefox.
>Would mipmapping help any here?
Yep! The current implementation only scales an image once per render, caching the resultant image data and reusing it for all of the other draws [2]. Images are also pre-scaled to various intervals (for example [3]), though that was to improve image scaling rather than performance. Actually, while working on the mipmapping implementation, I found evidence that the canvas putImageData call (for image buffers) is a good deal slower than drawIamge [4]. It looks like where I left things, I'm still using putImageData. Tomorrow, I'll try caching the actual canvas elements and see if that gives the predicted huge performance boost.
[1]: http://stackoverflow.com/a/7828803 http://stackoverflow.com/a/7828803
[2]: https://github.com/chromakode/xkcd-pixels/blob/master/zoom.js#L516 https://github.com/chromakode/xkcd-pixels/blob/master/zoom.j...
[3]: http://imgs.xkcd.com/turtledown/turtles-tiled.png http://imgs.xkcd.com/turtledown/turtles-tiled.png
[4]: http://jsperf.com/canvas-drawimage-vs-putimagedata/3 http://jsperf.com/canvas-drawimage-vs-putimagedata/3