Last week I made a new discovery on making GEGL plugins, and apparently someone from GNOME knew this trick back in 2013. Despite any public documentation of it.
I looked at the source code of GEGL's Gaussian Blur filter, something I had done long before.
During my previous look at
gegl:gaussian-blur 's code I knew it was based on two
gegl:gblur-1d being set horizontal and vertical. The stuff about gaussian blur is irrelevant to my discovery.
However just a few weeks ago I realized the nodes in the .c file were only listed once instead of twice. I didn't know this was possible. So in my latest filter that applies on a layer mask. I took note of gaussian-blur's .c file and made it where the code in my new filter only list nodes once instead of twice.
Example of required GEGL nodes being listed once (new discovery)#define GEGL_OP_META
#define GEGL_OP_NAME quickmaskfilter
#define GEGL_OP_C_SOURCE quickmaskfilter.c
#include "gegl-op.h"
static void attach (GeglOperation *operation)
{
GeglNode *gegl = operation->node;
GeglNode *input = gegl_node_get_input_proxy (gegl, "input");
GeglNode *output = gegl_node_get_output_proxy (gegl, "output");
GeglNode *spread = gegl_node_new_child (gegl,
"operation", "gegl:noise-spread", NULL);
GeglNode *blur = gegl_node_new_child (gegl, "operation", "gegl:gaussian-blur", NULL);
GeglNode *median = gegl_node_new_child (gegl, "operation", "gegl:median-blur", NULL);
GeglNode *median2 = gegl_node_new_child (gegl, "operation", "gegl:median-blur", NULL);
GeglNode *invertmask = gegl_node_new_child (gegl, "operation", "gegl:component-extract", NULL);
GeglNode *increaseopacity = gegl_node_new_child (gegl, "operation", "gegl:levels", NULL);
gegl_node_link_many (input, spread, median, blur, median2, invertmask, increaseopacity, output, NULL);
Example of GEGL nodes being listed twice. (The way I've been doing things)#define GEGL_OP_META
#define GEGL_OP_NAME quickmaskfilter
#define GEGL_OP_C_SOURCE quickmaskfilter.c
#include "gegl-op.h"
static void attach (GeglOperation *operation)
{
GeglNode *gegl = operation->node;
GeglNode *input, *output, *spread, *blur, *median, *median2, *invertmask, *increaseopacity;
input = gegl_node_get_input_proxy (gegl, "input");
output = gegl_node_get_output_proxy (gegl, "output");
spread = gegl_node_new_child (gegl,
"operation", "gegl:noise-spread", NULL);
blur = gegl_node_new_child (gegl, "operation", "gegl:gaussian-blur", NULL);
median = gegl_node_new_child (gegl, "operation", "gegl:median-blur", NULL);
median2 = gegl_node_new_child (gegl, "operation", "gegl:median-blur", NULL);
invertmask = gegl_node_new_child (gegl, "operation", "gegl:component-extract", NULL);
increaseopacity = gegl_node_new_child (gegl, "operation", "gegl:levels", NULL);
gegl_node_link_many (input, spread, median, blur, median2, invertmask, increaseopacity, output, NULL);
What is the major difference? is put in front of every filter instead of a list like
GeglNode *input, *output, *filter1, *filter2, *filter3;
This means it is EVEN EASIER to make a GEGL plugin.