static void attach (GeglOperation *operation) { GeglNode *gegl, *input, *output, *add, *multiply, *subtract, *blur; gegl = operation->node; input = gegl_node_get_input_proxy (gegl, "input"); output = gegl_node_get_output_proxy (gegl, "output"); add = gegl_node_new_child (gegl, "operation", "gegl:add", NULL); multiply = gegl_node_new_child (gegl, "operation", "gegl:multiply", NULL); subtract = gegl_node_new_child (gegl, "operation", "gegl:subtract", NULL); blur = gegl_node_new_child (gegl, "operation", "gegl:gaussian-blur", NULL); gegl_node_link_many (input, subtract, multiply, NULL); gegl_node_link (input, blur); gegl_node_link_many (multiply, add, output, NULL); gegl_node_connect_from (subtract, "aux", blur, "output"); gegl_node_connect_from (add, "aux", input, "output"); gegl_operation_meta_redirect (operation, "scale", multiply, "value"); gegl_operation_meta_redirect (operation, "std-dev", blur, "std-dev-x"); gegl_operation_meta_redirect (operation, "std-dev", blur, "std-dev-y"); gegl_operation_meta_watch_nodes (operation, add, multiply, subtract, blur, NULL); }
static void attach (GeglOperation *operation) { GeglNode *gegl = operation->node; GeglNode *input, *output, *subtract, *blur1, *blur2; input = gegl_node_get_input_proxy (gegl, "input"); output = gegl_node_get_output_proxy (gegl, "output"); subtract = gegl_node_new_child (gegl, "operation", "gegl:subtract", NULL); blur1 = gegl_node_new_child (gegl, "operation", "gegl:gaussian-blur", NULL); blur2 = gegl_node_new_child (gegl, "operation", "gegl:gaussian-blur", NULL); gegl_node_link_many (input, blur1, subtract, output, NULL); gegl_node_link (input, blur2); gegl_node_connect_from (subtract, "aux", blur2, "output"); gegl_operation_meta_redirect (operation, "radius1", blur1, "std-dev-x"); gegl_operation_meta_redirect (operation, "radius1", blur1, "std-dev-y"); gegl_operation_meta_redirect (operation, "radius2", blur2, "std-dev-x"); gegl_operation_meta_redirect (operation, "radius2", blur2, "std-dev-y"); gegl_operation_meta_watch_nodes (operation, subtract, blur1, blur2, NULL); }
static void attach (GeglOperation *operation) { GeglNode *gegl, *input, *output, *invert, *blur, *opacity, *over, *contrast; gegl = operation->node; input = gegl_node_get_input_proxy (gegl, "input"); output = gegl_node_get_output_proxy (gegl, "output"); invert = gegl_node_new_child (gegl, "operation", "gegl:invert-linear", NULL); blur = gegl_node_new_child (gegl, "operation", "gegl:gaussian-blur", NULL); opacity = gegl_node_new_child (gegl, "operation", "gegl:opacity", "value", 0.5, NULL); over = gegl_node_new_child (gegl, "operation", "gegl:over", NULL); contrast = gegl_node_new_child (gegl, "operation", "gegl:brightness-contrast", NULL); gegl_node_link_many (input, invert, blur, opacity, NULL); gegl_node_connect_to (opacity, "output", over, "aux"); gegl_node_link_many (input, over, contrast, output, NULL); gegl_operation_meta_redirect (operation, "std-dev", blur, "std-dev-x"); gegl_operation_meta_redirect (operation, "std-dev", blur, "std-dev-y"); gegl_operation_meta_redirect (operation, "contrast", contrast, "contrast"); gegl_operation_meta_watch_nodes (operation, invert, blur, opacity, over, contrast, NULL); }
static void attach (GeglOperation *operation) { /** * <input (BG)> <aux (FG)> * |"output" "output"| * | | * | "input" "aux" | * +-----> <seamless-clone> <----+ * | "output"| * | | * | "input" "aux" | * +---> <overlay> <---+ * |"output" * v * <output> */ GeglNode *gegl = operation->node; GeglNode *input, *aux, *seamless, *overlay, *output; input = gegl_node_get_input_proxy (gegl, "input"); aux = gegl_node_get_input_proxy (gegl, "aux"); seamless = gegl_node_new_child (gegl, "operation", "gegl:seamless-clone", NULL); /* Don't use a regular gegl:over, since we want the alpha to be set * by the background buffer - we need this for area which had opacity * which was more than half but not fulll. */ overlay = gegl_node_new_child (gegl, "operation", "svg:src-atop", NULL); output = gegl_node_get_output_proxy (gegl, "output"); gegl_node_connect_to (input, "output", seamless, "input"); gegl_node_connect_to (aux, "output", seamless, "aux"); gegl_node_connect_to (input, "output", overlay, "input"); gegl_node_connect_to (seamless, "output", overlay, "aux"); gegl_node_connect_to (overlay, "output", output, "input"); gegl_operation_meta_redirect (operation, "max-refine-scale", seamless, "max-refine-scale"); gegl_operation_meta_redirect (operation, "xoff", seamless, "xoff"); gegl_operation_meta_redirect (operation, "yoff", seamless, "yoff"); gegl_operation_meta_redirect (operation, "error-msg", seamless, "error-msg"); gegl_operation_meta_watch_nodes (operation, seamless, overlay, NULL); }
static void attach (GeglOperation *operation) { GeglNode *gegl = operation->node; GeglNode *output, *color, *crop; output = gegl_node_get_output_proxy (gegl, "output"); color = gegl_node_new_child (gegl, "operation", "gegl:color", NULL); crop = gegl_node_new_child (gegl, "operation", "gegl:crop", NULL); gegl_operation_meta_watch_node (operation, color); gegl_operation_meta_watch_node (operation, crop); gegl_node_link_many (color, crop, output, NULL); gegl_operation_meta_redirect (operation, "color", color, "value"); gegl_operation_meta_redirect (operation, "x", crop, "x"); gegl_operation_meta_redirect (operation, "y", crop, "y"); gegl_operation_meta_redirect (operation, "width", crop, "width"); gegl_operation_meta_redirect (operation, "height", crop, "height"); }
static void attach (GeglOperation *operation) { GeglChantO *o = GEGL_CHANT_PROPERTIES (operation); Priv *priv = g_new0 (Priv, 1); o->chant_data = (void*) priv; if (!priv->blur1) { GeglNode *gegl; gegl = operation->node; priv->input = gegl_node_get_input_proxy (gegl, "input"); priv->output = gegl_node_get_output_proxy (gegl, "output"); priv->subtract = gegl_node_new_child (gegl, "operation", "gegl:subtract", NULL); priv->blur1 = gegl_node_new_child (gegl, "operation", "gegl:gaussian-blur", NULL); priv->blur2 = gegl_node_new_child (gegl, "operation", "gegl:gaussian-blur", NULL); gegl_node_link_many (priv->input, priv->blur1, priv->subtract, priv->output, NULL); gegl_node_link (priv->input, priv->blur2); gegl_node_connect_from (priv->subtract, "aux", priv->blur2, "output"); gegl_operation_meta_redirect (operation, "radius1", priv->blur1, "std-dev-x"); gegl_operation_meta_redirect (operation, "radius1", priv->blur1, "std-dev-y"); gegl_operation_meta_redirect (operation, "radius2", priv->blur2, "std-dev-x"); gegl_operation_meta_redirect (operation, "radius2", priv->blur2, "std-dev-y"); } }
/* in attach we hook into graph adding the needed nodes */ static void attach (GeglOperation *operation) { GeglNode *gegl = operation->node; GeglNode *input, *output, *over, *translate, *opacity, *blur, *darken, *color; GeglColor *black_color = gegl_color_new ("rgb(0.0,0.0,0.0)"); input = gegl_node_get_input_proxy (gegl, "input"); output = gegl_node_get_output_proxy (gegl, "output"); over = gegl_node_new_child (gegl, "operation", "gegl:over", NULL); translate = gegl_node_new_child (gegl, "operation", "gegl:translate", NULL); opacity = gegl_node_new_child (gegl, "operation", "gegl:opacity", NULL); blur = gegl_node_new_child (gegl, "operation", "gegl:gaussian-blur", "clip-extent", FALSE, "abyss-policy", 0, NULL); darken = gegl_node_new_child (gegl, "operation", "gegl:src-in", NULL); color = gegl_node_new_child (gegl, "operation", "gegl:color", "value", black_color, NULL); g_object_unref (black_color); gegl_node_link_many (input, darken, blur, opacity, translate, over, output, NULL); gegl_node_connect_from (over, "aux", input, "output"); gegl_node_connect_from (darken, "aux", color, "output"); gegl_operation_meta_redirect (operation, "radius", blur, "std-dev-x"); gegl_operation_meta_redirect (operation, "radius", blur, "std-dev-y"); gegl_operation_meta_redirect (operation, "x", translate, "x"); gegl_operation_meta_redirect (operation, "y", translate, "y"); gegl_operation_meta_redirect (operation, "color", color, "value"); gegl_operation_meta_redirect (operation, "opacity", opacity, "value"); gegl_operation_meta_watch_nodes (operation, over, translate, opacity, blur, darken, color, NULL); }
static void attach (GeglOperation *operation) { JsonOp *self = (JsonOp *)operation; GeglNode *gegl = operation->node; JsonArray *connections; GList *l; // Processes JsonObject *root = self->json_root; JsonObject *processes = json_object_get_object_member(root, "processes"); GList *process_names = json_object_get_members(processes); for (l = process_names; l != NULL; l = l->next) { const gchar *name = l->data; JsonObject *proc = json_object_get_object_member(processes, name); const gchar *component = json_object_get_string_member(proc, "component"); gchar *opname = component2geglop(component); GeglNode *node = gegl_node_new_child (gegl, "operation", opname, NULL); gegl_operation_meta_watch_node (operation, node); g_assert(node); g_hash_table_insert(self->nodes, (gpointer)g_strdup(name), (gpointer)node); g_free(opname); } g_list_free(process_names); // Connections connections = json_object_get_array_member(root, "connections"); g_assert(connections); for (int i=0; i<json_array_get_length(connections); i++) { JsonObject *conn = json_array_get_object_element(connections, i); JsonObject *tgt = json_object_get_object_member(conn, "tgt"); const gchar *tgt_proc = json_object_get_string_member(tgt, "process"); const gchar *tgt_port = json_object_get_string_member(tgt, "port"); GeglNode *tgt_node = g_hash_table_lookup(self->nodes, tgt_proc); JsonNode *srcnode; g_assert(tgt_node); srcnode = json_object_get_member(conn, "src"); if (srcnode) { // Connection JsonObject *src = json_object_get_object_member(conn, "src"); const gchar *src_proc = json_object_get_string_member(src, "process"); const gchar *src_port = json_object_get_string_member(src, "port"); GeglNode *src_node = g_hash_table_lookup(self->nodes, src_proc); g_assert(src_node); gegl_node_connect_to (src_node, src_port, tgt_node, tgt_port); } else { // IIP JsonNode *datanode = json_object_get_member(conn, "data"); GValue value = G_VALUE_INIT; GParamSpec *paramspec; g_assert(JSON_NODE_HOLDS_VALUE(datanode)); json_node_get_value(datanode, &value); paramspec = gegl_node_find_property(tgt_node, tgt_port); set_prop(tgt_node, tgt_port, paramspec, &value); g_value_unset(&value); } } // Exported ports if (json_object_has_member(root, "inports")) { JsonObject *inports = json_object_get_object_member(root, "inports"); GList *inport_names = json_object_get_members(inports); for (l = inport_names; l != NULL; l = l->next) { const gchar *name = l->data; JsonObject *conn = json_object_get_object_member(inports, name); const gchar *proc = json_object_get_string_member(conn, "process"); const gchar *port = json_object_get_string_member(conn, "port"); GeglNode *node = g_hash_table_lookup(self->nodes, proc); g_assert(node); if (g_strcmp0(name, "input") == 0) { GeglNode *input = gegl_node_get_input_proxy (gegl, "input"); gegl_node_connect_to (input, "output", node, "input"); } else { gegl_operation_meta_redirect (operation, name, node, port); } } g_list_free(inport_names); } if (json_object_has_member(root, "outports")) { JsonObject *outports = json_object_get_object_member(root, "outports"); GList *outport_names = json_object_get_members(outports); for (l = outport_names; l != NULL; l = l->next) { const gchar *name = l->data; JsonObject *conn = json_object_get_object_member(outports, name); const gchar *proc = json_object_get_string_member(conn, "process"); const gchar *port = json_object_get_string_member(conn, "port"); GeglNode *node = g_hash_table_lookup(self->nodes, proc); g_assert(node); if (g_strcmp0(name, "output") == 0) { GeglNode *proxy = gegl_node_get_output_proxy (gegl, "output"); gegl_node_connect_to (node, port, proxy, "input"); } else { g_warning("Unsupported output '%s' exported in .json file", name); } } g_list_free(outport_names); } }