Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_file/filelist.c
| Show First 20 Lines • Show All 1,258 Lines • ▼ Show 20 Lines | for (entry = filelist_intern->entries.first; entry; entry = entry_next) { | ||||
| entry_next = entry->next; | entry_next = entry->next; | ||||
| filelist_intern_entry_free(entry); | filelist_intern_entry_free(entry); | ||||
| } | } | ||||
| BLI_listbase_clear(&filelist_intern->entries); | BLI_listbase_clear(&filelist_intern->entries); | ||||
| MEM_SAFE_FREE(filelist_intern->filtered); | MEM_SAFE_FREE(filelist_intern->filtered); | ||||
| } | } | ||||
| static void filelist_cache_preview_runf(TaskPool *__restrict pool, | static void filelist_cache_preview_runf(TaskPool *__restrict pool, void *taskdata) | ||||
| void *taskdata, | |||||
| int UNUSED(threadid)) | |||||
| { | { | ||||
| FileListEntryCache *cache = BLI_task_pool_userdata(pool); | FileListEntryCache *cache = BLI_task_pool_user_data(pool); | ||||
| FileListEntryPreviewTaskData *preview_taskdata = taskdata; | FileListEntryPreviewTaskData *preview_taskdata = taskdata; | ||||
| FileListEntryPreview *preview = preview_taskdata->preview; | FileListEntryPreview *preview = preview_taskdata->preview; | ||||
| ThumbSource source = 0; | ThumbSource source = 0; | ||||
| // printf("%s: Start (%d)...\n", __func__, threadid); | // printf("%s: Start (%d)...\n", __func__, threadid); | ||||
| // printf("%s: %d - %s - %p\n", __func__, preview->index, preview->path, preview->img); | // printf("%s: %d - %s - %p\n", __func__, preview->index, preview->path, preview->img); | ||||
| Show All 21 Lines | static void filelist_cache_preview_runf(TaskPool *__restrict pool, void *taskdata) | ||||
| /* That way task freeing function won't free th preview, since it does not own it anymore. */ | /* That way task freeing function won't free th preview, since it does not own it anymore. */ | ||||
| atomic_cas_ptr((void **)&preview_taskdata->preview, preview, NULL); | atomic_cas_ptr((void **)&preview_taskdata->preview, preview, NULL); | ||||
| BLI_thread_queue_push(cache->previews_done, preview); | BLI_thread_queue_push(cache->previews_done, preview); | ||||
| // printf("%s: End (%d)...\n", __func__, threadid); | // printf("%s: End (%d)...\n", __func__, threadid); | ||||
| } | } | ||||
| static void filelist_cache_preview_freef(TaskPool *__restrict UNUSED(pool), | static void filelist_cache_preview_freef(TaskPool *__restrict UNUSED(pool), void *taskdata) | ||||
| void *taskdata, | |||||
| int UNUSED(threadid)) | |||||
| { | { | ||||
| FileListEntryPreviewTaskData *preview_taskdata = taskdata; | FileListEntryPreviewTaskData *preview_taskdata = taskdata; | ||||
| FileListEntryPreview *preview = preview_taskdata->preview; | FileListEntryPreview *preview = preview_taskdata->preview; | ||||
| /* preview_taskdata->preview is atomically set to NULL once preview has been processed and sent | /* preview_taskdata->preview is atomically set to NULL once preview has been processed and sent | ||||
| * to previews_done queue. */ | * to previews_done queue. */ | ||||
| if (preview != NULL) { | if (preview != NULL) { | ||||
| if (preview->img) { | if (preview->img) { | ||||
| IMB_freeImBuf(preview->img); | IMB_freeImBuf(preview->img); | ||||
| } | } | ||||
| MEM_freeN(preview); | MEM_freeN(preview); | ||||
| } | } | ||||
| MEM_freeN(preview_taskdata); | MEM_freeN(preview_taskdata); | ||||
| } | } | ||||
| static void filelist_cache_preview_ensure_running(FileListEntryCache *cache) | static void filelist_cache_preview_ensure_running(FileListEntryCache *cache) | ||||
| { | { | ||||
| if (!cache->previews_pool) { | if (!cache->previews_pool) { | ||||
| TaskScheduler *scheduler = BLI_task_scheduler_get(); | cache->previews_pool = BLI_task_pool_create_background(cache, TASK_PRIORITY_LOW); | ||||
| cache->previews_pool = BLI_task_pool_create_background(scheduler, cache, TASK_PRIORITY_LOW); | |||||
| cache->previews_done = BLI_thread_queue_init(); | cache->previews_done = BLI_thread_queue_init(); | ||||
| IMB_thumb_locks_acquire(); | IMB_thumb_locks_acquire(); | ||||
| } | } | ||||
| } | } | ||||
| static void filelist_cache_previews_clear(FileListEntryCache *cache) | static void filelist_cache_previews_clear(FileListEntryCache *cache) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 1,757 Lines • Show Last 20 Lines | |||||