Commit 34c50b0f authored by Daniel Sabo's avatar Daniel Sabo

app, plug-ins: Don't modify iter->length

The new by-row iteration doesn't re-write the length
value for each row. In general it is not safe to modify
the iterator data because the internal logic depends
on the public data, but this specific case is new.
parent a481065f
......@@ -631,9 +631,10 @@ gradient_precalc_shapeburst (GimpImage *image,
while (gegl_buffer_iterator_next (iter))
{
gfloat *data = iter->data[0];
gint count = iter->length;
gfloat *data = iter->data[0];
while (iter->length--)
while (count--)
*data++ /= max_iteration;
}
}
......
......@@ -330,7 +330,8 @@ gimp_histogram_calculate (GimpHistogram *histogram,
while (gegl_buffer_iterator_next (iter))
{
const gfloat *data = iter->data[0];
const gfloat *data = iter->data[0];
gint length = iter->length;
gfloat max;
if (mask)
......@@ -340,7 +341,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
switch (n_components)
{
case 1:
while (iter->length--)
while (length--)
{
const gdouble masked = *mask_data;
......@@ -352,7 +353,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
break;
case 2:
while (iter->length--)
while (length--)
{
const gdouble masked = *mask_data;
const gdouble weight = data[1];
......@@ -366,7 +367,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
break;
case 3: /* calculate separate value values */
while (iter->length--)
while (length--)
{
const gdouble masked = *mask_data;
......@@ -385,7 +386,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
break;
case 4: /* calculate separate value values */
while (iter->length--)
while (length--)
{
const gdouble masked = *mask_data;
const gdouble weight = data[3];
......@@ -411,7 +412,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
switch (n_components)
{
case 1:
while (iter->length--)
while (length--)
{
VALUE (0, data[0]) += 1.0;
......@@ -420,7 +421,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
break;
case 2:
while (iter->length--)
while (length--)
{
const gdouble weight = data[1];
......@@ -432,7 +433,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
break;
case 3: /* calculate separate value values */
while (iter->length--)
while (length--)
{
VALUE (1, data[0]) += 1.0;
VALUE (2, data[1]) += 1.0;
......@@ -448,7 +449,7 @@ gimp_histogram_calculate (GimpHistogram *histogram,
break;
case 4: /* calculate separate value values */
while (iter->length--)
while (length--)
{
const gdouble weight = data[3];
......
......@@ -217,10 +217,11 @@ gimp_image_contiguous_region_by_color (GimpImage *image,
while (gegl_buffer_iterator_next (iter))
{
const gfloat *src = iter->data[0];
gfloat *dest = iter->data[1];
const gfloat *src = iter->data[0];
gfloat *dest = iter->data[1];
gint count = iter->length;
while (iter->length--)
while (count--)
{
/* Find how closely the colors match */
*dest = pixel_difference (start_col, src,
......
......@@ -690,11 +690,12 @@ remap_indexed_layer (GimpLayer *layer,
while (gegl_buffer_iterator_next (iter))
{
guchar *data = iter->data[0];
guchar *data = iter->data[0];
gint length = iter->length;
if (has_alpha)
{
while (iter->length--)
while (length--)
{
if (data[ALPHA_I])
data[INDEXED] = remap_table[data[INDEXED]];
......@@ -704,7 +705,7 @@ remap_indexed_layer (GimpLayer *layer,
}
else
{
while (iter->length--)
while (length--)
{
data[INDEXED] = remap_table[data[INDEXED]];
......@@ -1152,11 +1153,12 @@ generate_histogram_gray (CFHistogram histogram,
while (gegl_buffer_iterator_next (iter))
{
const guchar *data = iter->data[0];
const guchar *data = iter->data[0];
gint length = iter->length;
if (has_alpha)
{
while (iter->length--)
while (length--)
{
if (data[ALPHA_G] > 127)
histogram[*data]++;
......@@ -1166,7 +1168,7 @@ generate_histogram_gray (CFHistogram histogram,
}
else
{
while (iter->length--)
while (length--)
{
histogram[*data]++;
......@@ -1224,9 +1226,10 @@ generate_histogram_rgb (CFHistogram histogram,
while (gegl_buffer_iterator_next (iter))
{
const guchar *data = iter->data[0];
const guchar *data = iter->data[0];
gint length = iter->length;
total_size += iter->length;
total_size += length;
/* g_printerr (" [%d,%d - %d,%d]", srcPR.x, src_roi->y, offsetx, offsety); */
......@@ -1241,7 +1244,7 @@ generate_histogram_rgb (CFHistogram histogram,
coledge = col + roi->width;
row = roi->y + offsety;
while (iter->length--)
while (length--)
{
gboolean transparent = FALSE;
......@@ -1271,7 +1274,7 @@ generate_histogram_rgb (CFHistogram histogram,
}
else
{
while (iter->length--)
while (length--)
{
if ((has_alpha && ((data[ALPHA] > 127)))
|| (!has_alpha))
......@@ -1294,7 +1297,7 @@ generate_histogram_rgb (CFHistogram histogram,
coledge = col + roi->width;
row = roi->y + offsety;
while (iter->length--)
while (length--)
{
gboolean transparent = FALSE;
......
......@@ -311,11 +311,12 @@ gimp_palette_import_extract (GimpImage *image,
{
const guchar *data = iter->data[0];
const guchar *mask_data = NULL;
gint length = iter->length;
if (mask_roi)
mask_data = iter->data[1];
while (iter->length--)
while (length--)
{
/* ignore unselected, and completely transparent pixels */
if ((! mask_data || *mask_data) && data[ALPHA])
......
......@@ -235,10 +235,11 @@ gimp_gegl_dodgeburn (GeglBuffer *src_buffer,
while (gegl_buffer_iterator_next (iter))
{
gfloat *src = iter->data[0];
gfloat *dest = iter->data[1];
gfloat *src = iter->data[0];
gfloat *dest = iter->data[1];
gint count = iter->length;
while (iter->length--)
while (count--)
{
*dest++ = *src++ * factor;
*dest++ = *src++ * factor;
......@@ -257,10 +258,11 @@ gimp_gegl_dodgeburn (GeglBuffer *src_buffer,
while (gegl_buffer_iterator_next (iter))
{
gfloat *src = iter->data[0];
gfloat *dest = iter->data[1];
gfloat *src = iter->data[0];
gfloat *dest = iter->data[1];
gint count = iter->length;
while (iter->length--)
while (count--)
{
*dest++ = pow (*src++, factor);
*dest++ = pow (*src++, factor);
......@@ -279,10 +281,11 @@ gimp_gegl_dodgeburn (GeglBuffer *src_buffer,
while (gegl_buffer_iterator_next (iter))
{
gfloat *src = iter->data[0];
gfloat *dest = iter->data[1];
gfloat *src = iter->data[0];
gfloat *dest = iter->data[1];
gint count = iter->length;
while (iter->length--)
while (count--)
{
if (exposure >= 0)
{
......@@ -357,10 +360,11 @@ gimp_gegl_smudge_blend (GeglBuffer *top_buffer,
const gfloat *top = iter->data[0];
const gfloat *bottom = iter->data[1];
gfloat *dest = iter->data[2];
gint count = iter->length;
const gfloat blend1 = 1.0 - blend;
const gfloat blend2 = blend;
while (iter->length--)
while (count--)
{
const gfloat a1 = blend1 * bottom[3];
const gfloat a2 = blend2 * top[3];
......@@ -407,10 +411,11 @@ gimp_gegl_apply_mask (GeglBuffer *mask_buffer,
while (gegl_buffer_iterator_next (iter))
{
const gfloat *mask = iter->data[0];
gfloat *dest = iter->data[1];
const gfloat *mask = iter->data[0];
gfloat *dest = iter->data[1];
gint count = iter->length;
while (iter->length--)
while (count--)
{
dest[3] *= *mask * opacity;
......@@ -439,10 +444,11 @@ gimp_gegl_combine_mask (GeglBuffer *mask_buffer,
while (gegl_buffer_iterator_next (iter))
{
const gfloat *mask = iter->data[0];
gfloat *dest = iter->data[1];
const gfloat *mask = iter->data[0];
gfloat *dest = iter->data[1];
gint count = iter->length;
while (iter->length--)
while (count--)
{
*dest *= *mask * opacity;
......@@ -472,12 +478,13 @@ gimp_gegl_combine_mask_weird (GeglBuffer *mask_buffer,
while (gegl_buffer_iterator_next (iter))
{
const gfloat *mask = iter->data[0];
gfloat *dest = iter->data[1];
const gfloat *mask = iter->data[0];
gfloat *dest = iter->data[1];
gint count = iter->length;
if (stipple)
{
while (iter->length--)
while (count--)
{
dest[0] += (1.0 - dest[0]) * *mask * opacity;
......@@ -487,7 +494,7 @@ gimp_gegl_combine_mask_weird (GeglBuffer *mask_buffer,
}
else
{
while (iter->length--)
while (count--)
{
if (opacity > dest[0])
dest[0] += (opacity - dest[0]) * *mask * opacity;
......@@ -535,8 +542,9 @@ gimp_gegl_replace (GeglBuffer *top_buffer,
const gfloat *bottom = iter->data[1];
const gfloat *mask = iter->data[2];
gfloat *dest = iter->data[3];
gint count = iter->length;
while (iter->length--)
while (count--)
{
gint b;
gdouble mask_val = *mask * opacity;
......
......@@ -413,8 +413,9 @@ gimp_gegl_mask_combine_buffer (GeglBuffer *mask,
{
gfloat *mask_data = iter->data[0];
const gfloat *add_on_data = iter->data[1];
gint count = iter->length;
while (iter->length--)
while (count--)
{
const gfloat val = *mask_data + *add_on_data;
......@@ -431,8 +432,9 @@ gimp_gegl_mask_combine_buffer (GeglBuffer *mask,
{
gfloat *mask_data = iter->data[0];
const gfloat *add_on_data = iter->data[1];
gint count = iter->length;
while (iter->length--)
while (count--)
{
if (*add_on_data > *mask_data)
*mask_data = 0.0;
......@@ -450,8 +452,9 @@ gimp_gegl_mask_combine_buffer (GeglBuffer *mask,
{
gfloat *mask_data = iter->data[0];
const gfloat *add_on_data = iter->data[1];
gint count = iter->length;
while (iter->length--)
while (count--)
{
*mask_data = MIN (*mask_data, *add_on_data);
......
......@@ -1206,9 +1206,10 @@ load_image (const gchar *filename,
while (gegl_buffer_iterator_next (iter))
{
guchar *data = iter->data[0];
guchar *data = iter->data[0];
gint length = iter->length;
while (iter->length--)
while (length--)
{
data[1] = alpha[data[0]];
data[0] -= empty;
......@@ -1824,9 +1825,10 @@ ia_has_transparent_pixels (GeglBuffer *buffer)
while (gegl_buffer_iterator_next (iter))
{
const guchar *data = iter->data[0];
const guchar *data = iter->data[0];
gint length = iter->length;
while (iter->length--)
while (length--)
{
if (data[1] <= 127)
{
......@@ -1866,9 +1868,10 @@ find_unused_ia_color (GeglBuffer *buffer,
while (gegl_buffer_iterator_next (iter))
{
const guchar *data = iter->data[0];
const guchar *data = iter->data[0];
gint length = iter->length;
while (iter->length--)
while (length--)
{
if (data[1] > 127)
ix_used[data[0]] = TRUE;
......
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