Compositor should never add notifiers by himself, notifiers should be added
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 30 Nov 2012 09:12:10 +0000 (09:12 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 30 Nov 2012 09:12:10 +0000 (09:12 +0000)
from main thread using job update callback.

Added new execution-time callback to bNodeTree which marks job to be updated.

The code here could be a bit not so obvious because in some cases job update
callback need to merge local tree, but it's only needed for old compositor
system which is gonna to be removed soon, so decided not to bother with
cleanup now. Removing old compositor system will also allow to drop stats_draw
callback from bNodeTree.

This should fix following bugs:

source/blender/compositor/intern/COM_ExecutionGroup.cpp
source/blender/compositor/intern/COM_NodeOperation.h
source/blender/compositor/operations/COM_ViewerBaseOperation.cpp
source/blender/editors/space_node/node_edit.c
source/blender/makesdna/DNA_node_types.h

index 0553aebbba651369a62201c53dc400040b2a23a5..7095ccd57b74159955bd227a7e6e3509c743fedd 100644 (file)
@@ -352,7 +352,7 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
                                startEvaluated = true;
                                numberEvaluated++;
 
-                               WM_main_add_notifier(NC_WINDOW | ND_DRAW, NULL);
+                               bTree->update_draw(bTree->udh);
                        }
                        else if (state == COM_ES_SCHEDULED) {
                                finished = false;
index 42d90eca38f2818465be2d42009bf6ba0bc8d11d..b0cc24fc487ab9b2bafae88e31ff5e3fa2136adb 100644 (file)
@@ -77,7 +77,7 @@ private:
        ThreadMutex m_mutex;
        
        /**
-        * @brief reference to the editing bNodeTree only used for break callback
+        * @brief reference to the editing bNodeTree, used for break and update callback
         */
        const bNodeTree *m_btree;
 
@@ -247,6 +247,9 @@ public:
                return this->m_btree->test_break(this->m_btree->tbh);
        }
 
+       inline void updateDraw() {
+               this->m_btree->update_draw(this->m_btree->udh);
+       }
 protected:
        NodeOperation();
 
index cc313512316a2e6a203ca79002c8fb1c9721f1bf..d5f2c283c72a18e806720ec88405cfce37f047ca 100644 (file)
@@ -103,7 +103,7 @@ void ViewerBaseOperation:: updateImage(rcti *rect)
                                          this->m_viewSettings, this->m_displaySettings,
                                          rect->xmin, rect->ymin, rect->xmax, rect->ymax, FALSE);
 
-       WM_main_add_notifier(NC_WINDOW | ND_DRAW, NULL);
+       this->updateDraw();
 }
 
 void ViewerBaseOperation::deinitExecution()
index fd6d9ba80235ca0bcf132aaaad14149957646980..f757345bdcb01c1ce29a3a5a7caa66585ea0435f 100644 (file)
@@ -86,6 +86,7 @@ typedef struct CompoJob {
        short *stop;
        short *do_update;
        float *progress;
+       short need_sync;
 } CompoJob;
 
 /* called by compo, only to check job 'stop' value */
@@ -102,8 +103,17 @@ static int compo_breakjob(void *cjv)
                );
 }
 
+/* called by compo, wmJob sends notifier, old compositor system only */
+static void compo_statsdrawjob(void *cjv, char *UNUSED(str))
+{
+       CompoJob *cj = cjv;
+       
+       *(cj->do_update) = TRUE;
+       cj->need_sync = TRUE;
+}
+
 /* called by compo, wmJob sends notifier */
-static void compo_redrawjob(void *cjv, char *UNUSED(str))
+static void compo_redrawjob(void *cjv)
 {
        CompoJob *cj = cjv;
        
@@ -133,8 +143,15 @@ static void compo_initjob(void *cjv)
 static void compo_updatejob(void *cjv)
 {
        CompoJob *cj = cjv;
-       
-       ntreeLocalSync(cj->localtree, cj->ntree);
+
+       if (cj->need_sync) {
+               /* was used by old compositor system only */
+               ntreeLocalSync(cj->localtree, cj->ntree);
+
+               cj->need_sync = FALSE;
+       }
+
+       WM_main_add_notifier(NC_WINDOW | ND_DRAW, NULL);
 }
 
 static void compo_progressjob(void *cjv, float progress)
@@ -161,11 +178,13 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog
 
        ntree->test_break = compo_breakjob;
        ntree->tbh = cj;
-       ntree->stats_draw = compo_redrawjob;
+       ntree->stats_draw = compo_statsdrawjob;
        ntree->sdh = cj;
        ntree->progress = compo_progressjob;
        ntree->prh = cj;
-       
+       ntree->update_draw = compo_redrawjob;
+       ntree->udh = cj;
+
        // XXX BIF_store_spare();
        
        ntreeCompositExecTree(ntree, &cj->scene->r, 0, 1, &scene->view_settings, &scene->display_settings);  /* 1 is do_previews */
index 1684cf28b3c20b31592928082de31694e9c9e056..a05ff66e68324da089a368626dc1b543848ea610 100644 (file)
@@ -294,7 +294,8 @@ typedef struct bNodeTree {
        void (*progress)(void *, float progress);
        void (*stats_draw)(void *, char *str);
        int (*test_break)(void *);
-       void *tbh, *prh, *sdh;
+       void (*update_draw)(void *);
+       void *tbh, *prh, *sdh, *udh;
        
 } bNodeTree;