diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-02-29 16:08:26 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2012-02-29 16:08:26 +0400 |
commit | d8bdd4497eec824a522062c4a8b597ef25395d63 (patch) | |
tree | c797600b9e618ff184cdf16c36d59a9196d9cc7d /source/blender/editors/space_clip | |
parent | 31cd0521ae64e95982bd4bd4f8685b7cf96d4248 (diff) |
Refactor of proxies build operators
Split proxy build operator into three parts:
- Prepare context (IMB_anim_index_rebuild_context) which prepares all
needed data and stores it in an anonymous structure used by specific
builder lately.
- Build proxies/timecodes into temporary files (IMB_anim_index_rebuild)
This function will build all selected proxies/timecodes into a temporary
files so old proxies will be still available during building.
- Finish building proxies (IMB_anim_index_rebuild_finish) which copies
temporary files over old proxies filed and releases all resources used
by a context.
Context creation and finishing building happens in a main thread so
it's easy and safe to close all opened handles of proxies files and
refresh cache after rebuilding is finished.
This should finally fix #30315: Temporary proxy files are not erased and old proxys are not updated if the proxy is built more then once (windows)
Diffstat (limited to 'source/blender/editors/space_clip')
-rw-r--r-- | source/blender/editors/space_clip/clip_ops.c | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 459f40c64a5..99ee4974659 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -845,7 +845,8 @@ typedef struct ProxyBuildJob { Scene *scene; struct Main *main; MovieClip *clip; - int clip_flag; + int clip_flag, stop; + struct IndexBuildContext *index_context; } ProxyJob; static void proxy_freejob(void *pjv) @@ -896,11 +897,13 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog build_undistort_count= proxy_bitflag_to_array(size_flag, build_undistort_sizes, 1); if(clip->source == MCLIP_SRC_MOVIE) { - if(clip->anim) - IMB_anim_index_rebuild(clip->anim, tc_flag, size_flag, quality, stop, do_update, progress); + if (pj->index_context) + IMB_anim_index_rebuild(pj->index_context, stop, do_update, progress); if(!build_undistort_count) { - BKE_movieclip_reload(clip); + if (*stop) + pj->stop = 1; + return; } else { @@ -928,7 +931,23 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog if(distortion) BKE_tracking_distortion_destroy(distortion); - BKE_movieclip_reload(clip); + if (*stop) + pj->stop = 1; +} + +static void proxy_endjob(void *pjv) +{ + ProxyJob *pj = pjv; + + if (pj->clip->anim) + IMB_close_anim_proxies(pj->clip->anim); + + if (pj->index_context) + IMB_anim_index_rebuild_finish(pj->index_context, pj->stop); + + BKE_movieclip_reload(pj->clip); + + WM_main_add_notifier(NC_MOVIECLIP|ND_DISPLAY, pj->clip); } static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) @@ -951,9 +970,14 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) pj->clip= clip; pj->clip_flag= clip->flag&MCLIP_TIMECODE_FLAGS; + if (clip->anim) { + pj->index_context = IMB_anim_index_rebuild_context(clip->anim, clip->proxy.build_tc_flag, + clip->proxy.build_size_flag, clip->proxy.quality); + } + WM_jobs_customdata(steve, pj, proxy_freejob); WM_jobs_timer(steve, 0.2, NC_MOVIECLIP|ND_DISPLAY, 0); - WM_jobs_callbacks(steve, proxy_startjob, NULL, NULL, NULL); + WM_jobs_callbacks(steve, proxy_startjob, NULL, NULL, proxy_endjob); G.afbreek= 0; WM_jobs_start(CTX_wm_manager(C), steve); |