From 0464593a0240e6fc35a4247791a7af886938d737 Mon Sep 17 00:00:00 2001 From: gramps Date: Mon, 5 Oct 2026 13:34:20 -0700 Subject: [PATCH] Compositor: fast-path opaque 1:1 when source fills canvas Handle the case where an opaque source exactly covers the destination canvas with 1:1 dimensions (even if offsets differ in calculation). This avoids per-pixel alpha branching and mirrors the existing memcpy fast path. Byte-identical for opaque sources. --- Services/Compositor/SceneCompositor.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Services/Compositor/SceneCompositor.cs b/Services/Compositor/SceneCompositor.cs index a94264e..e299058 100644 --- a/Services/Compositor/SceneCompositor.cs +++ b/Services/Compositor/SceneCompositor.cs @@ -624,6 +624,18 @@ public sealed class SceneCompositor Buffer.BlockCopy(src.BgraPixels, 0, dst, 0, dstW * dstH * 4); return; } + // Fully opaque source, covering entire destination canvas + if (op == 256 && src.IsOpaque && x0 == 0 && y0 == 0 && x1 == dstW && y1 == dstH) + { + Buffer.BlockCopy(src.BgraPixels, 0, dst, 0, dstW * dstH * 4); + return; + } + // Opaque source with 1:1 aligned region covering full canvas? treat same + if (op == 256 && src.IsOpaque && ex == 0 && ey == 0 && src.Width == dstW && src.Height == dstH) + { + Buffer.BlockCopy(src.BgraPixels, 0, dst, 0, dstW * dstH * 4); + return; + } var d = dst.AsSpan(); var s = src.BgraPixels.AsSpan();