app: split legacy out of burn and divide

parent 08910282
......@@ -331,6 +331,8 @@ gimp_layer_mode_get_type (void)
{ GIMP_LAYER_MODE_HSV_SATURATION, "GIMP_LAYER_MODE_HSV_SATURATION", "hsv-saturation" },
{ GIMP_LAYER_MODE_HSV_COLOR, "GIMP_LAYER_MODE_HSV_COLOR", "hsv-color" },
{ 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_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" },
......@@ -354,9 +356,9 @@ gimp_layer_mode_get_type (void)
{ GIMP_LAYER_MODE_HSV_SATURATION_LEGACY, NC_("layer-mode", "Saturation (HSV) (legacy)"), NULL },
{ GIMP_LAYER_MODE_HSV_COLOR_LEGACY, NC_("layer-mode", "Color (HSV) (legacy)"), NULL },
{ GIMP_LAYER_MODE_HSV_VALUE_LEGACY, NC_("layer-mode", "Value (HSV) (legacy)"), NULL },
{ GIMP_LAYER_MODE_DIVIDE_LEGACY, NC_("layer-mode", "Divide"), NULL },
{ 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"), 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 },
......@@ -381,6 +383,8 @@ gimp_layer_mode_get_type (void)
{ GIMP_LAYER_MODE_HSV_SATURATION, NC_("layer-mode", "Saturation (HSV)"), NULL },
{ GIMP_LAYER_MODE_HSV_COLOR, NC_("layer-mode", "Color (HSV)"), NULL },
{ 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_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 },
......
......@@ -169,9 +169,9 @@ typedef enum
GIMP_LAYER_MODE_HSV_SATURATION_LEGACY, /*< desc="Saturation (HSV) (legacy)">*/
GIMP_LAYER_MODE_HSV_COLOR_LEGACY, /*< desc="Color (HSV) (legacy)" >*/
GIMP_LAYER_MODE_HSV_VALUE_LEGACY, /*< desc="Value (HSV) (legacy)" >*/
GIMP_LAYER_MODE_DIVIDE_LEGACY, /*< desc="Divide" >*/
GIMP_LAYER_MODE_DIVIDE_LEGACY, /*< desc="Divide (legacy)" >*/
GIMP_LAYER_MODE_DODGE_LEGACY, /*< desc="Dodge (legacy)" >*/
GIMP_LAYER_MODE_BURN_LEGACY, /*< desc="Burn" >*/
GIMP_LAYER_MODE_BURN_LEGACY, /*< desc="Burn (legacy)" >*/
GIMP_LAYER_MODE_HARDLIGHT_LEGACY, /*< desc="Hard light" >*/
GIMP_LAYER_MODE_SOFTLIGHT_LEGACY, /*< desc="Soft light" >*/
GIMP_LAYER_MODE_GRAIN_EXTRACT_LEGACY, /*< desc="Grain extract" >*/
......@@ -196,6 +196,8 @@ typedef enum
GIMP_LAYER_MODE_HSV_SATURATION, /*< desc="Saturation (HSV)" >*/
GIMP_LAYER_MODE_HSV_COLOR, /*< desc="Color (HSV)" >*/
GIMP_LAYER_MODE_HSV_VALUE, /*< desc="Value (HSV)" >*/
GIMP_LAYER_MODE_DIVIDE, /*< desc="Divide" >*/
GIMP_LAYER_MODE_BURN, /*< desc="Burn" >*/
/* internal modes, not available to the PDB */
GIMP_LAYER_MODE_ERASE = 1000, /*< pdb-skip, desc="Erase" >*/
......
......@@ -255,8 +255,12 @@ gimp_gegl_mode_node_set_mode (GeglNode *node,
operation = "gimp:hsv-value-legacy";
break;
case GIMP_LAYER_MODE_DIVIDE:
operation = "gimp:divide";
break;
case GIMP_LAYER_MODE_DIVIDE_LEGACY:
operation = "gimp:divide-mode";
operation = "gimp:divide-legacy";
break;
case GIMP_LAYER_MODE_DODGE:
......@@ -267,8 +271,12 @@ gimp_gegl_mode_node_set_mode (GeglNode *node,
operation = "gimp:dodge-legacy";
break;
case GIMP_LAYER_MODE_BURN:
operation = "gimp:burn";
break;
case GIMP_LAYER_MODE_BURN_LEGACY:
operation = "gimp:burn-mode";
operation = "gimp:burn-legacy";
break;
case GIMP_LAYER_MODE_HARDLIGHT_LEGACY:
......@@ -374,9 +382,11 @@ gimp_gegl_mode_node_set_mode (GeglNode *node,
case GIMP_LAYER_MODE_HSV_SATURATION_LEGACY:
case GIMP_LAYER_MODE_HSV_COLOR_LEGACY:
case GIMP_LAYER_MODE_HSV_VALUE_LEGACY:
case GIMP_LAYER_MODE_DIVIDE:
case GIMP_LAYER_MODE_DIVIDE_LEGACY:
case GIMP_LAYER_MODE_DODGE:
case GIMP_LAYER_MODE_DODGE_LEGACY:
case GIMP_LAYER_MODE_BURN:
case GIMP_LAYER_MODE_BURN_LEGACY:
case GIMP_LAYER_MODE_HARDLIGHT_LEGACY:
case GIMP_LAYER_MODE_SOFTLIGHT_LEGACY:
......@@ -391,7 +401,6 @@ gimp_gegl_mode_node_set_mode (GeglNode *node,
case GIMP_LAYER_MODE_LCH_CHROMA:
case GIMP_LAYER_MODE_LCH_COLOR:
case GIMP_LAYER_MODE_LCH_LIGHTNESS:
default:
gegl_node_set (node,
"linear", FALSE,
NULL);
......
......@@ -99,10 +99,6 @@ libappoperations_a_SOURCES = \
gimpoperationpointlayermode.h \
gimpoperationbehindmode.c \
gimpoperationbehindmode.h \
gimpoperationdividemode.c \
gimpoperationdividemode.h \
gimpoperationburnmode.c \
gimpoperationburnmode.h \
gimpoperationhardlightmode.c \
gimpoperationhardlightmode.h \
gimpoperationsoftlightmode.c \
......
......@@ -92,10 +92,12 @@
#include "layer-modes-legacy/gimpoperationhsvsaturationlegacy.h"
#include "layer-modes-legacy/gimpoperationhsvcolorlegacy.h"
#include "layer-modes-legacy/gimpoperationhsvvaluelegacy.h"
#include "gimpoperationdividemode.h"
#include "layer-modes/gimpoperationdivide.h"
#include "layer-modes-legacy/gimpoperationdividelegacy.h"
#include "layer-modes/gimpoperationdodge.h"
#include "layer-modes-legacy/gimpoperationdodgelegacy.h"
#include "gimpoperationburnmode.h"
#include "layer-modes/gimpoperationburn.h"
#include "layer-modes-legacy/gimpoperationburnlegacy.h"
#include "gimpoperationhardlightmode.h"
#include "gimpoperationsoftlightmode.h"
#include "gimpoperationgrainextractmode.h"
......@@ -168,10 +170,12 @@ gimp_operations_init (void)
g_type_class_ref (GIMP_TYPE_OPERATION_HSV_SATURATION_LEGACY);
g_type_class_ref (GIMP_TYPE_OPERATION_HSV_COLOR_LEGACY);
g_type_class_ref (GIMP_TYPE_OPERATION_HSV_VALUE_LEGACY);
g_type_class_ref (GIMP_TYPE_OPERATION_DIVIDE_MODE);
g_type_class_ref (GIMP_TYPE_OPERATION_DIVIDE);
g_type_class_ref (GIMP_TYPE_OPERATION_DIVIDE_LEGACY);
g_type_class_ref (GIMP_TYPE_OPERATION_DODGE);
g_type_class_ref (GIMP_TYPE_OPERATION_DODGE_LEGACY);
g_type_class_ref (GIMP_TYPE_OPERATION_BURN_MODE);
g_type_class_ref (GIMP_TYPE_OPERATION_BURN);
g_type_class_ref (GIMP_TYPE_OPERATION_BURN_LEGACY);
g_type_class_ref (GIMP_TYPE_OPERATION_HARDLIGHT_MODE);
g_type_class_ref (GIMP_TYPE_OPERATION_SOFTLIGHT_MODE);
g_type_class_ref (GIMP_TYPE_OPERATION_GRAIN_EXTRACT_MODE);
......
......@@ -52,10 +52,12 @@
#include "layer-modes-legacy/gimpoperationhsvcolorlegacy.h"
#include "layer-modes/gimpoperationhsvvalue.h"
#include "layer-modes-legacy/gimpoperationhsvvaluelegacy.h"
#include "gimpoperationdividemode.h"
#include "layer-modes/gimpoperationdivide.h"
#include "layer-modes-legacy/gimpoperationdividelegacy.h"
#include "layer-modes/gimpoperationdodge.h"
#include "layer-modes-legacy/gimpoperationdodgelegacy.h"
#include "gimpoperationburnmode.h"
#include "layer-modes/gimpoperationburn.h"
#include "layer-modes-legacy/gimpoperationburnlegacy.h"
#include "gimpoperationhardlightmode.h"
#include "gimpoperationsoftlightmode.h"
#include "gimpoperationgrainextractmode.h"
......@@ -182,8 +184,12 @@ get_layer_mode_function (GimpLayerMode paint_mode,
func = gimp_operation_hsv_value_legacy_process_pixels;
break;
case GIMP_LAYER_MODE_DIVIDE:
func = gimp_operation_divide_process_pixels;
break;
case GIMP_LAYER_MODE_DIVIDE_LEGACY:
func = gimp_operation_divide_mode_process_pixels;
func = gimp_operation_divide_legacy_process_pixels;
break;
case GIMP_LAYER_MODE_DODGE:
......@@ -195,7 +201,11 @@ get_layer_mode_function (GimpLayerMode paint_mode,
break;
case GIMP_LAYER_MODE_BURN_LEGACY:
func = gimp_operation_burn_mode_process_pixels;
func = gimp_operation_burn_legacy_process_pixels;
break;
case GIMP_LAYER_MODE_BURN:
func = gimp_operation_burn_process_pixels;
break;
case GIMP_LAYER_MODE_HARDLIGHT_LEGACY:
......
......@@ -38,4 +38,8 @@ libapplayermodeslegacy_a_SOURCES = \
gimpoperationhsvcolorlegacy.c \
gimpoperationhsvcolorlegacy.h \
gimpoperationhsvvaluelegacy.c \
gimpoperationhsvvaluelegacy.h
gimpoperationhsvvaluelegacy.h \
gimpoperationdividelegacy.c \
gimpoperationdividelegacy.h \
gimpoperationburnlegacy.c \
gimpoperationburnlegacy.h
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpoperationdividemode.c
* gimpoperationburnmode.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 "gimpoperationdividemode.h"
#include "gimpoperationburnlegacy.h"
static gboolean gimp_operation_divide_mode_process (GeglOperation *operation,
static gboolean gimp_operation_burn_legacy_process (GeglOperation *operation,
void *in_buf,
void *aux_buf,
void *aux2_buf,
......@@ -38,12 +38,12 @@ static gboolean gimp_operation_divide_mode_process (GeglOperation *operati
gint level);
G_DEFINE_TYPE (GimpOperationDivideMode, gimp_operation_divide_mode,
G_DEFINE_TYPE (GimpOperationBurnLegacy, gimp_operation_burn_legacy,
GIMP_TYPE_OPERATION_POINT_LAYER_MODE)
static void
gimp_operation_divide_mode_class_init (GimpOperationDivideModeClass *klass)
gimp_operation_burn_legacy_class_init (GimpOperationBurnLegacyClass *klass)
{
GeglOperationClass *operation_class;
GeglOperationPointComposer3Class *point_class;
......@@ -52,20 +52,20 @@ gimp_operation_divide_mode_class_init (GimpOperationDivideModeClass *klass)
point_class = GEGL_OPERATION_POINT_COMPOSER3_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "gimp:divide-mode",
"description", "GIMP divide mode operation",
"name", "gimp:burn-legacy",
"description", "GIMP burn mode operation",
NULL);
point_class->process = gimp_operation_divide_mode_process;
point_class->process = gimp_operation_burn_legacy_process;
}
static void
gimp_operation_divide_mode_init (GimpOperationDivideMode *self)
gimp_operation_burn_legacy_init (GimpOperationBurnLegacy *self)
{
}
static gboolean
gimp_operation_divide_mode_process (GeglOperation *operation,
gimp_operation_burn_legacy_process (GeglOperation *operation,
void *in_buf,
void *aux_buf,
void *aux2_buf,
......@@ -76,11 +76,11 @@ gimp_operation_divide_mode_process (GeglOperation *operation,
{
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
return gimp_operation_divide_mode_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
return gimp_operation_burn_legacy_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
}
gboolean
gimp_operation_divide_mode_process_pixels (gfloat *in,
gimp_operation_burn_legacy_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
......@@ -103,15 +103,18 @@ gimp_operation_divide_mode_process_pixels (gfloat *in,
if (comp_alpha && new_alpha)
{
gint b;
gfloat ratio = comp_alpha / new_alpha;
gint b;
for (b = RED; b < ALPHA; b++)
{
gfloat comp = (4294967296.0 / 4294967295.0 * in[b]) / (1.0 / 4294967295.0 + layer[b]);
gfloat comp = 1.0 - (1.0 - in[b]) / layer[b];
/* The CLAMP macro is deliberately inlined and
* written to map comp == NAN (0 / 0) -> 1
*/
comp = comp < 0 ? 0.0 : comp < 1.0 ? 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
*
* gimpoperationdividemode.h
* gimpoperationburnmode.h
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
*
* This program is free software: you can redistribute it and/or modify
......@@ -18,38 +18,38 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_OPERATION_DIVIDE_MODE_H__
#define __GIMP_OPERATION_DIVIDE_MODE_H__
#ifndef __GIMP_OPERATION_BURN_LEGACY_H__
#define __GIMP_OPERATION_BURN_LEGACY_H__
#include "gimpoperationpointlayermode.h"
#include "../gimpoperationpointlayermode.h"
#define GIMP_TYPE_OPERATION_DIVIDE_MODE (gimp_operation_divide_mode_get_type ())
#define GIMP_OPERATION_DIVIDE_MODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_DIVIDE_MODE, GimpOperationDivideMode))
#define GIMP_OPERATION_DIVIDE_MODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_DIVIDE_MODE, GimpOperationDivideModeClass))
#define GIMP_IS_OPERATION_DIVIDE_MODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_DIVIDE_MODE))
#define GIMP_IS_OPERATION_DIVIDE_MODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_OPERATION_DIVIDE_MODE))
#define GIMP_OPERATION_DIVIDE_MODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_DIVIDE_MODE, GimpOperationDivideModeClass))
#define GIMP_TYPE_OPERATION_BURN_LEGACY (gimp_operation_burn_legacy_get_type ())
#define GIMP_OPERATION_BURN_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_BURN_LEGACY, GimpOperationBurnLegacy))
#define GIMP_OPERATION_BURN_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_BURN_LEGACY, GimpOperationBurnLegacyClass))
#define GIMP_IS_OPERATION_BURN_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_BURN_LEGACY))
#define GIMP_IS_OPERATION_BURN_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_OPERATION_BURN_LEGACY))
#define GIMP_OPERATION_BURN_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_BURN_LEGACY, GimpOperationBurnLegacyClass))
typedef struct _GimpOperationDivideMode GimpOperationDivideMode;
typedef struct _GimpOperationDivideModeClass GimpOperationDivideModeClass;
typedef struct _GimpOperationBurnLegacy GimpOperationBurnLegacy;
typedef struct _GimpOperationBurnLegacyClass GimpOperationBurnLegacyClass;
struct _GimpOperationDivideMode
struct _GimpOperationBurnLegacy
{
GimpOperationPointLayerMode parent_instance;
};
struct _GimpOperationDivideModeClass
struct _GimpOperationBurnLegacyClass
{
GimpOperationPointLayerModeClass parent_class;
};
GType gimp_operation_divide_mode_get_type (void) G_GNUC_CONST;
GType gimp_operation_burn_legacy_get_type (void) G_GNUC_CONST;
gboolean gimp_operation_divide_mode_process_pixels (gfloat *in,
gboolean gimp_operation_burn_legacy_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
......@@ -58,4 +58,4 @@ gboolean gimp_operation_divide_mode_process_pixels (gfloat *in,
const GeglRectangle *roi,
gint level);
#endif /* __GIMP_OPERATION_DIVIDE_MODE_H__ */
#endif /* __GIMP_OPERATION_BURN_LEGACY_H__ */
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpoperationdividemode.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 "gimpoperationdividelegacy.h"
static gboolean gimp_operation_divide_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 (GimpOperationDivideLegacy, gimp_operation_divide_legacy,
GIMP_TYPE_OPERATION_POINT_LAYER_MODE)
static void
gimp_operation_divide_legacy_class_init (GimpOperationDivideLegacyClass *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:divide-legacy",
"description", "GIMP divide mode operation",
NULL);
point_class->process = gimp_operation_divide_legacy_process;
}
static void
gimp_operation_divide_legacy_init (GimpOperationDivideLegacy *self)
{
}
static gboolean
gimp_operation_divide_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_divide_legacy_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
}
gboolean
gimp_operation_divide_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 = (4294967296.0 / 4294967295.0 * in[b]) / (1.0 / 4294967295.0 + layer[b]);
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
*
* gimpoperationdividemode.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_DIVIDE_LEGACY_H__
#define __GIMP_OPERATION_DIVIDE_LEGACY_H__
#include "../gimpoperationpointlayermode.h"
#define GIMP_TYPE_OPERATION_DIVIDE_LEGACY (gimp_operation_divide_legacy_get_type ())
#define GIMP_OPERATION_DIVIDE_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_DIVIDE_LEGACY, GimpOperationDivideLegacy))
#define GIMP_OPERATION_DIVIDE_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_DIVIDE_LEGACY, GimpOperationDivideLegacyClass))
#define GIMP_IS_OPERATION_DIVIDE_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_DIVIDE_LEGACY))
#define GIMP_IS_OPERATION_DIVIDE_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_OPERATION_DIVIDE_LEGACY))
#define GIMP_OPERATION_DIVIDE_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_DIVIDE_LEGACY, GimpOperationDivideLegacyClass))
typedef struct _GimpOperationDivideLegacy GimpOperationDivideLegacy;
typedef struct _GimpOperationDivideLegacyClass GimpOperationDivideLegacyClass;
struct _GimpOperationDivideLegacy
{
GimpOperationPointLayerMode parent_instance;
};
struct _GimpOperationDivideLegacyClass
{
GimpOperationPointLayerModeClass parent_class;
};
GType gimp_operation_divide_legacy_get_type (void) G_GNUC_CONST;
gboolean gimp_operation_divide_legacy_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level);
#endif /* __GIMP_OPERATION_DIVIDE_LEGACY_H__ */
......@@ -59,7 +59,12 @@ libapplayermodes_generic_a_sources = \
gimpoperationerase.c \
gimpoperationerase.h \
gimpoperationantierase.c \
gimpoperationantierase.h
gimpoperationantierase.h \
gimpoperationhsvvalue.h \
gimpoperationdivide.c \
gimpoperationdivide.h \
gimpoperationburn.c \
gimpoperationburn.h
libapplayermodes_sse2_a_sources = \
gimpoperationnormal-sse2.c
......
......@@ -4,6 +4,7 @@
* gimpoperationburnmode.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
......@@ -23,27 +24,27 @@
#include <gegl-plugin.h>
#include "operations-types.h"
#include "../operations-types.h"
#include "gimpoperationburnmode.h"
#include "gimpoperationburn.h"
static gboolean gimp_operation_burn_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_burn_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 (GimpOperationBurnMode, gimp_operation_burn_mode,
G_DEFINE_TYPE (GimpOperationBurn, gimp_operation_burn,
GIMP_TYPE_OPERATION_POINT_LAYER_MODE)
static void
gimp_operation_burn_mode_class_init (GimpOperationBurnModeClass *klass)
gimp_operation_burn_class_init (GimpOperationBurnClass *klass)
{
GeglOperationClass *operation_class;
GeglOperationPointComposer3Class *point_class;
......@@ -52,58 +53,55 @@ gimp_operation_burn_mode_class_init (GimpOperationBurnModeClass *klass)
point_class = GEGL_OPERATION_POINT_COMPOSER3_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "gimp:burn-mode",
"name", "gimp:burn",
"description", "GIMP burn mode operation",
NULL);
point_class->process = gimp_operation_burn_mode_process;
point_class->process = gimp_operation_burn_process;
}
static void
gimp_operation_burn_mode_init (GimpOperationBurnMode *self)
gimp_operation_burn_init (GimpOperationBurn *self)
{
}
static gboolean
gimp_operation_burn_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_burn_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_burn_mode_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
return gimp_operation_burn_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
}
gboolean
gimp_operation_burn_mode_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level)
gimp_operation_burn_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;
gfloat comp_alpha;
comp_alpha = MIN (in[ALPHA], layer[ALPHA]) * opacity;
comp_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)
if (comp_alpha != 0.0)
{
gfloat ratio = comp_alpha / new_alpha;
gint b;