1414 * License along with GEGL; if not, see <https://www.gnu.org/licenses/>.
1515 *
1616 * Copyright 2006 Øyvind Kolås <pippin@gimp.org>
17+ * 2022 Beaver (GEGL Bevel)
1718 */
1819
1920#include "config.h"
2021#include <glib/gi18n-lib.h>
2122
2223#ifdef GEGL_PROPERTIES
2324
25+ property_boolean (effectsswitchbevel , _ ("Enable Bevel (FOR GEGL EFFECTS ONLY)" ), TRUE)
26+ description (_ ("This switch exist for GEGL Effects testing. You won't find it in stand alone bevel'" ))
27+ ui_meta ("role" , "output-extent" )
2428
29+ property_boolean (embossmode , _ ("Emboss Mode (use Gimp's layer Grain Merge blend mode)" ), FALSE)
30+ description (_ ("Make an embossed bevel'" ))
2531
26- property_double (radius1 , _ ("Radius" ), 7.0 )
32+
33+
34+
35+
36+
37+
38+
39+ property_double (radius1 , _ ("Radius Normal Bevel" ), 7.0 )
2740 value_range (1.0 , 40.0 )
2841 ui_range (1.0 , 12 )
2942 ui_gamma (1.5 )
3043
44+ property_int (radius2 , _ ("Radius Sharp Bevel" ), 0 )
45+ description (_ ("Box Blur -0 means disabled by default" ))
46+ value_range (0 , 8 )
47+ ui_range (0 , 8 )
48+ ui_gamma (1.5 )
3149
3250
3351property_double (bevel1 , _ ("Depth Angle" ), 90.0 )
@@ -59,10 +77,23 @@ property_double (azimuth, _("Rotate Lighting"), 40.0)
5977
6078#include "gegl-op.h"
6179
80+
81+ typedef struct
82+ {
83+ GeglNode * input ;
84+ GeglNode * blur ;
85+ GeglNode * boxblur ;
86+ GeglNode * emb ;
87+ GeglNode * th ;
88+ GeglNode * output ;
89+ } State ;
90+
91+
6292static void attach (GeglOperation * operation )
6393{
6494 GeglNode * gegl = operation -> node ;
65- GeglNode * input , * output , * blur , * emb , * th ;
95+ GeglProperties * o = GEGL_PROPERTIES (operation );
96+ GeglNode * input , * output , * boxblur , * blur , * emb , * th ;
6697
6798 input = gegl_node_get_input_proxy (gegl , "input" );
6899 output = gegl_node_get_output_proxy (gegl , "output" );
@@ -71,6 +102,12 @@ static void attach (GeglOperation *operation)
71102 "operation" , "gegl:gaussian-blur" ,
72103 NULL );
73104
105+ boxblur = gegl_node_new_child (gegl ,
106+ "operation" , "gegl:box-blur" ,
107+ NULL );
108+
109+
110+
74111
75112 emb = gegl_node_new_child (gegl ,
76113 "operation" , "gegl:emboss" ,
@@ -82,40 +119,72 @@ static void attach (GeglOperation *operation)
82119
83120
84121
85- gegl_node_link_many (input , blur , emb , th , output , NULL );
86-
122+ gegl_node_link_many (input , blur , boxblur , emb , th , output , NULL );
87123 gegl_operation_meta_redirect (operation , "radius1" , blur , "std-dev-x" );
88124 gegl_operation_meta_redirect (operation , "radius1" , blur , "std-dev-y" );
89-
90- gegl_operation_meta_redirect (operation , "bevelhidden" , emb , "" );
91-
92125 gegl_operation_meta_redirect (operation , "bevel1" , emb , "elevation" );
93-
94126 gegl_operation_meta_redirect (operation , "bevel2" , emb , "depth" );
95-
96127 gegl_operation_meta_redirect (operation , "azimuth" , emb , "azimuth" );
128+ gegl_operation_meta_redirect (operation , "radius2" , boxblur , "radius" );
129+ gegl_operation_meta_redirect (operation , "th" , th , "value" );
97130
98131
99- gegl_operation_meta_redirect (operation , "th" , th , "value" );
100132
101133
134+ /* Now save points to the various gegl nodes so we can rewire them in
135+ * update_graph() later
136+ */
137+ State * state = g_malloc0 (sizeof (State ));
138+ state -> input = input ;
139+ state -> blur = blur ;
140+ state -> boxblur = boxblur ;
141+ state -> emb = emb ;
142+ state -> th = th ;
143+ state -> output = output ;
144+ o -> user_data = state ;
102145}
103146
104147static void
105- gegl_op_class_init ( GeglOpClass * klass )
148+ update_graph ( GeglOperation * operation )
106149{
107- GeglOperationClass * operation_class ;
150+ GeglProperties * o = GEGL_PROPERTIES (operation );
151+ State * state = o -> user_data ;
152+ if (!state ) return ;
153+
154+ if (o -> effectsswitchbevel )
155+ if (o -> embossmode )
156+ {
157+ gegl_node_link_many (state -> blur , state -> boxblur , state -> emb , state -> output , NULL );
158+ }
159+ else
160+ {
161+ gegl_node_link_many (state -> blur , state -> boxblur , state -> emb , state -> th , state -> output , NULL );
162+ }
163+ else
164+ {
165+ gegl_node_link_many (state -> input , state -> output , NULL );
166+ }
167+ }
108168
109- operation_class = GEGL_OPERATION_CLASS (klass );
169+
170+
171+
172+
173+ static void
174+ gegl_op_class_init (GeglOpClass * klass )
175+ {
176+ GeglOperationClass * operation_class = GEGL_OPERATION_CLASS (klass );
177+ GeglOperationMetaClass * operation_meta_class = GEGL_OPERATION_META_CLASS (klass );
110178
111179 operation_class -> attach = attach ;
180+ operation_meta_class -> update = update_graph ;
112181
113182 gegl_operation_class_set_keys (operation_class ,
114183 "name" , "gegl:bevel" ,
115184 "title" , _ ("Bevel" ),
116185 "categories" , "Aristic" ,
117186 "reference-hash" , "45ed5656a28a512570f0f25sb2ac" ,
118- "description" , _ ("Bevel Images using GEGL. Use the multiply blend mode "
187+ "description" , _ ("You are expected to use GEGL or Gimp blend modes with this plugin. Works best with blend modes multiply and grain merge. Emboss mode requires non-GEGL Gimp blend modes "
119188 "" ),
120189 NULL );
121190}
0 commit comments