app: duplicate hsv layer modes, and fix alpha handling

parent 40ec407f
......@@ -327,6 +327,10 @@ gimp_layer_mode_get_type (void)
{ 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_HSV_HUE, "GIMP_LAYER_MODE_HSV_HUE", "hsv-hue" },
{ 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_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" },
......@@ -346,10 +350,10 @@ gimp_layer_mode_get_type (void)
{ GIMP_LAYER_MODE_SUBTRACT_LEGACY, NC_("layer-mode", "Subtract (legacy)"), 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 },
{ GIMP_LAYER_MODE_HSV_VALUE_LEGACY, NC_("layer-mode", "Value (HSV)"), NULL },
{ GIMP_LAYER_MODE_HSV_HUE_LEGACY, NC_("layer-mode", "Hue (HSV) (legacy)"), NULL },
{ 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_DODGE_LEGACY, NC_("layer-mode", "Dodge (legacy)"), NULL },
{ GIMP_LAYER_MODE_BURN_LEGACY, NC_("layer-mode", "Burn"), NULL },
......@@ -373,6 +377,10 @@ gimp_layer_mode_get_type (void)
{ 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_HSV_HUE, NC_("layer-mode", "Hue (HSV)"), NULL },
{ 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_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 },
......
......@@ -165,10 +165,10 @@ typedef enum
GIMP_LAYER_MODE_SUBTRACT_LEGACY, /*< desc="Subtract (legacy)" >*/
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)" >*/
GIMP_LAYER_MODE_HSV_VALUE_LEGACY, /*< desc="Value (HSV)" >*/
GIMP_LAYER_MODE_HSV_HUE_LEGACY, /*< desc="Hue (HSV) (legacy)" >*/
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_DODGE_LEGACY, /*< desc="Dodge (legacy)" >*/
GIMP_LAYER_MODE_BURN_LEGACY, /*< desc="Burn" >*/
......@@ -192,6 +192,10 @@ typedef enum
GIMP_LAYER_MODE_SUBTRACT, /*< desc="Subtract" >*/
GIMP_LAYER_MODE_DARKEN_ONLY, /*< desc="Darken only" >*/
GIMP_LAYER_MODE_LIGHTEN_ONLY, /*< desc="Lighten only" >*/
GIMP_LAYER_MODE_HSV_HUE, /*< desc="Hue (HSV)" >*/
GIMP_LAYER_MODE_HSV_SATURATION, /*< desc="Saturation (HSV)" >*/
GIMP_LAYER_MODE_HSV_COLOR, /*< desc="Color (HSV)" >*/
GIMP_LAYER_MODE_HSV_VALUE, /*< desc="Value (HSV)" >*/
/* internal modes, not available to the PDB */
GIMP_LAYER_MODE_ERASE = 1000, /*< pdb-skip, desc="Erase" >*/
......
......@@ -223,20 +223,36 @@ gimp_gegl_mode_node_set_mode (GeglNode *node,
operation = "gimp:lighten-only-legacy";
break;
case GIMP_LAYER_MODE_HSV_HUE:
operation = "gimp:hue";
break;
case GIMP_LAYER_MODE_HSV_SATURATION:
operation = "gimp:saturation";
break;
case GIMP_LAYER_MODE_HSV_COLOR:
operation = "gimp:color";
break;
case GIMP_LAYER_MODE_HSV_VALUE:
operation = "gimp:value";
break;
case GIMP_LAYER_MODE_HSV_HUE_LEGACY:
operation = "gimp:hue-mode";
operation = "gimp:hue-legacy";
break;
case GIMP_LAYER_MODE_HSV_SATURATION_LEGACY:
operation = "gimp:saturation-mode";
operation = "gimp:saturation-legacy";
break;
case GIMP_LAYER_MODE_HSV_COLOR_LEGACY:
operation = "gimp:color-mode";
operation = "gimp:color-legacy";
break;
case GIMP_LAYER_MODE_HSV_VALUE_LEGACY:
operation = "gimp:value-mode";
operation = "gimp:value-legacy";
break;
case GIMP_LAYER_MODE_DIVIDE_LEGACY:
......@@ -350,6 +366,10 @@ gimp_gegl_mode_node_set_mode (GeglNode *node,
case GIMP_LAYER_MODE_OVERLAY_LEGACY:
case GIMP_LAYER_MODE_DIFFERENCE_LEGACY:
case GIMP_LAYER_MODE_DIFFERENCE:
case GIMP_LAYER_MODE_HSV_HUE:
case GIMP_LAYER_MODE_HSV_SATURATION:
case GIMP_LAYER_MODE_HSV_COLOR:
case GIMP_LAYER_MODE_HSV_VALUE:
case GIMP_LAYER_MODE_HSV_HUE_LEGACY:
case GIMP_LAYER_MODE_HSV_SATURATION_LEGACY:
case GIMP_LAYER_MODE_HSV_COLOR_LEGACY:
......
......@@ -99,14 +99,6 @@ libappoperations_a_SOURCES = \
gimpoperationpointlayermode.h \
gimpoperationbehindmode.c \
gimpoperationbehindmode.h \
gimpoperationhuemode.c \
gimpoperationhuemode.h \
gimpoperationsaturationmode.c \
gimpoperationsaturationmode.h \
gimpoperationcolormode.c \
gimpoperationcolormode.h \
gimpoperationvaluemode.c \
gimpoperationvaluemode.h \
gimpoperationdividemode.c \
gimpoperationdividemode.h \
gimpoperationburnmode.c \
......
......@@ -84,10 +84,14 @@
#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"
#include "gimpoperationvaluemode.h"
#include "layer-modes/gimpoperationhsvhue.h"
#include "layer-modes/gimpoperationhsvsaturation.h"
#include "layer-modes/gimpoperationhsvcolor.h"
#include "layer-modes/gimpoperationhsvvalue.h"
#include "layer-modes-legacy/gimpoperationhsvhuelegacy.h"
#include "layer-modes-legacy/gimpoperationhsvsaturationlegacy.h"
#include "layer-modes-legacy/gimpoperationhsvcolorlegacy.h"
#include "layer-modes-legacy/gimpoperationhsvvaluelegacy.h"
#include "gimpoperationdividemode.h"
#include "layer-modes/gimpoperationdodge.h"
#include "layer-modes-legacy/gimpoperationdodgelegacy.h"
......@@ -156,10 +160,14 @@ gimp_operations_init (void)
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);
g_type_class_ref (GIMP_TYPE_OPERATION_VALUE_MODE);
g_type_class_ref (GIMP_TYPE_OPERATION_HSV_HUE);
g_type_class_ref (GIMP_TYPE_OPERATION_HSV_SATURATION);
g_type_class_ref (GIMP_TYPE_OPERATION_HSV_COLOR);
g_type_class_ref (GIMP_TYPE_OPERATION_HSV_VALUE);
g_type_class_ref (GIMP_TYPE_OPERATION_HSV_HUE_LEGACY);
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_DODGE);
g_type_class_ref (GIMP_TYPE_OPERATION_DODGE_LEGACY);
......
......@@ -44,10 +44,14 @@
#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"
#include "gimpoperationvaluemode.h"
#include "layer-modes/gimpoperationhsvhue.h"
#include "layer-modes-legacy/gimpoperationhsvhuelegacy.h"
#include "layer-modes/gimpoperationhsvsaturation.h"
#include "layer-modes-legacy/gimpoperationhsvsaturationlegacy.h"
#include "layer-modes/gimpoperationhsvcolor.h"
#include "layer-modes-legacy/gimpoperationhsvcolorlegacy.h"
#include "layer-modes/gimpoperationhsvvalue.h"
#include "layer-modes-legacy/gimpoperationhsvvaluelegacy.h"
#include "gimpoperationdividemode.h"
#include "layer-modes/gimpoperationdodge.h"
#include "layer-modes-legacy/gimpoperationdodgelegacy.h"
......@@ -146,20 +150,36 @@ get_layer_mode_function (GimpLayerMode paint_mode,
func = gimp_operation_lighten_only_legacy_process_pixels;
break;
case GIMP_LAYER_MODE_HSV_HUE:
func = gimp_operation_hsv_hue_process_pixels;
break;
case GIMP_LAYER_MODE_HSV_HUE_LEGACY:
func = gimp_operation_hue_mode_process_pixels;
func = gimp_operation_hsv_hue_legacy_process_pixels;
break;
case GIMP_LAYER_MODE_HSV_SATURATION:
func = gimp_operation_hsv_saturation_process_pixels;
break;
case GIMP_LAYER_MODE_HSV_SATURATION_LEGACY:
func = gimp_operation_saturation_mode_process_pixels;
func = gimp_operation_hsv_saturation_legacy_process_pixels;
break;
case GIMP_LAYER_MODE_HSV_COLOR:
func = gimp_operation_hsv_color_process_pixels;
break;
case GIMP_LAYER_MODE_HSV_COLOR_LEGACY:
func = gimp_operation_color_mode_process_pixels;
func = gimp_operation_hsv_color_legacy_process_pixels;
break;
case GIMP_LAYER_MODE_HSV_VALUE:
func = gimp_operation_hsv_value_process_pixels;
break;
case GIMP_LAYER_MODE_HSV_VALUE_LEGACY:
func = gimp_operation_value_mode_process_pixels;
func = gimp_operation_hsv_value_legacy_process_pixels;
break;
case GIMP_LAYER_MODE_DIVIDE_LEGACY:
......
......@@ -29,5 +29,13 @@ libapplayermodeslegacy_a_SOURCES = \
gimpoperationsubtractlegacy.h \
gimpoperationdarkenonlylegacy.c \
gimpoperationdarkenonlylegacy.h \
gimpoperationlightenonlylegacy.c \
gimpoperationlightenonlylegacy.h
gimpoperationlightenonlylegacy.c\
gimpoperationlightenonlylegacy.h\
gimpoperationhsvhuelegacy.c \
gimpoperationhsvhuelegacy.h \
gimpoperationhsvsaturationlegacy.c \
gimpoperationhsvsaturationlegacy.h \
gimpoperationhsvcolorlegacy.c \
gimpoperationhsvcolorlegacy.h \
gimpoperationhsvvaluelegacy.c \
gimpoperationhsvvaluelegacy.h
......@@ -27,27 +27,27 @@
#include "libgimpcolor/gimpcolor.h"
#include "operations-types.h"
#include "../operations-types.h"
#include "gimpoperationcolormode.h"
#include "gimpoperationhsvcolorlegacy.h"
static gboolean gimp_operation_color_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_hsv_color_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 (GimpOperationColorMode, gimp_operation_color_mode,
G_DEFINE_TYPE (GimpOperationHsvColorLegacy, gimp_operation_hsv_color_legacy,
GIMP_TYPE_OPERATION_POINT_LAYER_MODE)
static void
gimp_operation_color_mode_class_init (GimpOperationColorModeClass *klass)
gimp_operation_hsv_color_legacy_class_init (GimpOperationHsvColorLegacyClass *klass)
{
GeglOperationClass *operation_class;
GeglOperationPointComposer3Class *point_class;
......@@ -56,42 +56,42 @@ gimp_operation_color_mode_class_init (GimpOperationColorModeClass *klass)
point_class = GEGL_OPERATION_POINT_COMPOSER3_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "gimp:color-mode",
"name", "gimp:hsv-color-legacy",
"description", "GIMP color mode operation",
NULL);
point_class->process = gimp_operation_color_mode_process;
point_class->process = gimp_operation_hsv_color_legacy_process;
}
static void
gimp_operation_color_mode_init (GimpOperationColorMode *self)
gimp_operation_hsv_color_legacy_init (GimpOperationHsvColorLegacy *self)
{
}
static gboolean
gimp_operation_color_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_hsv_color_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_color_mode_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
return gimp_operation_hsv_color_legacy_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
}
gboolean
gimp_operation_color_mode_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level)
gimp_operation_hsv_color_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;
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpoperationcolormode.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_HSV_COLOR_LEGACY_H__
#define __GIMP_OPERATION_HSV_COLOR_LEGACY_H__
#include "../gimpoperationpointlayermode.h"
#define GIMP_TYPE_OPERATION_HSV_COLOR_LEGACY (gimp_operation_hsv_color_legacy_get_type ())
#define GIMP_OPERATION_HSV_COLOR_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_HSV_COLOR_LEGACY, GimpOperationHsvColorLegacy))
#define GIMP_OPERATION_HSV_COLOR_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_HSV_COLOR_LEGACY, GimpOperationHsvColorLegacyClass))
#define GIMP_IS_OPERATION_HSV_COLOR_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_HSV_COLOR_LEGACY))
#define GIMP_IS_OPERATION_HSV_COLOR_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_OPERATION_HSV_COLOR_LEGACY))
#define GIMP_OPERATION_HSV_COLOR_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_HSV_COLOR_LEGACY, GimpOperationHsvColorLegacyClass))
typedef struct _GimpOperationHsvColorLegacy GimpOperationHsvColorLegacy;
typedef struct _GimpOperationHsvColorLegacyClass GimpOperationHsvColorLegacyClass;
struct _GimpOperationHsvColorLegacy
{
GimpOperationPointLayerMode parent_instance;
};
struct _GimpOperationHsvColorLegacyClass
{
GimpOperationPointLayerModeClass parent_class;
};
GType gimp_operation_hsv_color_legacy_get_type (void) G_GNUC_CONST;
gboolean gimp_operation_hsv_color_legacy_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level);
#endif /* __GIMP_OPERATION_HSV_COLOR_LEGACY_H__ */
......@@ -27,27 +27,27 @@
#include "libgimpcolor/gimpcolor.h"
#include "operations-types.h"
#include "../operations-types.h"
#include "gimpoperationhuemode.h"
#include "gimpoperationhsvhuelegacy.h"
static gboolean gimp_operation_hue_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_hsv_hue_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 (GimpOperationHueMode, gimp_operation_hue_mode,
G_DEFINE_TYPE (GimpOperationHsvHueLegacy, gimp_operation_hsv_hue_legacy,
GIMP_TYPE_OPERATION_POINT_LAYER_MODE)
static void
gimp_operation_hue_mode_class_init (GimpOperationHueModeClass *klass)
gimp_operation_hsv_hue_legacy_class_init (GimpOperationHsvHueLegacyClass *klass)
{
GeglOperationClass *operation_class;
GeglOperationPointComposer3Class *point_class;
......@@ -56,42 +56,42 @@ gimp_operation_hue_mode_class_init (GimpOperationHueModeClass *klass)
point_class = GEGL_OPERATION_POINT_COMPOSER3_CLASS (klass);
gegl_operation_class_set_keys (operation_class,
"name", "gimp:hue-mode",
"name", "gimp:hsv-hue-legacy",
"description", "GIMP hue mode operation",
NULL);
point_class->process = gimp_operation_hue_mode_process;
point_class->process = gimp_operation_hsv_hue_legacy_process;
}
static void
gimp_operation_hue_mode_init (GimpOperationHueMode *self)
gimp_operation_hsv_hue_legacy_init (GimpOperationHsvHueLegacy *self)
{
}
static gboolean
gimp_operation_hue_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_hsv_hue_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_hue_mode_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
return gimp_operation_hsv_hue_legacy_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
}
gboolean
gimp_operation_hue_mode_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level)
gimp_operation_hsv_hue_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;
......
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpoperationhuemode.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_HSV_HUE_LEGACY_H__
#define __GIMP_OPERATION_HSV_HUE_LEGACY_H__
#include "../gimpoperationpointlayermode.h"
#define GIMP_TYPE_OPERATION_HSV_HUE_LEGACY (gimp_operation_hsv_hue_legacy_get_type ())
#define GIMP_OPERATION_HSV_HUE_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_HSV_HUE_LEGACY, GimpOperationHsvHueLegacy))
#define GIMP_OPERATION_HSV_HUE_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_HSV_HUE_LEGACY, GimpOperationHsvHueLegacyClass))
#define GIMP_IS_OPERATION_HSV_HUE_LEGACY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_HSV_HUE_LEGACY))
#define GIMP_IS_OPERATION_HSV_HUE_LEGACY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_OPERATION_HSV_HUE_LEGACY))
#define GIMP_OPERATION_HSV_HUE_LEGACY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_HSV_HUE_LEGACY, GimpOperationHsvHueLegacyClass))
typedef struct _GimpOperationHsvHueLegacy GimpOperationHsvHueLegacy;
typedef struct _GimpOperationHsvHueLegacyClass GimpOperationHsvHueLegacyClass;
struct _GimpOperationHsvHueLegacy
{
GimpOperationPointLayerMode parent_instance;
};
struct _GimpOperationHsvHueLegacyClass
{
GimpOperationPointLayerModeClass parent_class;
};
GType gimp_operation_hsv_hue_legacy_get_type (void) G_GNUC_CONST;
gboolean gimp_operation_hsv_hue_legacy_process_pixels (gfloat *in,
gfloat *layer,
gfloat *mask,
gfloat *out,
gfloat opacity,
glong samples,
const GeglRectangle *roi,
gint level);
#endif /* __GIMP_OPERATION_HSV_HUE_LEGACY_H__ */
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpoperationsaturationmode.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 <cairo.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libgimpcolor/gimpcolor.h"
#include "../operations-types.h"
#include "gimpoperationhsvsaturationlegacy.h"
static gboolean gimp_operation_hsv_saturation_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 (GimpOperationHsvSaturationLegacy, gimp_operation_hsv_saturation_legacy,
GIMP_TYPE_OPERATION_POINT_LAYER_MODE)
static void
gimp_operation_hsv_saturation_legacy_class_init (GimpOperationHsvSaturationLegacyClass *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:hsv-saturation-legacy",
"description", "GIMP saturation mode operation",
NULL);
point_class->process = gimp_operation_hsv_saturation_legacy_process;
}
static void
gimp_operation_hsv_saturation_legacy_init (GimpOperationHsvSaturationLegacy *self)
{
}
static gboolean
gimp_operation_hsv_saturation_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_hsv_saturation_legacy_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
}
gboolean
gimp_operation_hsv_saturation_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--)
{
GimpHSV layer_hsv, out_hsv;
GimpRGB layer_rgb = {layer[0], layer[1], layer[2]};
GimpRGB out_rgb = {in[0], in[1], in[2]};
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 out_tmp[3];
gfloat ratio = comp_alpha / new_alpha;