Skip to content

fix(abr): read tool blend mode and opacity from MdSl - #283

Merged
pmwoz merged 3 commits into
mainfrom
t3/issue-282
Nov 3, 2026
Merged

pmwoz merged 3 commits into
mainfrom
t3/issue-282

Conversation

@pmwoz

@pmwoz pmwoz commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Why

A consumer of brushkit-abr needs the tool blend mode and opacity of every preset (pmwoz/abr2brushset-app#912). Some presets store both in a nested MdSl object inside toolOptions, and the parser read only the top-level Md and Opct keys. So ToolOptions::blend_mode and opacity_pct were None for such a preset.

What changed

  • parse_tool_options reads MdSl/Opct into opacity_pct. It maps the layer blend key MdSl/Ky to its BlnM value id in blend_mode, with the 27 pairs from the issue's D2. An unknown key reads as the raw four bytes.
  • A top-level Md or Opct wins over MdSl in either key order.
  • A malformed MdSl ends the toolOptions read and keeps the preset, as the old skip did.
  • The doc comments on ToolOptions::blend_mode and opacity_pct name MdSl as the second source.

Scope

  • No new public field and no version change. The release is a separate commit.
  • MdSl/Sgnt and MdSl/Clpp stay unread.

Verification

  • Synthetic fixtures in descriptor::tests. mdsl_supplies_blend_mode_and_opacity reads mul and 35 as Some("Mltp") and Some(35). top_level_md_and_opct_win_over_mdsl_in_either_order reads the top-level values with them before and after MdSl. unknown_mdsl_layer_key_reads_raw reads zzz as Some("zzz "). The first and third fail before the fix. malformed_mdsl_keeps_the_preset_and_earlier_tool_options fails when the MdSl error drops the preset.
  • Real files. corpus_smoke::every_corpus_mdsl_preset_reads_its_blend_mode_and_opacity (runs with BRUSHKIT_CORPUS_DIR) checks every corpus preset that stores its opacity only in MdSl. One preset in a 140-pack corpus has it. Before the fix, opacity_pct is None and the test fails. After, it reads 35 and Mltp.
  • cargo test --workspace with the corpus, clippy with -D warnings, and the wasm32 build pass locally.

Closes #282

pmwoz added 3 commits November 3, 2026 23:48
Fails until parse_tool_options reads the nested MdSl object.
A preset can store its tool blend mode and opacity in toolOptions/MdSl instead of the top-level Md and Opct keys. Map the MdSl layer key to its BlnM value id, read MdSl/Opct, and keep the top-level keys first.
A malformed MdSl ends the toolOptions read as the skip did before, instead of dropping the preset. Tests cover both key orders for top-level precedence, and the corpus test checks the layer key maps to a BlnM id.
@pmwoz

pmwoz commented Nov 3, 2026

Copy link
Copy Markdown
Owner Author

PASS

Independently verified 875678c9dac38f272cc41fa293da2a991828c533 against default-branch commit ea152e8f36f9cd7dce009fa1c2a3d1e7fa258947.

  • F1: Ran verify-brushkit doctor, parse, and raw-descriptor dump before and after on a real ABR v10 pack with 144 presets. Its sole MdSl-only preset has Ky = mul and Opct = 35, without top-level mode/opacity. Through all four public parse functions, blend_mode and opacity_pct change from None/None to Some("Mltp")/Some(35), while flow stays 50.
  • F2: A separate release-built consumer of the public brushkit facade scanned all 140 real ABR packs (versions 1, 2, 6, 7, 9, 10). Compared all nine ToolOptions fields and every other exposed descriptor field before/after: 2,450 descriptors per parse function, 9,800 comparisons total. Only the intended preset changes. The other 2,449 descriptors per function and all compared pack counts remain identical. The corpus contains exactly one MdSl preset.
  • F3: All 33 independently generated synthetic ABR inputs pass through all four public parse functions: the 27 D2 mappings, an unknown key preserved as "zzz ", top-level precedence in both orders, each field falling back independently, and malformed MdSl retaining the preset and earlier flow. The before run confirms the missing fallback and unchanged precedence/malformed behavior.
  • F4: Full heavy cargo test --workspace runs pass with the corpus enabled on both commits (373 before, 378 after; the intentional fuzz-seed generator is ignored in both). On the PR head, formatting, native workspace build, clippy for all targets with -D warnings, and the wasm32 workspace build also pass. Full builds and suites ran through heavy.
  • F5: Both field docs name MdSl as the second source. No public field or version change. Both checkouts remain clean. No regression or unmet PR claim found.

@pmwoz
pmwoz merged commit a1ac0d5 into main Nov 3, 2026
8 checks passed
@pmwoz
pmwoz deleted the t3/issue-282 branch November 3, 2026 23:28
@pmwoz pmwoz mentioned this pull request Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Read the tool blend mode and opacity a preset stores in MdSl

1 participant