|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
/* !!!! AUTOGENERATED FILE generated by svg12-blend.rb !!!!!
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* This file is an image processing operation for GEGL
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* GEGL is free software; you can redistribute it and/or
|
|
Packit Service |
2781ba |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
2781ba |
* License as published by the Free Software Foundation; either
|
|
Packit Service |
2781ba |
* version 3 of the License, or (at your option) any later version.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* GEGL is distributed in the hope that it will be useful,
|
|
Packit Service |
2781ba |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
2781ba |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
2781ba |
* Lesser General Public License for more details.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
2781ba |
* License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* Copyright 2006, 2007 Øyvind Kolås <pippin@gimp.org>
|
|
Packit Service |
2781ba |
* 2007 John Marshall
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* SVG rendering modes; see:
|
|
Packit Service |
2781ba |
* http://www.w3.org/TR/SVG12/rendering.html
|
|
Packit Service |
2781ba |
* http://www.w3.org/TR/2004/WD-SVG12-20041027/rendering.html#comp-op-prop
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* aA = aux(src) alpha aB = in(dst) alpha aD = out alpha
|
|
Packit Service |
2781ba |
* cA = aux(src) colour cB = in(dst) colour cD = out colour
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* !!!! AUTOGENERATED FILE !!!!!
|
|
Packit Service |
2781ba |
*/
|
|
Packit Service |
2781ba |
#include "config.h"
|
|
Packit Service |
2781ba |
#include <glib/gi18n-lib.h>
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#ifdef GEGL_CHANT_PROPERTIES
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
/* no properties */
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#else
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#define GEGL_CHANT_TYPE_POINT_COMPOSER
|
|
Packit Service |
2781ba |
#define GEGL_CHANT_C_FILE "color-dodge.c"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "gegl-chant.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void prepare (GeglOperation *operation)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
const Babl *format = babl_format ("RaGaBaA float");
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_operation_set_format (operation, "input", format);
|
|
Packit Service |
2781ba |
gegl_operation_set_format (operation, "aux", format);
|
|
Packit Service |
2781ba |
gegl_operation_set_format (operation, "output", format);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static gboolean
|
|
Packit Service |
2781ba |
process (GeglOperation *op,
|
|
Packit Service |
2781ba |
void *in_buf,
|
|
Packit Service |
2781ba |
void *aux_buf,
|
|
Packit Service |
2781ba |
void *out_buf,
|
|
Packit Service |
2781ba |
glong n_pixels,
|
|
Packit Service |
2781ba |
const GeglRectangle *roi,
|
|
Packit Service |
2781ba |
gint level)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
gfloat * GEGL_ALIGNED in = in_buf;
|
|
Packit Service |
2781ba |
gfloat * GEGL_ALIGNED aux = aux_buf;
|
|
Packit Service |
2781ba |
gfloat * GEGL_ALIGNED out = out_buf;
|
|
Packit Service |
2781ba |
gint i;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (aux==NULL)
|
|
Packit Service |
2781ba |
return TRUE;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
for (i = 0; i < n_pixels; i++)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
gfloat aA, aB, aD;
|
|
Packit Service |
2781ba |
gint j;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
aB = in[3];
|
|
Packit Service |
2781ba |
aA = aux[3];
|
|
Packit Service |
2781ba |
aD = aA + aB - aA * aB;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
for (j = 0; j < 3; j++)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
gfloat cA, cB;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
cB = in[j];
|
|
Packit Service |
2781ba |
cA = aux[j];
|
|
Packit Service |
2781ba |
if (cA * aB + cB * aA >= aA * aB)
|
|
Packit Service |
2781ba |
out[j] = CLAMP (aA * aB + cA * (1 - aB) + cB * (1 - aA), 0, aD);
|
|
Packit Service |
2781ba |
else
|
|
Packit Service |
2781ba |
out[j] = CLAMP ((cA == aA ? 1 : cB * aA / (aA == 0 ? 1 : 1 - cA / aA)) + cA * (1 - aB) + cB * (1 - aA), 0, aD);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
out[3] = aD;
|
|
Packit Service |
2781ba |
in += 4;
|
|
Packit Service |
2781ba |
aux += 4;
|
|
Packit Service |
2781ba |
out += 4;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
return TRUE;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_chant_class_init (GeglChantClass *klass)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglOperationClass *operation_class;
|
|
Packit Service |
2781ba |
GeglOperationPointComposerClass *point_composer_class;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
operation_class = GEGL_OPERATION_CLASS (klass);
|
|
Packit Service |
2781ba |
point_composer_class = GEGL_OPERATION_POINT_COMPOSER_CLASS (klass);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
point_composer_class->process = process;
|
|
Packit Service |
2781ba |
operation_class->prepare = prepare;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
operation_class->compat_name = "gegl:color-dodge";
|
|
Packit Service |
2781ba |
gegl_operation_class_set_keys (operation_class,
|
|
Packit Service |
2781ba |
"name" , "svg:color-dodge",
|
|
Packit Service |
2781ba |
"description" ,
|
|
Packit Service |
2781ba |
_("SVG blend operation color-dodge (<tt>if cA * aB + cB * aA >= aA * aB: d = aA * aB + cA * (1 - aB) + cB * (1 - aA) otherwise: d = (cA == aA ? 1 : cB * aA / (aA == 0 ? 1 : 1 - cA / aA)) + cA * (1 - aB) + cB * (1 - aA)</tt>)"),
|
|
Packit Service |
2781ba |
NULL);
|
|
Packit Service |
2781ba |
gegl_operation_class_set_key (operation_class, "categories", "compositors:svgfilter");
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#endif
|