My previous commit withheld the format from `set_date` whenever the caller had
not named one, so a field the slide already had would not be rewritten. That is
right where there is a field. A placeholder showing a fixed date holds plain
text and no date field at all, so there was no format to preserve and the
withheld format left `date_kind("")` to build a `datetime1`: a slide taken from
`datetime11` to fixed text and back came away on the short date (noted in
review).
The deck's format now always reaches `set_date`, and `format_given` is what
decides whether it may rewrite an existing field. With no field, there is
nothing to preserve and the remembered format is what a new one takes.
`a_fixed_date_turned_automatic_again_comes_back_on_the_remembered_format` walks
that transition with no `dateFormat` in the call, which is what the dialog
sends, and goes on to assert the guard still holds where a field does exist. It
is a test of its own rather than more of `the_automatic_date_takes_the_format_it_is_given`,
because setting a format for one slide also moves the deck's global one, which
that test's later assertions depend on.
The dialog always sends `dateText`, so an Apply with no format selection
reached `set_date` carrying the deck's global format, and rewrote a slide's own
date field to it. Measured on two slides, the first on the time format and the
second on the short date:
before [datetime11, datetime5]
apply {"date": true, "dateText": "", "all": true}
after [datetime5, datetime5]
The first slide's format was never mentioned by the caller, and it was gone.
`set_date` already keeps an existing field when the format is empty, so it now
gets an empty format unless `dateFormat` was supplied; a format that is
supplied still reaches every slide, which the test checks so the guard cannot
quietly become a block.
`header_footer()` recorded a Date placeholder's text only when it held no field,
and never looked at the field itself, so an automatic date's format was dropped
on import: `date_format` stayed empty whatever the deck used.
With the dialog of the previous commit that is not only cosmetic. Opening a deck
whose dates are `datetime5` showed `datetime1` selected, and pressing Apply then
sent that back and reformatted the deck's dates — a silent change to a file the
user only opened to look at.
The reader now remembers which of the thirteen formats the field is, so the
dialog opens on the deck's own choice. An unknown spelling (`datetime`,
`datetimeFigureOut`, which both render as the short date) is left as no choice
rather than guessed at, since the command only accepts the thirteen and would
refuse it. A fixed date still comes back as its text, as before.
`crates/pptx` gains a dependency on `crates/text` for `datetime::DATE_KINDS`,
which layer 3 may take on layer 2; `cargo xtask layers` passes.
PDF export rasterises every slide as a backdrop and a content layer and
hands both to the writer. Profiling (gdb stack sampling) showed most of
the main thread outside rendering going to per-pixel work on those
rasters: compositing the backdrop onto white (not vectorised), the
writer hashing every backdrop to deduplicate it, and the straight-alpha
conversion scanning every content pixel.
- Composite the backdrop with saturating adds and skip 16-pixel blocks
that are already opaque; skip blocks with no partly transparent pixel
in the straight-alpha conversion. Same formulas, same bytes.
- Keep the last opaque backdrops (up to 32 MiB of pixels) and hand the
writer the same image again when a slide renders an identical
backdrop. The writer stored equal backdrops once already; now it also
skips hashing and compressing the copies. Output is byte-identical.
deckcraft-cli bench, export .pdf step, 15 interleaved runs each on a
16-thread Ryzen (A/A noise +0.9 %):
- sample x4 (32 slides): median 531 -> 322 ms (-39 %), min 529 -> 317 ms
- same deck, every slide a different background: 557 -> 441 ms (-21 %)
- sample (8 slides): 149 -> 103 ms (-31 %)
Exported PDFs are byte-identical.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>