fix(hdr): route identity-matrix HDR elements through region blit for clip rect support

parseTransformMatrix returns a valid matrix even for untransformed HDR
elements (Chrome reports matrix(1,0,0,1,0,0)). This made the affine blit
path always run, bypassing the region blit path which is the only one that
applies clip rects from overflow:hidden ancestors.

Fix: detect identity matrices and route them through the region path so
the cropRgb48le clip logic is reachable for split-screen layouts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Vance Ingalls
2026-04-27 19:57:52 -07:00
co-authored by Claude Opus 4.6
parent f743e1cada
commit 67d1f7195c
@@ -578,7 +578,22 @@ function blitHdrVideoLayer(
clipped = true;
}
if (viewportMatrix) {
// Detect identity matrix — route through the region path (which supports
// clip rects) instead of the affine path. Chrome reports a viewport matrix
// for all HDR elements, including untransformed ones inside overflow:hidden
// wrappers. An identity matrix means no visual transform is applied.
const isIdentity = !!(
viewportMatrix &&
viewportMatrix.length >= 6 &&
Math.abs(viewportMatrix[0]! - 1) < 0.001 &&
Math.abs(viewportMatrix[1]!) < 0.001 &&
Math.abs(viewportMatrix[2]!) < 0.001 &&
Math.abs(viewportMatrix[3]! - 1) < 0.001 &&
Math.abs(viewportMatrix[4]!) < 0.001 &&
Math.abs(viewportMatrix[5]!) < 0.001
);
if (viewportMatrix && !isIdentity) {
if (clipped && log) {
log.debug(
`HDR clip rect on affine-transformed element ${el.id} — clip not applied (affine scissor not yet supported)`,