1 2 /* !!!! AUTOGENERATED FILE generated by svg-12-porter-duff.rb !!!!! 3 * 4 * This file is an image processing operation for GEGL 5 * 6 * GEGL is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 3 of the License, or (at your option) any later version. 10 * 11 * GEGL is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with GEGL; if not, see <https://www.gnu.org/licenses/>. 18 * 19 * Copyright 2006, 2007 Øyvind Kolås <pippin@gimp.org> 20 * 2007 John Marshall 21 * 2013 Daniel Sabo 22 * 23 * SVG rendering modes; see: 24 * http://www.w3.org/TR/SVG12/rendering.html 25 * http://www.w3.org/TR/2004/WD-SVG12-20041027/rendering.html#comp-op-prop 26 * 27 * aA = aux(src) alpha aB = in(dst) alpha aD = out alpha 28 * cA = aux(src) colour cB = in(dst) colour cD = out colour 29 * 30 * !!!! AUTOGENERATED FILE !!!!! 31 */ 32 #include "config.h" 33 #include <glib/gi18n-lib.h> 34 35 36 #ifdef GEGL_PROPERTIES 37 38 property_boolean (srgb, _("sRGB"), FALSE) 39 description (_("Use sRGB gamma instead of linear")) 40 41 #else 42 43 #define GEGL_OP_POINT_COMPOSER 44 #define GEGL_OP_NAME dst_in 45 #define GEGL_OP_C_FILE "dst-in.c" 46 47 #include "gegl-op.h" 48 49 static void prepare (GeglOperation *operation) 50 { 51 const Babl *format = gegl_operation_get_source_format (operation, "input"); 52 if (!format) 53 format = gegl_operation_get_source_format (operation, "aux"); 54 55 if(GEGL_PROPERTIES (operation)->srgb) 56 format = gegl_babl_variant (format, GEGL_BABL_VARIANT_PERCEPTUAL_PREMULTIPLIED); 57 else 58 format = gegl_babl_variant (format, GEGL_BABL_VARIANT_LINEAR_PREMULTIPLIED); 59 60 gegl_operation_set_format (operation, "input", format); 61 gegl_operation_set_format (operation, "aux", format); 62 gegl_operation_set_format (operation, "output", format); 63 } 64 65 static gboolean 66 process (GeglOperation *op, 67 void *in_buf, 68 void *aux_buf, 69 void *out_buf, 70 glong n_pixels, 71 const GeglRectangle *roi, 72 gint level) 73 { 74 gint i; 75 gfloat * GEGL_ALIGNED in = in_buf; 76 gfloat * GEGL_ALIGNED aux = aux_buf; 77 gfloat * GEGL_ALIGNED out = out_buf; 78 const Babl *format = gegl_operation_get_format (op, "output"); 79 gint components = babl_format_get_n_components (format); 80 gint alpha = components-1; 81 82 if (!aux) 83 return TRUE; 84 else 85 { 86 for (i = 0; i < n_pixels; i++) 87 { 88 gint j; 89 gfloat aA G_GNUC_UNUSED, aB G_GNUC_UNUSED, aD G_GNUC_UNUSED; 90 91 aB = in[alpha]; 92 aA = aux[alpha]; 93 aD = aA * aB; 94 95 for (j = 0; j < alpha; j++) 96 { 97 gfloat cA G_GNUC_UNUSED, cB G_GNUC_UNUSED; 98 99 cB = in[j]; 100 cA = aux[j]; 101 out[j] = cB * aA; 102 } 103 out[alpha] = aD; 104 in += components; 105 aux += components; 106 out += components; 107 } 108 } 109 return TRUE; 110 } 111 112 113 static void 114 gegl_op_class_init (GeglOpClass *klass) 115 { 116 GeglOperationClass *operation_class; 117 GeglOperationPointComposerClass *point_composer_class; 118 119 operation_class = GEGL_OPERATION_CLASS (klass); 120 point_composer_class = GEGL_OPERATION_POINT_COMPOSER_CLASS (klass); 121 122 point_composer_class->process = process; 123 operation_class->prepare = prepare; 124 125 126 gegl_operation_class_set_keys (operation_class, 127 "name" , "svg:dst-in", 128 "compat-name", "gegl:dst-in", 129 "title" , "Dst-in", 130 "reference-hash" , "e7e478208bc463c6894049aefd1616b5", 131 "categories" , "compositors:porter-duff", 132 "description", 133 _("Porter Duff operation dst-in (d = cB * aA)"), 134 NULL); 135 136 137 } 138 139 #endif 140