diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/render/render_preview.c | 5 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_jobs.c | 48 |
3 files changed, 32 insertions, 22 deletions
diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 2dee51ac448..9589c46d726 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -1231,7 +1231,8 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r wmJob *steve; ShaderPreview *sp; - steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner, "Icon Preview", WM_JOB_EXCL_RENDER); + /* suspended start means it starts after 1 timer step, see WM_jobs_timer below */ + steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner, "Icon Preview", WM_JOB_EXCL_RENDER|WM_JOB_SUSPEND); sp= MEM_callocN(sizeof(ShaderPreview), "shader preview"); /* customdata for preview thread */ @@ -1245,7 +1246,7 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r /* setup job */ WM_jobs_customdata(steve, sp, shader_preview_free); - WM_jobs_timer(steve, 0.1, NC_MATERIAL, NC_MATERIAL); + WM_jobs_timer(steve, 0.25, NC_MATERIAL, NC_MATERIAL); WM_jobs_callbacks(steve, common_preview_startjob, NULL, NULL, common_preview_endjob); WM_jobs_start(CTX_wm_manager(C), steve); 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); |