@@ -323,14 +323,13 @@ static inline dt_hash_t _get_cache_hash(dt_iop_module_t *self)
323
323
return hash ;
324
324
}
325
325
326
- static float * _get_rasterfile_mask (dt_dev_pixelpipe_iop_t * piece )
326
+ static float * _get_rasterfile_mask (dt_dev_pixelpipe_iop_t * piece ,
327
+ const dt_iop_roi_t * const roi ,
328
+ const dt_iop_roi_t * const roo )
327
329
{
328
330
dt_iop_module_t * self = piece -> module ;
329
331
dt_iop_rasterfile_data_t * d = piece -> data ;
330
332
331
- const dt_iop_roi_t * roi = & piece -> processed_roi_in ;
332
- const dt_iop_roi_t * roo = & piece -> processed_roi_out ;
333
-
334
333
dt_rasterfile_cache_t * cd = self -> data ;
335
334
float * res = NULL ;
336
335
@@ -346,13 +345,14 @@ static float *_get_rasterfile_mask(dt_dev_pixelpipe_iop_t *piece)
346
345
}
347
346
if (cd -> mask )
348
347
{
349
- float * tmp = dt_iop_image_alloc (roi -> width , roi -> height , 1 );
348
+ const gboolean scale = cd -> width != roi -> width || cd -> height != roi -> height ;
349
+ float * tmp = scale ? dt_iop_image_alloc (roi -> width , roi -> height , 1 ) : cd -> mask ;
350
350
if (tmp )
351
351
{
352
- interpolate_bilinear (cd -> mask , cd -> width , cd -> height , tmp , roi -> width , roi -> height , 1 );
352
+ if ( scale ) interpolate_bilinear (cd -> mask , cd -> width , cd -> height , tmp , roi -> width , roi -> height , 1 );
353
353
res = dt_iop_image_alloc (roo -> width , roo -> height , 1 );
354
354
if (res ) self -> distort_mask (self , piece , tmp , res , roi , roo );
355
- dt_free_align (tmp );
355
+ if ( scale ) dt_free_align (tmp );
356
356
}
357
357
}
358
358
dt_pthread_mutex_unlock (& cd -> lock );
@@ -378,7 +378,7 @@ int process_cl(dt_iop_module_t *self,
378
378
if (visual ) return err ;
379
379
380
380
if (roi_out -> scale != roi_in -> scale && ch == 4 )
381
- err = dt_iop_clip_and_zoom_roi_cl (devid , dev_out , dev_in , roi_out , roi_in );
381
+ err = dt_iop_clip_and_zoom_cl (devid , dev_out , dev_in , roi_out , roi_in );
382
382
else
383
383
{
384
384
size_t iorigin [] = { roi_out -> x , roi_out -> y , 0 };
@@ -390,7 +390,7 @@ int process_cl(dt_iop_module_t *self,
390
390
if (dt_iop_is_raster_mask_used (piece -> module , BLEND_RASTER_ID )
391
391
&& (err == CL_SUCCESS ))
392
392
{
393
- float * mask = _get_rasterfile_mask (piece );
393
+ float * mask = _get_rasterfile_mask (piece , roi_in , roi_out );
394
394
if (mask )
395
395
dt_iop_piece_set_raster (piece , mask , roi_in , roi_out );
396
396
else
@@ -427,7 +427,7 @@ void process(dt_iop_module_t *self,
427
427
const gboolean fullpipe = pipe -> type & DT_DEV_PIXELPIPE_FULL ;
428
428
const gboolean request = dt_iop_is_raster_mask_used (piece -> module , BLEND_RASTER_ID );
429
429
const gboolean visual = fullpipe && dt_iop_has_focus (self );
430
- float * mask = visual || request ? _get_rasterfile_mask (piece ) : NULL ;
430
+ float * mask = visual || request ? _get_rasterfile_mask (piece , roi_in , roi_out ) : NULL ;
431
431
432
432
if (visual )
433
433
{
0 commit comments