Fix nested non-isolated groups in knockout rendering

It fixes #18032.

Only use the special inner-backdrop compositing path for nested non-isolated groups that actually need isolation.
This preserves the parent/page backdrop for simple nested groups inside knockout groups, preventing later group
compositing from erasing existing backdrop content.
This commit is contained in:
Calixte Denizet 2026-05-12 15:48:06 +02:00
parent 0c66063cd4
commit 0e335d53ee
4 changed files with 14 additions and 3 deletions

View File

@ -3342,13 +3342,15 @@ class CanvasGraphics {
// #compositeKnockoutSurface so it doesn't become part of the group
// source itself.
const backdropCtx = group.knockout && !group.isolated ? currentCtx : null;
// Non-isolated non-KO subgroup inside a KO parent: at endGroup we'll
// blend its elements against the outer KO running canvas (also frozen),
// so just record the flag here and read ctx.canvas at composite time.
// Non-isolated non-KO subgroup inside a KO parent, with inner compositing
// of its own: at endGroup we'll blend its elements against the outer KO
// running canvas (also frozen), so just record the flag here and read
// ctx.canvas at composite time.
const hasInnerBackdrop =
!group.isolated &&
!group.knockout &&
!group.smask &&
group.needsIsolation &&
this.#knockoutGroupLevel > 0;
// Pool the per-element shape mask for the lifetime of this KO group.

View File

@ -920,3 +920,4 @@
!smask_luminosity_oob_transfer.pdf
!operator_list_cycle.pdf
!knockout_groups_test.pdf
!issue18032.pdf

BIN
test/pdfs/issue18032.pdf Normal file

Binary file not shown.

View File

@ -14252,5 +14252,13 @@
"rounds": 1,
"type": "eq",
"about": "Knockout groups composite-modes survey."
},
{
"id": "issue18032",
"file": "pdfs/issue18032.pdf",
"md5": "656234fde97953c4e3fc7698831590a9",
"rounds": 1,
"type": "eq",
"about": "Non-isolated knockout group with a nested non-isolated subgroup over existing text."
}
]