diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2015-04-24 17:58:59 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2015-04-24 17:58:59 +0300 |
commit | 544f6dd9b6978e221b1c9ae9305d615bc0742a81 (patch) | |
tree | bab15cee424f2c20f27218c8d4b3f7a1be155120 /source/blender/editors/animation | |
parent | 8c5a9cc8df8db91d64632be29e6b16f41bed985a (diff) |
Animation scrubbing - optimization attempt
Experiment for animators to try - only do full notification of scene at
end of scrubbing, do only manual area update instead like we do for
animation. Also skip audio update unless we do audio scrubbing.
Diffstat (limited to 'source/blender/editors/animation')
-rw-r--r-- | source/blender/editors/animation/anim_ops.c | 61 |
1 files changed, 53 insertions, 8 deletions
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 47eafcbaed1..22eda47482d 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -90,10 +90,11 @@ static int change_frame_poll(bContext *C) } /* Set the new frame number */ -static void change_frame_apply(bContext *C, wmOperator *op) +static void change_frame_apply(bContext *C, wmOperator *op, bool final) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); + ARegion *ar_op = CTX_wm_region(C); int frame = RNA_int_get(op->ptr, "frame"); bool do_snap = RNA_boolean_get(op->ptr, "snap"); @@ -107,8 +108,46 @@ static void change_frame_apply(bContext *C, wmOperator *op) SUBFRA = 0.0f; /* do updates */ - BKE_sound_seek_scene(bmain, scene); - WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); + + if (final) { + BKE_sound_seek_scene(bmain, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); + } + else + { + bScreen *screen = CTX_wm_screen(C); + wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *window; + ScrArea *sa; + /* since we follow drawflags, we can't send notifier but tag regions ourselves */ + /* only do audio if scrubbing */ + if (scene->audio.flag & AUDIO_SCRUB) + BKE_sound_seek_scene(bmain, scene); + + ED_update_for_newframe(bmain, scene, 1); + + for (window = wm->windows.first; window; window = window->next) { + for (sa = window->screen->areabase.first; sa; sa = sa->next) { + ARegion *ar; + for (ar = sa->regionbase.first; ar; ar = ar->next) { + bool redraw = false; + if (ar == ar_op) { + redraw = true; + } + else if (ED_match_region_with_redraws(sa->spacetype, ar->regiontype, screen->redraws_flag)) { + redraw = true; + } + + if (redraw) { + ED_region_tag_redraw(ar); + } + } + + if (ED_match_area_with_refresh(sa->spacetype, SPACE_TIME)) + ED_area_tag_refresh(sa); + } + } + } } /* ---- */ @@ -116,8 +155,7 @@ static void change_frame_apply(bContext *C, wmOperator *op) /* Non-modal callback for running operator without user input */ static int change_frame_exec(bContext *C, wmOperator *op) { - change_frame_apply(C, op); - + change_frame_apply(C, op, true); return OPERATOR_FINISHED; } @@ -174,7 +212,7 @@ static int change_frame_invoke(bContext *C, wmOperator *op, const wmEvent *event change_frame_seq_preview_begin(C, event); - change_frame_apply(C, op); + change_frame_apply(C, op, false); /* add temp handler */ WM_event_add_modal_handler(C, op); @@ -190,16 +228,20 @@ static void change_frame_cancel(bContext *C, wmOperator *UNUSED(op)) /* Modal event handling of frame changing */ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event) { + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); int ret = OPERATOR_RUNNING_MODAL; /* execute the events */ switch (event->type) { case ESCKEY: + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); + BKE_sound_seek_scene(bmain, scene); ret = OPERATOR_FINISHED; break; case MOUSEMOVE: RNA_int_set(op->ptr, "frame", frame_from_event(C, event)); - change_frame_apply(C, op); + change_frame_apply(C, op, false); break; case LEFTMOUSE: @@ -208,8 +250,11 @@ static int change_frame_modal(bContext *C, wmOperator *op, const wmEvent *event) /* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init * the modal op) doesn't work for some reason */ - if (event->val == KM_RELEASE) + if (event->val == KM_RELEASE) { + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); + BKE_sound_seek_scene(bmain, scene); ret = OPERATOR_FINISHED; + } break; case LEFTCTRLKEY: |