Skip to content

Commit e12f72e

Browse files
committed
perf: add early-out for transparent overlay in blendColors
Skip pow and vector math when overlay alpha is fully transparent, returning text color directly. The common case for text backgrounds.
1 parent 1ef2fae commit e12f72e

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

packages/core/src/zig/buffer.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ fn blendColors(overlay: RGBA, text: RGBA) RGBA {
9797
if (overlay[3] == 1.0) {
9898
return overlay;
9999
}
100+
if (overlay[3] == 0.0) {
101+
return text;
102+
}
100103

101104
const alpha = overlay[3];
102105
var perceptualAlpha: f32 = undefined;

0 commit comments

Comments
 (0)