[gegl] gegl-serialize: start handling relative coordinates



commit d71c47b3d31591f8b077300ca8917bc7d0af41fa
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Mar 30 16:20:48 2016 +0200

    gegl-serialize: start handling relative coordinates

 bin/ui.c              |   14 --------------
 gegl/gegl-serialize.c |   46 ++++++++++++++++++++++++++++++++++------------
 gegl/gegl-xml.c       |    7 +++++++
 3 files changed, 41 insertions(+), 26 deletions(-)
---
diff --git a/bin/ui.c b/bin/ui.c
index 3ae2d9e..e797831 100644
--- a/bin/ui.c
+++ b/bin/ui.c
@@ -93,7 +93,6 @@ static void sdl_add_audio_sample (int sample_pos, float left, float right)
 
 static int audio_started = 0;
 
-
 /*  this structure contains the full application state, and is what
  *  re-renderings of the UI is directly based on.
  */
@@ -101,12 +100,9 @@ typedef struct _State State;
 struct _State {
   void      (*ui) (Mrg *mrg, void *state);
   Mrg        *mrg;
-
   char       *path;
   char       *save_path;
-
   GList      *paths;
-
   GeglBuffer *buffer;
   GeglNode   *gegl;
   GeglNode   *sink;
@@ -114,37 +110,27 @@ struct _State {
   GeglNode   *load;
   GeglNode   *save;
   GeglNode   *active;
-
   GeglNode   *rotate;
-
   int         rev;
   float       u, v;
   float       scale;
   int         show_actions;
   int         show_controls;
-
   float       render_quality;
   float       preview_quality;
-
   int         controls_timeout;
-
   char      **ops; // the operations part of the commandline, if any
-
   float       slide_pause;
   int         slide_enabled;
   int         slide_timeout;
-
   GeglNode   *gegl_decode;
   GeglNode   *decode_load;
   GeglNode   *decode_store;
-
   int         is_video;
   int         frame_no;
-
   int         prev_frame_played;
 };
 
-
 typedef struct ActionData {
   const char *label;
   float priority; /* XXX: not yey used, should force scale/crop to happen early */
diff --git a/gegl/gegl-serialize.c b/gegl/gegl-serialize.c
index 1743723..7128838 100644
--- a/gegl/gegl-serialize.c
+++ b/gegl/gegl-serialize.c
@@ -49,8 +49,16 @@ void gegl_create_chain_argv (char **ops, GeglNode *start, GeglNode *proxy, doubl
         {
           value = eq + 1;
           value[-1] = '\0';
-          gegl_curve_add_point (curve, g_strtod (key, NULL),
-                                       g_strtod (value, NULL));
+          if (strstr (value, "rel"))
+          {
+            gegl_curve_add_point (curve, g_strtod (key, NULL),
+              g_strtod (value, NULL) * gegl_node_get_bounding_box (iter[0]).height);
+          }
+          else
+          {
+            gegl_curve_add_point (curve, g_strtod (key, NULL),
+                                         g_strtod (value, NULL));
+          }
         }
         else
         {
@@ -74,7 +82,7 @@ void gegl_create_chain_argv (char **ops, GeglNode *start, GeglNode *proxy, doubl
 
           gegl_node_set (new, prop, gegl_curve_calc_value (
               g_object_get_qdata (G_OBJECT (new),
-                  g_quark_from_static_string(prop)), time), NULL);
+                  g_quark_from_string(prop)), time), NULL);
           /* set interpolated values to initially passed in time */
 
           in_keyframes = 0;
@@ -101,7 +109,7 @@ void gegl_create_chain_argv (char **ops, GeglNode *start, GeglNode *proxy, doubl
             g_free (prop);
           prop = g_strdup (key);
 
-          g_object_set_qdata_full (G_OBJECT (new), g_quark_from_static_string(key), curve, g_object_unref);
+          g_object_set_qdata_full (G_OBJECT (new), g_quark_from_string(key), curve, g_object_unref);
 
           g_free (key);
         }
@@ -171,12 +179,27 @@ void gegl_create_chain_argv (char **ops, GeglNode *start, GeglNode *proxy, doubl
                 g_type_is_a (target_type, G_TYPE_FLOAT) ||
                 g_type_is_a (target_type, G_TYPE_INT))
               {
-                if (g_type_is_a (target_type, G_TYPE_INT))
-                  gegl_node_set (iter[level], key, 
-                     (int)g_strtod (value, NULL), NULL);
+                if (strstr (value, "rel"))
+                {
+                   g_object_set_qdata_full (G_OBJECT (new), g_quark_from_string(key), g_strdup (value), 
g_free);
+
+                  if (g_type_is_a (target_type, G_TYPE_INT))
+                    gegl_node_set (iter[level], key, 
+                       (int)(g_strtod (value, NULL) * gegl_node_get_bounding_box (iter[0]).height), NULL);
+                  else
+                    gegl_node_set (iter[level], key, 
+                       g_strtod (value, NULL) * gegl_node_get_bounding_box (iter[0]).height, NULL);
+
+                }
                 else
-                  gegl_node_set (iter[level], key, 
-                     g_strtod (value, NULL), NULL);
+                {
+                  if (g_type_is_a (target_type, G_TYPE_INT))
+                    gegl_node_set (iter[level], key, 
+                       (int)g_strtod (value, NULL), NULL);
+                  else
+                    gegl_node_set (iter[level], key, 
+                       g_strtod (value, NULL), NULL);
+                }
               }
             else if (g_type_is_a (target_type, G_TYPE_BOOLEAN))
             {
@@ -208,8 +231,8 @@ void gegl_create_chain_argv (char **ops, GeglNode *start, GeglNode *proxy, doubl
                 }
               else
                 {
-              /* warn, but try to get a valid nick out of the old-style
-               * value name
+              /* warn, but try to get a valid nick out of the old-style value
+               * name
                */
                 gchar *nick;
                 gchar *c;
@@ -327,7 +350,6 @@ gchar *gegl_serialize (GeglNode *start, GeglNode *end)
     {
       GString *s2 = g_string_new ("");
       g_string_append_printf (s2, " %s", gegl_node_get_operation (iter));
-
       {
         gint i;
         guint n_properties;
diff --git a/gegl/gegl-xml.c b/gegl/gegl-xml.c
index 03ee66d..5260614 100644
--- a/gegl/gegl-xml.c
+++ b/gegl/gegl-xml.c
@@ -28,6 +28,7 @@
 #include "property-types/gegl-paramspecs.h"
 #include "gegl-instrument.h"
 #include "gegl-xml.h"
+#include "gegl-audio-fragment.h"
 
 #ifdef G_OS_WIN32
 #define realpath(a, b)    _fullpath (b, a, _MAX_PATH)
@@ -931,6 +932,12 @@ serialize_properties (SerializeState *ss,
                 value = "";
               xml_param (ss, indent + 2, properties[i]->name, value);
             }
+          else if (properties[i]->value_type == GEGL_TYPE_AUDIO_FRAGMENT)
+            {
+            }
+          else if (properties[i]->value_type == GEGL_TYPE_BUFFER)
+            {
+            }
           else
             {
               g_warning ("%s: serialization of %s properties not implemented",


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]