[client] egl: improve HDR cursor rendering, fixes alpha blending

This commit is contained in:
Geoffrey McRae
2026-07-17 16:48:57 +10:00
parent 04441bfd85
commit d41c9fdc5d
4 changed files with 53 additions and 86 deletions

View File

@@ -3,6 +3,7 @@ precision highp float;
precision highp int;
#include "color_blind.h"
#include "hdr.h"
in vec2 uv;
out vec4 color;
@@ -10,6 +11,7 @@ out vec4 color;
uniform sampler2D sampler1;
uniform float scale;
uniform int cbMode;
uniform bool mapSDRtoPQ;
void main()
{
@@ -27,4 +29,18 @@ void main()
if (cbMode > 0)
color = cbTransform(color, cbMode);
if (mapSDRtoPQ)
{
if (color.a > 0.0)
{
// Cursor pixels are premultiplied. Convert the straight color to PQ,
// then premultiply again so the blend operation remains valid.
vec3 srgb = clamp(color.rgb / color.a, 0.0, 1.0);
vec3 linear = bt709to2020(srgb2lin(srgb));
color.rgb = lin2pq(linear * (203.0 / 10000.0)) * color.a;
}
else
color.rgb = vec3(0.0);
}
}