- previously, we reallocated the glyph atlas on every upload. Instead, we're now using glTexSubImage2D to reuse the existing buffer
- we're no longer forcing a texture upload when we remove glyphs; they won't be rendered anyway
- we're now only doing a texture upload once per frame; previously, worker threads that added glyphs mid-render could trigger a texture upload while rendering is in progress
We always need to do a full upload to adjust the image buffer size when we adjust the size of our sprite atlas. This can happen when we change the pixelRatio of the map we're rendering.
This moves all texture updates and buffer uploads to the beginning of every frame, before we issue any drawing commands. This means the GPU typically has much more time to upload the data in the background until we actually need it, and doesn't have to pause to store/load the framebuffer.
~Object is likely to join threads that want to dispatch results
back to this RunLoop. This happens, for example, when MapContext
is destructed: it joins the worker threads, which need to complete
work before shutting down.
The promise could be deallocated before promise.set_value() had returned,
which apparently caused an invalid read on some implementations.
By moving the promise declaration up the stack, we ensure that the map is
deallocated first, and therefore the map thread is joined, before the
promise is deallocated.
Even though we only bind the shared_ptr in the after callback, the
worker thread was still copying the callback and therefore gaining
a shared reference. Here we try to eliminate the copies.
This ensures that the worker threads associated with the
style are joined before new worker threads are launched.
I don't know exactly why, but it seems to fix#1384.