diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/object/object_bake.c | 28 | ||||
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 14 | ||||
-rw-r--r-- | source/blender/editors/physics/physics_fluid.c | 11 | ||||
-rw-r--r-- | source/blender/editors/render/render_internal.c | 12 | ||||
-rw-r--r-- | source/blender/editors/render/render_preview.c | 28 | ||||
-rw-r--r-- | source/blender/editors/screen/screendump.c | 10 | ||||
-rw-r--r-- | source/blender/editors/space_clip/clip_ops.c | 14 | ||||
-rw-r--r-- | source/blender/editors/space_clip/tracking_ops.c | 30 | ||||
-rw-r--r-- | source/blender/editors/space_file/filelist.c | 14 | ||||
-rw-r--r-- | source/blender/editors/space_node/node_edit.c | 14 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_edit.c | 18 | ||||
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 1 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_jobs.c | 327 |
13 files changed, 264 insertions, 257 deletions
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index be0d9e67779..13681407d54 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -1241,7 +1241,7 @@ static int multiresbake_image_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); MultiresBakeJob *bkr; - wmJob *steve; + wmJob *wm_job; if (!multiresbake_check(C, op)) return OPERATOR_CANCELLED; @@ -1255,15 +1255,15 @@ static int multiresbake_image_exec(bContext *C, wmOperator *op) } /* setup job */ - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Multires Bake", - WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE); - WM_jobs_customdata_set(steve, bkr, multiresbake_freejob); - WM_jobs_timer(steve, 0.2, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */ - WM_jobs_callbacks(steve, multiresbake_startjob, NULL, NULL, NULL); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Multires Bake", + WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE); + WM_jobs_customdata_set(wm_job, bkr, multiresbake_freejob); + WM_jobs_timer(wm_job, 0.2, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */ + WM_jobs_callbacks(wm_job, multiresbake_startjob, NULL, NULL, NULL); G.is_break = FALSE; - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); WM_cursor_wait(0); /* add modal handler for ESC */ @@ -1477,22 +1477,22 @@ static int objects_bake_render_invoke(bContext *C, wmOperator *op, wmEvent *UNUS } else { BakeRender *bkr = MEM_callocN(sizeof(BakeRender), "render bake"); - wmJob *steve; + wmJob *wm_job; init_bake_internal(bkr, C); bkr->reports = op->reports; /* setup job */ - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Texture Bake", - WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE); - WM_jobs_customdata_set(steve, bkr, bake_freejob); - WM_jobs_timer(steve, 0.2, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */ - WM_jobs_callbacks(steve, bake_startjob, NULL, bake_update, NULL); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Texture Bake", + WM_JOB_EXCL_RENDER | WM_JOB_PRIORITY | WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE); + WM_jobs_customdata_set(wm_job, bkr, bake_freejob); + WM_jobs_timer(wm_job, 0.2, NC_IMAGE, 0); /* TODO - only draw bake image, can we enforce this */ + WM_jobs_callbacks(wm_job, bake_startjob, NULL, bake_update, NULL); G.is_break = FALSE; G.is_rendering = TRUE; - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); WM_cursor_wait(0); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 556ed44520c..47f5a285374 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -2114,7 +2114,7 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) int f, cfra, i = 0; int free = RNA_boolean_get(op->ptr, "free"); - wmJob *steve; + wmJob *wm_job; OceanBakeJob *oj; if (!omd) @@ -2181,18 +2181,18 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) scene->r.cfra = cfra; /* setup job */ - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Ocean Simulation", - WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_SIM_OCEAN); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Ocean Simulation", + WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_SIM_OCEAN); oj = MEM_callocN(sizeof(OceanBakeJob), "ocean bake job"); oj->ocean = ocean; oj->och = och; oj->omd = omd; - WM_jobs_customdata_set(steve, oj, oceanbake_free); - WM_jobs_timer(steve, 0.1, NC_OBJECT | ND_MODIFIER, NC_OBJECT | ND_MODIFIER); - WM_jobs_callbacks(steve, oceanbake_startjob, NULL, NULL, oceanbake_endjob); + WM_jobs_customdata_set(wm_job, oj, oceanbake_free); + WM_jobs_timer(wm_job, 0.1, NC_OBJECT | ND_MODIFIER, NC_OBJECT | ND_MODIFIER); + WM_jobs_callbacks(wm_job, oceanbake_startjob, NULL, NULL, oceanbake_endjob); - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 60907e8cefa..5b0a58b394a 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -1068,14 +1068,15 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor fb->settings = fsset; if (do_job) { - wmJob *steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Fluid Simulation", WM_JOB_PROGRESS); + wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Fluid Simulation", + WM_JOB_PROGRESS, WM_JOB_TYPE_OBJECT_SIM_FLUID); /* setup job */ - WM_jobs_customdata_set(steve, fb, fluidbake_free); - WM_jobs_timer(steve, 0.1, NC_SCENE|ND_FRAME, NC_SCENE|ND_FRAME); - WM_jobs_callbacks(steve, fluidbake_startjob, NULL, NULL, fluidbake_endjob); + WM_jobs_customdata_set(wm_job, fb, fluidbake_free); + WM_jobs_timer(wm_job, 0.1, NC_SCENE|ND_FRAME, NC_SCENE|ND_FRAME); + WM_jobs_callbacks(wm_job, fluidbake_startjob, NULL, NULL, fluidbake_endjob); - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); } else { short dummy_stop, dummy_do_update; diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index c5467051bb2..ecab47cf67d 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -479,7 +479,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) SceneRenderLayer *srl = NULL; View3D *v3d = CTX_wm_view3d(C); Render *re; - wmJob *steve; + wmJob *wm_job; RenderJob *rj; Image *ima; int jobflag; @@ -564,10 +564,10 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) if (RE_seq_render_active(scene, &scene->r)) name = "Sequence Render"; else name = "Render"; - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, name, jobflag, WM_JOB_TYPE_RENDER); - WM_jobs_customdata_set(steve, rj, render_freejob); - WM_jobs_timer(steve, 0.2, NC_SCENE | ND_RENDER_RESULT, 0); - WM_jobs_callbacks(steve, render_startjob, NULL, NULL, render_endjob); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, name, jobflag, WM_JOB_TYPE_RENDER); + WM_jobs_customdata_set(wm_job, rj, render_freejob); + WM_jobs_timer(wm_job, 0.2, NC_SCENE | ND_RENDER_RESULT, 0); + WM_jobs_callbacks(wm_job, render_startjob, NULL, NULL, render_endjob); /* get a render result image, and make sure it is empty */ ima = BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result"); @@ -592,7 +592,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) */ op->customdata = scene; - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); WM_cursor_wait(0); WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, scene); diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index bdc44af76c8..4f62974a3e1 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -1022,17 +1022,17 @@ static void icon_preview_free(void *customdata) void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *rect, int sizex, int sizey) { - wmJob *steve; + wmJob *wm_job; IconPreview *ip, *old_ip; /* 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, WM_JOB_TYPE_RENDER_PREVIEW); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner, "Icon Preview", + WM_JOB_EXCL_RENDER | WM_JOB_SUSPEND, WM_JOB_TYPE_RENDER_PREVIEW); ip = MEM_callocN(sizeof(IconPreview), "icon preview"); /* render all resolutions from suspended job too */ - old_ip = WM_jobs_customdata_get(steve); + old_ip = WM_jobs_customdata_get(wm_job); if (old_ip) BLI_movelisttolist(&ip->sizes, &old_ip->sizes); @@ -1044,20 +1044,20 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r icon_preview_add_size(ip, rect, sizex, sizey); /* setup job */ - WM_jobs_customdata_set(steve, ip, icon_preview_free); - WM_jobs_timer(steve, 0.25, NC_MATERIAL, NC_MATERIAL); - WM_jobs_callbacks(steve, icon_preview_startjob_all_sizes, NULL, NULL, icon_preview_endjob); + WM_jobs_customdata_set(wm_job, ip, icon_preview_free); + WM_jobs_timer(wm_job, 0.25, NC_MATERIAL, NC_MATERIAL); + WM_jobs_callbacks(wm_job, icon_preview_startjob_all_sizes, NULL, NULL, icon_preview_endjob); - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); } void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, MTex *slot, int sizex, int sizey, int method) { Object *ob = CTX_data_active_object(C); - wmJob *steve; + wmJob *wm_job; ShaderPreview *sp; - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner, "Shader Preview", + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), owner, "Shader Preview", WM_JOB_EXCL_RENDER, WM_JOB_TYPE_RENDER_PREVIEW); sp = MEM_callocN(sizeof(ShaderPreview), "shader preview"); @@ -1074,11 +1074,11 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M else sp->col[0] = sp->col[1] = sp->col[2] = sp->col[3] = 1.0f; /* setup job */ - WM_jobs_customdata_set(steve, sp, shader_preview_free); - WM_jobs_timer(steve, 0.1, NC_MATERIAL, NC_MATERIAL); - WM_jobs_callbacks(steve, common_preview_startjob, NULL, shader_preview_updatejob, NULL); + WM_jobs_customdata_set(wm_job, sp, shader_preview_free); + WM_jobs_timer(wm_job, 0.1, NC_MATERIAL, NC_MATERIAL); + WM_jobs_callbacks(wm_job, common_preview_startjob, NULL, shader_preview_updatejob, NULL); - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); } void ED_preview_kill_jobs(const struct bContext *C) diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 3dd3a28a7e5..41e2f0b16a4 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -396,7 +396,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float static int screencast_exec(bContext *C, wmOperator *op) { bScreen *screen = CTX_wm_screen(C); - wmJob *steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), screen, "Screencast", 0, WM_JOB_TYPE_SCREENCAST); + wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), screen, "Screencast", 0, WM_JOB_TYPE_SCREENCAST); ScreenshotJob *sj = MEM_callocN(sizeof(ScreenshotJob), "screenshot job"); /* setup sj */ @@ -420,11 +420,11 @@ static int screencast_exec(bContext *C, wmOperator *op) BKE_reports_init(&sj->reports, RPT_PRINT); /* setup job */ - WM_jobs_customdata_set(steve, sj, screenshot_freejob); - WM_jobs_timer(steve, 0.1, 0, NC_SCREEN | ND_SCREENCAST); - WM_jobs_callbacks(steve, screenshot_startjob, NULL, screenshot_updatejob, NULL); + WM_jobs_customdata_set(wm_job, sj, screenshot_freejob); + WM_jobs_timer(wm_job, 0.1, 0, NC_SCREEN | ND_SCREENCAST); + WM_jobs_callbacks(wm_job, screenshot_startjob, NULL, screenshot_updatejob, NULL); - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); WM_event_add_notifier(C, NC_SCREEN | ND_SCREENCAST, screen); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index c88ab095b2e..36199b1908d 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -1031,7 +1031,7 @@ static void proxy_endjob(void *pjv) static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) { - wmJob * steve; + wmJob *wm_job; ProxyJob *pj; Scene *scene = CTX_data_scene(C); ScrArea *sa = CTX_wm_area(C); @@ -1041,8 +1041,8 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) if ((clip->flag & MCLIP_USE_PROXY) == 0) return OPERATOR_CANCELLED; - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Building Proxies", - WM_JOB_PROGRESS, WM_JOB_TYPE_CLIP_BUILD_PROXY); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Building Proxies", + WM_JOB_PROGRESS, WM_JOB_TYPE_CLIP_BUILD_PROXY); pj = MEM_callocN(sizeof(ProxyJob), "proxy rebuild job"); pj->scene = scene; @@ -1055,12 +1055,12 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) clip->proxy.build_size_flag, clip->proxy.quality); } - WM_jobs_customdata_set(steve, pj, proxy_freejob); - WM_jobs_timer(steve, 0.2, NC_MOVIECLIP | ND_DISPLAY, 0); - WM_jobs_callbacks(steve, proxy_startjob, NULL, NULL, proxy_endjob); + WM_jobs_customdata_set(wm_job, pj, proxy_freejob); + WM_jobs_timer(wm_job, 0.2, NC_MOVIECLIP | ND_DISPLAY, 0); + WM_jobs_callbacks(wm_job, proxy_startjob, NULL, NULL, proxy_endjob); G.is_break = FALSE; - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); ED_area_tag_redraw(CTX_wm_area(C)); diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 580b23486e8..cbf05026152 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -1235,7 +1235,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve ScrArea *sa = CTX_wm_area(C); SpaceClip *sc = CTX_wm_space_clip(C); MovieClip *clip = ED_space_clip_get_clip(sc); - wmJob *steve; + wmJob *wm_job; int backwards = RNA_boolean_get(op->ptr, "backwards"); int sequence = RNA_boolean_get(op->ptr, "sequence"); @@ -1261,24 +1261,24 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve } /* setup job */ - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Track Markers", - WM_JOB_PROGRESS, WM_JOB_TYPE_CLIP_TRACK_MARKERS); - WM_jobs_customdata_set(steve, tmj, track_markers_freejob); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Track Markers", + WM_JOB_PROGRESS, WM_JOB_TYPE_CLIP_TRACK_MARKERS); + WM_jobs_customdata_set(wm_job, tmj, track_markers_freejob); /* if there's delay set in tracking job, tracking should happen * with fixed FPS. To deal with editor refresh we have to synchronize * tracks from job and tracks in clip. Do this in timer callback * to prevent threading conflicts. */ if (tmj->delay > 0) - WM_jobs_timer(steve, tmj->delay / 1000.0f, NC_MOVIECLIP | NA_EVALUATED, 0); + WM_jobs_timer(wm_job, tmj->delay / 1000.0f, NC_MOVIECLIP | NA_EVALUATED, 0); else - WM_jobs_timer(steve, 0.2, NC_MOVIECLIP | NA_EVALUATED, 0); + WM_jobs_timer(wm_job, 0.2, NC_MOVIECLIP | NA_EVALUATED, 0); - WM_jobs_callbacks(steve, track_markers_startjob, NULL, track_markers_updatejob, NULL); + WM_jobs_callbacks(wm_job, track_markers_startjob, NULL, track_markers_updatejob, NULL); G.is_break = FALSE; - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); WM_cursor_wait(0); /* add modal handler for ESC */ @@ -1468,7 +1468,7 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; MovieTrackingReconstruction *reconstruction = BKE_tracking_get_active_reconstruction(tracking); - wmJob *steve; + wmJob *wm_job; char error_msg[256] = "\0"; if (WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C), WM_JOB_TYPE_ANY)) { @@ -1493,15 +1493,15 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); /* setup job */ - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Solve Camera", - WM_JOB_PROGRESS, WM_JOB_TYPE_CLIP_SOLVE_CAMERA); - WM_jobs_customdata_set(steve, scj, solve_camera_freejob); - WM_jobs_timer(steve, 0.1, NC_MOVIECLIP | NA_EVALUATED, 0); - WM_jobs_callbacks(steve, solve_camera_startjob, NULL, solve_camera_updatejob, NULL); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Solve Camera", + WM_JOB_PROGRESS, WM_JOB_TYPE_CLIP_SOLVE_CAMERA); + WM_jobs_customdata_set(wm_job, scj, solve_camera_freejob); + WM_jobs_timer(wm_job, 0.1, NC_MOVIECLIP | NA_EVALUATED, 0); + WM_jobs_callbacks(wm_job, solve_camera_startjob, NULL, solve_camera_updatejob, NULL); G.is_break = FALSE; - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); WM_cursor_wait(0); /* add modal handler for ESC */ diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 83ddead92dc..eeef6c7908b 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -1346,7 +1346,7 @@ static void thumbnails_free(void *tjv) void thumbnails_start(struct FileList *filelist, const struct bContext *C) { - wmJob *steve; + wmJob *wm_job; ThumbnailJob *tj; int idx; @@ -1368,14 +1368,14 @@ void thumbnails_start(struct FileList *filelist, const struct bContext *C) BKE_reports_init(&tj->reports, RPT_PRINT); /* setup job */ - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), filelist, "Thumbnails", - 0, WM_JOB_TYPE_FILESEL_THUMBNAIL); - WM_jobs_customdata_set(steve, tj, thumbnails_free); - WM_jobs_timer(steve, 0.5, NC_WINDOW, NC_WINDOW); - WM_jobs_callbacks(steve, thumbnails_startjob, NULL, thumbnails_update, NULL); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), filelist, "Thumbnails", + 0, WM_JOB_TYPE_FILESEL_THUMBNAIL); + WM_jobs_customdata_set(wm_job, tj, thumbnails_free); + WM_jobs_timer(wm_job, 0.5, NC_WINDOW, NC_WINDOW); + WM_jobs_callbacks(wm_job, thumbnails_startjob, NULL, thumbnails_update, NULL); /* start the job */ - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); } void thumbnails_stop(struct FileList *filelist, const struct bContext *C) diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 6ef466ba1c3..d34c5f16afa 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -173,7 +173,7 @@ static void compo_startjob(void *cjv, short *stop, short *do_update, float *prog */ void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene *scene_owner) { - wmJob *steve; + wmJob *wm_job; CompoJob *cj; /* to fix bug: [#32272] */ @@ -181,8 +181,8 @@ void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene return; } - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene_owner, "Compositing", - WM_JOB_EXCL_RENDER | WM_JOB_PROGRESS, WM_JOB_TYPE_COMPOSITE); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene_owner, "Compositing", + WM_JOB_EXCL_RENDER | WM_JOB_PROGRESS, WM_JOB_TYPE_COMPOSITE); cj = MEM_callocN(sizeof(CompoJob), "compo job"); /* customdata for preview thread */ @@ -190,11 +190,11 @@ void ED_node_composite_job(const bContext *C, struct bNodeTree *nodetree, Scene cj->ntree = nodetree; /* setup job */ - WM_jobs_customdata_set(steve, cj, compo_freejob); - WM_jobs_timer(steve, 0.1, NC_SCENE, NC_SCENE | ND_COMPO_RESULT); - WM_jobs_callbacks(steve, compo_startjob, compo_initjob, compo_updatejob, NULL); + WM_jobs_customdata_set(wm_job, cj, compo_freejob); + WM_jobs_timer(wm_job, 0.1, NC_SCENE, NC_SCENE | ND_COMPO_RESULT); + WM_jobs_callbacks(wm_job, compo_startjob, compo_initjob, compo_updatejob, NULL); - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); } /* ***************************************** */ diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 66739f83597..5bb3f710133 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -177,7 +177,7 @@ static void proxy_endjob(void *pjv) static void seq_proxy_build_job(const bContext *C) { - wmJob *steve; + wmJob *wm_job; ProxyJob *pj; Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, FALSE); @@ -186,10 +186,10 @@ static void seq_proxy_build_job(const bContext *C) LinkData *link; Sequence *seq; - steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Building Proxies", - WM_JOB_PROGRESS, WM_JOB_TYPE_SEQ_BUILD_PROXY); + wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Building Proxies", + WM_JOB_PROGRESS, WM_JOB_TYPE_SEQ_BUILD_PROXY); - pj = WM_jobs_customdata_get(steve); + pj = WM_jobs_customdata_get(wm_job); if (!pj) { pj = MEM_callocN(sizeof(ProxyJob), "proxy rebuild job"); @@ -197,9 +197,9 @@ static void seq_proxy_build_job(const bContext *C) pj->scene = scene; pj->main = CTX_data_main(C); - WM_jobs_customdata_set(steve, pj, proxy_freejob); - WM_jobs_timer(steve, 0.1, NC_SCENE | ND_SEQUENCER, NC_SCENE | ND_SEQUENCER); - WM_jobs_callbacks(steve, proxy_startjob, NULL, NULL, proxy_endjob); + WM_jobs_customdata_set(wm_job, pj, proxy_freejob); + WM_jobs_timer(wm_job, 0.1, NC_SCENE | ND_SEQUENCER, NC_SCENE | ND_SEQUENCER); + WM_jobs_callbacks(wm_job, proxy_startjob, NULL, NULL, proxy_endjob); } SEQP_BEGIN (ed, seq) @@ -212,9 +212,9 @@ static void seq_proxy_build_job(const bContext *C) } SEQ_END - if (!WM_jobs_is_running(steve)) { + if (!WM_jobs_is_running(wm_job)) { G.is_break = FALSE; - WM_jobs_start(CTX_wm_manager(C), steve); + WM_jobs_start(CTX_wm_manager(C), wm_job); } ED_area_tag_redraw(CTX_wm_area(C)); diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 27507640bdc..588be336afa 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -316,6 +316,7 @@ enum { WM_JOB_TYPE_RENDER_PREVIEW, /* UI preview */ WM_JOB_TYPE_SCREENCAST, WM_JOB_TYPE_OBJECT_SIM_OCEAN, + WM_JOB_TYPE_OBJECT_SIM_FLUID, WM_JOB_TYPE_OBJECT_BAKE_TEXTURE, WM_JOB_TYPE_FILESEL_THUMBNAIL, WM_JOB_TYPE_CLIP_BUILD_PROXY, diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index feca042d2a6..c9fe561e6b0 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -136,13 +136,13 @@ struct wmJob { */ static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const char *name) { - wmJob *steve, *found = NULL; + wmJob *wm_job, *found = NULL; - for (steve = wm->jobs.first; steve; steve = steve->next) - if (steve->owner == owner) { - found = steve; - if (name && strcmp(steve->name, name) == 0) - return steve; + for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) + if (wm_job->owner == owner) { + found = wm_job; + if (name && strcmp(wm_job->name, name) == 0) + return wm_job; } return found; @@ -155,32 +155,32 @@ static wmJob *wm_job_find(wmWindowManager *wm, void *owner, const char *name) * when stopped it starts the new one */ wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, void *owner, const char *name, int flag, int job_type) { - wmJob *steve = wm_job_find(wm, owner, name); + wmJob *wm_job = wm_job_find(wm, owner, name); - if (steve == NULL) { - steve = MEM_callocN(sizeof(wmJob), "new job"); + if (wm_job == NULL) { + wm_job = MEM_callocN(sizeof(wmJob), "new job"); - BLI_addtail(&wm->jobs, steve); - steve->win = win; - steve->owner = owner; - steve->flag = flag; - steve->job_type = job_type; - BLI_strncpy(steve->name, name, sizeof(steve->name)); + BLI_addtail(&wm->jobs, wm_job); + wm_job->win = win; + wm_job->owner = owner; + wm_job->flag = flag; + wm_job->job_type = job_type; + BLI_strncpy(wm_job->name, name, sizeof(wm_job->name)); } - return steve; + return wm_job; } /* returns true if job runs, for UI (progress) indicators */ int WM_jobs_test(wmWindowManager *wm, void *owner, int job_type) { - wmJob *steve; + wmJob *wm_job; /* job can be running or about to run (suspended) */ - for (steve = wm->jobs.first; steve; steve = steve->next) { - if (steve->owner == owner) { - if (job_type == WM_JOB_TYPE_ANY || (steve->job_type == job_type)) { - if (steve->running || steve->suspended) { + for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) { + if (wm_job->owner == owner) { + if (job_type == WM_JOB_TYPE_ANY || (wm_job->job_type == job_type)) { + if (wm_job->running || wm_job->suspended) { return TRUE; } } @@ -192,79 +192,79 @@ int WM_jobs_test(wmWindowManager *wm, void *owner, int job_type) float WM_jobs_progress(wmWindowManager *wm, void *owner) { - wmJob *steve = wm_job_find(wm, owner, NULL); + wmJob *wm_job = wm_job_find(wm, owner, NULL); - if (steve && steve->flag & WM_JOB_PROGRESS) - return steve->progress; + if (wm_job && wm_job->flag & WM_JOB_PROGRESS) + return wm_job->progress; return 0.0; } char *WM_jobs_name(wmWindowManager *wm, void *owner) { - wmJob *steve = wm_job_find(wm, owner, NULL); + wmJob *wm_job = wm_job_find(wm, owner, NULL); - if (steve) - return steve->name; + if (wm_job) + return wm_job->name; return NULL; } -int WM_jobs_is_running(wmJob *steve) +int WM_jobs_is_running(wmJob *wm_job) { - return steve->running; + return wm_job->running; } -void *WM_jobs_customdata_get(wmJob *steve) +void *WM_jobs_customdata_get(wmJob *wm_job) { - if (!steve->customdata) { - return steve->run_customdata; + if (!wm_job->customdata) { + return wm_job->run_customdata; } else { - return steve->customdata; + return wm_job->customdata; } } -void WM_jobs_customdata_set(wmJob *steve, void *customdata, void (*free)(void *)) +void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void (*free)(void *)) { /* pending job? just free */ - if (steve->customdata) - steve->free(steve->customdata); + if (wm_job->customdata) + wm_job->free(wm_job->customdata); - steve->customdata = customdata; - steve->free = free; + wm_job->customdata = customdata; + wm_job->free = free; - if (steve->running) { + if (wm_job->running) { /* signal job to end */ - steve->stop = 1; + wm_job->stop = 1; } } -void WM_jobs_timer(wmJob *steve, double timestep, unsigned int note, unsigned int endnote) +void WM_jobs_timer(wmJob *wm_job, double timestep, unsigned int note, unsigned int endnote) { - steve->timestep = timestep; - steve->note = note; - steve->endnote = endnote; + wm_job->timestep = timestep; + wm_job->note = note; + wm_job->endnote = endnote; } -void WM_jobs_callbacks(wmJob *steve, +void WM_jobs_callbacks(wmJob *wm_job, void (*startjob)(void *, short *, short *, float *), void (*initjob)(void *), void (*update)(void *), void (*endjob)(void *)) { - steve->startjob = startjob; - steve->initjob = initjob; - steve->update = update; - steve->endjob = endjob; + wm_job->startjob = startjob; + wm_job->initjob = initjob; + wm_job->update = update; + wm_job->endjob = endjob; } static void *do_job_thread(void *job_v) { - wmJob *steve = job_v; + wmJob *wm_job = job_v; - steve->startjob(steve->run_customdata, &steve->stop, &steve->do_update, &steve->progress); - steve->ready = 1; + wm_job->startjob(wm_job->run_customdata, &wm_job->stop, &wm_job->do_update, &wm_job->progress); + wm_job->ready = 1; return NULL; } @@ -272,7 +272,7 @@ static void *do_job_thread(void *job_v) /* don't allow same startjob to be executed twice */ static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test) { - wmJob *steve; + wmJob *wm_job; int suspend = 0; /* job added with suspend flag, we wait 1 timer step before activating it */ @@ -282,26 +282,26 @@ static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test) } else { /* check other jobs */ - for (steve = wm->jobs.first; steve; steve = steve->next) { + for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) { /* obvious case, no test needed */ - if (steve == test || !steve->running) continue; + if (wm_job == test || !wm_job->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) + if (wm_job->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)) + if (0 == (wm_job->flag & WM_JOB_EXCL_RENDER)) continue; 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); + wm_job->stop = 1; + // printf("job stopped: %s\n", wm_job->name); } } } @@ -313,110 +313,113 @@ static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test) /* if job running, the same owner gave it a new job */ /* if different owner starts existing startjob, it suspends itself */ -void WM_jobs_start(wmWindowManager *wm, wmJob *steve) +void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job) { - if (steve->running) { + if (wm_job->running) { /* signal job to end and restart */ - steve->stop = 1; - // printf("job started a running job, ending... %s\n", steve->name); + wm_job->stop = 1; + // printf("job started a running job, ending... %s\n", wm_job->name); } else { - if (steve->customdata && steve->startjob) { + if (wm_job->customdata && wm_job->startjob) { - wm_jobs_test_suspend_stop(wm, steve); + wm_jobs_test_suspend_stop(wm, wm_job); - if (steve->suspended == 0) { + if (wm_job->suspended == 0) { /* copy to ensure proper free in end */ - steve->run_customdata = steve->customdata; - steve->run_free = steve->free; - steve->free = NULL; - steve->customdata = NULL; - steve->running = 1; + wm_job->run_customdata = wm_job->customdata; + wm_job->run_free = wm_job->free; + wm_job->free = NULL; + wm_job->customdata = NULL; + wm_job->running = 1; - if (steve->initjob) - steve->initjob(steve->run_customdata); + if (wm_job->initjob) + wm_job->initjob(wm_job->run_customdata); - steve->stop = 0; - steve->ready = 0; - steve->progress = 0.0; + wm_job->stop = 0; + wm_job->ready = 0; + wm_job->progress = 0.0; - // printf("job started: %s\n", steve->name); + // printf("job started: %s\n", wm_job->name); - BLI_init_threads(&steve->threads, do_job_thread, 1); - BLI_insert_thread(&steve->threads, steve); + BLI_init_threads(&wm_job->threads, do_job_thread, 1); + BLI_insert_thread(&wm_job->threads, wm_job); } /* restarted job has timer already */ - if (steve->wt == NULL) - steve->wt = WM_event_add_timer(wm, steve->win, TIMERJOBS, steve->timestep); + if (wm_job->wt == NULL) + wm_job->wt = WM_event_add_timer(wm, wm_job->win, TIMERJOBS, wm_job->timestep); if (G.debug & G_DEBUG_JOBS) - steve->start_time = PIL_check_seconds_timer(); + wm_job->start_time = PIL_check_seconds_timer(); } else printf("job fails, not initialized\n"); } } /* stop job, free data completely */ -static void wm_jobs_kill_job(wmWindowManager *wm, wmJob *steve) +static void wm_jobs_kill_job(wmWindowManager *wm, wmJob *wm_job) { - if (steve->running) { + if (wm_job->running) { /* signal job to end */ - steve->stop = 1; - BLI_end_threads(&steve->threads); + wm_job->stop = 1; + BLI_end_threads(&wm_job->threads); - if (steve->endjob) - steve->endjob(steve->run_customdata); + if (wm_job->endjob) + wm_job->endjob(wm_job->run_customdata); } - if (steve->wt) - WM_event_remove_timer(wm, steve->win, steve->wt); - if (steve->customdata) - steve->free(steve->customdata); - if (steve->run_customdata) - steve->run_free(steve->run_customdata); + if (wm_job->wt) + WM_event_remove_timer(wm, wm_job->win, wm_job->wt); + if (wm_job->customdata) + wm_job->free(wm_job->customdata); + if (wm_job->run_customdata) + wm_job->run_free(wm_job->run_customdata); - /* remove steve */ - BLI_remlink(&wm->jobs, steve); - MEM_freeN(steve); + /* remove wm_job */ + BLI_remlink(&wm->jobs, wm_job); + MEM_freeN(wm_job); } void WM_jobs_stop_all(wmWindowManager *wm) { - wmJob *steve; + wmJob *wm_job; - while ((steve = wm->jobs.first)) - wm_jobs_kill_job(wm, steve); + while ((wm_job = wm->jobs.first)) + wm_jobs_kill_job(wm, wm_job); } /* signal job(s) from this owner or callback to stop, timer is required to get handled */ void WM_jobs_stop(wmWindowManager *wm, void *owner, void *startjob) { - wmJob *steve; + wmJob *wm_job; - for (steve = wm->jobs.first; steve; steve = steve->next) - if (steve->owner == owner || steve->startjob == startjob) - if (steve->running) - steve->stop = 1; + for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) { + if (wm_job->owner == owner || wm_job->startjob == startjob) { + if (wm_job->running) { + wm_job->stop = 1; + } + } + } } /* actually terminate thread and job timer */ void WM_jobs_kill(wmWindowManager *wm, void *owner, void (*startjob)(void *, short int *, short int *, float *)) { - wmJob *steve; + wmJob *wm_job; - steve = wm->jobs.first; - while (steve) { - if (steve->owner == owner || steve->startjob == startjob) { - wmJob *bill = steve; - steve = steve->next; + wm_job = wm->jobs.first; + while (wm_job) { + if (wm_job->owner == owner || wm_job->startjob == startjob) { + wmJob *bill = wm_job; + wm_job = wm_job->next; wm_jobs_kill_job(wm, bill); } else { - steve = steve->next; + wm_job = wm_job->next; } } } @@ -425,11 +428,11 @@ void WM_jobs_kill(wmWindowManager *wm, void *owner, void (*startjob)(void *, sho /* kill job entirely, also removes timer itself */ void wm_jobs_timer_ended(wmWindowManager *wm, wmTimer *wt) { - wmJob *steve; + wmJob *wm_job; - for (steve = wm->jobs.first; steve; steve = steve->next) { - if (steve->wt == wt) { - wm_jobs_kill_job(wm, steve); + for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) { + if (wm_job->wt == wt) { + wm_jobs_kill_job(wm, wm_job); return; } } @@ -438,85 +441,85 @@ void wm_jobs_timer_ended(wmWindowManager *wm, wmTimer *wt) /* hardcoded to event TIMERJOBS */ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) { - wmJob *steve = wm->jobs.first, *stevenext; + wmJob *wm_job, *wm_jobnext; float total_progress = 0.f; float jobs_progress = 0; - for (; steve; steve = stevenext) { - stevenext = steve->next; + for (wm_job = wm->jobs.first; wm_job; wm_job = wm_jobnext) { + wm_jobnext = wm_job->next; - if (steve->wt == wt) { + if (wm_job->wt == wt) { /* running threads */ - if (steve->threads.first) { + if (wm_job->threads.first) { /* always call note and update when ready */ - if (steve->do_update || steve->ready) { - if (steve->update) - steve->update(steve->run_customdata); - if (steve->note) - WM_event_add_notifier(C, steve->note, NULL); + if (wm_job->do_update || wm_job->ready) { + if (wm_job->update) + wm_job->update(wm_job->run_customdata); + if (wm_job->note) + WM_event_add_notifier(C, wm_job->note, NULL); - if (steve->flag & WM_JOB_PROGRESS) + if (wm_job->flag & WM_JOB_PROGRESS) WM_event_add_notifier(C, NC_WM | ND_JOB, NULL); - steve->do_update = FALSE; + wm_job->do_update = FALSE; } - if (steve->ready) { - if (steve->endjob) - steve->endjob(steve->run_customdata); + if (wm_job->ready) { + if (wm_job->endjob) + wm_job->endjob(wm_job->run_customdata); /* free own data */ - steve->run_free(steve->run_customdata); - steve->run_customdata = NULL; - steve->run_free = NULL; + wm_job->run_free(wm_job->run_customdata); + wm_job->run_customdata = NULL; + wm_job->run_free = NULL; - // if (steve->stop) printf("job ready but stopped %s\n", steve->name); - // else printf("job finished %s\n", steve->name); + // if (wm_job->stop) printf("job ready but stopped %s\n", wm_job->name); + // else printf("job finished %s\n", wm_job->name); if (G.debug & G_DEBUG_JOBS) { - printf("Job '%s' finished in %f seconds\n", steve->name, - PIL_check_seconds_timer() - steve->start_time); + printf("Job '%s' finished in %f seconds\n", wm_job->name, + PIL_check_seconds_timer() - wm_job->start_time); } - steve->running = 0; - BLI_end_threads(&steve->threads); + wm_job->running = 0; + BLI_end_threads(&wm_job->threads); - if (steve->endnote) - WM_event_add_notifier(C, steve->endnote, NULL); + if (wm_job->endnote) + WM_event_add_notifier(C, wm_job->endnote, NULL); WM_event_add_notifier(C, NC_WM | ND_JOB, NULL); - /* new job added for steve? */ - if (steve->customdata) { - // printf("job restarted with new data %s\n", steve->name); - WM_jobs_start(wm, steve); + /* new job added for wm_job? */ + if (wm_job->customdata) { + // printf("job restarted with new data %s\n", wm_job->name); + WM_jobs_start(wm, wm_job); } else { - WM_event_remove_timer(wm, steve->win, steve->wt); - steve->wt = NULL; + WM_event_remove_timer(wm, wm_job->win, wm_job->wt); + wm_job->wt = NULL; - /* remove steve */ - BLI_remlink(&wm->jobs, steve); - MEM_freeN(steve); + /* remove wm_job */ + BLI_remlink(&wm->jobs, wm_job); + MEM_freeN(wm_job); } } - else if (steve->flag & WM_JOB_PROGRESS) { + else if (wm_job->flag & WM_JOB_PROGRESS) { /* accumulate global progress for running jobs */ jobs_progress++; - total_progress += steve->progress; + total_progress += wm_job->progress; } } - else if (steve->suspended) { - WM_jobs_start(wm, steve); + else if (wm_job->suspended) { + WM_jobs_start(wm, wm_job); } } - else if (steve->threads.first && !steve->ready) { - if (steve->flag & WM_JOB_PROGRESS) { + else if (wm_job->threads.first && !wm_job->ready) { + if (wm_job->flag & WM_JOB_PROGRESS) { /* accumulate global progress for running jobs */ jobs_progress++; - total_progress += steve->progress; + total_progress += wm_job->progress; } } } @@ -536,11 +539,13 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) int WM_jobs_has_running(wmWindowManager *wm) { - wmJob *steve; + wmJob *wm_job; - for (steve = wm->jobs.first; steve; steve = steve->next) - if (steve->running) + for (wm_job = wm->jobs.first; wm_job; wm_job = wm_job->next) { + if (wm_job->running) { return 1; + } + } return 0; } |