diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-07-01 16:23:42 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-07-01 16:36:02 +0300 |
commit | 2698544db2a19436155191608e4ef13c001b8209 (patch) | |
tree | 2d369a6ac5610fef85f2cabe94029b3699913acb /source/blender/windowmanager | |
parent | 3c6260d42de007c223c4bdb1bc8ed5431f2f2963 (diff) |
Fix T66262: slow preview icon loading
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 2 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_jobs.c | 19 |
2 files changed, 17 insertions, 4 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index d4fbbd1ecff..d3c1e5f146d 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -649,7 +649,6 @@ enum { WM_JOB_PRIORITY = (1 << 0), WM_JOB_EXCL_RENDER = (1 << 1), WM_JOB_PROGRESS = (1 << 2), - WM_JOB_SUSPEND = (1 << 3), }; /** Identifying jobs by owner alone is unreliable, this isnt saved, @@ -700,6 +699,7 @@ bool WM_jobs_is_stopped(wmWindowManager *wm, void *owner); void *WM_jobs_customdata_get(struct wmJob *); void WM_jobs_customdata_set(struct wmJob *, void *customdata, void (*free)(void *)); void WM_jobs_timer(struct wmJob *, double timestep, unsigned int note, unsigned int endnote); +void WM_jobs_delay_start(struct wmJob *, double delay_time); void WM_jobs_callbacks(struct wmJob *, void (*startjob)(void *, short *, short *, float *), void (*initjob)(void *), diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index a63592f7b60..a417d80a9a9 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -92,6 +92,8 @@ struct wmJob { /** Running jobs each have own timer */ double timestep; wmTimer *wt; + /** Only start job after specified time delay */ + double start_delay_time; /** The notifier event timers should send */ unsigned int note, endnote; @@ -356,6 +358,11 @@ void WM_jobs_timer(wmJob *wm_job, double timestep, unsigned int note, unsigned i wm_job->endnote = endnote; } +void WM_jobs_delay_start(wmJob *wm_job, double delay_time) +{ + wm_job->start_delay_time = delay_time; +} + void WM_jobs_callbacks(wmJob *wm_job, void (*startjob)(void *, short *, short *, float *), void (*initjob)(void *), @@ -386,9 +393,9 @@ static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test) bool suspend = false; /* job added with suspend flag, we wait 1 timer step before activating it */ - if (test->flag & WM_JOB_SUSPEND) { + if (test->start_delay_time > 0.0) { suspend = true; - test->flag &= ~WM_JOB_SUSPEND; + test->start_delay_time = 0.0; } else { /* check other jobs */ @@ -441,6 +448,8 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job) else { if (wm_job->customdata && wm_job->startjob) { + const double timestep = (wm_job->start_delay_time > 0.0) ? wm_job->start_delay_time : + wm_job->timestep; wm_jobs_test_suspend_stop(wm, wm_job); @@ -467,8 +476,12 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job) } /* restarted job has timer already */ + if (wm_job->wt && (wm_job->wt->timestep > timestep)) { + WM_event_remove_timer(wm, wm_job->win, wm_job->wt); + wm_job->wt = WM_event_add_timer(wm, wm_job->win, TIMERJOBS, timestep); + } if (wm_job->wt == NULL) { - wm_job->wt = WM_event_add_timer(wm, wm_job->win, TIMERJOBS, wm_job->timestep); + wm_job->wt = WM_event_add_timer(wm, wm_job->win, TIMERJOBS, timestep); } wm_job->start_time = PIL_check_seconds_timer(); |