[gimp/gimp-2-10] app: don't modify paint buffer when pasting to canvas
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: don't modify paint buffer when pasting to canvas
- Date: Wed, 15 May 2019 14:56:12 +0000 (UTC)
commit 24e956714ca65d73235bd8232666dfbeb024b972
Author: Ell <ell_se yahoo com>
Date: Wed May 15 09:44:41 2019 -0400
app: don't modify paint buffer when pasting to canvas
We now have enough machinery in gimppaintcore-loops to avoid
modifying the paint buffer in gimp_paint_core_paste() in the no-
applicator case, by using the same set of algorithms as
gimp_paint_core_replace(). Other than reducing the number of
different code paths we have, this is both more efficient, and
allows us to reuse the paint buffer across dabs, as done in the
following commits.
Implement gimp_paint_core_replace() in terms of
gimp_paint_core_paste(). We keep the two functions separate, since
their implementation is still differnet when using an applicator.
Suppress the paint-buffer-modifying algorithms in
gimppaintcore-loops, but keep them around; using the same logic for
normal painting as we use for REPLACE painting is possible due to
the fact that all our current non-REPLACE modes treat alpha values
and mask values interchangeably. In the future we might have modes
that distinguish between alpha and mask values, requiring the old
algorithms.
(cherry picked from commit f24bca515652f17c653ba2902639e4323fbea150)
app/paint/gimppaintcore-loops.cc | 6 +--
app/paint/gimppaintcore.c | 84 ++++++----------------------------------
2 files changed, 14 insertions(+), 76 deletions(-)
---
diff --git a/app/paint/gimppaintcore-loops.cc b/app/paint/gimppaintcore-loops.cc
index a66c6a120b..3c06ec1d25 100644
--- a/app/paint/gimppaintcore-loops.cc
+++ b/app/paint/gimppaintcore-loops.cc
@@ -1230,7 +1230,7 @@ struct CombinePaintMaskToCanvasBufferToPaintBufAlpha : Base
}
};
-static AlgorithmDispatch<
+static SuppressedAlgorithmDispatch<
CombinePaintMaskToCanvasBufferToPaintBufAlpha,
GIMP_PAINT_CORE_LOOPS_ALGORITHM_COMBINE_PAINT_MASK_TO_CANVAS_BUFFER |
GIMP_PAINT_CORE_LOOPS_ALGORITHM_CANVAS_BUFFER_TO_PAINT_BUF_ALPHA,
@@ -1403,7 +1403,7 @@ struct CanvasBufferToPaintBufAlpha : Base
}
};
-static AlgorithmDispatch<
+static SuppressedAlgorithmDispatch<
CanvasBufferToPaintBufAlpha,
GIMP_PAINT_CORE_LOOPS_ALGORITHM_CANVAS_BUFFER_TO_PAINT_BUF_ALPHA,
decltype (dispatch_paint_buf),
@@ -1475,7 +1475,7 @@ struct PaintMaskToPaintBufAlpha : Base
}
};
-static AlgorithmDispatch<
+static SuppressedAlgorithmDispatch<
PaintMaskToPaintBufAlpha,
GIMP_PAINT_CORE_LOOPS_ALGORITHM_PAINT_MASK_TO_PAINT_BUF_ALPHA,
decltype (dispatch_paint_buf),
diff --git a/app/paint/gimppaintcore.c b/app/paint/gimppaintcore.c
index 7a190fa530..94b399f154 100644
--- a/app/paint/gimppaintcore.c
+++ b/app/paint/gimppaintcore.c
@@ -885,7 +885,7 @@ gimp_paint_core_paste (GimpPaintCore *core,
}
/* Write canvas_buffer to paint_buf */
- algorithms |= GIMP_PAINT_CORE_LOOPS_ALGORITHM_CANVAS_BUFFER_TO_PAINT_BUF_ALPHA;
+ algorithms |= GIMP_PAINT_CORE_LOOPS_ALGORITHM_CANVAS_BUFFER_TO_COMP_MASK;
/* undo buf -> paint_buf -> dest_buffer */
params.src_buffer = core->undo_buffer;
@@ -900,7 +900,7 @@ gimp_paint_core_paste (GimpPaintCore *core,
params.paint_mask_offset_y = paint_mask_offset_y;
params.paint_opacity = paint_opacity;
- algorithms |= GIMP_PAINT_CORE_LOOPS_ALGORITHM_PAINT_MASK_TO_PAINT_BUF_ALPHA;
+ algorithms |= GIMP_PAINT_CORE_LOOPS_ALGORITHM_PAINT_MASK_TO_COMP_MASK;
/* dest_buffer -> paint_buf -> dest_buffer */
params.src_buffer = params.dest_buffer;
@@ -1107,77 +1107,15 @@ gimp_paint_core_replace (GimpPaintCore *core,
}
else
{
- GimpPaintCoreLoopsParams params = {};
- GimpPaintCoreLoopsAlgorithm algorithms = GIMP_PAINT_CORE_LOOPS_ALGORITHM_NONE;
-
- params.paint_buf = gimp_gegl_buffer_get_temp_buf (core->paint_buffer);
- params.paint_buf_offset_x = core->paint_buffer_x;
- params.paint_buf_offset_y = core->paint_buffer_y;
-
- if (! params.paint_buf)
- return;
-
- params.dest_buffer = gimp_drawable_get_buffer (drawable);
-
- if (mode == GIMP_PAINT_CONSTANT)
- {
- params.canvas_buffer = core->canvas_buffer;
-
- /* This step is skipped by the ink tool, which writes
- * directly to canvas_buffer
- */
- if (paint_mask != NULL)
- {
- /* Mix paint mask and canvas_buffer */
- params.paint_mask = paint_mask;
- params.paint_mask_offset_x = paint_mask_offset_x;
- params.paint_mask_offset_y = paint_mask_offset_y;
- params.stipple = GIMP_IS_AIRBRUSH (core);
- params.paint_opacity = paint_opacity;
-
- algorithms |= GIMP_PAINT_CORE_LOOPS_ALGORITHM_COMBINE_PAINT_MASK_TO_CANVAS_BUFFER;
- }
-
- /* Write canvas_buffer to the compositing mask */
- algorithms |= GIMP_PAINT_CORE_LOOPS_ALGORITHM_CANVAS_BUFFER_TO_COMP_MASK;
-
- /* undo buf -> paint_buf -> dest_buffer */
- params.src_buffer = core->undo_buffer;
- }
- else
- {
- g_return_if_fail (paint_mask);
-
- /* Write paint_mask to the compositing mask, does not modify
- * canvas_buffer
- */
- params.paint_mask = paint_mask;
- params.paint_mask_offset_x = paint_mask_offset_x;
- params.paint_mask_offset_y = paint_mask_offset_y;
- params.paint_opacity = paint_opacity;
-
- algorithms |= GIMP_PAINT_CORE_LOOPS_ALGORITHM_PAINT_MASK_TO_COMP_MASK;
-
- /* dest_buffer -> paint_buf -> dest_buffer */
- params.src_buffer = params.dest_buffer;
- }
-
- params.mask_buffer = core->mask_buffer;
- params.mask_offset_x = core->mask_x_offset;
- params.mask_offset_y = core->mask_y_offset;
- params.image_opacity = image_opacity;
- params.paint_mode = GIMP_LAYER_MODE_REPLACE;
-
- algorithms |= GIMP_PAINT_CORE_LOOPS_ALGORITHM_DO_LAYER_BLEND;
-
- if (affect != GIMP_COMPONENT_MASK_ALL)
- {
- params.affect = affect;
-
- algorithms |= GIMP_PAINT_CORE_LOOPS_ALGORITHM_MASK_COMPONENTS;
- }
-
- gimp_paint_core_loops_process (¶ms, algorithms);
+ gimp_paint_core_paste (core, paint_mask,
+ paint_mask_offset_x,
+ paint_mask_offset_y,
+ drawable,
+ paint_opacity,
+ image_opacity,
+ GIMP_LAYER_MODE_REPLACE,
+ mode);
+ return;
}
/* Update the undo extents */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]