1 /* This file is an image processing operation for GEGL
2 *
3 * GEGL is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 3 of the License, or (at your option) any later version.
7 *
8 * GEGL is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with GEGL; if not, see <https://www.gnu.org/licenses/>.
15 *
16 * Copyright 2006 Øyvind Kolås <pippin@gimp.org>
17 */
18
19 #include "config.h"
20 #include <glib/gi18n-lib.h>
21
22
23 #ifdef GEGL_PROPERTIES
24
25 /* no properties */
26
27 #else
28
29 #define GEGL_OP_FILTER
30 #define GEGL_OP_NAME nop
31 #define GEGL_OP_C_SOURCE nop.c
32
33 #include "gegl-op.h"
34
35 static void
gegl_nop_prepare(GeglOperation * self)36 gegl_nop_prepare (GeglOperation *self)
37 {
38 const Babl *fmt = gegl_operation_get_source_format (self, "input");
39
40 gegl_operation_set_format (self, "output", fmt);
41 }
42
43 static gboolean
gegl_nop_process(GeglOperation * operation,GeglOperationContext * context,const gchar * output_prop,const GeglRectangle * result,gint level)44 gegl_nop_process (GeglOperation *operation,
45 GeglOperationContext *context,
46 const gchar *output_prop,
47 const GeglRectangle *result,
48 gint level)
49 {
50 GeglBuffer *input;
51
52 if (strcmp (output_prop, "output"))
53 {
54 g_warning ("requested processing of %s pad on a nop", output_prop);
55 return FALSE;
56 }
57
58 input = GEGL_BUFFER (gegl_operation_context_get_object (context, "input"));
59 if (!input)
60 {
61 g_warning ("nop received NULL input");
62 return FALSE;
63 }
64
65 gegl_operation_context_take_object (context, "output",
66 g_object_ref ((GObject *) input));
67 return TRUE;
68 }
69
70 static void
gegl_op_class_init(GeglOpClass * klass)71 gegl_op_class_init (GeglOpClass *klass)
72 {
73 GeglOperationClass *operation_class;
74
75 operation_class = GEGL_OPERATION_CLASS (klass);
76 operation_class->process = gegl_nop_process;
77 operation_class->prepare = gegl_nop_prepare;
78
79 gegl_operation_class_set_keys (operation_class,
80 "name", "gegl:nop",
81 "title", _("No Operation"),
82 "categories", "core",
83 "description", _("No operation (can be used as a routing point)"),
84 NULL);
85 }
86
87 #endif
88