prepareChapter

open override fun prepareChapter(chapter: Int)(source)

Lays out one chapter. This is where a book's time goes, so it is also the only thing a reader has to wait for: opening at chapter 20 prepares chapter 20, not chapters 0 to 20.

Pages laid out this way count as never used: a loader that walks the whole book behind the reader must not push the chapter being read out of the budget, so these are the first to drop.


open suspend override fun prepareChapter(chapter: Int, checkpoint: suspend () -> Unit)(source)

Lays chapter out a step at a time, each step the parse of the chapter, its box tree, a child of a block in normal flow, or its pages, and calls checkpoint between two (#389). A viewer on a thread that must draw frames suspends in checkpoint once a frame's share of time is used, and the layout goes on after the frame. No lock is held across a checkpoint, so two callers for one chapter may each lay it out; the first to finish publishes its pages, as prepareChapter would.