Verbatim copy of src/fl/gfx/rgbw_colorimetric.cpp.hpp:build_profile_cache — minus the CCT shift (which doesn't matter for the comparison) and the degeneracy warning (covered elsewhere).
| 589 | // minus the CCT shift (which doesn't matter for the comparison) and the |
| 590 | // degeneracy warning (covered elsewhere). |
| 591 | inline void build_cache(const DiodeProfile* p, ProfileCache* cache) { |
| 592 | cache->profile = p; |
| 593 | xyY_to_XYZ(p->xy_r[0], p->xy_r[1], p->lum_r, cache->P_R); |
| 594 | xyY_to_XYZ(p->xy_g[0], p->xy_g[1], p->lum_g, cache->P_G); |
| 595 | xyY_to_XYZ(p->xy_b[0], p->xy_b[1], p->lum_b, cache->P_B); |
| 596 | cache->xy_w[0] = p->xy_w[0]; |
| 597 | cache->xy_w[1] = p->xy_w[1]; |
| 598 | xyY_to_XYZ(cache->xy_w[0], cache->xy_w[1], p->lum_w, cache->P_W); |
| 599 | auto pack = [](const float* a, const float* b, const float* c, float out[3][3]) { |
| 600 | out[0][0]=a[0]; out[0][1]=b[0]; out[0][2]=c[0]; |
| 601 | out[1][0]=a[1]; out[1][1]=b[1]; out[1][2]=c[1]; |
| 602 | out[2][0]=a[2]; out[2][1]=b[2]; out[2][2]=c[2]; |
| 603 | }; |
| 604 | float P_RGB[3][3], P_RGW[3][3], P_RBW[3][3], P_BGW[3][3]; |
| 605 | pack(cache->P_R, cache->P_G, cache->P_B, P_RGB); |
| 606 | pack(cache->P_R, cache->P_G, cache->P_W, P_RGW); |
| 607 | pack(cache->P_R, cache->P_B, cache->P_W, P_RBW); |
| 608 | pack(cache->P_B, cache->P_G, cache->P_W, P_BGW); |
| 609 | invert3x3(P_RGB, cache->P_RGB_inv); |
| 610 | invert3x3(P_RGW, cache->P_RGW_inv); |
| 611 | invert3x3(P_RBW, cache->P_RBW_inv); |
| 612 | invert3x3(P_BGW, cache->P_BGW_inv); |
| 613 | matvec3(cache->P_RGB_inv, cache->P_W, cache->d_W); |
| 614 | cache->has_source_space = (p->input_xy_w[1] > 1e-6f) && |
| 615 | build_source_matrix(p->input_xy_r, p->input_xy_g, p->input_xy_b, |
| 616 | p->input_xy_w, cache->M_src); |
| 617 | } |
| 618 | |
| 619 | // Mirror of project_to_hull (#2708) — verbatim copy of the static helper in |
| 620 | // rgbw_colorimetric.cpp.hpp (which can't be linked from the default test |
no test coverage detected