Allow raster mask to be combined with drawn & parametric mask
The idea is to use external raster mask to mask out areas parametric & drawn mask that we don't want them to take effect (i.e. background exposure).
Changes to pixel pipeline is not implemented yet
I've had thoughts about adding raster masks to the conditional blending, but never got around to implementing anything. My idea was to treat the raster mask as just another "shape" in drawn masks (which would also allow multiple rasters to be combined with AND/OR/XOR/ANDNOT). Internally, darktable generates a raster mask for each drawn shape and then merges those layers into the final drawn mask. Adding a raster as another layer would take very little code beyond the GUI stuff to select the raster.
@ralfbrown Sounds good! What I've been thinking is to multiply the raster mask with the mask generated by drawn and/or parametric mask.
Can you point me to the function that merges layers into the final drawn mask?
Not an expert on that part of the codebase, but I'd start in files src/develop/masks.h and src/develop/masks/masks.c. My suggestion after a quick scan of those files: Add a new value to dt_masks_type_t and update dt_masks_create() to setup the config for copying a raster mask as a "shape". This involves writing several (but not all) of the functions that a dt_masks_functions_t struct points at; look in src/develop/masks/circle.c for probably the simplest model for those functions. My first impression is you'll need set_form_name, get_mask, get_mask_roi, and possibly get_area/get_source_area; sanitize_config is probably a good idea but not strictly required.
After that, there's a good chance that the existing machinery will just work, letting you use the mask manager module to specify combination methods (union/intersection/diff/sum).
@stnKrisna : Please do not merge origin/master into your topic branch. If needed do a rebase. TIA.
@ralfbrown It took me a while to implement this. But I got a working prototype.
Also, as of now, I don't think any of the mask operations are working. The only way to invert the raster mask is to invert it in another module (or original module) before using it.
As of now, to load the raster mask into the drawn mask, you'd need to configure the raster map and switching back to the drawn & parametric mask. I need suggestion how to best load the raster mask into the raster shape.
Also, it's currently not possible to select the raster "shape" in the viewport, as I think this would block selection of other drawn masks. When updating shape of the raster mask, it will not update the mask value when used in the parametric "shape".
Implementing the _raster_get_mask_roi fixed some of the issues. Raster "shape" and drawn mask is now intersecting as expected.
currently not possible to select the raster "shape" in the viewport, as I think this would block selection of other drawn masks.
Yeah, that might be tricky. The obvious idea is to treat raster as being "behind" all drawn shapes, i.e. selected whenever the mouse is not over or near-enough a drawn shape. You can probably achieve that by returning a fixed distance equal to the maximum distance at which a shape gets selected. Won't help when multiple raster masks are enabled, though, and I'm not sure how to indicate that the raster is currently selected (beyond the hinter message) since there's no outline to emphasize.
If you're expanding mask functionality, I offer up this - https://discuss.pixls.us/t/strategies-for-masking-fragmented-areas/42601/24?u=rawconvert