gegl r2970 - in trunk: . gegl/process



Author: martinn
Date: Wed Mar 18 19:36:52 2009
New Revision: 2970
URL: http://svn.gnome.org/viewvc/gegl?rev=2970&view=rev

Log:
Turn GeglEvalMgr::state into an enum

Apply patch from Henrik Akesson that turns GeglEvalMgr::state into an
enum instead of using pure ints since that increases readability.

Modified:
   trunk/ChangeLog
   trunk/gegl/process/gegl-eval-mgr.c
   trunk/gegl/process/gegl-eval-mgr.h

Modified: trunk/gegl/process/gegl-eval-mgr.c
==============================================================================
--- trunk/gegl/process/gegl-eval-mgr.c	(original)
+++ trunk/gegl/process/gegl-eval-mgr.c	Wed Mar 18 19:36:52 2009
@@ -64,7 +64,7 @@
   self->eval_visitor = g_object_new (GEGL_TYPE_EVAL_VISITOR, "id", context_id, NULL);
   self->cr_visitor = g_object_new (GEGL_TYPE_CR_VISITOR, "id", context_id, NULL);
   self->finish_visitor = g_object_new (GEGL_TYPE_FINISH_VISITOR, "id", context_id, NULL);
-  self->state = 0;
+  self->state = UNINITIALIZED;
 }
 
 static void
@@ -114,9 +114,9 @@
         }
     }
 
-  if (mgr->state)
+  if (mgr->state != UNINITIALIZED)
     {
-      mgr->state = 1;
+      mgr->state = NEED_REDO_PREPARE_AND_HAVE_RECT_TRAVERSAL;
     }
 
   return FALSE;
@@ -151,21 +151,21 @@
   /* do the necessary set-up work (all using depth first traversal) */
   switch (self->state)
     {
-      case 0:
+      case UNINITIALIZED:
         /* Set up the node's context and "needed rectangle"*/
         gegl_visitor_reset (self->prepare_visitor);
         gegl_visitor_dfs_traverse (self->prepare_visitor, GEGL_VISITABLE (root));
         /* No idea why there is a second call */
         gegl_visitor_reset (self->prepare_visitor);
         gegl_visitor_dfs_traverse (self->prepare_visitor, GEGL_VISITABLE (root));
-      case 1:
+      case NEED_REDO_PREPARE_AND_HAVE_RECT_TRAVERSAL:
         /* sets up the node's rect (bounding box) */
         gegl_visitor_reset (self->have_visitor);
         gegl_visitor_dfs_traverse (self->have_visitor, GEGL_VISITABLE (root));
-      case 2:
+      case NEED_CONTEXT_SETUP_TRAVERSAL:
         gegl_visitor_reset (self->prepare_visitor);
         gegl_visitor_dfs_traverse (self->prepare_visitor, GEGL_VISITABLE (root));      
-        self->state = 2;
+        self->state = NEED_CONTEXT_SETUP_TRAVERSAL;
      }
 
   /* set up the root node */

Modified: trunk/gegl/process/gegl-eval-mgr.h
==============================================================================
--- trunk/gegl/process/gegl-eval-mgr.h	(original)
+++ trunk/gegl/process/gegl-eval-mgr.h	Wed Mar 18 19:36:52 2009
@@ -25,6 +25,22 @@
 G_BEGIN_DECLS
 
 
+typedef enum
+{
+  UNINITIALIZED,
+
+  /* means we need to redo an extra prepare and have_rect
+   * traversal
+   */
+  NEED_REDO_PREPARE_AND_HAVE_RECT_TRAVERSAL,
+
+  /* means we need a prepare traversal to set up the contexts on the
+   * nodes
+   */
+  NEED_CONTEXT_SETUP_TRAVERSAL
+} GeglEvalMgrStates;
+
+
 #define GEGL_TYPE_EVAL_MGR            (gegl_eval_mgr_get_type ())
 #define GEGL_EVAL_MGR(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_EVAL_MGR, GeglEvalMgr))
 #define GEGL_EVAL_MGR_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  GEGL_TYPE_EVAL_MGR, GeglEvalMgrClass))
@@ -42,14 +58,10 @@
   gchar     *pad_name;
   GeglRectangle roi;
 
-  gint       state; /* whether we can fire off rendering requests straight
-                           away or we have to re-prepare etc the graph
-                           0: mean uninitialized.
-                           1: means we need to redo an extra prepare and
-                              have_rect traversal.
-                           2: means we need a prepare traversal to set
-                              up the contexts on the nodes.
-                         */
+  /* whether we can fire off rendering requests straight
+   * away or we have to re-prepare etc of the graph
+   */
+  GeglEvalMgrStates state;
 
   /* we keep these objects around, they are too expensive to throw away */
   GeglVisitor *prepare_visitor;



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