@@ -292,16 +292,19 @@ static void _update_filepath(dt_iop_module_t *self)
292292 {
293293 const char * file = entries [i ]-> d_name ;
294294 char * normalized_filename = g_locale_to_utf8 (file , -1 , NULL , NULL , NULL );
295- dt_bauhaus_combobox_add_aligned (g -> file , normalized_filename , DT_BAUHAUS_COMBOBOX_ALIGN_LEFT );
295+ dt_bauhaus_combobox_add_aligned (g -> file , normalized_filename ,
296+ DT_BAUHAUS_COMBOBOX_ALIGN_LEFT );
296297 free (entries [i ]);
297298 g_free (normalized_filename );
298299 }
299- if (numentries != -1 ) free (entries );
300+ if (numentries != -1 )
301+ free (entries );
300302
301303 if (!dt_bauhaus_combobox_set_from_text (g -> file , p -> file ))
302304 { // file may have disappeared - show it
303305 char * invalidfilepath = g_strconcat (" ??? " , p -> file , NULL );
304- dt_bauhaus_combobox_add_aligned (g -> file , invalidfilepath , DT_BAUHAUS_COMBOBOX_ALIGN_LEFT );
306+ dt_bauhaus_combobox_add_aligned (g -> file , invalidfilepath ,
307+ DT_BAUHAUS_COMBOBOX_ALIGN_LEFT );
305308 dt_bauhaus_combobox_set_from_text (g -> file , invalidfilepath );
306309 g_free (invalidfilepath );
307310 }
@@ -388,7 +391,9 @@ static inline dt_hash_t _get_cache_hash(dt_iop_module_t *self)
388391{
389392 dt_hash_t hash = dt_hash (DT_INITHASH , self -> params , self -> params_size );
390393 // not technically required but possibly reduces mem footprint
391- hash = dt_hash (hash , & self -> dev -> image_storage .id , sizeof (self -> dev -> image_storage .id ));
394+ hash = dt_hash (hash ,
395+ & self -> dev -> image_storage .id ,
396+ sizeof (self -> dev -> image_storage .id ));
392397 return hash ;
393398}
394399
@@ -407,21 +412,27 @@ static float *_get_rasterfile_mask(dt_dev_pixelpipe_iop_t *piece,
407412 if (hash != cd -> hash )
408413 {
409414 _clear_cache (cd );
410- dt_print (DT_DEBUG_PIPE , "read image raster file `%s'" , d -> filepath );
415+ dt_print (DT_DEBUG_PIPE ,
416+ "read image raster file `%s'" , d -> filepath );
411417 cd -> mask = _read_rasterfile (d -> filepath , d -> mode , & cd -> width , & cd -> height );
412418 cd -> hash = cd -> mask ? hash : DT_INVALID_HASH ;
413- dt_print (DT_DEBUG_PIPE , "got raster mask data %p %dx%d" , cd -> mask , cd -> width , cd -> height );
419+ dt_print (DT_DEBUG_PIPE ,
420+ "got raster mask data %p %dx%d" , cd -> mask , cd -> width , cd -> height );
414421 }
415422 if (cd -> mask )
416423 {
417424 const gboolean scale = cd -> width != roi -> width || cd -> height != roi -> height ;
418425 float * tmp = scale ? dt_iop_image_alloc (roi -> width , roi -> height , 1 ) : cd -> mask ;
419426 if (tmp )
420427 {
421- if (scale ) interpolate_bilinear (cd -> mask , cd -> width , cd -> height , tmp , roi -> width , roi -> height , 1 );
428+ if (scale )
429+ interpolate_bilinear (cd -> mask , cd -> width , cd -> height , tmp ,
430+ roi -> width , roi -> height , 1 );
422431 res = dt_iop_image_alloc (roo -> width , roo -> height , 1 );
423- if (res ) self -> distort_mask (self , piece , tmp , res , roi , roo );
424- if (scale ) dt_free_align (tmp );
432+ if (res )
433+ self -> distort_mask (self , piece , tmp , res , roi , roo );
434+ if (scale )
435+ dt_free_align (tmp );
425436 }
426437 }
427438
@@ -504,17 +515,24 @@ void process(dt_iop_module_t *self,
504515 pipe -> mask_display = DT_DEV_PIXELPIPE_DISPLAY_PASSTHRU ;
505516 if (ch == 1 )
506517 {
507- dt_box_mean (out , roi_out -> height , roi_out -> width , 1 , 3 , 2 ); // simple blur to remove CFA colors
518+ // simple blur to remove CFA colors:
519+ dt_box_mean (out , roi_out -> height , roi_out -> width , 1 , 3 , 2 );
508520 DT_OMP_FOR ()
509521 for (size_t k = 0 ; k < (size_t )roi_out -> width * roi_out -> height ; k ++ )
510- out [k ] = 0.2f * CLAMPF (sqrtf (out [k ]), 0.0f , 0.5f ) + (mask ? mask [k ] : 0.0f );
522+ out [k ] =
523+ 0.2f
524+ * CLAMPF (sqrtf (out [k ]), 0.0f , 0.5f )
525+ + (mask ? mask [k ] : 0.0f );
511526 }
512527 else
513528 {
514529 DT_OMP_FOR ()
515530 for (size_t k = 0 ; k < (size_t )roi_out -> width * roi_out -> height ; k ++ )
516531 {
517- float val = 0.2f * CLAMPF (sqrtf (0.33f * (out [4 * k ] + out [4 * k + 1 ]+ out [4 * k + 2 ])), 0.0f , 0.5f ) + (mask ? mask [k ] : 0.0f );
532+ const float val =
533+ 0.2f
534+ * CLAMPF (sqrtf (0.33f * (out [4 * k ] + out [4 * k + 1 ]+ out [4 * k + 2 ])), 0.0f , 0.5f )
535+ + (mask ? mask [k ] : 0.0f );
518536 for_three_channels (m ) out [4 * k + m ] = val ;
519537 }
520538 }
@@ -558,8 +576,10 @@ void tiling_callback(dt_iop_module_t *self,
558576
559577void reload_defaults (dt_iop_module_t * self )
560578{
561- // we might be called from presets update infrastructure => there is no image
562- if (!self -> dev || !dt_is_valid_imgid (self -> dev -> image_storage .id )) return ;
579+ // we might be called from presets update infrastructure => there is
580+ // no image
581+ if (!self -> dev || !dt_is_valid_imgid (self -> dev -> image_storage .id ))
582+ return ;
563583
564584 self -> default_enabled = FALSE;
565585 dt_iop_rasterfile_params_t * dp = self -> default_params ;
@@ -583,9 +603,13 @@ void distort_mask(dt_iop_module_t *self,
583603 dt_iop_copy_image_roi (out , in , 1 , roi_in , roi_out );
584604}
585605
586- void gui_changed (dt_iop_module_t * self , GtkWidget * w , void * previous )
606+ void gui_changed (dt_iop_module_t * self ,
607+ GtkWidget * w ,
608+ void * previous )
587609{
588610 dt_iop_rasterfile_gui_data_t * g = self -> gui_data ;
611+ dt_iop_rasterfile_params_t * p = self -> params ;
612+
589613 if (!w || w == g -> mode )
590614 _update_filepath (self );
591615
@@ -597,7 +621,9 @@ void gui_changed(dt_iop_module_t *self, GtkWidget *w, void *previous)
597621 const gboolean other = hash != cd -> hash ;
598622 if (other ) _clear_cache (cd );
599623 dt_pthread_mutex_unlock (& cd -> lock );
600- if (other ) dt_dev_reprocess_center (self -> dev );
624+
625+ if (other )
626+ dt_dev_reprocess_center (self -> dev );
601627 }
602628
603629 gtk_widget_set_sensitive (g -> vectorize , p -> path [0 ] && p -> file [0 ]);
@@ -618,15 +644,19 @@ void init(dt_iop_module_t *self)
618644
619645 /*
620646 Implementation note and reminder:
647+
621648 Here we allocate per-module-instance memory shared by all pipes.
622649 To be sure data are valid and access is safe we
623- a) ensure validity via a hash. Here it's just based on the parameters of the module's instance
624- in other situations we might have to use the piece hash
650+
651+ a) ensure validity via a hash. Here it's just based on the
652+ parameters of the module's instance in other situations we
653+ might have to use the piece hash
654+
625655 b) **always** access any module->data within a mutex-locked state.
626656
627- In this module the data do **not** depend on the using pipe.
628- In other cases, the pipe changing data according to a diffenrent hash must make sure
629- the other pipes get restarted afterwards.
657+ In this module the data do **not** depend on the using pipe. In
658+ other cases, the pipe changing data according to a diffenrent hash
659+ must make sure the other pipes get restarted afterwards.
630660 */
631661
632662 dt_rasterfile_cache_t * cd = calloc (1 , sizeof (dt_rasterfile_cache_t ));
@@ -658,18 +688,26 @@ void gui_init(dt_iop_module_t *self)
658688 dt_iop_rasterfile_gui_data_t * g = IOP_GUI_ALLOC (rasterfile );
659689
660690 g -> mode = dt_bauhaus_combobox_from_params (self , "mode" );
661- gtk_widget_set_tooltip_text (g -> mode , _ ("select the RGB channels taken into account to generate the raster mask" ));
691+ gtk_widget_set_tooltip_text
692+ (g -> mode ,
693+ _ ("select the RGB channels taken into account to generate the raster mask" ));
662694
663695 g -> fbutton = dtgtk_button_new (dtgtk_cairo_paint_directory , CPF_NONE , NULL );
664696 gtk_widget_set_name (g -> fbutton , "non-flat" );
665- gtk_widget_set_tooltip_text (g -> fbutton , _ ("select the PFM file recorded as a raster mask,\n"
666- "CAUTION: path must be set in preferences/processing before choosing" ));
667- g_signal_connect (G_OBJECT (g -> fbutton ), "clicked" , G_CALLBACK (_fbutton_clicked ), self );
697+ gtk_widget_set_tooltip_text
698+ (g -> fbutton ,
699+ _ ("select the PFM file recorded as a raster mask,\n"
700+ "CAUTION: path must be set in preferences/processing before choosing" ));
701+ g_signal_connect (G_OBJECT (g -> fbutton ), "clicked" ,
702+ G_CALLBACK (_fbutton_clicked ), self );
668703
669704 g -> file = dt_bauhaus_combobox_new (self );
670705 dt_bauhaus_combobox_set_entries_ellipsis (g -> file , PANGO_ELLIPSIZE_MIDDLE );
671- gtk_widget_set_tooltip_text (g -> file , _ ("the mask file path is saved with the image history" ));
672- g_signal_connect (G_OBJECT (g -> file ), "value-changed" , G_CALLBACK (_file_callback ), self );
706+ gtk_widget_set_tooltip_text
707+ (g -> file ,
708+ _ ("the mask file path is saved with the image history" ));
709+ g_signal_connect (G_OBJECT (g -> file ), "value-changed" ,
710+ G_CALLBACK (_file_callback ), self );
673711
674712 // Vectorize button
675713
0 commit comments