[gimp] app: change mask handling in GimpOperationReplaceMode
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: change mask handling in GimpOperationReplaceMode
- Date: Wed, 11 Jan 2017 11:39:46 +0000 (UTC)
commit 01b25baffd87f1e57aed52b4aeebcbb9cb39642e
Author: Michael Natterer <mitch gimp org>
Date: Wed Jan 11 12:38:58 2017 +0100
app: change mask handling in GimpOperationReplaceMode
to be like in the other modes, and proably speed it up a little.
app/operations/gimpoperationreplacemode.c | 24 +++++++++++-------------
1 files changed, 11 insertions(+), 13 deletions(-)
---
diff --git a/app/operations/gimpoperationreplacemode.c b/app/operations/gimpoperationreplacemode.c
index 6391185..46d7dbb 100644
--- a/app/operations/gimpoperationreplacemode.c
+++ b/app/operations/gimpoperationreplacemode.c
@@ -88,24 +88,22 @@ gimp_operation_replace_mode_process_pixels (gfloat *in,
const GeglRectangle *roi,
gint level)
{
+ const gboolean has_mask = mask != NULL;
+
while (samples--)
{
- gint b;
+ gfloat opacity_value = opacity;
gfloat new_alpha;
+ gint b;
- if (mask)
- new_alpha = (layer[ALPHA] - in[ALPHA]) * (*mask) * opacity + in[ALPHA];
- else
- new_alpha = (layer[ALPHA] - in[ALPHA]) * opacity + in[ALPHA];
+ if (has_mask)
+ opacity_value *= *mask;
+
+ new_alpha = (layer[ALPHA] - in[ALPHA]) * opacity_value + in[ALPHA];
if (new_alpha)
{
- gfloat ratio;
-
- if (mask)
- ratio = *mask * opacity * layer[ALPHA] / new_alpha;
- else
- ratio = opacity * layer[ALPHA] / new_alpha;
+ gfloat ratio = opacity_value * layer[ALPHA] / new_alpha;
for (b = RED; b < ALPHA; b++)
{
@@ -135,8 +133,8 @@ gimp_operation_replace_mode_process_pixels (gfloat *in,
layer += 4;
out += 4;
- if (mask)
- mask += 1;
+ if (has_mask)
+ mask++;
}
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]