From d4cb2d57bdbe7828bbf1b3a7f2a490ad9fa8acb1 Mon Sep 17 00:00:00 2001 From: Ell Date: Mon, 11 Feb 2019 03:42:16 -0500 Subject: [PATCH] app: in gimppaintcore-loops, make sure dest_buffer is the primary iterator buffer In gimppaintcore-loops, in the DO_LAYER_BLEND paint algorithm, and in the CanvasBufferIterator algorithm helper-class, initialize the iterator *before* initializing the base class, to make sure that dest_buffer, or canvas_buffer, respectively and in that order, is the primary buffer of the iterator. In particular, this avoids the mask buffer being the primary buffer. This is desirable, since most of the buffers we iterate over are tile-aligned to the dest/ canvas buffers. (cherry picked from commit f9c072c328666d332ea46212336394f33d474072) --- app/paint/gimppaintcore-loops.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/paint/gimppaintcore-loops.cc b/app/paint/gimppaintcore-loops.cc index 3613d877f4..8631a3e9d9 100644 --- a/app/paint/gimppaintcore-loops.cc +++ b/app/paint/gimppaintcore-loops.cc @@ -907,11 +907,15 @@ struct CanvasBufferIterator : Base const GeglRectangle *roi, const GeglRectangle *area) const { - Base::init (params, state, iter, roi, area); - state->canvas_buffer_iterator = gegl_buffer_iterator_add ( iter, params->canvas_buffer, area, 0, babl_format ("Y float"), Derived::canvas_buffer_access, GEGL_ABYSS_NONE); + + /* initialize the base class *after* initializing the iterator, to make + * sure that canvas_buffer is the primary buffer of the iterator, if no + * subclass added an iterator first. + */ + Base::init (params, state, iter, roi, area); } }; @@ -1317,8 +1321,6 @@ struct DoLayerBlend : Base const GeglRectangle *roi, const GeglRectangle *area) const { - Base::init (params, state, iter, roi, area); - state->iterator_base = gegl_buffer_iterator_add (iter, params->dest_buffer, area, 0, iterator_format, GEGL_ACCESS_WRITE, @@ -1327,6 +1329,12 @@ struct DoLayerBlend : Base gegl_buffer_iterator_add (iter, params->src_buffer, area, 0, iterator_format, GEGL_ACCESS_READ, GEGL_ABYSS_NONE); + + /* initialize the base class *after* initializing the iterator, to make + * sure that dest_buffer is the primary buffer of the iterator, if no + * subclass added an iterator first. + */ + Base::init (params, state, iter, roi, area); } template