| 240 | namespace { void invalidate_colorimetric_caches_for(const DiodeProfile* profile) FL_NOEXCEPT; } |
| 241 | |
| 242 | void set_input_gamut(DiodeProfile* profile, InputGamut g, |
| 243 | const float white_xy[2]) FL_NOEXCEPT { |
| 244 | if (profile == nullptr) return; |
| 245 | auto apply = [profile](const float r[2], const float gp[2], |
| 246 | const float b[2], const float w[2]) { |
| 247 | profile->input_xy_r[0] = r[0]; profile->input_xy_r[1] = r[1]; |
| 248 | profile->input_xy_g[0] = gp[0]; profile->input_xy_g[1] = gp[1]; |
| 249 | profile->input_xy_b[0] = b[0]; profile->input_xy_b[1] = b[1]; |
| 250 | profile->input_xy_w[0] = w[0]; profile->input_xy_w[1] = w[1]; |
| 251 | }; |
| 252 | switch (g) { |
| 253 | case InputGamut::Native: { |
| 254 | // For Native, the input gamut tracks this profile's LED primaries — |
| 255 | // copy them over rather than picking a fixed sRGB-like fallback. |
| 256 | const float d65[2] = {0.31272f, 0.32903f}; |
| 257 | const float* w = (white_xy != nullptr) ? white_xy : d65; |
| 258 | apply(profile->xy_r, profile->xy_g, profile->xy_b, w); |
| 259 | invalidate_colorimetric_caches_for(profile); |
| 260 | return; |
| 261 | } |
| 262 | case InputGamut::Rec709: apply(kRec709.xy_r, kRec709.xy_g, kRec709.xy_b, |
| 263 | white_xy != nullptr ? white_xy : kRec709.xy_w); |
| 264 | invalidate_colorimetric_caches_for(profile); return; |
| 265 | case InputGamut::Rec2020: apply(kRec2020.xy_r, kRec2020.xy_g, kRec2020.xy_b, |
| 266 | white_xy != nullptr ? white_xy : kRec2020.xy_w); |
| 267 | invalidate_colorimetric_caches_for(profile); return; |
| 268 | case InputGamut::DciP3D65: apply(kDciP3D65.xy_r, kDciP3D65.xy_g, kDciP3D65.xy_b, |
| 269 | white_xy != nullptr ? white_xy : kDciP3D65.xy_w); |
| 270 | invalidate_colorimetric_caches_for(profile); return; |
| 271 | case InputGamut::DciP3D60: apply(kDciP3D60.xy_r, kDciP3D60.xy_g, kDciP3D60.xy_b, |
| 272 | white_xy != nullptr ? white_xy : kDciP3D60.xy_w); |
| 273 | invalidate_colorimetric_caches_for(profile); return; |
| 274 | } |
| 275 | // Default-fallthrough for forward-compat with future enum additions: |
| 276 | // leave the profile's input_xy_* untouched — also nothing to invalidate. |
| 277 | } |
| 278 | |
| 279 | void set_input_gamut(DiodeProfile* profile, InputGamut g) FL_NOEXCEPT { |
| 280 | set_input_gamut(profile, g, nullptr); |
no test coverage detected