I have this mind for a long time, and seeing again performance issue with large maps that use the pre-rendering flag, I figured it would be good to bring it back on the table.
Basically today we have two different rendering mode :
- preRender
true will render the whole layer on a offscreen canvas :that's fast as we only do 1 draw operation at the end, but very memory consuming on large maps (especially when using several layers)
- preRender
false will render the visible part of the layer at each draw : slower than the above, as it's 1 draw operation per visible tile, but very memory optimized (no off-screen buffer is used)
Both have their advantages and ultimately we should provide something in between that brings the best of both :
- only render a portion of the map : ideally a "next power of 2" size compared to the viewport size (for performances reason)
- at each frame update, we translate the off-screen canvas by the camera offset and just draw the missing part
we could also make the off-screen size configurable so that we could tweak it for the best performances
I have this mind for a long time, and seeing again performance issue with large maps that use the pre-rendering flag, I figured it would be good to bring it back on the table.
Basically today we have two different rendering mode :
truewill render the whole layer on a offscreen canvas :that's fast as we only do 1 draw operation at the end, but very memory consuming on large maps (especially when using several layers)falsewill render the visible part of the layer at each draw : slower than the above, as it's 1 draw operation per visible tile, but very memory optimized (no off-screen buffer is used)Both have their advantages and ultimately we should provide something in between that brings the best of both :
we could also make the off-screen size configurable so that we could tweak it for the best performances