startBatch

open override fun startBatch()(source)

Begins a new batching operation for the SlugMap.

Batching mode accumulates curve and band data in memory buffers instead of immediately writing them to GPU textures after each shape is added. This significantly reduces the number of texture write operations, which are expensive GPU operations, by deferring all writes until endBatch is called.

This is particularly beneficial and advised when generating slugmaps dynamically at runtime (online generation), such as when processing multiple glyphs or shapes in sequence. Instead of performing one texture write per shape, batching allows all accumulated data to be written in fewer, larger operations when the batch is complete.

Usage pattern:

slugMap.startBatch()
// Add multiple shapes
slugMap.addShape(shape1)
slugMap.addShape(shape2)
slugMap.addShape(shape3)
slugMap.endBatch() // All data written to GPU textures at once

This method ensures that the batching process is not already active by requiring the batching property to be false. If the condition is met, it sets the batching property to true, marking the start of a new batch.

See also

Throws

if batching is already active (i.e., batching is true).