app: split legacy out of grain extract and merge

parent 8f384243
......@@ -333,6 +333,10 @@ gimp_layer_mode_get_type (void)
{ GIMP_LAYER_MODE_HSV_VALUE, "GIMP_LAYER_MODE_HSV_VALUE", "hsv-value" },
{ GIMP_LAYER_MODE_DIVIDE, "GIMP_LAYER_MODE_DIVIDE", "divide" },
{ GIMP_LAYER_MODE_BURN, "GIMP_LAYER_MODE_BURN", "burn" },
{ GIMP_LAYER_MODE_HARDLIGHT, "GIMP_LAYER_MODE_HARDLIGHT", "hardlight" },
{ GIMP_LAYER_MODE_SOFTLIGHT, "GIMP_LAYER_MODE_SOFTLIGHT", "softlight" },
{ GIMP_LAYER_MODE_GRAIN_EXTRACT, "GIMP_LAYER_MODE_GRAIN_EXTRACT", "grain-extract" },
{ GIMP_LAYER_MODE_GRAIN_MERGE, "GIMP_LAYER_MODE_GRAIN_MERGE", "grain-merge" },
{ GIMP_LAYER_MODE_ERASE, "GIMP_LAYER_MODE_ERASE", "erase" },
{ GIMP_LAYER_MODE_REPLACE, "GIMP_LAYER_MODE_REPLACE", "replace" },
{ GIMP_LAYER_MODE_ANTI_ERASE, "GIMP_LAYER_MODE_ANTI_ERASE", "anti-erase" },
......@@ -359,10 +363,10 @@ gimp_layer_mode_get_type (void)
{ GIMP_LAYER_MODE_DIVIDE_LEGACY, NC_("layer-mode", "Divide (legacy)"), NULL },
{ GIMP_LAYER_MODE_DODGE_LEGACY, NC_("layer-mode", "Dodge (legacy)"), NULL },
{ GIMP_LAYER_MODE_BURN_LEGACY, NC_("layer-mode", "Burn (legacy)"), NULL },
{ GIMP_LAYER_MODE_HARDLIGHT_LEGACY, NC_("layer-mode", "Hard light"), NULL },
{ GIMP_LAYER_MODE_SOFTLIGHT_LEGACY, NC_("layer-mode", "Soft light"), NULL },
{ GIMP_LAYER_MODE_GRAIN_EXTRACT_LEGACY, NC_("layer-mode", "Grain extract"), NULL },
{ GIMP_LAYER_MODE_GRAIN_MERGE_LEGACY, NC_("layer-mode", "Grain merge"), NULL },
{ GIMP_LAYER_MODE_HARDLIGHT_LEGACY, NC_("layer-mode", "Hard light (legacy)"), NULL },
{ GIMP_LAYER_MODE_SOFTLIGHT_LEGACY, NC_("layer-mode", "Soft light (legacy)"), NULL },
{ GIMP_LAYER_MODE_GRAIN_EXTRACT_LEGACY, NC_("layer-mode", "Grain extract (legacy)"), NULL },
{ GIMP_LAYER_MODE_GRAIN_MERGE_LEGACY, NC_("layer-mode", "Grain merge (legacy)"), NULL },
{ GIMP_LAYER_MODE_COLOR_ERASE, NC_("layer-mode", "Color erase"), NULL },
{ GIMP_LAYER_MODE_OVERLAY, NC_("layer-mode", "Overlay"), NULL },
{ GIMP_LAYER_MODE_LCH_HUE, NC_("layer-mode", "Hue (LCH)"), NULL },
......@@ -385,6 +389,10 @@ gimp_layer_mode_get_type (void)
{ GIMP_LAYER_MODE_HSV_VALUE, NC_("layer-mode", "Value (HSV)"), NULL },
{ GIMP_LAYER_MODE_DIVIDE, NC_("layer-mode", "Divide"), NULL },
{ GIMP_LAYER_MODE_BURN, NC_("layer-mode", "Burn"), NULL },
{ GIMP_LAYER_MODE_HARDLIGHT, NC_("layer-mode", "Hard light"), NULL },
{ GIMP_LAYER_MODE_SOFTLIGHT, NC_("layer-mode", "Soft light"), NULL },
{ GIMP_LAYER_MODE_GRAIN_EXTRACT, NC_("layer-mode", "Grain extract"), NULL },
{ GIMP_LAYER_MODE_GRAIN_MERGE, NC_("layer-mode", "Grain merge"), NULL },
{ GIMP_LAYER_MODE_ERASE, NC_("layer-mode", "Erase"), NULL },
{ GIMP_LAYER_MODE_REPLACE, NC_("layer-mode", "Replace"), NULL },
{ GIMP_LAYER_MODE_ANTI_ERASE, NC_("layer-mode", "Anti erase"), NULL },
......
......@@ -174,8 +174,8 @@ typedef enum
GIMP_LAYER_MODE_BURN_LEGACY, /*< desc="Burn (legacy)" >*/
GIMP_LAYER_MODE_HARDLIGHT_LEGACY, /*< desc="Hard light (legacy)" >*/
GIMP_LAYER_MODE_SOFTLIGHT_LEGACY, /*< desc="Soft light (legacy)" >*/
GIMP_LAYER_MODE_GRAIN_EXTRACT_LEGACY, /*< desc="Grain extract" >*/
GIMP_LAYER_MODE_GRAIN_MERGE_LEGACY, /*< desc="Grain merge" >*/
GIMP_LAYER_MODE_GRAIN_EXTRACT_LEGACY, /*< desc="Grain extract (legacy)">*/
GIMP_LAYER_MODE_GRAIN_MERGE_LEGACY, /*< desc="Grain merge (legacy)" >*/
GIMP_LAYER_MODE_COLOR_ERASE, /*< desc="Color erase" >*/
GIMP_LAYER_MODE_OVERLAY, /*< desc="Overlay" >*/
GIMP_LAYER_MODE_LCH_HUE, /*< desc="Hue (LCH)" >*/
......@@ -200,6 +200,8 @@ typedef enum
GIMP_LAYER_MODE_BURN, /*< desc="Burn" >*/
GIMP_LAYER_MODE_HARDLIGHT, /*< desc="Hard light" >*/
GIMP_LAYER_MODE_SOFTLIGHT, /*< desc="Soft light" >*/
GIMP_LAYER_MODE_GRAIN_EXTRACT, /*< desc="Grain extract" >*/
GIMP_LAYER_MODE_GRAIN_MERGE, /*< desc="Grain merge" >*/
/* internal modes, not available to the PDB */
GIMP_LAYER_MODE_ERASE = 1000, /*< pdb-skip, desc="Erase" >*/
......
......@@ -295,12 +295,20 @@ gimp_gegl_mode_node_set_mode (GeglNode *node,
operation = "gimp:softlight-legacy";
break;
case GIMP_LAYER_MODE_GRAIN_EXTRACT:
operation = "gimp:grain-extract";
break;
case GIMP_LAYER_MODE_GRAIN_EXTRACT_LEGACY:
operation = "gimp:grain-extract-mode";
operation = "gimp:grain-extract-legacy";
break;
case GIMP_LAYER_MODE_GRAIN_MERGE:
operation = "gimp:grain-merge";
break;
case GIMP_LAYER_MODE_GRAIN_MERGE_LEGACY:
operation = "gimp:grain-merge-mode";
operation = "gimp:grain-merge-legacy";
break;
case GIMP_LAYER_MODE_COLOR_ERASE:
......@@ -398,7 +406,9 @@ gimp_gegl_mode_node_set_mode (GeglNode *node,
case GIMP_LAYER_MODE_BURN_LEGACY:
case GIMP_LAYER_MODE_HARDLIGHT_LEGACY:
case GIMP_LAYER_MODE_SOFTLIGHT_LEGACY:
case GIMP_LAYER_MODE_GRAIN_EXTRACT:
case GIMP_LAYER_MODE_GRAIN_EXTRACT_LEGACY:
case GIMP_LAYER_MODE_GRAIN_MERGE:
case GIMP_LAYER_MODE_GRAIN_MERGE_LEGACY:
case GIMP_LAYER_MODE_COLOR_ERASE:
case GIMP_LAYER_MODE_OVERLAY:
......
......@@ -99,10 +99,6 @@ libappoperations_a_SOURCES = \
gimpoperationpointlayermode.h \
gimpoperationbehindmode.c \
gimpoperationbehindmode.h \
gimpoperationgrainextractmode.c \
gimpoperationgrainextractmode.h \
gimpoperationgrainmergemode.c \
gimpoperationgrainmergemode.h \
gimpoperationcolorerasemode.c \
gimpoperationcolorerasemode.h \
gimpoperationreplacemode.c \
......
......@@ -102,8 +102,10 @@
#include "layer-modes-legacy/gimpoperationhardlightlegacy.h"
#include "layer-modes/gimpoperationsoftlight.h"
#include "layer-modes-legacy/gimpoperationsoftlightlegacy.h"
#include "gimpoperationgrainextractmode.h"
#include "gimpoperationgrainmergemode.h"
#include "layer-modes/gimpoperationgrainextract.h"
#include "layer-modes-legacy/gimpoperationgrainextractlegacy.h"
#include "layer-modes/gimpoperationgrainmerge.h"
#include "layer-modes-legacy/gimpoperationgrainmergelegacy.h"
#include "gimpoperationcolorerasemode.h"
#include "layer-modes/gimpoperationlchhue.h"
#include "layer-modes/gimpoperationlchchroma.h"
......@@ -182,8 +184,10 @@ gimp_operations_init (void)
g_type_class_ref (GIMP_TYPE_OPERATION_HARDLIGHT_LEGACY);
g_type_class_ref (GIMP_TYPE_OPERATION_SOFTLIGHT);
g_type_class_ref (GIMP_TYPE_OPERATION_SOFTLIGHT_LEGACY);
g_type_class_ref (GIMP_TYPE_OPERATION_GRAIN_EXTRACT_MODE);
g_type_class_ref (GIMP_TYPE_OPERATION_GRAIN_MERGE_MODE);
g_type_class_ref (GIMP_TYPE_OPERATION_GRAIN_EXTRACT);
g_type_class_ref (GIMP_TYPE_OPERATION_GRAIN_EXTRACT_LEGACY);
g_type_class_ref (GIMP_TYPE_OPERATION_GRAIN_MERGE);
g_type_class_ref (GIMP_TYPE_OPERATION_GRAIN_MERGE_LEGACY);
g_type_class_ref (GIMP_TYPE_OPERATION_COLOR_ERASE_MODE);
g_type_class_ref (GIMP_TYPE_OPERATION_LCH_HUE);
g_type_class_ref (GIMP_TYPE_OPERATION_LCH_CHROMA);
......
......@@ -62,8 +62,10 @@
#include "layer-modes-legacy/gimpoperationhardlightlegacy.h"
#include "layer-modes/gimpoperationsoftlight.h"
#include "layer-modes-legacy/gimpoperationsoftlightlegacy.h"
#include "gimpoperationgrainextractmode.h"
#include "gimpoperationgrainmergemode.h"
#include "layer-modes/gimpoperationgrainextract.h"
#include "layer-modes-legacy/gimpoperationgrainextractlegacy.h"
#include "layer-modes/gimpoperationgrainmerge.h"
#include "layer-modes-legacy/gimpoperationgrainmergelegacy.h"
#include "gimpoperationcolorerasemode.h"
#include "layer-modes/gimpoperationlchhue.h"
#include "layer-modes/gimpoperationlchchroma.h"
......@@ -111,7 +113,7 @@ get_layer_mode_function (GimpLayerMode paint_mode,
break;
case GIMP_LAYER_MODE_OVERLAY_LEGACY:
func = gimp_operation_softlight_mode_process_pixels;
func = gimp_operation_softlight_legacy_process_pixels;
break;
case GIMP_LAYER_MODE_DIFFERENCE_LEGACY:
......@@ -226,12 +228,20 @@ get_layer_mode_function (GimpLayerMode paint_mode,
func = gimp_operation_softlight_legacy_process_pixels;
break;
case GIMP_LAYER_MODE_GRAIN_EXTRACT:
func = gimp_operation_grain_extract_process_pixels;
break;
case GIMP_LAYER_MODE_GRAIN_EXTRACT_LEGACY:
func = gimp_operation_grain_extract_mode_process_pixels;
func = gimp_operation_grain_extract_legacy_process_pixels;
break;
case GIMP_LAYER_MODE_GRAIN_MERGE:
func = gimp_operation_grain_merge_process_pixels;
break;
case GIMP_LAYER_MODE_GRAIN_MERGE_LEGACY:
func = gimp_operation_grain_merge_mode_process_pixels;
func = gimp_operation_grain_merge_legacy_process_pixels;
break;
case GIMP_LAYER_MODE_COLOR_ERASE:
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpoperationgrain_extractmode.h
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_OPERATION_GRAIN_EXTRACT_MODE_H__
#define __GIMP_OPERATION_GRAIN_EXTRACT_MODE_H__
#include "gimpoperationpointlayermode.h"
#define GIMP_TYPE_OPERATION_GRAIN_EXTRACT_MODE (gimp_operation_grain_extract_mode_get_type ())
#define GIMP_OPERATION_GRAIN_EXTRACT_MODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_GRAIN_EXTRACT_MODE, GimpOperationGrainExtractMode))
#define GIMP_OPERATION_GRAIN_EXTRACT_MODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_GRAIN_EXTRACT_MODE, GimpOperationGrainExtractModeClass))
#define GIMP_IS_OPERATION_GRAIN_EXTRACT_MODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_GRAIN_EXTRACT_MODE))
#define GIMP_IS_OPERATION_GRAIN_EXTRACT_MODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_OPERATION_GRAIN_EXTRACT_MODE))
#define GIMP_OPERATION_GRAIN_EXTRACT_MODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_GRAIN_EXTRACT_MODE, GimpOperationGrainExtractModeClass))
typedef struct _GimpOperationGrainExtractMode GimpOperationGrainExtractMode;
typedef struct _GimpOperationGrainExtractModeClass GimpOperationGrainExtractModeClass;
struct _GimpOperationGrainExtractMode
{
GimpOperationPointLayerMode parent_instance;
};
struct _GimpOperationGrainExtractModeClass
{
GimpOperationPointLayerModeClass parent_class;
};
GType gimp_operation_grain_extract_mode_get_type (void) G_GNUC_CONST;
gboolean gimp_operation_grain_extract_mode_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level);
#endif /* __GIMP_OPERATION_GRAIN_EXTRACT_MODE_H__ */
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpoperationgrain_mergemode.h
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_OPERATION_GRAIN_MERGE_MODE_H__
#define __GIMP_OPERATION_GRAIN_MERGE_MODE_H__
#include "gimpoperationpointlayermode.h"
#define GIMP_TYPE_OPERATION_GRAIN_MERGE_MODE (gimp_operation_grain_merge_mode_get_type ())
#define GIMP_OPERATION_GRAIN_MERGE_MODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_GRAIN_MERGE_MODE, GimpOperationGrainMergeMode))
#define GIMP_OPERATION_GRAIN_MERGE_MODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_GRAIN_MERGE_MODE, GimpOperationGrainMergeModeClass))
#define GIMP_IS_OPERATION_GRAIN_MERGE_MODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_GRAIN_MERGE_MODE))
#define GIMP_IS_OPERATION_GRAIN_MERGE_MODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_OPERATION_GRAIN_MERGE_MODE))
#define GIMP_OPERATION_GRAIN_MERGE_MODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_GRAIN_MERGE_MODE, GimpOperationGrainMergeModeClass))
typedef struct _GimpOperationGrainMergeMode GimpOperationGrainMergeMode;
typedef struct _GimpOperationGrainMergeModeClass GimpOperationGrainMergeModeClass;
struct _GimpOperationGrainMergeMode
{
GimpOperationPointLayerMode parent_instance;
};
struct _GimpOperationGrainMergeModeClass
{
GimpOperationPointLayerModeClass parent_class;
};
GType gimp_operation_grain_merge_mode_get_type (void) G_GNUC_CONST;
gboolean gimp_operation_grain_merge_mode_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level);
#endif /* __GIMP_OPERATION_GRAIN_MERGE_MODE_H__ */
......@@ -46,5 +46,9 @@ libapplayermodeslegacy_a_SOURCES = \
gimpoperationhardlightlegacy.c \
gimpoperationhardlightlegacy.h \
gimpoperationsoftlightlegacy.c \
gimpoperationsoftlightlegacy.h
gimpoperationsoftlightlegacy.h \
gimpoperationgrainextractlegacy.c \
gimpoperationgrainextractlegacy.h \
gimpoperationgrainmergelegacy.c \
gimpoperationgrainmergelegacy.h
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpoperationgrainextractmode.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl-plugin.h>
#include "../operations-types.h"
#include "gimpoperationgrainextractlegacy.h"
static gboolean gimp_operation_grain_extract_legacy_process (GeglOperation *operation,
void *in_buf,
void *aux_buf,
void *aux2_buf,
void *out_buf,
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (GimpOperationGrainExtractLegacy, gimp_operation_grain_extract_legacy,
GIMP_TYPE_OPERATION_POINT_LAYER_MODE)
static void
gimp_operation_grain_extract_legacy_class_init (GimpOperationGrainExtractLegacyClass *klass)
{
GeglOperationClass *operation_class;
GeglOperationPointComposer3Class *point_class;
operation_class = GEGL_OPERATION_CLASS (klass);
point_class = GEGL_OPERATION_POINT_COMPOSER3_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "gimp:grain-extract-legacy",
"description", "GIMP grain extract mode operation",
NULL);
point_class->process = gimp_operation_grain_extract_legacy_process;
}
static void
gimp_operation_grain_extract_legacy_init (GimpOperationGrainExtractLegacy *self)
{
}
static gboolean
gimp_operation_grain_extract_legacy_process (GeglOperation *operation,
void *in_buf,
void *aux_buf,
void *aux2_buf,
void *out_buf,
glong samples,
const GeglRectangle *roi,
gint level)
{
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
return gimp_operation_grain_extract_legacy_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
}
gboolean
gimp_operation_grain_extract_legacy_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level)
{
const gboolean has_mask = mask != NULL;
while (samples--)
{
gfloat comp_alpha, new_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
if (has_mask)
comp_alpha *= *mask;
new_alpha = in[ALPHA] + (1.0 - in[ALPHA]) * comp_alpha;
if (comp_alpha && new_alpha)
{
gfloat ratio = comp_alpha / new_alpha;
gint b;
for (b = RED; b < ALPHA; b++)
{
gfloat comp = in[b] - layer[b] + 0.5;
out[b] = comp * ratio + in[b] * (1.0 - ratio);
out[b] = CLAMP (out[b], 0.0, 1.0);
}
}
else
{
gint b;
for (b = RED; b < ALPHA; b++)
{
out[b] = in[b];
}
}
out[ALPHA] = in[ALPHA];
in += 4;
layer += 4;
out += 4;
if (has_mask)
mask++;
}
return TRUE;
}
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpoperationgrainextractmode.c
* gimpoperationgrainmergemode.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
......@@ -23,27 +23,27 @@
#include <gegl-plugin.h>
#include "operations-types.h"
#include "../operations-types.h"
#include "gimpoperationgrainextractmode.h"
#include "gimpoperationgrainmergelegacy.h"
static gboolean gimp_operation_grain_extract_mode_process (GeglOperation *operation,
void *in_buf,
void *aux_buf,
void *aux2_buf,
void *out_buf,
glong samples,
const GeglRectangle *roi,
gint level);
static gboolean gimp_operation_grain_merge_legacy_process (GeglOperation *operation,
void *in_buf,
void *aux_buf,
void *aux2_buf,
void *out_buf,
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (GimpOperationGrainExtractMode, gimp_operation_grain_extract_mode,
G_DEFINE_TYPE (GimpOperationGrainMergeLegacy, gimp_operation_grain_merge_legacy,
GIMP_TYPE_OPERATION_POINT_LAYER_MODE)
static void
gimp_operation_grain_extract_mode_class_init (GimpOperationGrainExtractModeClass *klass)
gimp_operation_grain_merge_legacy_class_init (GimpOperationGrainMergeLegacyClass *klass)
{
GeglOperationClass *operation_class;
GeglOperationPointComposer3Class *point_class;
......@@ -52,20 +52,20 @@ gimp_operation_grain_extract_mode_class_init (GimpOperationGrainExtractModeClass
point_class = GEGL_OPERATION_POINT_COMPOSER3_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "gimp:grain-extract-mode",
"description", "GIMP grain extract mode operation",
"name", "gimp:grain-merge-legacy",
"description", "GIMP grain merge mode operation",
NULL);
point_class->process = gimp_operation_grain_extract_mode_process;
point_class->process = gimp_operation_grain_merge_legacy_process;
}
static void
gimp_operation_grain_extract_mode_init (GimpOperationGrainExtractMode *self)
gimp_operation_grain_merge_legacy_init (GimpOperationGrainMergeLegacy *self)
{
}
static gboolean
gimp_operation_grain_extract_mode_process (GeglOperation *operation,
gimp_operation_grain_merge_legacy_process (GeglOperation *operation,
void *in_buf,
void *aux_buf,
void *aux2_buf,
......@@ -76,11 +76,11 @@ gimp_operation_grain_extract_mode_process (GeglOperation *operation,
{
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
return gimp_operation_grain_extract_mode_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
return gimp_operation_grain_merge_legacy_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
}
gboolean
gimp_operation_grain_extract_mode_process_pixels (gfloat *in,
gimp_operation_grain_merge_legacy_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
......@@ -108,7 +108,7 @@ gimp_operation_grain_extract_mode_process_pixels (gfloat *in,
for (b = RED; b < ALPHA; b++)
{
gfloat comp = in[b] - layer[b] + 0.5;
gfloat comp = in[b] + layer[b] - 0.5;
out[b] = comp * ratio + in[b] * (1.0 - ratio);
out[b] = CLAMP (out[b], 0.0, 1.0);
......@@ -131,7 +131,7 @@ gimp_operation_grain_extract_mode_process_pixels (gfloat *in,
out += 4;
if (has_mask)
mask++;
mask ++;
}
return TRUE;
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpoperationgrainmergemode.c
* gimpoperationhardlightmode.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
......@@ -23,12 +23,12 @@
#include <gegl-plugin.h>
#include "operations-types.h"
#include "../operations-types.h"
#include "gimpoperationgrainmergemode.h"
#include "gimpoperationhardlightlegacy.h"
static gboolean gimp_operation_grain_merge_mode_process (GeglOperation *operation,
static gboolean gimp_operation_hardlight_legacy_process (GeglOperation *operation,
void *in_buf,
void *aux_buf,
void *aux2_buf,
......@@ -36,14 +36,14 @@ static gboolean gimp_operation_grain_merge_mode_process (GeglOperation *op
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (GimpOperationGrainMergeMode, gimp_operation_grain_merge_mode,
G_DEFINE_TYPE (GimpOperationHardlightLegacy, gimp_operation_hardlight_legacy,
GIMP_TYPE_OPERATION_POINT_LAYER_MODE)
static void
gimp_operation_grain_merge_mode_class_init (GimpOperationGrainMergeModeClass *klass)
gimp_operation_hardlight_legacy_class_init (GimpOperationHardlightLegacyClass *klass)
{
GeglOperationClass *operation_class;
GeglOperationPointComposer3Class *point_class;
......@@ -52,20 +52,20 @@ gimp_operation_grain_merge_mode_class_init (GimpOperationGrainMergeModeClass *kl
point_class = GEGL_OPERATION_POINT_COMPOSER3_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "gimp:grain-merge-mode",
"description", "GIMP grain merge mode operation",
"name", "gimp:hardlight-legacy",
"description", "GIMP hardlight mode operation",
NULL);
point_class->process = gimp_operation_grain_merge_mode_process;
point_class->process = gimp_operation_hardlight_legacy_process;
}
static void
gimp_operation_grain_merge_mode_init (GimpOperationGrainMergeMode *self)
gimp_operation_hardlight_legacy_init (GimpOperationHardlightLegacy *self)
{
}
static gboolean
gimp_operation_grain_merge_mode_process (GeglOperation *operation,
gimp_operation_hardlight_legacy_process (GeglOperation *operation,
void *in_buf,
void *aux_buf,
void *aux2_buf,
......@@ -76,11 +76,11 @@ gimp_operation_grain_merge_mode_process (GeglOperation *operation,
{
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
return gimp_operation_grain_merge_mode_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
return gimp_operation_hardlight_legacy_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
}
gboolean
gimp_operation_grain_merge_mode_process_pixels (gfloat *in,
gimp_operation_hardlight_legacy_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
......@@ -108,10 +108,20 @@ gimp_operation_grain_merge_mode_process_pixels (gfloat *in,
for (b = RED; b < ALPHA; b++)
{
gfloat comp = in[b] + layer[b] - 0.5;
gfloat comp;
if (layer[b] > 0.5)
{
comp = (1.0 - in[b]) * (1.0 - (layer[b] - 0.5) * 2.0);
comp = MIN (1 - comp, 1);
}
else
{
comp = in[b] * (layer[b] * 2.0);
comp = MIN (comp, 1.0);
}
out[b] = comp * ratio + in[b] * (1.0 - ratio);
out[b] = CLAMP (out[b], 0.0, 1.0);
}
}
else
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpoperationsoftlightmode.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl-plugin.h>
#include "../operations-types.h"
#include "gimpoperationsoftlightlegacy.h"
static gboolean gimp_operation_softlight_legacy_process (GeglOperation *operation,
void *in_buf,
void *aux_buf,
void *aux2_buf,
void *out_buf,
glong samples,
const GeglRectangle *roi,
gint level);
G_DEFINE_TYPE (GimpOperationSoftlightLegacy, gimp_operation_softlight_legacy,
GIMP_TYPE_OPERATION_POINT_LAYER_MODE)