diff options
author | Ton Roosendaal <ton@blender.org> | 2011-01-04 17:59:55 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2011-01-04 17:59:55 +0300 |
commit | 5db20b512e3d3c87ee9310ba940232109d8e1f60 (patch) | |
tree | f2d203dc9a6b57fae8e87fe6a3a441c8b9dfc9d5 /source/blender/windowmanager | |
parent | becca813d796bca8c59c20b496f24f42277f25c7 (diff) |
Todo item:
New option to start threaded wmJobs, with flag WM_JOB_SUSPEND.
This makes the job wait 1 timer step before running.
Used now for Material Icon render renders, which makes the
big preview to be always rendered first while using UI.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_jobs.c | 48 |
2 files changed, 29 insertions, 20 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 9c3e19ef4b7..a7aad83d471 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -316,6 +316,7 @@ int WM_framebuffer_to_index(unsigned int col); #define WM_JOB_PRIORITY 1 #define WM_JOB_EXCL_RENDER 2 #define WM_JOB_PROGRESS 4 +#define WM_JOB_SUSPEND 8 struct wmJob *WM_jobs_get(struct wmWindowManager *wm, struct wmWindow *win, void *owner, const char *name, int flag); diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index b8dfae63b4d..591ed5c33b5 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -247,33 +247,40 @@ static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test) wmJob *steve; int suspend= 0; - for(steve= wm->jobs.first; steve; steve= steve->next) { - /* obvious case, no test needed */ - if(steve==test || !steve->running) continue; - - /* if new job is not render, then check for same startjob */ - if(0==(test->flag & WM_JOB_EXCL_RENDER)) - if(steve->startjob!=test->startjob) - continue; - - /* if new job is render, any render job should be stopped */ - if(test->flag & WM_JOB_EXCL_RENDER) - if(0==(steve->flag & WM_JOB_EXCL_RENDER)) - continue; - + /* job added with suspend flag, we wait 1 timer step before activating it */ + if(test->flag & WM_JOB_SUSPEND) { suspend= 1; + test->flag &= ~WM_JOB_SUSPEND; + } + else { + /* check other jobs */ + for(steve= wm->jobs.first; steve; steve= steve->next) { + /* obvious case, no test needed */ + if(steve==test || !steve->running) continue; + + /* if new job is not render, then check for same startjob */ + if(0==(test->flag & WM_JOB_EXCL_RENDER)) + if(steve->startjob!=test->startjob) + continue; + + /* if new job is render, any render job should be stopped */ + if(test->flag & WM_JOB_EXCL_RENDER) + if(0==(steve->flag & WM_JOB_EXCL_RENDER)) + continue; - /* if this job has higher priority, stop others */ - if(test->flag & WM_JOB_PRIORITY) { - steve->stop= 1; - // printf("job stopped: %s\n", steve->name); + suspend= 1; + + /* if this job has higher priority, stop others */ + if(test->flag & WM_JOB_PRIORITY) { + steve->stop= 1; + // printf("job stopped: %s\n", steve->name); + } } } - + /* possible suspend ourselfs, waiting for other jobs, or de-suspend */ test->suspended= suspend; // if(suspend) printf("job suspended: %s\n", test->name); - } /* if job running, the same owner gave it a new job */ @@ -286,6 +293,7 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *steve) // printf("job started a running job, ending... %s\n", steve->name); } else { + if(steve->customdata && steve->startjob) { wm_jobs_test_suspend_stop(wm, steve); |