app: split legacy lighten only and darken only ops

parent 2ed8bd1f
......@@ -325,6 +325,8 @@ gimp_layer_mode_get_type (void)
{ GIMP_LAYER_MODE_DIFFERENCE, "GIMP_LAYER_MODE_DIFFERENCE", "difference" },
{ GIMP_LAYER_MODE_ADDITION, "GIMP_LAYER_MODE_ADDITION", "addition" },
{ GIMP_LAYER_MODE_SUBTRACT, "GIMP_LAYER_MODE_SUBTRACT", "subtract" },
{ GIMP_LAYER_MODE_DARKEN_ONLY, "GIMP_LAYER_MODE_DARKEN_ONLY", "darken-only" },
{ GIMP_LAYER_MODE_LIGHTEN_ONLY, "GIMP_LAYER_MODE_LIGHTEN_ONLY", "lighten-only" },
{ 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" },
......@@ -342,8 +344,8 @@ gimp_layer_mode_get_type (void)
{ GIMP_LAYER_MODE_DIFFERENCE_LEGACY, NC_("layer-mode", "Difference (legacy)"), NULL },
{ GIMP_LAYER_MODE_ADDITION_LEGACY, NC_("layer-mode", "Addition (legacy)"), NULL },
{ GIMP_LAYER_MODE_SUBTRACT_LEGACY, NC_("layer-mode", "Subtract (legacy)"), NULL },
{ GIMP_LAYER_MODE_DARKEN_ONLY_LEGACY, NC_("layer-mode", "Darken only"), NULL },
{ GIMP_LAYER_MODE_LIGHTEN_ONLY_LEGACY, NC_("layer-mode", "Lighten only"), NULL },
{ GIMP_LAYER_MODE_DARKEN_ONLY_LEGACY, NC_("layer-mode", "Darken only (legacy)"), NULL },
{ GIMP_LAYER_MODE_LIGHTEN_ONLY_LEGACY, NC_("layer-mode", "Lighten only (legacy)"), NULL },
{ GIMP_LAYER_MODE_HSV_HUE_LEGACY, NC_("layer-mode", "Hue (HSV)"), NULL },
{ GIMP_LAYER_MODE_HSV_SATURATION_LEGACY, NC_("layer-mode", "Saturation (HSV)"), NULL },
{ GIMP_LAYER_MODE_HSV_COLOR_LEGACY, NC_("layer-mode", "Color (HSV)"), NULL },
......@@ -369,6 +371,8 @@ gimp_layer_mode_get_type (void)
{ GIMP_LAYER_MODE_DIFFERENCE, NC_("layer-mode", "Difference"), NULL },
{ GIMP_LAYER_MODE_ADDITION, NC_("layer-mode", "Addition"), NULL },
{ GIMP_LAYER_MODE_SUBTRACT, NC_("layer-mode", "Subtract"), NULL },
{ GIMP_LAYER_MODE_DARKEN_ONLY, NC_("layer-mode", "Darken only"), NULL },
{ GIMP_LAYER_MODE_LIGHTEN_ONLY, NC_("layer-mode", "Lighten only"), 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 },
......
......@@ -163,8 +163,8 @@ typedef enum
GIMP_LAYER_MODE_DIFFERENCE_LEGACY, /*< desc="Difference (legacy)" >*/
GIMP_LAYER_MODE_ADDITION_LEGACY, /*< desc="Addition (legacy)" >*/
GIMP_LAYER_MODE_SUBTRACT_LEGACY, /*< desc="Subtract (legacy)" >*/
GIMP_LAYER_MODE_DARKEN_ONLY_LEGACY, /*< desc="Darken only" >*/
GIMP_LAYER_MODE_LIGHTEN_ONLY_LEGACY, /*< desc="Lighten only" >*/
GIMP_LAYER_MODE_DARKEN_ONLY_LEGACY, /*< desc="Darken only (legacy)" >*/
GIMP_LAYER_MODE_LIGHTEN_ONLY_LEGACY, /*< desc="Lighten only (legacy)">*/
GIMP_LAYER_MODE_HSV_HUE_LEGACY, /*< desc="Hue (HSV)" >*/
GIMP_LAYER_MODE_HSV_SATURATION_LEGACY, /*< desc="Saturation (HSV)" >*/
GIMP_LAYER_MODE_HSV_COLOR_LEGACY, /*< desc="Color (HSV)" >*/
......@@ -190,6 +190,8 @@ typedef enum
GIMP_LAYER_MODE_DIFFERENCE, /*< desc="Difference" >*/
GIMP_LAYER_MODE_ADDITION, /*< desc="Addition" >*/
GIMP_LAYER_MODE_SUBTRACT, /*< desc="Subtract" >*/
GIMP_LAYER_MODE_DARKEN_ONLY, /*< desc="Darken only" >*/
GIMP_LAYER_MODE_LIGHTEN_ONLY, /*< desc="Lighten only" >*/
/* internal modes, not available to the PDB */
GIMP_LAYER_MODE_ERASE = 1000, /*< pdb-skip, desc="Erase" >*/
......
......@@ -207,12 +207,20 @@ gimp_gegl_mode_node_set_mode (GeglNode *node,
operation = "gimp:subtract-legacy";
break;
case GIMP_LAYER_MODE_DARKEN_ONLY:
operation = "gimp:darken-only";
break;
case GIMP_LAYER_MODE_DARKEN_ONLY_LEGACY:
operation = "gimp:darken-only-mode";
operation = "gimp:darken-only-legacy";
break;
case GIMP_LAYER_MODE_LIGHTEN_ONLY:
operation = "gimp:lighten-only";
break;
case GIMP_LAYER_MODE_LIGHTEN_ONLY_LEGACY:
operation = "gimp:lighten-only-mode";
operation = "gimp:lighten-only-legacy";
break;
case GIMP_LAYER_MODE_HSV_HUE_LEGACY:
......@@ -334,7 +342,9 @@ gimp_gegl_mode_node_set_mode (GeglNode *node,
case GIMP_LAYER_MODE_SUBTRACT:
case GIMP_LAYER_MODE_ADDITION_LEGACY:
case GIMP_LAYER_MODE_SUBTRACT_LEGACY:
case GIMP_LAYER_MODE_DARKEN_ONLY:
case GIMP_LAYER_MODE_DARKEN_ONLY_LEGACY:
case GIMP_LAYER_MODE_LIGHTEN_ONLY:
case GIMP_LAYER_MODE_LIGHTEN_ONLY_LEGACY:
case GIMP_LAYER_MODE_NORMAL_NON_LINEAR:
case GIMP_LAYER_MODE_OVERLAY_LEGACY:
......
......@@ -99,10 +99,6 @@ libappoperations_a_SOURCES = \
gimpoperationpointlayermode.h \
gimpoperationbehindmode.c \
gimpoperationbehindmode.h \
gimpoperationdarkenonlymode.c \
gimpoperationdarkenonlymode.h \
gimpoperationlightenonlymode.c \
gimpoperationlightenonlymode.h \
gimpoperationhuemode.c \
gimpoperationhuemode.h \
gimpoperationsaturationmode.c \
......
......@@ -80,8 +80,10 @@
#include "layer-modes-legacy/gimpoperationadditionlegacy.h"
#include "layer-modes/gimpoperationsubtract.h"
#include "layer-modes-legacy/gimpoperationsubtractlegacy.h"
#include "gimpoperationdarkenonlymode.h"
#include "gimpoperationlightenonlymode.h"
#include "layer-modes/gimpoperationdarkenonly.h"
#include "layer-modes-legacy/gimpoperationdarkenonlylegacy.h"
#include "layer-modes/gimpoperationlightenonly.h"
#include "layer-modes-legacy/gimpoperationlightenonlylegacy.h"
#include "gimpoperationhuemode.h"
#include "gimpoperationsaturationmode.h"
#include "gimpoperationcolormode.h"
......@@ -150,8 +152,10 @@ gimp_operations_init (void)
g_type_class_ref (GIMP_TYPE_OPERATION_ADDITION_LEGACY);
g_type_class_ref (GIMP_TYPE_OPERATION_SUBTRACT);
g_type_class_ref (GIMP_TYPE_OPERATION_SUBTRACT_LEGACY);
g_type_class_ref (GIMP_TYPE_OPERATION_DARKEN_ONLY_MODE);
g_type_class_ref (GIMP_TYPE_OPERATION_LIGHTEN_ONLY_MODE);
g_type_class_ref (GIMP_TYPE_OPERATION_DARKEN_ONLY);
g_type_class_ref (GIMP_TYPE_OPERATION_DARKEN_ONLY_LEGACY);
g_type_class_ref (GIMP_TYPE_OPERATION_LIGHTEN_ONLY);
g_type_class_ref (GIMP_TYPE_OPERATION_LIGHTEN_ONLY_LEGACY);
g_type_class_ref (GIMP_TYPE_OPERATION_HUE_MODE);
g_type_class_ref (GIMP_TYPE_OPERATION_SATURATION_MODE);
g_type_class_ref (GIMP_TYPE_OPERATION_COLOR_MODE);
......
......@@ -40,8 +40,10 @@
#include "layer-modes/gimpoperationsubtract.h"
#include "layer-modes-legacy/gimpoperationadditionlegacy.h"
#include "layer-modes-legacy/gimpoperationsubtractlegacy.h"
#include "gimpoperationdarkenonlymode.h"
#include "gimpoperationlightenonlymode.h"
#include "layer-modes/gimpoperationdarkenonly.h"
#include "layer-modes-legacy/gimpoperationdarkenonlylegacy.h"
#include "layer-modes/gimpoperationlightenonly.h"
#include "layer-modes-legacy/gimpoperationlightenonlylegacy.h"
#include "gimpoperationhuemode.h"
#include "gimpoperationsaturationmode.h"
#include "gimpoperationcolormode.h"
......@@ -128,12 +130,20 @@ get_layer_mode_function (GimpLayerMode paint_mode,
func = gimp_operation_subtract_legacy_process_pixels;
break;
case GIMP_LAYER_MODE_DARKEN_ONLY:
func = gimp_operation_darken_only_process_pixels;
break;
case GIMP_LAYER_MODE_DARKEN_ONLY_LEGACY:
func = gimp_operation_darken_only_mode_process_pixels;
func = gimp_operation_darken_only_legacy_process_pixels;
break;
case GIMP_LAYER_MODE_LIGHTEN_ONLY:
func = gimp_operation_lighten_only_process_pixels;
break;
case GIMP_LAYER_MODE_LIGHTEN_ONLY_LEGACY:
func = gimp_operation_lighten_only_mode_process_pixels;
func = gimp_operation_lighten_only_legacy_process_pixels;
break;
case GIMP_LAYER_MODE_HSV_HUE_LEGACY:
......
......@@ -26,4 +26,8 @@ libapplayermodeslegacy_a_SOURCES = \
gimpoperationadditionlegacy.c \
gimpoperationadditionlegacy.h \
gimpoperationsubtractlegacy.c \
gimpoperationsubtractlegacy.h
gimpoperationsubtractlegacy.h \
gimpoperationdarkenonlylegacy.c \
gimpoperationdarkenonlylegacy.h \
gimpoperationlightenonlylegacy.c \
gimpoperationlightenonlylegacy.h
......@@ -23,27 +23,27 @@
#include <gegl-plugin.h>
#include "operations-types.h"
#include "../operations-types.h"
#include "gimpoperationdarkenonlymode.h"
#include "gimpoperationdarkenonlylegacy.h"
static gboolean gimp_operation_darken_only_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_darken_only_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 (GimpOperationDarkenOnlyMode, gimp_operation_darken_only_mode,
G_DEFINE_TYPE (GimpOperationDarkenOnlyLegacy, gimp_operation_darken_only_legacy,
GIMP_TYPE_OPERATION_POINT_LAYER_MODE)
static void
gimp_operation_darken_only_mode_class_init (GimpOperationDarkenOnlyModeClass *klass)
gimp_operation_darken_only_legacy_class_init (GimpOperationDarkenOnlyLegacyClass *klass)
{
GeglOperationClass *operation_class;
GeglOperationPointComposer3Class *point_class;
......@@ -52,35 +52,35 @@ gimp_operation_darken_only_mode_class_init (GimpOperationDarkenOnlyModeClass *kl
point_class = GEGL_OPERATION_POINT_COMPOSER3_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "gimp:darken-only-mode",
"name", "gimp:darken-only-legacy",
"description", "GIMP darken only mode operation",
NULL);
point_class->process = gimp_operation_darken_only_mode_process;
point_class->process = gimp_operation_darken_only_legacy_process;
}
static void
gimp_operation_darken_only_mode_init (GimpOperationDarkenOnlyMode *self)
gimp_operation_darken_only_legacy_init (GimpOperationDarkenOnlyLegacy *self)
{
}
static gboolean
gimp_operation_darken_only_mode_process (GeglOperation *operation,
void *in_buf,
void *aux_buf,
void *aux2_buf,
void *out_buf,
glong samples,
const GeglRectangle *roi,
gint level)
gimp_operation_darken_only_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_darken_only_mode_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
return gimp_operation_darken_only_legacy_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
}
gboolean
gimp_operation_darken_only_mode_process_pixels (gfloat *in,
gimp_operation_darken_only_legacy_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpoperationdarken_onlymode.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_DARKEN_ONLY_LEGACY_H__
#define __GIMP_OPERATION_DARKEN_ONLY_LEGACY_H__
#include "../gimpoperationpointlayermode.h"
#define GIMP_TYPE_OPERATION_DARKEN_ONLY_LEGACY (gimp_operation_darken_only_legacy_get_type ())
#define GIMP_OPERATION_DARKEN_ONLY_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_DARKEN_ONLY_MODE, GimpOperationDarkenOnlyLegacy))
#define GIMP_OPERATION_DARKEN_ONLY_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_DARKEN_ONLY_MODE, GimpOperationDarkenOnlyLegacyClass))
#define GIMP_IS_OPERATION_DARKEN_ONLY_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_DARKEN_ONLY_MODE))
#define GIMP_IS_OPERATION_DARKEN_ONLY_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_OPERATION_DARKEN_ONLY_MODE))
#define GIMP_OPERATION_DARKEN_ONLY_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_DARKEN_ONLY_MODE, GimpOperationDarkenOnlyLegacyClass))
typedef struct _GimpOperationDarkenOnlyLegacy GimpOperationDarkenOnlyLegacy;
typedef struct _GimpOperationDarkenOnlyLegacyClass GimpOperationDarkenOnlyLegacyClass;
struct _GimpOperationDarkenOnlyLegacy
{
GimpOperationPointLayerMode parent_instance;
};
struct _GimpOperationDarkenOnlyLegacyClass
{
GimpOperationPointLayerModeClass parent_class;
};
GType gimp_operation_darken_only_legacy_get_type (void) G_GNUC_CONST;
gboolean gimp_operation_darken_only_legacy_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level);
#endif /* __GIMP_OPERATION_DARKEN_ONLY_LEGACY_H__ */
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpoperationlightenonlylegacy.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 "gimpoperationlightenonlylegacy.h"
static gboolean gimp_operation_lighten_only_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 (GimpOperationLightenOnlyLegacy, gimp_operation_lighten_only_legacy,
GIMP_TYPE_OPERATION_POINT_LAYER_MODE)
static void
gimp_operation_lighten_only_legacy_class_init (GimpOperationLightenOnlyLegacyClass *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:lighten-only-legacy",
"description", "GIMP lighten only legacy operation",
NULL);
point_class->process = gimp_operation_lighten_only_legacy_process;
}
static void
gimp_operation_lighten_only_legacy_init (GimpOperationLightenOnlyLegacy *self)
{
}
static gboolean
gimp_operation_lighten_only_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_lighten_only_legacy_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
}
gboolean
gimp_operation_lighten_only_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)
{
gint b;
gfloat ratio = comp_alpha / new_alpha;
for (b = RED; b < ALPHA; b++)
{
gfloat comp = MAX (layer[b], in[b]);
out[b] = comp * ratio + in[b] * (1.0 - ratio);
}
}
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
*
* gimpoperationlighten_onlymode.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_LIGHTEN_ONLY_LEGACY_H__
#define __GIMP_OPERATION_LIGHTEN_ONLY_LEGACY_H__
#include "../gimpoperationpointlayermode.h"
#define GIMP_TYPE_OPERATION_LIGHTEN_ONLY_LEGACY (gimp_operation_lighten_only_legacy_get_type ())
#define GIMP_OPERATION_LIGHTEN_ONLY_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_LIGHTEN_ONLY_LEGACY, GimpOperationLightenOnlyLegacy))
#define GIMP_OPERATION_LIGHTEN_ONLY_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_LIGHTEN_ONLY_LEGACY, GimpOperationLightenOnlyLegacyClass))
#define GIMP_IS_OPERATION_LIGHTEN_ONLY_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_LIGHTEN_ONLY_LEGACY))
#define GIMP_IS_OPERATION_LIGHTEN_ONLY_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_OPERATION_LIGHTEN_ONLY_LEGACY))
#define GIMP_OPERATION_LIGHTEN_ONLY_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_LIGHTEN_ONLY_LEGACY, GimpOperationLightenOnlyLegacyClass))
typedef struct _GimpOperationLightenOnlyLegacy GimpOperationLightenOnlyLegacy;
typedef struct _GimpOperationLightenOnlyLegacyClass GimpOperationLightenOnlyLegacyClass;
struct _GimpOperationLightenOnlyLegacy
{
GimpOperationPointLayerMode parent_instance;
};
struct _GimpOperationLightenOnlyLegacyClass
{
GimpOperationPointLayerModeClass parent_class;
};
GType gimp_operation_lighten_only_legacy_get_type (void) G_GNUC_CONST;
gboolean gimp_operation_lighten_only_legacy_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level);
#endif /* __GIMP_OPERATION_LIGHTEN_ONLY_LEGACY_H__ */
......@@ -43,7 +43,11 @@ libapplayermodes_generic_a_sources = \
gimpoperationaddition.c \
gimpoperationaddition.h \
gimpoperationsubtract.c \
gimpoperationsubtract.h
gimpoperationsubtract.h \
gimpoperationdarkenonly.c \
gimpoperationdarkenonly.h \
gimpoperationlightenonly.c \
gimpoperationlightenonly.h
libapplayermodes_sse2_a_sources = \
gimpoperationnormal-sse2.c
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpoperationdarkenonlymode.c
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2012 Ville Sokk <ville.sokk@gmail.com>
* 2017 Øyvind Kolås <pippin@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/>.
*/
#include "config.h"
#include <gegl-plugin.h>
#include "../operations-types.h"
#include "gimpoperationdarkenonly.h"
static gboolean gimp_operation_darken_only_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 (GimpOperationDarkenOnly, gimp_operation_darken_only,
GIMP_TYPE_OPERATION_POINT_LAYER_MODE)
static void
gimp_operation_darken_only_class_init (GimpOperationDarkenOnlyClass *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:darken-only",
"description", "GIMP darken only mode operation",
NULL);
point_class->process = gimp_operation_darken_only_process;
}
static void
gimp_operation_darken_only_init (GimpOperationDarkenOnly *self)
{
}
static gboolean
gimp_operation_darken_only_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_darken_only_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
}
gboolean
gimp_operation_darken_only_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;
comp_alpha = layer[ALPHA] * opacity;
if (has_mask)
comp_alpha *= *mask;
if (comp_alpha != 0.0)
{
gint b;
for (b = RED; b < ALPHA; b++)
{
gfloat comp = MIN (in[b], layer[b]);
out[b] = comp * comp_alpha + in[b] * (1.0 - comp_alpha);
}
}
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;
}
......@@ -3,6 +3,7 @@
*
* gimpoperationdarken_onlymode.h
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
* 2017 Øyvind Kolås <pippin@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
......@@ -18,44 +19,44 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_OPERATION_DARKEN_ONLY_MODE_H__
#define __GIMP_OPERATION_DARKEN_ONLY_MODE_H__
#ifndef __GIMP_OPERATION_DARKEN_ONLY_H__
#define __GIMP_OPERATION_DARKEN_ONLY_H__
#include "gimpoperationpointlayermode.h"
#include "../gimpoperationpointlayermode.h"
#define GIMP_TYPE_OPERATION_DARKEN_ONLY_MODE (gimp_operation_darken_only_mode_get_type ())
#define GIMP_OPERATION_DARKEN_ONLY_MODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_DARKEN_ONLY_MODE, GimpOperationDarkenOnlyMode))
#define GIMP_OPERATION_DARKEN_ONLY_MODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_DARKEN_ONLY_MODE, GimpOperationDarkenOnlyModeClass))
#define GIMP_IS_OPERATION_DARKEN_ONLY_MODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_DARKEN_ONLY_MODE))
#define GIMP_IS_OPERATION_DARKEN_ONLY_MODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_OPERATION_DARKEN_ONLY_MODE))
#define GIMP_OPERATION_DARKEN_ONLY_MODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_DARKEN_ONLY_MODE, GimpOperationDarkenOnlyModeClass))
#define GIMP_TYPE_OPERATION_DARKEN_ONLY (gimp_operation_darken_only_get_type ())
#define GIMP_OPERATION_DARKEN_ONLY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_DARKEN_ONLY_MODE, GimpOperationDarkenOnly))
#define GIMP_OPERATION_DARKEN_ONLY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_DARKEN_ONLY_MODE, GimpOperationDarkenOnlyClass))
#define GIMP_IS_OPERATION_DARKEN_ONLY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_DARKEN_ONLY_MODE))