Compositor should never add notifiers by himself, notifiers should be added

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:
This commit is contained in:
Sergey Sharybin 2012-11-30 09:12:10 +00:00
parent ceedd5bd35
commit 323e86694e
5 changed files with 32 additions and 9 deletions

@ -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;

@ -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();

@ -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()

@ -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 */

@ -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;