Commit 3f1bd3a4 authored by Ulrich Pegelow's avatar Ulrich Pegelow

blending: several improvements and fixes

parent 15b43a35
......@@ -304,7 +304,7 @@ blendop_mask_Lab (__read_only image2d_t in_a, __read_only image2d_t in_b, __read
if(x >= width || y >= height) return;
float4 a = read_imagef(in_a, sampleri, (int2)(x, y) + offs);
float4 a = read_imagef(in_a, sampleri, (int2)(x, y) + offs); // see comment in blend.c:dt_develop_blend_process_cl()
float4 b = read_imagef(in_b, sampleri, (int2)(x, y));
float form = read_imagef(mask_in, sampleri, (int2)(x, y)).x;
......@@ -340,7 +340,7 @@ blendop_mask_rgb (__read_only image2d_t in_a, __read_only image2d_t in_b, __read
if(x >= width || y >= height) return;
float4 a = read_imagef(in_a, sampleri, (int2)(x, y) + offs);
float4 a = read_imagef(in_a, sampleri, (int2)(x, y) + offs); // see comment in blend.c:dt_develop_blend_process_cl()
float4 b = read_imagef(in_b, sampleri, (int2)(x, y));
float form = read_imagef(mask_in, sampleri, (int2)(x, y)).x;
......@@ -365,7 +365,7 @@ blendop_Lab (__read_only image2d_t in_a, __read_only image2d_t in_b, __read_only
float4 ta, tb, to;
float d, s;
float4 a = read_imagef(in_a, sampleri, (int2)(x, y) + offs);
float4 a = read_imagef(in_a, sampleri, (int2)(x, y) + offs); // see comment in blend.c:dt_develop_blend_process_cl()
float4 b = read_imagef(in_b, sampleri, (int2)(x, y));
float opacity = read_imagef(mask, sampleri, (int2)(x, y)).x;
......@@ -661,7 +661,7 @@ blendop_RAW (__read_only image2d_t in_a, __read_only image2d_t in_b, __read_only
float o;
float a = read_imagef(in_a, sampleri, (int2)(x, y) + offs).x;
float a = read_imagef(in_a, sampleri, (int2)(x, y) + offs).x; // see comment in blend.c:dt_develop_blend_process_cl()
float b = read_imagef(in_b, sampleri, (int2)(x, y)).x;
float opacity = read_imagef(mask, sampleri, (int2)(x, y)).x;
......@@ -808,7 +808,7 @@ blendop_rgb (__read_only image2d_t in_a, __read_only image2d_t in_b, __read_only
float4 ta, tb, to;
float d, s;
float4 a = read_imagef(in_a, sampleri, (int2)(x, y) + offs);
float4 a = read_imagef(in_a, sampleri, (int2)(x, y) + offs); // see comment in blend.c:dt_develop_blend_process_cl()
float4 b = read_imagef(in_b, sampleri, (int2)(x, y));
float opacity = read_imagef(mask, sampleri, (int2)(x, y)).x;
......@@ -1028,7 +1028,7 @@ blendop_display_channel (__read_only image2d_t in_a, __read_only image2d_t in_b,
if(x >= width || y >= height) return;
float4 a = read_imagef(in_a, sampleri, (int2)(x, y) + offs);
float4 a = read_imagef(in_a, sampleri, (int2)(x, y) + offs); // see comment in blend.c:dt_develop_blend_process_cl()
float4 b = read_imagef(in_b, sampleri, (int2)(x, y));
float opacity = read_imagef(mask, sampleri, (int2)(x, y)).x;
......
......@@ -2961,8 +2961,13 @@ void dt_develop_blend_process(struct dt_iop_module_t *self, struct dt_dev_pixelp
/* check if blend is disabled */
if(!(mask_mode & DEVELOP_MASK_ENABLED)) return;
/* we can only handle blending if roi_out and roi_in have the same scale and
if roi_out fits into the area given by roi_in */
/* In most cases of blending-enabled modules input and output of the module have
* the exact same dimensions. Only in very special cases we allow a module's input
* to exceed its output. This is namely the case for the spot removal module where
* the source of a patch might lie outside the roi of the output image. Therefore:
* We can only handle blending if roi_out and roi_in have the same scale and
* if roi_out fits into the area given by roi_in. xoffs and yoffs describe the relative
* offset of the input image to the output image. */
if(roi_out->scale != roi_in->scale || xoffs < 0 || yoffs < 0
|| ((xoffs > 0 || yoffs > 0)
&& (roi_out->width + xoffs > roi_in->width || roi_out->height + yoffs > roi_in->height)))
......@@ -3172,8 +3177,13 @@ int dt_develop_blend_process_cl(struct dt_iop_module_t *self, struct dt_dev_pixe
/* check if blend is disabled: just return, output is already in dev_out */
if(!(mask_mode & DEVELOP_MASK_ENABLED)) return TRUE;
/* we can only handle blending if roi_out and roi_in have the same scale and
if roi_out fits into the area given by roi_in */
/* In most cases of blending-enabled modules input and output of the module have
* the exact same dimensions. Only in very special cases we allow a module's input
* to exceed its output. This is namely the case for the spot removal module where
* the source of a patch might lie outside the roi of the output image. Therefore:
* We can only handle blending if roi_out and roi_in have the same scale and
* if roi_out fits into the area given by roi_in. xoffs and yoffs describe the relative
* offset of the input image to the output image. */
if(roi_out->scale != roi_in->scale || xoffs < 0 || yoffs < 0
|| ((xoffs > 0 || yoffs > 0)
&& (roi_out->width + xoffs > roi_in->width || roi_out->height + yoffs > roi_in->height)))
......
......@@ -548,7 +548,7 @@ static void _blendop_blendif_showmask_clicked(GtkWidget *button, GdkEventButton
module->request_mask_display &= ~(DT_DEV_PIXELPIPE_DISPLAY_MASK | DT_DEV_PIXELPIPE_DISPLAY_CHANNEL | DT_DEV_PIXELPIPE_DISPLAY_ANY);
GdkModifierType modifiers = gtk_accelerator_get_default_mod_mask();
if((event->state & modifiers) == (GDK_CONTROL_MASK | GDK_CONTROL_MASK))
if((event->state & modifiers) == (GDK_CONTROL_MASK | GDK_SHIFT_MASK))
module->request_mask_display |= (DT_DEV_PIXELPIPE_DISPLAY_MASK | DT_DEV_PIXELPIPE_DISPLAY_CHANNEL);
else if((event->state & modifiers) == GDK_SHIFT_MASK)
module->request_mask_display |= DT_DEV_PIXELPIPE_DISPLAY_CHANNEL;
......
......@@ -67,7 +67,7 @@ static inline float Hue_2_RGB(float v1, float v2, float vH)
if((6.0f * vH) < 1.0f) return (v1 + (v2 - v1) * 6.0f * vH);
if((2.0f * vH) < 1.0f) return (v2);
if((3.0f * vH) < 2.0f) return (v1 + (v2 - v1) * ((2.0f / 3.0f) - vH) * 6.0f);
return (v1);
return v1;
}
static inline void HSL_2_RGB(const float *HSL, float *RGB)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment