app: make layer modes more configurable
Implement a common utility function gimp_blend_composite that uses utility functions for implementing layer modes, with separate (possibly SIMD) optimized loops for blending and compositing, with configured linear TRC, perceptual gamma TRC or even using CIE Lab as the space.
This commit is contained in:
@ -22,6 +22,7 @@ libapplayermodes_generic_a_sources = \
|
||||
gimpoperationpointlayermode.h \
|
||||
gimplayermodefunctions.c \
|
||||
gimplayermodefunctions.h \
|
||||
gimpblendcomposite.h \
|
||||
\
|
||||
gimpoperationaddition.c \
|
||||
gimpoperationaddition.h \
|
||||
|
912
app/operations/layer-modes/gimpblendcomposite.h
Normal file
912
app/operations/layer-modes/gimpblendcomposite.h
Normal file
@ -0,0 +1,912 @@
|
||||
/* GIMP - The GNU Image Manipulation Program
|
||||
* gimpblendcomposite
|
||||
* Copyright (C) 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/>.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_BLEND_COMPOSITE_H__
|
||||
#define __GIMP_BLEND_COMPOSITE_H__
|
||||
|
||||
|
||||
#include <gegl-plugin.h>
|
||||
#include <math.h>
|
||||
#include <alloca.h>
|
||||
#include <cairo.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include "../operations-enums.h"
|
||||
#include "../operations-types.h"
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
extern const Babl *_gimp_fish_rgba_to_perceptual;
|
||||
extern const Babl *_gimp_fish_perceptual_to_rgba;
|
||||
extern const Babl *_gimp_fish_perceptual_to_laba;
|
||||
extern const Babl *_gimp_fish_rgba_to_laba;
|
||||
extern const Babl *_gimp_fish_laba_to_rgba;
|
||||
extern const Babl *_gimp_fish_laba_to_perceptual;
|
||||
|
||||
static inline void
|
||||
compfun_src_atop (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat opacity,
|
||||
gfloat *out,
|
||||
gint samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
gfloat comp_alpha = layer[ALPHA] * opacity;
|
||||
if (mask)
|
||||
comp_alpha *= *mask;
|
||||
|
||||
if (comp_alpha == 0.0f)
|
||||
{
|
||||
out[RED] = in[RED];
|
||||
out[GREEN] = in[GREEN];
|
||||
out[BLUE] = in[BLUE];
|
||||
}
|
||||
else
|
||||
{
|
||||
gint b;
|
||||
for (b = RED; b < ALPHA; b++)
|
||||
out[b] = layer[b] * comp_alpha + in[b] * (1.0f - comp_alpha);
|
||||
}
|
||||
out[ALPHA] = in[ALPHA];
|
||||
|
||||
in += 4;
|
||||
out += 4;
|
||||
layer += 4;
|
||||
|
||||
if (mask)
|
||||
mask++;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
compfun_src_over (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
gint samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
gfloat new_alpha;
|
||||
gfloat comp_alpha = layer[ALPHA] * opacity;
|
||||
if (mask)
|
||||
comp_alpha *= *mask;
|
||||
|
||||
new_alpha = comp_alpha + (1.0f - comp_alpha) * in[ALPHA];
|
||||
|
||||
if (comp_alpha == 0.0f || new_alpha == 0.0f)
|
||||
{
|
||||
out[RED] = in[RED];
|
||||
out[GREEN] = in[GREEN];
|
||||
out[BLUE] = in[BLUE];
|
||||
}
|
||||
else
|
||||
{
|
||||
gint b;
|
||||
gfloat ratio = comp_alpha / new_alpha;
|
||||
for (b = RED; b < ALPHA; b++)
|
||||
out[b] = layer[b] * ratio + in[b] * (1.0f - ratio);
|
||||
}
|
||||
|
||||
out[ALPHA] = new_alpha;
|
||||
|
||||
in += 4;
|
||||
layer += 4;
|
||||
out += 4;
|
||||
|
||||
if (mask)
|
||||
mask++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
compfun_src_in (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat opacity,
|
||||
gfloat *out,
|
||||
gint samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
gfloat new_alpha = in[ALPHA] * layer[ALPHA] * opacity;
|
||||
if (mask)
|
||||
new_alpha *= *mask;
|
||||
|
||||
if (new_alpha == 0.0f)
|
||||
{
|
||||
out[RED] = in[RED];
|
||||
out[GREEN] = in[GREEN];
|
||||
out[BLUE] = in[BLUE];
|
||||
}
|
||||
else
|
||||
{
|
||||
out[RED] = layer[RED];
|
||||
out[GREEN] = layer[GREEN];
|
||||
out[BLUE] = layer[BLUE];
|
||||
}
|
||||
out[ALPHA] = new_alpha;
|
||||
in += 4;
|
||||
out += 4;
|
||||
layer += 4;
|
||||
|
||||
if (mask)
|
||||
mask++;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
gimp_composite_blend (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode,
|
||||
void (*blendfun) (const float *dst,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples))
|
||||
{
|
||||
gfloat *blend_in = in;
|
||||
gfloat *blend_layer = layer;
|
||||
gfloat *blend_out = out;
|
||||
|
||||
const Babl *fish_to_blend = NULL;
|
||||
const Babl *fish_to_composite = NULL;
|
||||
const Babl *fish_from_composite = NULL;
|
||||
|
||||
switch (blend_trc)
|
||||
{
|
||||
default:
|
||||
case GIMP_LAYER_BLEND_RGB_LINEAR:
|
||||
fish_to_blend = NULL;
|
||||
switch (composite_trc)
|
||||
{
|
||||
case GIMP_LAYER_BLEND_LAB:
|
||||
fish_to_composite = _gimp_fish_rgba_to_laba;
|
||||
fish_from_composite = _gimp_fish_laba_to_rgba;
|
||||
default:
|
||||
case GIMP_LAYER_BLEND_RGB_LINEAR:
|
||||
fish_to_composite = NULL;
|
||||
fish_from_composite = NULL;
|
||||
break;
|
||||
case GIMP_LAYER_BLEND_RGB_PERCEPTUAL:
|
||||
fish_to_composite = _gimp_fish_rgba_to_perceptual;
|
||||
fish_from_composite = _gimp_fish_perceptual_to_rgba;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case GIMP_LAYER_BLEND_LAB:
|
||||
fish_to_blend = _gimp_fish_rgba_to_laba;
|
||||
switch (composite_trc)
|
||||
{
|
||||
case GIMP_LAYER_BLEND_LAB:
|
||||
default:
|
||||
fish_to_composite = NULL;
|
||||
fish_from_composite = _gimp_fish_laba_to_rgba;
|
||||
case GIMP_LAYER_BLEND_RGB_LINEAR:
|
||||
fish_to_composite = _gimp_fish_laba_to_rgba;
|
||||
fish_from_composite = NULL;
|
||||
break;
|
||||
case GIMP_LAYER_BLEND_RGB_PERCEPTUAL:
|
||||
fish_to_composite = _gimp_fish_laba_to_perceptual;
|
||||
fish_from_composite = _gimp_fish_perceptual_to_rgba;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case GIMP_LAYER_BLEND_RGB_PERCEPTUAL:
|
||||
fish_to_blend = _gimp_fish_rgba_to_perceptual;
|
||||
switch (composite_trc)
|
||||
{
|
||||
case GIMP_LAYER_BLEND_LAB:
|
||||
default:
|
||||
fish_to_composite = _gimp_fish_perceptual_to_laba;
|
||||
fish_from_composite = NULL;
|
||||
case GIMP_LAYER_BLEND_RGB_LINEAR:
|
||||
fish_to_composite = _gimp_fish_perceptual_to_rgba;
|
||||
fish_from_composite = NULL;
|
||||
break;
|
||||
case GIMP_LAYER_BLEND_RGB_PERCEPTUAL:
|
||||
fish_to_composite = NULL;
|
||||
fish_from_composite = _gimp_fish_perceptual_to_rgba;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (in == out) /* in-place detected, avoid clobbering since we need to
|
||||
read it for the compositing stage */
|
||||
blend_out = alloca (sizeof (gfloat) * 4 * samples);
|
||||
|
||||
if (fish_to_blend)
|
||||
{
|
||||
blend_in = alloca (sizeof (gfloat) * 4 * samples);
|
||||
blend_layer = alloca (sizeof (gfloat) * 4 * samples);
|
||||
babl_process (fish_to_blend, in, blend_in, samples);
|
||||
babl_process (fish_to_blend, layer, blend_layer, samples);
|
||||
}
|
||||
|
||||
blendfun (blend_in, blend_layer, blend_out, samples);
|
||||
|
||||
if (fish_to_composite)
|
||||
{
|
||||
babl_process (fish_to_composite, blend_in, blend_in, samples);
|
||||
babl_process (fish_to_composite, blend_out, blend_out, samples);
|
||||
}
|
||||
|
||||
switch (composite_mode)
|
||||
{
|
||||
case GIMP_LAYER_COMPOSITE_SRC_ATOP:
|
||||
default:
|
||||
compfun_src_atop (blend_in, blend_out, mask, opacity, out, samples);
|
||||
break;
|
||||
case GIMP_LAYER_COMPOSITE_SRC_OVER:
|
||||
//compfun_src_over (blend_in, blend_out, mask, opacity, out, samples);
|
||||
gimp_operation_normal_process_pixels (blend_in, blend_out, mask, out, opacity, samples, NULL, 0, 0, 0, 0);
|
||||
break;
|
||||
case GIMP_LAYER_COMPOSITE_DST_ATOP:
|
||||
if (fish_to_composite)
|
||||
babl_process (fish_to_composite, blend_layer, blend_layer, samples);
|
||||
|
||||
compfun_src_atop (blend_out, blend_in, mask, opacity, out, samples); /* swapped arguments */
|
||||
break;
|
||||
case GIMP_LAYER_COMPOSITE_SRC_IN:
|
||||
compfun_src_in (blend_in, blend_out, mask, opacity, out, samples);
|
||||
break;
|
||||
}
|
||||
|
||||
if (fish_from_composite)
|
||||
{
|
||||
babl_process (fish_from_composite, out, out, samples);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_screen (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
int c;
|
||||
for (c = 0; c < 3; c++)
|
||||
out[c] = 1.0f - (1.0f - dest[c]) * (1.0f - src[c]);
|
||||
}
|
||||
out[ALPHA] = src[ALPHA];
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_addition (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
int c;
|
||||
for (c = 0; c < 3; c++)
|
||||
out[c] = dest[c] + src[c];
|
||||
}
|
||||
out[ALPHA] = src[ALPHA];
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_subtract (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
int c;
|
||||
for (c = 0; c < 3; c++)
|
||||
out[c] = dest[c] - src[c];
|
||||
}
|
||||
out[ALPHA] = src[ALPHA];
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_multiply (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
int c;
|
||||
for (c = 0; c < 3; c++)
|
||||
out[c] = dest[c] * src[c];
|
||||
}
|
||||
out[ALPHA] = src[ALPHA];
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_normal (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
int c;
|
||||
for (c = 0; c < 3; c++)
|
||||
out[c] = src[c];
|
||||
}
|
||||
out[ALPHA] = src[ALPHA];
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_burn (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
int c;
|
||||
for (c = 0; c < 3; c++)
|
||||
{
|
||||
gfloat comp = 1.0f - (1.0f - dest[c]) / src[c];
|
||||
/* The CLAMP macro is deliberately inlined and written to map comp ==
|
||||
* NAN (0 / 0) -> 1 */
|
||||
out[c] = comp < 0 ? 0.0f : comp < 1.0f ? comp : 1.0f;
|
||||
}
|
||||
}
|
||||
out[ALPHA] = src[ALPHA];
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_darken_only (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
int c;
|
||||
for (c = 0; c < 3; c++)
|
||||
{
|
||||
out[c] = MIN(dest[c], src[c]);
|
||||
}
|
||||
}
|
||||
out[ALPHA] = src[ALPHA];
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_lighten_only (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
int c;
|
||||
for (c = 0; c < 3; c++)
|
||||
{
|
||||
out[c] = MAX(dest[c], src[c]);
|
||||
}
|
||||
}
|
||||
out[ALPHA] = src[ALPHA];
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_difference (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
int c;
|
||||
for (c = 0; c < 3; c++)
|
||||
{
|
||||
out[c] = dest[c] - src[c];
|
||||
if (out[c] < 0)
|
||||
out[c] = -out[c];
|
||||
}
|
||||
}
|
||||
out[ALPHA] = src[ALPHA];
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_divide (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
int c;
|
||||
for (c = 0; c < 3; c++)
|
||||
{
|
||||
gfloat comp = dest[c] / src[c];
|
||||
|
||||
/* make infinities(or NaN) correspond to a high number, to get more
|
||||
* predictable math, ideally higher than 5.0 but it seems like some
|
||||
* babl conversions might be acting up then
|
||||
*/
|
||||
if (!(comp > -42949672.0f && comp < 5.0f))
|
||||
comp = 5.0f;
|
||||
|
||||
out[c] = comp;
|
||||
}
|
||||
}
|
||||
out[ALPHA] = src[ALPHA];
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_dodge (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
int c;
|
||||
for (c = 0; c < 3; c++)
|
||||
{
|
||||
gfloat comp = dest[c] / (1.0f - src[c]);
|
||||
comp = MIN (comp, 1.0f);
|
||||
|
||||
out[c] = comp;
|
||||
}
|
||||
}
|
||||
out[ALPHA] = src[ALPHA];
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
blendfun_grain_extract (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
int c;
|
||||
for (c = 0; c < 3; c++)
|
||||
{
|
||||
out[c] = dest[c] - src[c] + 0.5f;
|
||||
}
|
||||
}
|
||||
out[ALPHA] = src[ALPHA];
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_grain_merge (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
int c;
|
||||
for (c = 0; c < 3; c++)
|
||||
{
|
||||
out[c] = dest[c] + src[c] - 0.5f;
|
||||
}
|
||||
}
|
||||
out[ALPHA] = src[ALPHA];
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
blendfun_hardlight (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
int c;
|
||||
for (c = 0; c < 3; c++)
|
||||
{
|
||||
gfloat comp;
|
||||
if (src[c] > 0.5f)
|
||||
{
|
||||
comp = (1.0f - dest[c]) * (1.0f - (src[c] - 0.5f) * 2.0f);
|
||||
comp = MIN (1 - comp, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
comp = dest[c] * (src[c] * 2.0f);
|
||||
comp = MIN (comp, 1.0f);
|
||||
}
|
||||
out[c] = comp;
|
||||
}
|
||||
out[ALPHA] = src[ALPHA];
|
||||
}
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_softlight (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
int c;
|
||||
for (c = 0; c < 3; c++)
|
||||
{
|
||||
gfloat multiply = dest[c] * src[c];
|
||||
gfloat screen = 1.0f - (1.0f - dest[c]) * (1.0f - src[c]);
|
||||
gfloat comp = (1.0f - src[c]) * multiply + dest[c] * screen;
|
||||
out[c] = comp;
|
||||
}
|
||||
out[ALPHA] = src[ALPHA];
|
||||
}
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static inline void
|
||||
blendfun_overlay (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
int c;
|
||||
for (c = 0; c < 3; c++)
|
||||
{
|
||||
gfloat comp;
|
||||
if (src[c] < 0.5f)
|
||||
{
|
||||
comp = 2.0f * dest[c] * src[c];
|
||||
}
|
||||
else
|
||||
{
|
||||
comp = 1.0f - 2.0f * (1.0f - src[c]) * (1.0f - dest[c]);
|
||||
}
|
||||
out[c] = comp;
|
||||
}
|
||||
out[ALPHA] = src[ALPHA];
|
||||
}
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_hsv_color (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
GimpRGB dest_rgb = {dest[0], dest[1], dest[2]};
|
||||
GimpRGB src_rgb = {src[0], src[1], src[2]};
|
||||
GimpHSL src_hsl, dest_hsl;
|
||||
gimp_rgb_to_hsl (&dest_rgb, &dest_hsl);
|
||||
gimp_rgb_to_hsl (&src_rgb, &src_hsl);
|
||||
dest_hsl.h = src_hsl.h;
|
||||
dest_hsl.s = src_hsl.s;
|
||||
gimp_hsl_to_rgb (&dest_hsl, &dest_rgb);
|
||||
out[RED] = dest_rgb.r;
|
||||
out[GREEN] = dest_rgb.g;
|
||||
out[BLUE] = dest_rgb.b;
|
||||
}
|
||||
out[ALPHA] = src[ALPHA];
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_hsv_hue (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
GimpRGB dest_rgb = {dest[0], dest[1], dest[2]};
|
||||
GimpRGB src_rgb = {src[0], src[1], src[2]};
|
||||
GimpHSV src_hsv, dest_hsv;
|
||||
gimp_rgb_to_hsv (&dest_rgb, &dest_hsv);
|
||||
gimp_rgb_to_hsv (&src_rgb, &src_hsv);
|
||||
dest_hsv.h = src_hsv.h;
|
||||
gimp_hsv_to_rgb (&dest_hsv, &dest_rgb);
|
||||
out[RED] = dest_rgb.r;
|
||||
out[GREEN] = dest_rgb.g;
|
||||
out[BLUE] = dest_rgb.b;
|
||||
}
|
||||
out[ALPHA] = src[ALPHA];
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_hsv_saturation (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
GimpRGB dest_rgb = {dest[0], dest[1], dest[2]};
|
||||
GimpRGB src_rgb = {src[0], src[1], src[2]};
|
||||
GimpHSV src_hsv, dest_hsv;
|
||||
gimp_rgb_to_hsv (&dest_rgb, &dest_hsv);
|
||||
gimp_rgb_to_hsv (&src_rgb, &src_hsv);
|
||||
dest_hsv.s = src_hsv.s;
|
||||
gimp_hsv_to_rgb (&dest_hsv, &dest_rgb);
|
||||
out[RED] = dest_rgb.r;
|
||||
out[GREEN] = dest_rgb.g;
|
||||
out[BLUE] = dest_rgb.b;
|
||||
}
|
||||
out[ALPHA] = src[ALPHA];
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_hsv_value (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
GimpRGB dest_rgb = {dest[0], dest[1], dest[2]};
|
||||
GimpRGB src_rgb = {src[0], src[1], src[2]};
|
||||
GimpHSV src_hsv, dest_hsv;
|
||||
gimp_rgb_to_hsv (&dest_rgb, &dest_hsv);
|
||||
gimp_rgb_to_hsv (&src_rgb, &src_hsv);
|
||||
dest_hsv.v = src_hsv.v;
|
||||
gimp_hsv_to_rgb (&dest_hsv, &dest_rgb);
|
||||
out[RED] = dest_rgb.r;
|
||||
out[GREEN] = dest_rgb.g;
|
||||
out[BLUE] = dest_rgb.b;
|
||||
}
|
||||
out[ALPHA] = src[ALPHA];
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_lch_chroma (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
gfloat A1 = dest[1];
|
||||
gfloat B1 = dest[2];
|
||||
gfloat c1 = hypotf (A1, B1);
|
||||
|
||||
if (c1 != 0.0f)
|
||||
{
|
||||
gfloat A2 = src[1];
|
||||
gfloat B2 = src[2];
|
||||
gfloat c2 = hypotf (A2, B2);
|
||||
gfloat A = c2 * A1 / c1;
|
||||
gfloat B = c2 * B1 / c1;
|
||||
out[0] = dest[0];
|
||||
out[1] = A;
|
||||
out[2] = B;
|
||||
}
|
||||
}
|
||||
out[ALPHA] = src[ALPHA];
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_lch_color (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
out[0] = dest[0];
|
||||
out[1] = src[1];
|
||||
out[2] = src[2];
|
||||
}
|
||||
out[3] = src[3];
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_lch_hue (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
gfloat A2 = src[1];
|
||||
gfloat B2 = src[2];
|
||||
gfloat c2 = hypotf (A2, B2);
|
||||
|
||||
if (c2 > 0.1f)
|
||||
{
|
||||
gfloat A1 = dest[1];
|
||||
gfloat B1 = dest[2];
|
||||
gfloat c1 = hypotf (A1, B1);
|
||||
gfloat A = c1 * A2 / c2;
|
||||
gfloat B = c1 * B2 / c2;
|
||||
|
||||
out[0] = dest[0];
|
||||
out[1] = A;
|
||||
out[2] = B;
|
||||
}
|
||||
else
|
||||
{
|
||||
out[0] = dest[0];
|
||||
out[1] = dest[1];
|
||||
out[2] = dest[2];
|
||||
}
|
||||
}
|
||||
out[3] = src[3];
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
blendfun_lch_lightness (const float *dest,
|
||||
const float *src,
|
||||
float *out,
|
||||
int samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
if (src[ALPHA] != 0.0f)
|
||||
{
|
||||
out[0] = src[0];
|
||||
out[1] = dest[1];
|
||||
out[2] = dest[2];
|
||||
}
|
||||
out[3] = src[3];
|
||||
out += 4;
|
||||
src += 4;
|
||||
dest += 4;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -27,6 +27,7 @@
|
||||
#include "../operations-types.h"
|
||||
|
||||
#include "gimpoperationaddition.h"
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
|
||||
static gboolean gimp_operation_addition_process (GeglOperation *operation,
|
||||
@ -75,61 +76,29 @@ gimp_operation_addition_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
|
||||
return gimp_operation_addition_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
GimpOperationPointLayerMode *layer_mode = (GimpOperationPointLayerMode*)operation;
|
||||
return gimp_operation_addition_process_pixels (in_buf, aux_buf, aux2_buf,
|
||||
out_buf, layer_mode->opacity, samples, roi, level,
|
||||
layer_mode->blend_trc, layer_mode->composite_trc,
|
||||
layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_addition_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_addition_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
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 = 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++;
|
||||
}
|
||||
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples,
|
||||
blend_trc, composite_trc, composite_mode,
|
||||
blendfun_addition);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -50,14 +50,17 @@ struct _GimpOperationAdditionClass
|
||||
|
||||
GType gimp_operation_addition_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_addition_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_addition_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_ADDITION_H__ */
|
||||
|
@ -87,20 +87,23 @@ gimp_operation_anti_erase_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
GimpOperationPointLayerMode *layer_mode = (void*)operation;
|
||||
|
||||
return gimp_operation_anti_erase_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
return gimp_operation_anti_erase_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_anti_erase_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_anti_erase_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
const gboolean has_mask = mask != NULL;
|
||||
|
||||
|
@ -49,14 +49,17 @@ struct _GimpOperationAntiEraseClass
|
||||
|
||||
GType gimp_operation_anti_erase_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_anti_erase_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_anti_erase_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_ANTI_ERASE_H__ */
|
||||
|
@ -74,20 +74,26 @@ gimp_operation_behind_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
GimpOperationPointLayerMode *layer_mode = (void*)operation;
|
||||
|
||||
return gimp_operation_behind_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
return gimp_operation_behind_process_pixels (in_buf, aux_buf, aux2_buf,
|
||||
out_buf, layer_mode->opacity, samples, roi, level,
|
||||
layer_mode->blend_trc, layer_mode->composite_trc,
|
||||
layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_behind_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_behind_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
const gboolean has_mask = mask != NULL;
|
||||
|
||||
|
@ -49,14 +49,17 @@ struct _GimpOperationBehindClass
|
||||
|
||||
GType gimp_operation_behind_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_behind_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_behind_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_BEHIND_H__ */
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "../operations-types.h"
|
||||
|
||||
#include "gimpoperationburn.h"
|
||||
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
static gboolean gimp_operation_burn_process (GeglOperation *operation,
|
||||
void *in_buf,
|
||||
@ -75,65 +75,30 @@ gimp_operation_burn_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
GimpOperationPointLayerMode *layer_mode = (void*)operation;
|
||||
|
||||
return gimp_operation_burn_process_pixels (in_buf, aux_buf, aux2_buf,
|
||||
out_buf, layer_mode->opacity, samples, roi, level,
|
||||
layer_mode->blend_trc, layer_mode->composite_mode,
|
||||
layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
return gimp_operation_burn_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_burn_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,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
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 = 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 * 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++;
|
||||
}
|
||||
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples, blend_trc,
|
||||
composite_trc, composite_mode, blendfun_burn);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -50,14 +50,17 @@ struct _GimpOperationBurnClass
|
||||
|
||||
GType gimp_operation_burn_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_burn_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_burn_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_BURN_H__ */
|
||||
|
@ -78,20 +78,23 @@ gimp_operation_color_erase_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
GimpOperationPointLayerMode *layer_mode = (void*)operation;
|
||||
|
||||
return gimp_operation_color_erase_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
return gimp_operation_color_erase_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_color_erase_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_color_erase_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
const gboolean has_mask = mask != NULL;
|
||||
|
||||
|
@ -49,14 +49,17 @@ struct _GimpOperationColorEraseClass
|
||||
|
||||
GType gimp_operation_color_erase_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_color_erase_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_color_erase_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_COLOR_ERASE_H__ */
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "../operations-types.h"
|
||||
|
||||
#include "gimpoperationdarkenonly.h"
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
|
||||
static gboolean gimp_operation_darken_only_process (GeglOperation *operation,
|
||||
@ -75,61 +76,25 @@ gimp_operation_darken_only_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
GimpOperationPointLayerMode *layer_mode = (void*)operation;
|
||||
|
||||
return gimp_operation_darken_only_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
return gimp_operation_darken_only_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_darken_only_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_darken_only_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
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++;
|
||||
}
|
||||
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples,
|
||||
blend_trc, composite_trc, composite_mode, blendfun_darken_only);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -50,14 +50,17 @@ struct _GimpOperationDarkenOnlyClass
|
||||
|
||||
GType gimp_operation_darken_only_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_darken_only_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint 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,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_DARKEN_ONLY_H__ */
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "../operations-types.h"
|
||||
|
||||
#include "gimpoperationdifference.h"
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
|
||||
static gboolean gimp_operation_difference_process (GeglOperation *operation,
|
||||
@ -75,62 +76,25 @@ gimp_operation_difference_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
GimpOperationPointLayerMode *layer_mode = (void*)operation;
|
||||
|
||||
return gimp_operation_difference_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
return gimp_operation_difference_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_difference_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_difference_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
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.0f)
|
||||
{
|
||||
gint b;
|
||||
|
||||
for (b = RED; b < ALPHA; b++)
|
||||
{
|
||||
gfloat comp = in[b] - layer[b];
|
||||
comp = (comp < 0) ? -comp : comp;
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples, blend_trc,
|
||||
composite_trc, composite_mode, blendfun_difference);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -58,7 +58,10 @@ gboolean gimp_operation_difference_process_pixels (gfloat *in,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_DIFFERENCE_H__ */
|
||||
|
@ -90,20 +90,23 @@ gimp_operation_dissolve_process (GeglOperation *operation,
|
||||
const GeglRectangle *result,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
GimpOperationPointLayerMode *layer_mode = (void*) operation;
|
||||
|
||||
return gimp_operation_dissolve_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, result, level);
|
||||
return gimp_operation_dissolve_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, result, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_dissolve_process_pixels (gfloat *in,
|
||||
gfloat *aux,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *result,
|
||||
gint level)
|
||||
gimp_operation_dissolve_process_pixels (gfloat *in,
|
||||
gfloat *aux,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *result,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
const gboolean has_mask = mask != NULL;
|
||||
gint x, y;
|
||||
|
@ -49,14 +49,17 @@ struct _GimpOperationDissolve
|
||||
|
||||
GType gimp_operation_dissolve_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_dissolve_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *result,
|
||||
gint level);
|
||||
gboolean gimp_operation_dissolve_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *result,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_DISSOLVE_H__ */
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "../operations-types.h"
|
||||
|
||||
#include "gimpoperationdivide.h"
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
|
||||
static gboolean gimp_operation_divide_process (GeglOperation *operation,
|
||||
@ -75,66 +76,25 @@ gimp_operation_divide_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
GimpOperationPointLayerMode *layer_mode = (void*)operation;
|
||||
|
||||
return gimp_operation_divide_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
return gimp_operation_divide_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_divide_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_divide_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
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.0f)
|
||||
{
|
||||
gint b;
|
||||
|
||||
for (b = RED; b < ALPHA; b++)
|
||||
{
|
||||
gfloat comp = in[b] / layer[b];
|
||||
|
||||
/* make infitinities(or NaN) correspond to a really high number,
|
||||
* to get more predictable math */
|
||||
if (!(comp > -4294967296.0f && comp < 5.0f))
|
||||
comp = 5.0f;
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples,
|
||||
blend_trc, composite_trc, composite_mode, blendfun_divide);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -50,14 +50,17 @@ struct _GimpOperationDivideClass
|
||||
|
||||
GType gimp_operation_divide_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_divide_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_divide_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_DIVIDE_H__ */
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "operations/operations-types.h"
|
||||
|
||||
#include "gimpoperationdodge.h"
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
|
||||
static gboolean gimp_operation_dodge_process (GeglOperation *operation,
|
||||
@ -75,63 +76,25 @@ gimp_operation_dodge_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
GimpOperationPointLayerMode *layer_mode = (void*)operation;
|
||||
|
||||
return gimp_operation_dodge_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
return gimp_operation_dodge_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_dodge_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_dodge_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
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.0f)
|
||||
{
|
||||
gint b;
|
||||
|
||||
for (b = RED; b < ALPHA; b++)
|
||||
{
|
||||
gfloat comp = in[b] / (1.0 - layer[b]);
|
||||
comp = MIN (comp, 1.0);
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples,
|
||||
blend_trc, composite_trc, composite_mode, blendfun_dodge);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -50,14 +50,17 @@ struct _GimpOperationDodgeClass
|
||||
|
||||
GType gimp_operation_dodge_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_dodge_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_dodge_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_DODGE_H__ */
|
||||
|
@ -87,20 +87,23 @@ gimp_operation_erase_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
GimpOperationPointLayerMode *layer_mode = (GimpOperationPointLayerMode*)operation;
|
||||
|
||||
return gimp_operation_erase_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
return gimp_operation_erase_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_erase_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_erase_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
const gboolean has_mask = mask != NULL;
|
||||
|
||||
|
@ -49,14 +49,17 @@ struct _GimpOperationEraseClass
|
||||
|
||||
GType gimp_operation_erase_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_erase_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_erase_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_ERASE_MODE_H__ */
|
||||
|
@ -27,16 +27,17 @@
|
||||
#include "../operations-types.h"
|
||||
|
||||
#include "gimpoperationgrainextract.h"
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
|
||||
static gboolean gimp_operation_grain_extract_process (GeglOperation *operation,
|
||||
void *in_buf,
|
||||
void *aux_buf,
|
||||
void *aux2_buf,
|
||||
void *out_buf,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
void *in_buf,
|
||||
void *aux_buf,
|
||||
void *aux2_buf,
|
||||
void *out_buf,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpOperationGrainExtract, gimp_operation_grain_extract,
|
||||
@ -75,62 +76,24 @@ gimp_operation_grain_extract_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
|
||||
return gimp_operation_grain_extract_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
GimpOperationPointLayerMode *layer_mode = (GimpOperationPointLayerMode*)operation;
|
||||
return gimp_operation_grain_extract_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_grain_extract_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_grain_extract_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
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.0f)
|
||||
{
|
||||
gint b;
|
||||
|
||||
for (b = RED; b < ALPHA; b++)
|
||||
{
|
||||
gfloat comp = in[b] - layer[b] + 0.5;
|
||||
|
||||
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++;
|
||||
}
|
||||
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples, blend_trc,
|
||||
composite_trc, composite_mode, blendfun_grain_extract);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -50,14 +50,17 @@ struct _GimpOperationGrainExtractClass
|
||||
|
||||
GType gimp_operation_grain_extract_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_grain_extract_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_grain_extract_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_GRAIN_EXTRACT_H__ */
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "../operations-types.h"
|
||||
|
||||
#include "gimpoperationgrainmerge.h"
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
|
||||
static gboolean gimp_operation_grain_merge_process (GeglOperation *operation,
|
||||
@ -75,61 +76,24 @@ gimp_operation_grain_merge_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
|
||||
return gimp_operation_grain_merge_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
GimpOperationPointLayerMode *layer_mode = (GimpOperationPointLayerMode*)operation;
|
||||
return gimp_operation_grain_merge_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_grain_merge_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_grain_merge_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
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 = in[b] + layer[b] - 0.5;
|
||||
|
||||
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 ++;
|
||||
}
|
||||
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples, blend_trc,
|
||||
composite_trc, composite_mode, blendfun_grain_merge);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -50,14 +50,17 @@ struct _GimpOperationGrainMergeClass
|
||||
|
||||
GType gimp_operation_grain_merge_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_grain_merge_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_grain_merge_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_GRAIN_MERGE_H__ */
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "../operations-types.h"
|
||||
|
||||
#include "gimpoperationhardlight.h"
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
|
||||
static gboolean gimp_operation_hardlight_process (GeglOperation *operation,
|
||||
@ -74,75 +75,25 @@ gimp_operation_hardlight_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
GimpOperationPointLayerMode *layer_mode = (GimpOperationPointLayerMode*)operation;
|
||||
|
||||
return gimp_operation_hardlight_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
return gimp_operation_hardlight_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_hardlight_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_hardlight_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
const gboolean has_mask = mask != NULL;
|
||||
|
||||
while (samples--)
|
||||
{
|
||||
gfloat comp_alpha, new_alpha;
|
||||
|
||||
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)
|
||||
{
|
||||
gfloat ratio = comp_alpha / new_alpha;
|
||||
gint b;
|
||||
|
||||
for (b = RED; b < ALPHA; b++)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
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 ++;
|
||||
}
|
||||
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples,
|
||||
blend_trc, composite_trc, composite_mode, blendfun_hardlight);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -49,14 +49,17 @@ struct _GimpOperationHardlightClass
|
||||
|
||||
GType gimp_operation_hardlight_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_hardlight_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_hardlight_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_HARDLIGHT_H__ */
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "../operations-types.h"
|
||||
|
||||
#include "gimpoperationhsvcolor.h"
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
|
||||
static gboolean gimp_operation_hsv_color_process (GeglOperation *operation,
|
||||
@ -79,74 +80,25 @@ gimp_operation_hsv_color_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
GimpOperationPointLayerMode *layer_mode = (GimpOperationPointLayerMode*)operation;
|
||||
|
||||
return gimp_operation_hsv_color_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
return gimp_operation_hsv_color_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_hsv_color_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_hsv_color_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
const gboolean has_mask = mask != NULL;
|
||||
|
||||
while (samples--)
|
||||
{
|
||||
GimpHSL layer_hsl, out_hsl;
|
||||
GimpRGB layer_rgb = {layer[0], layer[1], layer[2]};
|
||||
GimpRGB out_rgb = {in[0], in[1], in[2]};
|
||||
gfloat comp_alpha;
|
||||
|
||||
comp_alpha = layer[ALPHA] * opacity;
|
||||
if (has_mask)
|
||||
comp_alpha *= *mask;
|
||||
|
||||
if (comp_alpha)
|
||||
{
|
||||
gint b;
|
||||
gfloat out_tmp[3];
|
||||
|
||||
gimp_rgb_to_hsl (&layer_rgb, &layer_hsl);
|
||||
gimp_rgb_to_hsl (&out_rgb, &out_hsl);
|
||||
|
||||
out_hsl.h = layer_hsl.h;
|
||||
out_hsl.s = layer_hsl.s;
|
||||
gimp_hsl_to_rgb (&out_hsl, &out_rgb);
|
||||
|
||||
out_tmp[0] = out_rgb.r;
|
||||
out_tmp[1] = out_rgb.g;
|
||||
out_tmp[2] = out_rgb.b;
|
||||
|
||||
for (b = RED; b < ALPHA; b++)
|
||||
{
|
||||
out[b] = out_tmp[b] * 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++;
|
||||
}
|
||||
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples,
|
||||
blend_trc, composite_trc, composite_mode, blendfun_hsv_color);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -50,14 +50,17 @@ struct _GimpOperationHsvColorClass
|
||||
|
||||
GType gimp_operation_hsv_color_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_hsv_color_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_hsv_color_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_HSV_COLOR_H__ */
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "../operations-types.h"
|
||||
|
||||
#include "gimpoperationhsvhue.h"
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
|
||||
static gboolean gimp_operation_hsv_hue_process (GeglOperation *operation,
|
||||
@ -79,79 +80,25 @@ gimp_operation_hsv_hue_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
GimpOperationPointLayerMode *layer_mode = (GimpOperationPointLayerMode*)operation;
|
||||
|
||||
return gimp_operation_hsv_hue_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
return gimp_operation_hsv_hue_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_hsv_hue_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_hsv_hue_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
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;
|
||||
|
||||
comp_alpha = layer[ALPHA] * opacity;
|
||||
if (has_mask)
|
||||
comp_alpha *= *mask;
|
||||
|
||||
if (comp_alpha != 0.0f)
|
||||
{
|
||||
gint b;
|
||||
gfloat out_tmp[3];
|
||||
|
||||
gimp_rgb_to_hsv (&layer_rgb, &layer_hsv);
|
||||
gimp_rgb_to_hsv (&out_rgb, &out_hsv);
|
||||
|
||||
/* Composition should have no effect if saturation is zero.
|
||||
* otherwise, black would be painted red (see bug #123296).
|
||||
*/
|
||||
if (layer_hsv.s)
|
||||
{
|
||||
out_hsv.h = layer_hsv.h;
|
||||
}
|
||||
gimp_hsv_to_rgb (&out_hsv, &out_rgb);
|
||||
|
||||
out_tmp[0] = out_rgb.r;
|
||||
out_tmp[1] = out_rgb.g;
|
||||
out_tmp[2] = out_rgb.b;
|
||||
|
||||
for (b = RED; b < ALPHA; b++)
|
||||
{
|
||||
out[b] = out_tmp[b] * 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++;
|
||||
}
|
||||
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples, blend_trc,
|
||||
composite_trc, composite_mode, blendfun_hsv_hue);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -50,14 +50,17 @@ struct _GimpOperationHsvHueClass
|
||||
|
||||
GType gimp_operation_hsv_hue_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_hsv_hue_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_hsv_hue_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_HSV_HUE_H__ */
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "../operations-types.h"
|
||||
|
||||
#include "gimpoperationhsvsaturation.h"
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
|
||||
static gboolean gimp_operation_hsv_saturation_process (GeglOperation *operation,
|
||||
@ -79,73 +80,24 @@ gimp_operation_hsv_saturation_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
|
||||
return gimp_operation_hsv_saturation_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
GimpOperationPointLayerMode *layer_mode = (GimpOperationPointLayerMode*)operation;
|
||||
return gimp_operation_hsv_saturation_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_hsv_saturation_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_hsv_saturation_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
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;
|
||||
|
||||
comp_alpha = layer[ALPHA] * opacity;
|
||||
if (has_mask)
|
||||
comp_alpha *= *mask;
|
||||
|
||||
if (comp_alpha != 0.0f)
|
||||
{
|
||||
gint b;
|
||||
gfloat out_tmp[3];
|
||||
|
||||
gimp_rgb_to_hsv (&layer_rgb, &layer_hsv);
|
||||
gimp_rgb_to_hsv (&out_rgb, &out_hsv);
|
||||
|
||||
out_hsv.s = layer_hsv.s;
|
||||
gimp_hsv_to_rgb (&out_hsv, &out_rgb);
|
||||
|
||||
out_tmp[0] = out_rgb.r;
|
||||
out_tmp[1] = out_rgb.g;
|
||||
out_tmp[2] = out_rgb.b;
|
||||
|
||||
for (b = RED; b < ALPHA; b++)
|
||||
{
|
||||
out[b] = out_tmp[b] * 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++;
|
||||
}
|
||||
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples,
|
||||
blend_trc, composite_trc, composite_mode, blendfun_hsv_saturation);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -50,14 +50,17 @@ struct _GimpOperationHsvSaturationClass
|
||||
|
||||
GType gimp_operation_hsv_saturation_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_hsv_saturation_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_hsv_saturation_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_HSV_SATURATION_H__ */
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "../operations-types.h"
|
||||
|
||||
#include "gimpoperationhsvvalue.h"
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
|
||||
static gboolean gimp_operation_hsv_value_process (GeglOperation *operation,
|
||||
@ -79,61 +80,24 @@ gimp_operation_hsv_value_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
|
||||
return gimp_operation_hsv_value_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
GimpOperationPointLayerMode *layer_mode = (GimpOperationPointLayerMode*)operation;
|
||||
return gimp_operation_hsv_value_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_hsv_value_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_hsv_value_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
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 = layer[ALPHA] * opacity;
|
||||
|
||||
if (has_mask)
|
||||
comp_alpha *= *mask;
|
||||
|
||||
if (comp_alpha != 0.0f)
|
||||
{
|
||||
gimp_rgb_to_hsv (&layer_rgb, &layer_hsv);
|
||||
gimp_rgb_to_hsv (&out_rgb, &out_hsv);
|
||||
|
||||
out_hsv.v = layer_hsv.v;
|
||||
gimp_hsv_to_rgb (&out_hsv, &out_rgb);
|
||||
|
||||
out[RED] = out_rgb.r * comp_alpha + in[RED] * (1.0 - comp_alpha);
|
||||
out[GREEN] = out_rgb.g * comp_alpha + in[GREEN] * (1.0 - comp_alpha);
|
||||
out[BLUE] = out_rgb.b * comp_alpha + in[BLUE] * (1.0 - comp_alpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
out[RED] = in[RED];
|
||||
out[GREEN] = in[GREEN];
|
||||
out[BLUE] = in[BLUE];
|
||||
}
|
||||
|
||||
out[ALPHA] = in[ALPHA];
|
||||
|
||||
in += 4;
|
||||
layer += 4;
|
||||
out += 4;
|
||||
|
||||
if (has_mask)
|
||||
mask++;
|
||||
}
|
||||
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples, blend_trc,
|
||||
composite_trc, composite_mode, blendfun_hsv_value);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -50,14 +50,17 @@ struct _GimpOperationHsvValueClass
|
||||
|
||||
GType gimp_operation_hsv_value_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_hsv_value_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_hsv_value_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_HSV_VALUE_H__ */
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <math.h>
|
||||
#include "../operations-types.h"
|
||||
#include "gimpoperationlchchroma.h"
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
static gboolean gimp_operation_lch_chroma_process (GeglOperation *operation,
|
||||
void *in_buf,
|
||||
@ -83,7 +84,7 @@ gimp_operation_lch_chroma_process (GeglOperation *operation,
|
||||
|
||||
return (linear ? gimp_operation_lch_chroma_process_pixels_linear :
|
||||
gimp_operation_lch_chroma_process_pixels)
|
||||
(in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
(in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level, gimp_op->blend_trc, gimp_op->composite_trc, gimp_op->composite_mode);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -122,39 +123,19 @@ chroma_pre_process (const Babl *from_fish,
|
||||
babl_process (to_fish, out, out, samples);
|
||||
}
|
||||
|
||||
/* XXX: this and pre_process should be removed */
|
||||
gboolean
|
||||
gimp_operation_lch_chroma_process_pixels_linear (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
static const Babl *from_fish;
|
||||
static const Babl *to_fish;
|
||||
|
||||
if (!from_fish)
|
||||
from_fish = babl_fish ("RGBA float", "CIE Lab alpha float");
|
||||
if (!to_fish)
|
||||
to_fish = babl_fish ("CIE Lab alpha float", "RGBA float");
|
||||
|
||||
chroma_pre_process (from_fish, to_fish, in, layer, out, samples);
|
||||
gimp_operation_layer_composite (in, layer, mask, out, opacity, samples);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_lch_chroma_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_lch_chroma_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
static const Babl *from_fish = NULL;
|
||||
static const Babl *to_fish = NULL;
|
||||
@ -165,8 +146,25 @@ gimp_operation_lch_chroma_process_pixels (gfloat *in,
|
||||
to_fish = babl_fish ("CIE Lab alpha float", "R'G'B'A float");
|
||||
|
||||
chroma_pre_process (from_fish, to_fish, in, layer, out, samples);
|
||||
gimp_operation_layer_composite (in, layer, mask, out, opacity, samples);
|
||||
compfun_src_atop (in, layer, mask, opacity, out, samples);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_lch_chroma_process_pixels_linear (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples, blend_trc,
|
||||
composite_trc, composite_mode, blendfun_lch_chroma);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -58,16 +58,22 @@ gboolean gimp_operation_lch_chroma_process_pixels_linear (gfloat *i
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
gboolean gimp_operation_lch_chroma_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_lch_chroma_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_LCH_CHROMA_H__ */
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <gegl-plugin.h>
|
||||
#include "../operations-types.h"
|
||||
#include "gimpoperationlchcolor.h"
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
|
||||
static gboolean gimp_operation_lch_color_process (GeglOperation *operation,
|
||||
@ -78,12 +79,10 @@ gimp_operation_lch_color_process (GeglOperation *operation,
|
||||
gint level)
|
||||
{
|
||||
GimpOperationPointLayerMode *gimp_op = GIMP_OPERATION_POINT_LAYER_MODE (operation);
|
||||
gfloat opacity = gimp_op->opacity;
|
||||
gboolean linear = gimp_op->linear;
|
||||
|
||||
return (linear ? gimp_operation_lch_color_process_pixels_linear :
|
||||
return (gimp_op->linear ? gimp_operation_lch_color_process_pixels_linear :
|
||||
gimp_operation_lch_color_process_pixels)
|
||||
(in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
(in_buf, aux_buf, aux2_buf, out_buf, gimp_op->opacity, samples, roi, level, gimp_op->blend_trc, gimp_op->composite_trc, gimp_op->composite_mode);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -112,42 +111,19 @@ color_pre_process (const Babl *from_fish_la,
|
||||
babl_process (to_fish, out, out, samples);
|
||||
}
|
||||
|
||||
/* XXX: should be removed along with the pre_process fun */
|
||||
gboolean
|
||||
gimp_operation_lch_color_process_pixels_linear (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
static const Babl *from_fish_laba = NULL;
|
||||
static const Babl *from_fish_la = NULL;
|
||||
static const Babl *to_fish = NULL;
|
||||
|
||||
if (!from_fish_laba)
|
||||
from_fish_laba = babl_fish ("RGBA float", "CIE Lab alpha float");
|
||||
if (!from_fish_la)
|
||||
from_fish_la = babl_fish ("RGBA float", "CIE L alpha float");
|
||||
if (!to_fish)
|
||||
to_fish = babl_fish ("CIE Lab alpha float", "RGBA float");
|
||||
|
||||
color_pre_process (from_fish_la, from_fish_laba, to_fish, in, layer, out, samples);
|
||||
gimp_operation_layer_composite (in, layer, mask, out, opacity, samples);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_lch_color_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_lch_color_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
static const Babl *from_fish_laba = NULL;
|
||||
static const Babl *from_fish_la = NULL;
|
||||
@ -161,7 +137,26 @@ gimp_operation_lch_color_process_pixels (gfloat *in,
|
||||
to_fish = babl_fish ("CIE Lab alpha float", "R'G'B'A float");
|
||||
|
||||
color_pre_process (from_fish_la, from_fish_laba, to_fish, in, layer, out, samples);
|
||||
gimp_operation_layer_composite (in, layer, mask, out, opacity, samples);
|
||||
compfun_src_atop (in, layer, mask, opacity, out, samples);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
gimp_operation_lch_color_process_pixels_linear (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples,
|
||||
blend_trc, composite_trc, composite_mode, blendfun_lch_color);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -51,23 +51,29 @@ struct _GimpOperationLchColorClass
|
||||
|
||||
GType gimp_operation_lch_color_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_lch_color_process_pixels_linear (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_lch_color_process_pixels_linear (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
gboolean gimp_operation_lch_color_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_lch_color_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_LCH_COLOR_H__ */
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <math.h>
|
||||
#include "../operations-types.h"
|
||||
#include "gimpoperationlchhue.h"
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
|
||||
static gboolean gimp_operation_lch_hue_process (GeglOperation *operation,
|
||||
@ -78,13 +79,11 @@ gimp_operation_lch_hue_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
GimpOperationPointLayerMode *gimp_op = GIMP_OPERATION_POINT_LAYER_MODE (operation);
|
||||
gfloat opacity = gimp_op->opacity;
|
||||
gboolean linear = gimp_op->linear;
|
||||
GimpOperationPointLayerMode *layer_mode = (GimpOperationPointLayerMode*)operation;
|
||||
|
||||
return (linear ? gimp_operation_lch_hue_process_pixels_linear :
|
||||
return (layer_mode->linear ? gimp_operation_lch_hue_process_pixels_linear :
|
||||
gimp_operation_lch_hue_process_pixels)
|
||||
(in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
(in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -123,39 +122,19 @@ hue_pre_process (const Babl *from_fish,
|
||||
babl_process (to_fish, out, out, samples);
|
||||
}
|
||||
|
||||
/* XXX: this should be removed along with _pre_process */
|
||||
gboolean
|
||||
gimp_operation_lch_hue_process_pixels_linear (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
static const Babl *from_fish = NULL;
|
||||
static const Babl *to_fish = NULL;
|
||||
|
||||
if (!from_fish)
|
||||
from_fish = babl_fish ("RGBA float", "CIE Lab alpha float");
|
||||
if (!to_fish)
|
||||
to_fish = babl_fish ("CIE Lab alpha float", "RGBA float");
|
||||
|
||||
hue_pre_process (from_fish, to_fish, in, layer, out, samples);
|
||||
gimp_operation_layer_composite (in, layer, mask, out, opacity, samples);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_lch_hue_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_lch_hue_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
static const Babl *from_fish = NULL;
|
||||
static const Babl *to_fish = NULL;
|
||||
@ -166,7 +145,26 @@ gimp_operation_lch_hue_process_pixels (gfloat *in,
|
||||
to_fish = babl_fish ("CIE Lab alpha float", "R'G'B'A float");
|
||||
|
||||
hue_pre_process (from_fish, to_fish, in, layer, out, samples);
|
||||
gimp_operation_layer_composite (in, layer, mask, out, opacity, samples);
|
||||
compfun_src_atop (in, layer, mask, opacity, out, samples);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
gimp_operation_lch_hue_process_pixels_linear (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples, blend_trc,
|
||||
composite_trc, composite_mode, blendfun_lch_hue);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -51,23 +51,28 @@ struct _GimpOperationLchHueClass
|
||||
|
||||
GType gimp_operation_lch_hue_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_lch_hue_process_pixels_linear (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
|
||||
gboolean gimp_operation_lch_hue_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_lch_hue_process_pixels_linear (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
gboolean gimp_operation_lch_hue_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
#endif /* __GIMP_OPERATION_LCH_HUE_H__ */
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "../operations-types.h"
|
||||
|
||||
#include "gimpoperationlchlightness.h"
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
|
||||
static gboolean gimp_operation_lch_lightness_process (GeglOperation *operation,
|
||||
@ -78,13 +79,9 @@ gimp_operation_lch_lightness_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
GimpOperationPointLayerMode *gimp_op = GIMP_OPERATION_POINT_LAYER_MODE (operation);
|
||||
gfloat opacity = gimp_op->opacity;
|
||||
gboolean linear = gimp_op->linear;
|
||||
|
||||
return (linear ? gimp_operation_lch_lightness_process_pixels_linear :
|
||||
gimp_operation_lch_lightness_process_pixels)
|
||||
(in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
GimpOperationPointLayerMode *layer_mode = (GimpOperationPointLayerMode*)operation;
|
||||
return (layer_mode->linear ? gimp_operation_lch_lightness_process_pixels_linear : gimp_operation_lch_lightness_process_pixels)
|
||||
(in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -108,42 +105,19 @@ lightness_pre_process (const Babl *from_fish_la,
|
||||
babl_process (to_fish, out, out, samples);
|
||||
}
|
||||
|
||||
/* XXX: this should be remove along with _pre_process */
|
||||
gboolean
|
||||
gimp_operation_lch_lightness_process_pixels_linear (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
static const Babl *from_fish_laba = NULL;
|
||||
static const Babl *from_fish_la = NULL;
|
||||
static const Babl *to_fish = NULL;
|
||||
|
||||
if (!from_fish_laba)
|
||||
from_fish_laba = babl_fish ("RGBA float", "CIE Lab alpha float");
|
||||
if (!from_fish_la)
|
||||
from_fish_la = babl_fish ("RGBA float", "CIE L alpha float");
|
||||
if (!to_fish)
|
||||
to_fish = babl_fish ("CIE Lab alpha float", "RGBA float");
|
||||
|
||||
lightness_pre_process (from_fish_la, from_fish_laba, to_fish, in, layer, out, samples);
|
||||
gimp_operation_layer_composite (in, layer, mask, out, opacity, samples);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_lch_lightness_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_lch_lightness_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
static const Babl *from_fish_laba = NULL;
|
||||
static const Babl *from_fish_la = NULL;
|
||||
@ -158,7 +132,26 @@ gimp_operation_lch_lightness_process_pixels (gfloat *in,
|
||||
|
||||
|
||||
lightness_pre_process (from_fish_la, from_fish_laba, to_fish, in, layer, out, samples);
|
||||
gimp_operation_layer_composite (in, layer, mask, out, opacity, samples);
|
||||
compfun_src_atop (in, layer, mask, opacity, out, samples);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
gimp_operation_lch_lightness_process_pixels_linear (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples,
|
||||
blend_trc, composite_trc, composite_mode, blendfun_lch_lightness);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -51,23 +51,29 @@ struct _GimpOperationLchLightnessClass
|
||||
|
||||
GType gimp_operation_lch_lightness_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_lch_lightness_process_pixels_linear (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_lch_lightness_process_pixels_linear (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
gboolean gimp_operation_lch_lightness_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_lch_lightness_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_LCH_LIGHTNESS_H__ */
|
||||
|
@ -27,16 +27,17 @@
|
||||
#include "../operations-types.h"
|
||||
|
||||
#include "gimpoperationlightenonly.h"
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
|
||||
static gboolean gimp_operation_lighten_only_process (GeglOperation *operation,
|
||||
void *in_buf,
|
||||
void *aux_buf,
|
||||
void *aux2_buf,
|
||||
void *out_buf,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
void *in_buf,
|
||||
void *aux_buf,
|
||||
void *aux2_buf,
|
||||
void *out_buf,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpOperationLightenOnly, gimp_operation_lighten_only,
|
||||
@ -75,61 +76,25 @@ gimp_operation_lighten_only_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
GimpOperationPointLayerMode *layer_mode = (GimpOperationPointLayerMode*)operation;
|
||||
|
||||
return gimp_operation_lighten_only_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
return gimp_operation_lighten_only_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_lighten_only_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_lighten_only_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
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 = MAX (layer[b], in[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++;
|
||||
}
|
||||
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples,
|
||||
blend_trc, composite_trc, composite_mode, blendfun_lighten_only);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -50,14 +50,17 @@ struct _GimpOperationLightenOnlyClass
|
||||
|
||||
GType gimp_operation_lighten_only_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_lighten_only_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_lighten_only_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_LIGHTEN_ONLY_H__ */
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "operations/operations-types.h"
|
||||
|
||||
#include "gimpoperationmultiply.h"
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
|
||||
static gboolean gimp_operation_multiply_process (GeglOperation *operation,
|
||||
@ -75,60 +76,25 @@ gimp_operation_multiply_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
GimpOperationPointLayerMode *layer_mode = (GimpOperationPointLayerMode*)operation;
|
||||
|
||||
return gimp_operation_multiply_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
return gimp_operation_multiply_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_multiply_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_multiply_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
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.0f)
|
||||
{
|
||||
gint b;
|
||||
|
||||
for (b = RED; b < ALPHA; b++)
|
||||
{
|
||||
gfloat comp = layer[b] * in[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++;
|
||||
}
|
||||
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples,
|
||||
blend_trc, composite_trc, composite_mode, blendfun_multiply);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -50,14 +50,17 @@ struct _GimpOperationMultiplyClass
|
||||
|
||||
GType gimp_operation_multiply_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_multiply_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_multiply_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_MULTIPLY_H__ */
|
||||
|
@ -32,21 +32,26 @@
|
||||
#include <emmintrin.h>
|
||||
|
||||
gboolean
|
||||
gimp_operation_normal_process_pixels_sse2 (gfloat *in,
|
||||
gfloat *aux,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_normal_process_pixels_sse2 (gfloat *in,
|
||||
gfloat *aux,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
/* check alignment */
|
||||
if ((((uintptr_t)in) | ((uintptr_t)aux) | ((uintptr_t)out)) & 0x0F)
|
||||
{
|
||||
return gimp_operation_normal_process_pixels_core (in, aux, mask, out,
|
||||
opacity, samples,
|
||||
roi, level);
|
||||
roi, level, blend_trc,
|
||||
composite_trc,
|
||||
composite_mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -32,21 +32,26 @@
|
||||
#include <smmintrin.h>
|
||||
|
||||
gboolean
|
||||
gimp_operation_normal_process_pixels_sse4 (gfloat *in,
|
||||
gfloat *aux,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_normal_process_pixels_sse4 (gfloat *in,
|
||||
gfloat *aux,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
/* check alignment */
|
||||
if ((((uintptr_t)in) | ((uintptr_t)aux) | ((uintptr_t)out)) & 0x0F)
|
||||
{
|
||||
return gimp_operation_normal_process_pixels_core (in, aux, mask, out,
|
||||
opacity, samples,
|
||||
roi, level);
|
||||
roi, level, blend_trc,
|
||||
composite_trc,
|
||||
composite_mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -173,20 +173,22 @@ gimp_operation_normal_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
|
||||
return gimp_operation_normal_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
GimpOperationPointLayerMode *layer_mode = (GimpOperationPointLayerMode*)operation;
|
||||
return gimp_operation_normal_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_normal_process_pixels_core (gfloat *in,
|
||||
gfloat *aux,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_normal_process_pixels_core (gfloat *in,
|
||||
gfloat *aux,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
const gboolean has_mask = mask != NULL;
|
||||
|
||||
|
@ -51,32 +51,41 @@ GType gimp_operation_normal_get_type (void) G_GNUC_CONST;
|
||||
|
||||
extern GimpLayerModeFunc gimp_operation_normal_process_pixels;
|
||||
|
||||
gboolean gimp_operation_normal_process_pixels_core (gfloat *in,
|
||||
gfloat *aux,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_normal_process_pixels_core (gfloat *in,
|
||||
gfloat *aux,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
gboolean gimp_operation_normal_process_pixels_sse2 (gfloat *in,
|
||||
gfloat *aux,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_normal_process_pixels_sse2 (gfloat *in,
|
||||
gfloat *aux,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
gboolean gimp_operation_normal_process_pixels_sse4 (gfloat *in,
|
||||
gfloat *aux,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_normal_process_pixels_sse4 (gfloat *in,
|
||||
gfloat *aux,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_NORMAL_H__ */
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "../operations-types.h"
|
||||
|
||||
#include "gimpoperationoverlay.h"
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
|
||||
static gboolean gimp_operation_overlay_process (GeglOperation *operation,
|
||||
@ -74,69 +75,26 @@ gimp_operation_overlay_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
GimpOperationPointLayerMode *layer_mode = (GimpOperationPointLayerMode*)operation;
|
||||
|
||||
return gimp_operation_overlay_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
return gimp_operation_overlay_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_overlay_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_overlay_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
const gboolean has_mask = mask != NULL;
|
||||
|
||||
while (samples--)
|
||||
{
|
||||
gfloat comp_alpha, new_alpha;
|
||||
|
||||
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)
|
||||
{
|
||||
gint b;
|
||||
gfloat ratio = comp_alpha / new_alpha;
|
||||
|
||||
for (b = RED; b < ALPHA; b++)
|
||||
{
|
||||
gfloat comp;
|
||||
|
||||
if (in[b] < 0.5)
|
||||
comp = 2.0 * in[b] * layer[b];
|
||||
else
|
||||
comp = 1.0 - 2.0 * (1.0 - layer[b]) * (1.0 - 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++;
|
||||
}
|
||||
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples, blend_trc,
|
||||
composite_trc, composite_mode, blendfun_overlay);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -49,14 +49,17 @@ struct _GimpOperationOverlayClass
|
||||
|
||||
GType gimp_operation_overlay_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_overlay_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_overlay_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_OVERLAY_H__ */
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <cairo.h>
|
||||
#include <gegl-plugin.h>
|
||||
#include <cairo.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
@ -66,6 +66,13 @@ G_DEFINE_TYPE (GimpOperationPointLayerMode, gimp_operation_point_layer_mode,
|
||||
#define parent_class gimp_operation_point_layer_mode_parent_class
|
||||
|
||||
|
||||
const Babl *_gimp_fish_rgba_to_perceptual = NULL;
|
||||
const Babl *_gimp_fish_perceptual_to_rgba = NULL;
|
||||
const Babl *_gimp_fish_perceptual_to_laba = NULL;
|
||||
const Babl *_gimp_fish_rgba_to_laba = NULL;
|
||||
const Babl *_gimp_fish_laba_to_rgba = NULL;
|
||||
const Babl *_gimp_fish_laba_to_perceptual = NULL;
|
||||
|
||||
static void
|
||||
gimp_operation_point_layer_mode_class_init (GimpOperationPointLayerModeClass *klass)
|
||||
{
|
||||
@ -117,6 +124,15 @@ gimp_operation_point_layer_mode_class_init (GimpOperationPointLayerModeClass *kl
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
|
||||
if (_gimp_fish_rgba_to_perceptual == NULL)
|
||||
{
|
||||
_gimp_fish_rgba_to_perceptual = babl_fish ("RGBA float", "R'G'B'A float");
|
||||
_gimp_fish_perceptual_to_rgba = babl_fish ("R'G'B'A float", "RGBA float");
|
||||
_gimp_fish_perceptual_to_laba = babl_fish ("R'G'B'A float", "CIE Lab alpha float");
|
||||
_gimp_fish_rgba_to_laba = babl_fish ("RGBA float", "CIE Lab alpha float");
|
||||
_gimp_fish_laba_to_rgba = babl_fish ("CIE Lab alpha float", "RGBA float");
|
||||
_gimp_fish_laba_to_perceptual = babl_fish ("CIE Lab alpha float", "R'G'B'A float");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -23,7 +23,13 @@
|
||||
|
||||
|
||||
#include <gegl-plugin.h>
|
||||
|
||||
#include <math.h>
|
||||
#include <alloca.h>
|
||||
#include <cairo.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include "../operations-enums.h"
|
||||
#include "../operations-types.h"
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
|
||||
#define GIMP_TYPE_OPERATION_POINT_LAYER_MODE (gimp_operation_point_layer_mode_get_type ())
|
||||
#define GIMP_OPERATION_POINT_LAYER_MODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_POINT_LAYER_MODE, GimpOperationPointLayerMode))
|
||||
@ -51,46 +57,9 @@ struct _GimpOperationPointLayerMode
|
||||
GimpLayerCompositeMode composite_mode;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_operation_point_layer_mode_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
static inline void
|
||||
gimp_operation_layer_composite (const gfloat *in,
|
||||
const gfloat *layer,
|
||||
const gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples)
|
||||
{
|
||||
while (samples--)
|
||||
{
|
||||
gfloat comp_alpha = layer[ALPHA] * opacity;
|
||||
if (mask)
|
||||
comp_alpha *= *mask++;
|
||||
if (comp_alpha != 0.0f)
|
||||
{
|
||||
out[RED] = out[RED] * comp_alpha + in[RED] * (1.0f - comp_alpha);
|
||||
out[GREEN] = out[GREEN] * comp_alpha + in[GREEN] * (1.0f - comp_alpha);
|
||||
out[BLUE] = out[BLUE] * comp_alpha + in[BLUE] * (1.0f - 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;
|
||||
}
|
||||
}
|
||||
|
||||
#include "gimpoperationnormal.h"
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_POINT_LAYER_MODE_H__ */
|
||||
|
@ -73,20 +73,23 @@ gimp_operation_replace_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
GimpOperationPointLayerMode *layer_mode = (GimpOperationPointLayerMode*)operation;
|
||||
|
||||
return gimp_operation_replace_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
return gimp_operation_replace_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_replace_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_replace_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
const gboolean has_mask = mask != NULL;
|
||||
|
||||
|
@ -49,14 +49,17 @@ struct _GimpOperationReplaceClass
|
||||
|
||||
GType gimp_operation_replace_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_replace_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_replace_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_REPLACE_H__ */
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "../operations-types.h"
|
||||
|
||||
#include "gimpoperationscreen.h"
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
|
||||
static gboolean gimp_operation_screen_process (GeglOperation *operation,
|
||||
@ -65,6 +66,7 @@ gimp_operation_screen_init (GimpOperationScreen *self)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
gimp_operation_screen_process (GeglOperation *operation,
|
||||
void *in_buf,
|
||||
@ -75,61 +77,25 @@ gimp_operation_screen_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
|
||||
return gimp_operation_screen_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
GimpOperationPointLayerMode *layer_mode = (GimpOperationPointLayerMode*)operation;
|
||||
return gimp_operation_screen_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_screen_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_screen_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
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.0f)
|
||||
{
|
||||
gint b;
|
||||
|
||||
for (b = RED; b < ALPHA; b++)
|
||||
{
|
||||
gfloat comp = 1.0 - (1.0 - in[b]) * (1.0 - 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++;
|
||||
}
|
||||
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples,
|
||||
blend_trc, composite_trc, composite_mode, blendfun_screen);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -49,14 +49,17 @@ struct _GimpOperationScreenClass
|
||||
|
||||
GType gimp_operation_screen_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_screen_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_screen_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_SCREEN_H__ */
|
||||
|
@ -26,16 +26,17 @@
|
||||
#include "../operations-types.h"
|
||||
|
||||
#include "gimpoperationsoftlight.h"
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
|
||||
static gboolean gimp_operation_softlight_process (GeglOperation *operation,
|
||||
void *in_buf,
|
||||
void *aux_buf,
|
||||
void *aux2_buf,
|
||||
void *out_buf,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
void *in_buf,
|
||||
void *aux_buf,
|
||||
void *aux2_buf,
|
||||
void *out_buf,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpOperationSoftlight, gimp_operation_softlight,
|
||||
@ -92,75 +93,24 @@ gimp_operation_softlight_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
|
||||
return gimp_operation_softlight_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
GimpOperationPointLayerMode *layer_mode = (GimpOperationPointLayerMode*)operation;
|
||||
return gimp_operation_softlight_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_softlight_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_softlight_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
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.0f)
|
||||
{
|
||||
gint b;
|
||||
|
||||
for (b = RED; b < ALPHA; b++)
|
||||
{
|
||||
#if 0
|
||||
/* softlight is now used for what GIMP formerly called
|
||||
* OVERLAY. We fixed OVERLAY to use the right math
|
||||
* (under the name NEW_OVERLAY), and redirect uses of
|
||||
* the old OVERLAY blend mode here. This math was
|
||||
* formerly used for OVERLAY and is exactly the same as
|
||||
* the multiply, screen, comp math used below.
|
||||
* See bug #673501.
|
||||
*/
|
||||
gfloat comp = in[b] * (in[b] + (2.0 * layer[b]) * (1.0 - in[b]));
|
||||
#endif
|
||||
|
||||
gfloat multiply = in[b] * layer[b];
|
||||
gfloat screen = 1.0 - (1.0 - in[b]) * (1.0 - layer[b]);
|
||||
gfloat comp = (1.0 - in[b]) * multiply + in[b] * screen;
|
||||
|
||||
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 ++;
|
||||
}
|
||||
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples,
|
||||
blend_trc, composite_trc, composite_mode, blendfun_softlight);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -49,14 +49,16 @@ struct _GimpOperationSoftlightClass
|
||||
|
||||
GType gimp_operation_softlight_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_softlight_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
|
||||
gboolean gimp_operation_softlight_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
#endif /* __GIMP_OPERATION_SOFTLIGHT_H__ */
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "../operations-types.h"
|
||||
|
||||
#include "gimpoperationsubtract.h"
|
||||
|
||||
#include "gimpblendcomposite.h"
|
||||
|
||||
static gboolean gimp_operation_subtract_process (GeglOperation *operation,
|
||||
void *in_buf,
|
||||
@ -75,60 +75,25 @@ gimp_operation_subtract_process (GeglOperation *operation,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
{
|
||||
gfloat opacity = GIMP_OPERATION_POINT_LAYER_MODE (operation)->opacity;
|
||||
GimpOperationPointLayerMode *layer_mode = (GimpOperationPointLayerMode*)operation;
|
||||
|
||||
return gimp_operation_subtract_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, opacity, samples, roi, level);
|
||||
return gimp_operation_subtract_process_pixels (in_buf, aux_buf, aux2_buf, out_buf, layer_mode->opacity, samples, roi, level, layer_mode->blend_trc, layer_mode->composite_trc, layer_mode->composite_mode);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_operation_subtract_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level)
|
||||
gimp_operation_subtract_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode)
|
||||
{
|
||||
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 = 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++;
|
||||
}
|
||||
|
||||
gimp_composite_blend (in, layer, mask, out, opacity, samples, blend_trc,
|
||||
composite_trc, composite_mode, blendfun_subtract);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -50,14 +50,17 @@ struct _GimpOperationSubtractClass
|
||||
|
||||
GType gimp_operation_subtract_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gboolean gimp_operation_subtract_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level);
|
||||
gboolean gimp_operation_subtract_process_pixels (gfloat *in,
|
||||
gfloat *layer,
|
||||
gfloat *mask,
|
||||
gfloat *out,
|
||||
gfloat opacity,
|
||||
glong samples,
|
||||
const GeglRectangle *roi,
|
||||
gint level,
|
||||
GimpLayerBlendTRC blend_trc,
|
||||
GimpLayerBlendTRC composite_trc,
|
||||
GimpLayerCompositeMode composite_mode);
|
||||
|
||||
|
||||
#endif /* __GIMP_OPERATION_SUBTRACT_H__ */
|
||||
|
Reference in New Issue
Block a user