@@ -646,6 +646,23 @@ static gboolean _get_d65_correction_ratios(const dt_iop_module_t *self,
646646 return FALSE;
647647}
648648
649+ static void _get_corrected_illuminant_xy (const dt_iop_module_t * self ,
650+ const dt_iop_channelmixer_rgb_params_t * p ,
651+ float * x , float * y )
652+ {
653+ dt_aligned_pixel_t correction_ratios ;
654+ _get_d65_correction_ratios (self , correction_ratios );
655+ dt_aligned_pixel_t wb_coeffs = { 0.f };
656+ if (p -> illuminant == DT_ILLUMINANT_FROM_WB )
657+ {
658+ for (int k = 0 ; k < 4 ; k ++ )
659+ wb_coeffs [k ] = self -> dev -> chroma .wb_coeffs [k ];
660+ }
661+ illuminant_to_xy (p -> illuminant , & (self -> dev -> image_storage ), correction_ratios ,
662+ wb_coeffs , x , y , p -> temperature , p -> illum_fluo ,
663+ p -> illum_led );
664+ }
665+
649666
650667DT_OMP_DECLARE_SIMD (aligned (input , output :16 ) uniform (compression , clip ))
651668static inline void _gamut_mapping (const dt_aligned_pixel_t input ,
@@ -3183,17 +3200,7 @@ void commit_params(dt_iop_module_t *self,
31833200 // find x y coordinates of illuminant for CIE 1931 2° observer
31843201 float x = p -> x ;
31853202 float y = p -> y ;
3186- dt_aligned_pixel_t correction_ratios ;
3187- _get_d65_correction_ratios (self , correction_ratios );
3188- dt_aligned_pixel_t wb_coeffs = {0.f };
3189- if (p -> illuminant == DT_ILLUMINANT_FROM_WB )
3190- {
3191- for (int k = 0 ; k < 4 ; k ++ )
3192- wb_coeffs [k ] = self -> dev -> chroma .wb_coeffs [k ];
3193- }
3194- illuminant_to_xy (p -> illuminant , & (self -> dev -> image_storage ), correction_ratios ,
3195- wb_coeffs , & x , & y , p -> temperature , p -> illum_fluo ,
3196- p -> illum_led );
3203+ _get_corrected_illuminant_xy (self , p , & x , & y );
31973204
31983205 // if illuminant is from camera or user WB coefficients, x and y are set on-the-fly at
31993206 // commit time, so we need to set adaptation too
@@ -3635,17 +3642,7 @@ static gboolean _illuminant_color_draw(GtkWidget *widget,
36353642 float x = p -> x ;
36363643 float y = p -> y ;
36373644 dt_aligned_pixel_t RGB = { 0.f };
3638- dt_aligned_pixel_t correction_ratios ;
3639- _get_d65_correction_ratios (self , correction_ratios );
3640- dt_aligned_pixel_t wb_coeffs = { 0.f };
3641- if (p -> illuminant == DT_ILLUMINANT_FROM_WB )
3642- {
3643- for (int k = 0 ; k < 4 ; k ++ )
3644- wb_coeffs [k ] = self -> dev -> chroma .wb_coeffs [k ];
3645- }
3646- illuminant_to_xy (p -> illuminant , & (self -> dev -> image_storage ), correction_ratios ,
3647- wb_coeffs , & x , & y , p -> temperature , p -> illum_fluo ,
3648- p -> illum_led );
3645+ _get_corrected_illuminant_xy (self , p , & x , & y );
36493646 illuminant_xy_to_RGB (x , y , RGB );
36503647 cairo_set_source_rgb (cr , RGB [0 ], RGB [1 ], RGB [2 ]);
36513648 cairo_rectangle (cr , INNER_PADDING , margin , width , height );
@@ -3745,17 +3742,7 @@ static void _update_approx_cct(const dt_iop_module_t *self)
37453742
37463743 float x = p -> x ;
37473744 float y = p -> y ;
3748- dt_aligned_pixel_t correction_ratios ;
3749- _get_d65_correction_ratios (self , correction_ratios );
3750- dt_aligned_pixel_t wb_coeffs = { 0.f };
3751- if (p -> illuminant == DT_ILLUMINANT_FROM_WB )
3752- {
3753- for (int k = 0 ; k < 4 ; k ++ )
3754- wb_coeffs [k ] = self -> dev -> chroma .wb_coeffs [k ];
3755- }
3756- illuminant_to_xy (p -> illuminant , & (self -> dev -> image_storage ), correction_ratios ,
3757- wb_coeffs , & x , & y , p -> temperature , p -> illum_fluo ,
3758- p -> illum_led );
3745+ _get_corrected_illuminant_xy (self , p , & x , & y );
37593746
37603747 dt_illuminant_t test_illuminant ;
37613748 float t = 5000.f ;
@@ -4349,17 +4336,7 @@ static void _auto_set_illuminant(dt_iop_module_t *self,
43494336 // find x y coordinates of illuminant for CIE 1931 2° observer
43504337 float x = p -> x ;
43514338 float y = p -> y ;
4352- dt_aligned_pixel_t correction_ratios ;
4353- _get_d65_correction_ratios (self , correction_ratios );
4354- dt_aligned_pixel_t wb_coeffs = { 0.f };
4355- if (p -> illuminant == DT_ILLUMINANT_FROM_WB )
4356- {
4357- for (int k = 0 ; k < 4 ; k ++ )
4358- wb_coeffs [k ] = self -> dev -> chroma .wb_coeffs [k ];
4359- }
4360- illuminant_to_xy (p -> illuminant , & (self -> dev -> image_storage ), correction_ratios ,
4361- wb_coeffs , & x , & y , p -> temperature , p -> illum_fluo ,
4362- p -> illum_led );
4339+ _get_corrected_illuminant_xy (self , p , & x , & y );
43634340
43644341 dt_adaptation_t adaptation = p -> adaptation ;
43654342
0 commit comments