Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_file/filelist.c
| Show All 32 Lines | |||||
| #include "BLI_stack.h" | #include "BLI_stack.h" | ||||
| #include "BLI_task.h" | #include "BLI_task.h" | ||||
| #include "BLI_threads.h" | #include "BLI_threads.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_uuid.h" | #include "BLI_uuid.h" | ||||
| #ifdef WIN32 | #ifdef WIN32 | ||||
| # include "BLI_winstuff.h" | # include "BLI_winstuff.h" | ||||
| # include "IMB_thumbs_win32.h" | |||||
mano-wii: Is Include with `<>` instead of `"` really the one indicated here? | |||||
| #endif | #endif | ||||
| #include "BKE_asset.h" | #include "BKE_asset.h" | ||||
| #include "BKE_asset_library.h" | #include "BKE_asset_library.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_global.h" | #include "BKE_global.h" | ||||
| #include "BKE_icons.h" | #include "BKE_icons.h" | ||||
| #include "BKE_idtype.h" | #include "BKE_idtype.h" | ||||
| ▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | |||||
| if (entry->preview_icon_id) { | if (entry->preview_icon_id) { | ||||
| return; | return; | ||||
| } | } | ||||
| if (entry->flags & (FILE_ENTRY_INVALID_PREVIEW | FILE_ENTRY_PREVIEW_LOADING)) { | if (entry->flags & (FILE_ENTRY_INVALID_PREVIEW | FILE_ENTRY_PREVIEW_LOADING)) { | ||||
| return; | return; | ||||
| } | } | ||||
| #ifndef WIN32 | |||||
| if (!(entry->typeflag & (FILE_TYPE_IMAGE | FILE_TYPE_MOVIE | FILE_TYPE_FTFONT | | if (!(entry->typeflag & (FILE_TYPE_IMAGE | FILE_TYPE_MOVIE | FILE_TYPE_FTFONT | | ||||
| FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP | FILE_TYPE_BLENDERLIB))) { | FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP | FILE_TYPE_BLENDERLIB))) { | ||||
| return; | return; | ||||
| } | } | ||||
| #endif | |||||
Not Done Inline ActionsIt looks like these lines might continue for non-Windows systems. mano-wii: It looks like these lines might continue for non-Windows systems. | |||||
| FileListInternEntry *intern_entry = filelist->filelist_intern.filtered[index]; | FileListInternEntry *intern_entry = filelist->filelist_intern.filtered[index]; | ||||
| PreviewImage *preview_in_memory = intern_entry->local_data.preview_image; | PreviewImage *preview_in_memory = intern_entry->local_data.preview_image; | ||||
| if (preview_in_memory && !BKE_previewimg_is_finished(preview_in_memory, ICON_SIZE_PREVIEW)) { | if (preview_in_memory && !BKE_previewimg_is_finished(preview_in_memory, ICON_SIZE_PREVIEW)) { | ||||
| /* Nothing to set yet. Wait for next call. */ | /* Nothing to set yet. Wait for next call. */ | ||||
| return; | return; | ||||
| } | } | ||||
| filelist_cache_preview_ensure_running(cache); | filelist_cache_preview_ensure_running(cache); | ||||
| entry->flags |= FILE_ENTRY_PREVIEW_LOADING; | entry->flags |= FILE_ENTRY_PREVIEW_LOADING; | ||||
| FileListEntryPreview *preview = MEM_mallocN(sizeof(*preview), __func__); | FileListEntryPreview *preview = MEM_mallocN(sizeof(*preview), __func__); | ||||
| preview->index = index; | preview->index = index; | ||||
| preview->flags = entry->typeflag; | preview->flags = entry->typeflag; | ||||
| preview->attributes = entry->attributes; | preview->attributes = entry->attributes; | ||||
| preview->icon_id = 0; | preview->icon_id = 0; | ||||
| if (entry->redirection_path) { | |||||
mano-wiiUnsubmitted Not Done Inline ActionsWhen it is preview_in_memory the preview->path is set to '\0'. if (preview_in_memory) {
preview->path[0] = '\0';
}
else if (entry->redirection_path) {mano-wii: When it is `preview_in_memory` the `preview->path`` is set to '\0'`.
So maybe it's worth adding… | |||||
| BLI_strncpy(preview->path, entry->redirection_path, FILE_MAXDIR); | |||||
| } | |||||
| else { | |||||
Done Inline ActionsIs there any way we can deduplicate this part? mano-wii: Is there any way we can deduplicate this part? | |||||
| BLI_join_dirfile( | |||||
| preview->path, sizeof(preview->path), filelist->filelist.root, entry->relpath); | |||||
| } | |||||
| #ifdef WIN32 | |||||
| if (!(entry->typeflag & (FILE_TYPE_IMAGE | FILE_TYPE_MOVIE | FILE_TYPE_FTFONT | | |||||
| FILE_TYPE_BLENDER | FILE_TYPE_BLENDER_BACKUP | FILE_TYPE_BLENDERLIB))) { | |||||
| ImBuf *imbuf = IMB_thumb_win32(preview->path, 256); | |||||
| if (imbuf) { | |||||
| preview->icon_id = BKE_icon_imbuf_create(imbuf); | |||||
| } | |||||
| BLI_thread_queue_push(cache->previews_done, preview); | |||||
| cache->previews_todo_count++; | |||||
| return; | |||||
| } | |||||
| #endif | |||||
| if (preview_in_memory) { | if (preview_in_memory) { | ||||
| /* TODO(mano-wii): No need to use the thread API here. */ | /* TODO(mano-wii): No need to use the thread API here. */ | ||||
| BLI_assert(BKE_previewimg_is_finished(preview_in_memory, ICON_SIZE_PREVIEW)); | BLI_assert(BKE_previewimg_is_finished(preview_in_memory, ICON_SIZE_PREVIEW)); | ||||
| preview->path[0] = '\0'; | preview->path[0] = '\0'; | ||||
| ImBuf *imbuf = BKE_previewimg_to_imbuf(preview_in_memory, ICON_SIZE_PREVIEW); | ImBuf *imbuf = BKE_previewimg_to_imbuf(preview_in_memory, ICON_SIZE_PREVIEW); | ||||
| if (imbuf) { | if (imbuf) { | ||||
| preview->icon_id = BKE_icon_imbuf_create(imbuf); | preview->icon_id = BKE_icon_imbuf_create(imbuf); | ||||
| } | } | ||||
| BLI_thread_queue_push(cache->previews_done, preview); | BLI_thread_queue_push(cache->previews_done, preview); | ||||
| } | } | ||||
| else { | else { | ||||
| if (entry->redirection_path) { | |||||
| BLI_strncpy(preview->path, entry->redirection_path, FILE_MAXDIR); | |||||
| } | |||||
| else { | |||||
| BLI_join_dirfile( | |||||
| preview->path, sizeof(preview->path), filelist->filelist.root, entry->relpath); | |||||
| } | |||||
| // printf("%s: %d - %s\n", __func__, preview->index, preview->path); | |||||
| FileListEntryPreviewTaskData *preview_taskdata = MEM_mallocN(sizeof(*preview_taskdata), | FileListEntryPreviewTaskData *preview_taskdata = MEM_mallocN(sizeof(*preview_taskdata), | ||||
| __func__); | __func__); | ||||
| preview_taskdata->preview = preview; | preview_taskdata->preview = preview; | ||||
| BLI_task_pool_push(cache->previews_pool, | BLI_task_pool_push(cache->previews_pool, | ||||
| filelist_cache_preview_runf, | filelist_cache_preview_runf, | ||||
| preview_taskdata, | preview_taskdata, | ||||
| true, | true, | ||||
| filelist_cache_preview_freef); | filelist_cache_preview_freef); | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||
Is Include with <> instead of " really the one indicated here?