diff --git a/source/blender/asset_system/AS_asset_representation.hh b/source/blender/asset_system/AS_asset_representation.hh index c7b679fafd1..867a9f65fec 100644 --- a/source/blender/asset_system/AS_asset_representation.hh +++ b/source/blender/asset_system/AS_asset_representation.hh @@ -26,6 +26,7 @@ struct AssetMetaData; struct ID; +struct PreviewImage; namespace blender::asset_system { @@ -44,6 +45,7 @@ class AssetRepresentation : NonCopyable, NonMovable { std::string name; int id_type = 0; std::unique_ptr metadata_ = nullptr; + PreviewImage *preview_ = nullptr; }; std::variant asset_; @@ -63,7 +65,7 @@ class AssetRepresentation : NonCopyable, NonMovable { AssetRepresentation(StringRef relative_asset_path, ID &id, const AssetLibrary &owner_asset_library); - ~AssetRepresentation() = default; + ~AssetRepresentation(); /** * Create a weak reference for this asset that can be written to files, but can break under a @@ -72,6 +74,25 @@ class AssetRepresentation : NonCopyable, NonMovable { */ AssetWeakReference make_weak_reference() const; + /** + * Makes sure the asset ready to load a preview, if necessary. + * + * For local IDs it calls #BKE_previewimg_id_ensure(). For others, this sets loading information + * to the preview but doesn't actually load it. To load it, attach its + * #PreviewImageRuntime::icon_id to a UI button (UI loads it asynchronously then) or call + * #BKE_previewimg_ensure() (not asynchronous). + * + * \returns the prepared preview, same as calling #get_preview(). + */ + void ensure_previewable(); + /** + * Get the preview of this asset. + * + * This will only return a preview for local ID assets or after #ensure_previewable() was + * called. + */ + PreviewImage *get_preview() const; + StringRefNull get_name() const; ID_Type get_id_type() const; AssetMetaData &get_metadata() const; diff --git a/source/blender/asset_system/CMakeLists.txt b/source/blender/asset_system/CMakeLists.txt index 1f7ea7b729c..cf3d5839d50 100644 --- a/source/blender/asset_system/CMakeLists.txt +++ b/source/blender/asset_system/CMakeLists.txt @@ -48,6 +48,7 @@ set(LIB PRIVATE bf::blenkernel PRIVATE bf::blenlib PRIVATE bf::dna + PRIVATE bf::imbuf PRIVATE bf::intern::clog PRIVATE bf::intern::guardedalloc ) diff --git a/source/blender/asset_system/intern/asset_representation.cc b/source/blender/asset_system/intern/asset_representation.cc index 245075da83c..bdfdcd5ff4a 100644 --- a/source/blender/asset_system/intern/asset_representation.cc +++ b/source/blender/asset_system/intern/asset_representation.cc @@ -11,10 +11,14 @@ #include "BLI_path_utils.hh" #include "BKE_blendfile.hh" +#include "BKE_icons.h" +#include "BKE_preview_image.hh" #include "DNA_ID.h" #include "DNA_asset_types.h" +#include "IMB_thumbs.hh" + #include "AS_asset_library.hh" #include "AS_asset_representation.hh" @@ -27,7 +31,7 @@ AssetRepresentation::AssetRepresentation(StringRef relative_asset_path, const AssetLibrary &owner_asset_library) : owner_asset_library_(owner_asset_library), relative_identifier_(relative_asset_path), - asset_(AssetRepresentation::ExternalAsset{name, id_type, std::move(metadata)}) + asset_(AssetRepresentation::ExternalAsset{name, id_type, std::move(metadata), nullptr}) { } @@ -43,11 +47,46 @@ AssetRepresentation::AssetRepresentation(StringRef relative_asset_path, } } +AssetRepresentation::~AssetRepresentation() +{ + if (const ExternalAsset *extern_asset = std::get_if(&asset_); + extern_asset && extern_asset->preview_) + { + BKE_previewimg_cached_release(this->full_path().c_str()); + } +} + AssetWeakReference AssetRepresentation::make_weak_reference() const { return AssetWeakReference::make_reference(owner_asset_library_, relative_identifier_); } +void AssetRepresentation::ensure_previewable() +{ + if (ID *id = this->local_id()) { + BKE_previewimg_id_ensure(id); + } + + ExternalAsset &extern_asset = std::get(asset_); + + /* Use the full path as preview name, it's the only unique identifier we have. */ + const std::string full_path = this->full_path(); + /* Doesn't do the actual reading, just allocates and attaches the derrived load info. */ + extern_asset.preview_ = BKE_previewimg_cached_thumbnail_read( + full_path.c_str(), full_path.c_str(), THB_SOURCE_BLEND, false); + + BKE_icon_preview_ensure(nullptr, extern_asset.preview_); +} + +PreviewImage *AssetRepresentation::get_preview() const +{ + if (const ID *id = this->local_id()) { + return BKE_previewimg_id_get(id); + } + + return std::get(asset_).preview_; +} + StringRefNull AssetRepresentation::get_name() const { if (const ID *id = this->local_id()) { diff --git a/source/blender/blenkernel/intern/preview_image.cc b/source/blender/blenkernel/intern/preview_image.cc index 977ce935412..841469d8c29 100644 --- a/source/blender/blenkernel/intern/preview_image.cc +++ b/source/blender/blenkernel/intern/preview_image.cc @@ -354,6 +354,10 @@ PreviewImage *BKE_previewimg_cached_thumbnail_read(const char *name, void BKE_previewimg_cached_release(const char *name) { BLI_assert(BLI_thread_is_main()); + if (!gCachedPreviews) { + /* Static cache was already freed including all contained previews. Can happen on shutdown. */ + return; + } PreviewImage *prv = (PreviewImage *)BLI_ghash_popkey(gCachedPreviews, name, MEM_freeN); diff --git a/source/blender/editors/asset/ED_asset_handle.hh b/source/blender/editors/asset/ED_asset_handle.hh index 2ba12bd4c28..e81f62252ac 100644 --- a/source/blender/editors/asset/ED_asset_handle.hh +++ b/source/blender/editors/asset/ED_asset_handle.hh @@ -14,8 +14,6 @@ #pragma once -#include "DNA_asset_types.h" - struct AssetHandle; namespace blender::asset_system { class AssetRepresentation; @@ -24,7 +22,5 @@ class AssetRepresentation; namespace blender::ed::asset { asset_system::AssetRepresentation *handle_get_representation(const AssetHandle *asset); -int handle_get_preview_icon_id(const AssetHandle *asset); -int handle_get_preview_or_type_icon_id(const AssetHandle *asset); } // namespace blender::ed::asset diff --git a/source/blender/editors/asset/ED_asset_list.hh b/source/blender/editors/asset/ED_asset_list.hh index 719cda412fe..3572af373f8 100644 --- a/source/blender/editors/asset/ED_asset_list.hh +++ b/source/blender/editors/asset/ED_asset_list.hh @@ -66,7 +66,6 @@ void iterate(const AssetLibraryReference &library_reference, AssetListIterFn fn) */ void storage_fetch(const AssetLibraryReference *library_reference, const bContext *C); bool is_loaded(const AssetLibraryReference *library_reference); -void previews_fetch(const AssetLibraryReference *library_reference, const bContext *C); /** * Clears this asset library and the "All" asset library for reload in both the static asset list * storage, as well as for all open asset browsers. Call this whenever the content of the given @@ -104,12 +103,6 @@ AssetHandle asset_handle_get_by_index(const AssetLibraryReference *library_refer asset_system::AssetRepresentation *asset_get_by_index( const AssetLibraryReference &library_reference, int asset_index); -bool asset_image_is_loading(const AssetLibraryReference *library_reference, - const AssetHandle *asset_handle); -void asset_preview_ensure_requested(const bContext &C, - const AssetLibraryReference *library_reference, - AssetHandle *asset_handle); - /** * \return True if the region needs a UI redraw. */ diff --git a/source/blender/editors/asset/intern/asset_handle.cc b/source/blender/editors/asset/intern/asset_handle.cc index cb72e185f01..2510bfbb5aa 100644 --- a/source/blender/editors/asset/intern/asset_handle.cc +++ b/source/blender/editors/asset/intern/asset_handle.cc @@ -6,6 +6,8 @@ * \ingroup edasset */ +#include "AS_asset_representation.hh" + #include "DNA_space_types.h" #include "ED_fileselect.hh" @@ -19,14 +21,4 @@ asset_system::AssetRepresentation *handle_get_representation(const AssetHandle * return asset->file_data->asset; } -int handle_get_preview_icon_id(const AssetHandle *asset) -{ - return asset->file_data->preview_icon_id; -} - -int handle_get_preview_or_type_icon_id(const AssetHandle *asset) -{ - return ED_file_icon(asset->file_data); -} - } // namespace blender::ed::asset diff --git a/source/blender/editors/asset/intern/asset_list.cc b/source/blender/editors/asset/intern/asset_list.cc index 026202766be..21d56854855 100644 --- a/source/blender/editors/asset/intern/asset_list.cc +++ b/source/blender/editors/asset/intern/asset_list.cc @@ -16,6 +16,7 @@ #include #include "AS_asset_library.hh" +#include "AS_asset_representation.hh" #include "BKE_context.hh" #include "BKE_screen.hh" @@ -32,6 +33,7 @@ #include "../space_file/file_indexer.hh" #include "../space_file/filelist.hh" +#include "ED_asset_handle.hh" #include "ED_asset_indexer.hh" #include "ED_asset_list.hh" #include "ED_fileselect.hh" @@ -77,32 +79,9 @@ class FileListWrapper { } }; -class PreviewTimer { - /* Non-owning! The Window-Manager registers and owns this. */ - wmTimer *timer_ = nullptr; - - public: - void ensure_running(const bContext *C) - { - if (!timer_) { - timer_ = WM_event_timer_add_notifier( - CTX_wm_manager(C), CTX_wm_window(C), NC_ASSET | ND_ASSET_LIST_PREVIEW, 0.01); - } - } - - void stop(const bContext *C) - { - if (timer_) { - WM_event_timer_remove_notifier(CTX_wm_manager(C), CTX_wm_window(C), timer_); - timer_ = nullptr; - } - } -}; - class AssetList : NonCopyable { FileListWrapper filelist_; AssetLibraryReference library_ref_; - PreviewTimer previews_timer_; public: AssetList() = delete; @@ -114,16 +93,12 @@ class AssetList : NonCopyable { void setup(); void fetch(const bContext &C); - void update_previews(const bContext &C); void clear(const bContext *C); AssetHandle asset_get_by_index(int index) const; - void previews_job_update(const bContext *C); bool needs_refetch() const; bool is_loaded() const; - bool is_asset_preview_loading(const AssetHandle &asset) const; - void ensure_asset_preview_requested(const bContext &C, AssetHandle &asset); asset_system::AssetLibrary *asset_library() const; void iterate(AssetListIndexIterFn fn) const; void iterate(AssetListIterFn fn) const; @@ -157,7 +132,6 @@ void AssetList::setup() true, "", ""); - filelist_set_no_preview_auto_cache(files); const bool use_asset_indexer = !USER_EXPERIMENTAL_TEST(&U, no_asset_indexing); filelist_setindexer(files, use_asset_indexer ? &index::file_indexer_asset : &file_indexer_noop); @@ -187,16 +161,6 @@ void AssetList::fetch(const bContext &C) filelist_filter(files); } -void AssetList::update_previews(const bContext &C) -{ - if (filelist_cache_previews_enabled(filelist_)) { - /* Get newest loaded previews from the background thread queue. */ - filelist_cache_previews_update(filelist_); - } - /* Update preview job, it might have to be stopped. */ - this->previews_job_update(&C); -} - bool AssetList::needs_refetch() const { return filelist_needs_force_reset(filelist_) || filelist_needs_reading(filelist_); @@ -207,23 +171,6 @@ bool AssetList::is_loaded() const return filelist_is_ready(filelist_); } -void AssetList::ensure_asset_preview_requested(const bContext &C, AssetHandle &asset) -{ - /* Ensure previews are enabled. */ - filelist_cache_previews_set(filelist_, true); - - if (filelist_file_ensure_preview_requested(filelist_, - const_cast(asset.file_data))) - { - previews_timer_.ensure_running(&C); - } -} - -bool AssetList::is_asset_preview_loading(const AssetHandle &asset) const -{ - return filelist_file_is_preview_pending(filelist_, asset.file_data); -} - asset_system::AssetLibrary *AssetList::asset_library() const { return reinterpret_cast(filelist_asset_library(filelist_)); @@ -264,28 +211,6 @@ void AssetList::iterate(AssetListIterFn fn) const } } -void AssetList::previews_job_update(const bContext *C) -{ - FileList *files = filelist_; - - if (!filelist_cache_previews_enabled(files)) { - previews_timer_.stop(C); - return; - } - - { - const bool previews_running = filelist_cache_previews_running(files) && - !filelist_cache_previews_done(files); - if (previews_running) { - previews_timer_.ensure_running(C); - } - else { - /* Preview is not running, no need to keep generating update events! */ - previews_timer_.stop(C); - } - } -} - void AssetList::clear(const bContext *C) { /* Based on #ED_fileselect_clear() */ @@ -466,14 +391,6 @@ bool is_loaded(const AssetLibraryReference *library_reference) return list->is_loaded(); } -void previews_fetch(const AssetLibraryReference *library_reference, const bContext *C) -{ - AssetList *list = lookup_list(*library_reference); - if (list) { - list->update_previews(*C); - } -} - void clear(const AssetLibraryReference *library_reference, const bContext *C) { AssetList *list = lookup_list(*library_reference); @@ -556,21 +473,6 @@ asset_system::AssetRepresentation *asset_get_by_index( return reinterpret_cast(asset_handle.file_data->asset); } -bool asset_image_is_loading(const AssetLibraryReference *library_reference, - const AssetHandle *asset_handle) -{ - const AssetList *list = lookup_list(*library_reference); - return list->is_asset_preview_loading(*asset_handle); -} - -void asset_preview_ensure_requested(const bContext &C, - const AssetLibraryReference *library_reference, - AssetHandle *asset_handle) -{ - AssetList *list = lookup_list(*library_reference); - list->ensure_asset_preview_requested(C, *asset_handle); -} - bool listen(const wmNotifier *notifier) { return AssetList::listen(*notifier); diff --git a/source/blender/editors/asset/intern/asset_shelf_asset_view.cc b/source/blender/editors/asset/intern/asset_shelf_asset_view.cc index ef601906743..7dbded3b7f4 100644 --- a/source/blender/editors/asset/intern/asset_shelf_asset_view.cc +++ b/source/blender/editors/asset/intern/asset_shelf_asset_view.cc @@ -206,7 +206,7 @@ static std::optional create_activate_operator_params( return wmOperatorCallParams{ot, op_props, WM_OP_INVOKE_REGION_WIN}; } -void AssetViewItem::build_grid_tile(const bContext &C, uiLayout &layout) const +void AssetViewItem::build_grid_tile(const bContext & /*C*/, uiLayout &layout) const { const AssetView &asset_view = reinterpret_cast(this->get_view()); const AssetShelfType &shelf_type = *asset_view.shelf_.type; @@ -254,13 +254,17 @@ void AssetViewItem::build_grid_tile(const bContext &C, uiLayout &layout) const /* Request preview when drawing. Grid views have an optimization to only draw items that are * actually visible, so only previews scrolled into view will be loaded this way. This reduces * total loading time and memory footprint. */ - list::asset_preview_ensure_requested(C, &asset_view.library_ref_, &asset_handle); + asset_.ensure_previewable(); const int preview_id = [&]() -> int { - if (list::asset_image_is_loading(&asset_view.library_ref_, &asset_handle)) { + /* Show loading icon while list is loading still. Previews might get pushed out of view again + * while the list grows, which can cause a lot of flickering. Note that this also means the + * actual loading of previews is delayed, because that only happens when a preview icon-ID is + * attached to a button. */ + if (!list::is_loaded(&asset_view.library_ref_)) { return ICON_TEMP; } - return handle_get_preview_or_type_icon_id(&asset_handle); + return asset_preview_or_icon(asset_); }(); ui::PreviewGridItem::build_grid_tile_button(layout, preview_id); @@ -337,7 +341,6 @@ void build_asset_view(uiLayout &layout, const bContext &C) { list::storage_fetch(&library_ref, &C); - list::previews_fetch(&library_ref, &C); const asset_system::AssetLibrary *library = list::library_get_once_available(library_ref); if (!library) { diff --git a/source/blender/editors/asset/intern/asset_ui_utils.cc b/source/blender/editors/asset/intern/asset_ui_utils.cc index 7189136725d..e387cf871bf 100644 --- a/source/blender/editors/asset/intern/asset_ui_utils.cc +++ b/source/blender/editors/asset/intern/asset_ui_utils.cc @@ -12,6 +12,11 @@ #include "AS_asset_representation.hh" #include "BKE_preferences.h" +#include "BKE_preview_image.hh" + +#include "UI_interface_icons.hh" +#include "UI_resources.hh" + #include "DNA_userdef_types.h" #include "ED_asset.hh" #include "RNA_access.hh" @@ -35,6 +40,33 @@ std::string asset_tooltip(const asset_system::AssetRepresentation &asset, const return complete_string; } +BIFIconID asset_preview_icon_id(const asset_system::AssetRepresentation &asset) +{ + if (const PreviewImage *preview = asset.get_preview()) { + if (!BKE_previewimg_is_finished(preview, ICON_SIZE_PREVIEW)) { + /* Loading icon. */ + return ICON_TEMP; + } + + if (!BKE_previewimg_is_invalid(preview)) { + return preview->runtime->icon_id; + } + } + + return ICON_NONE; +} + +BIFIconID asset_preview_or_icon(const asset_system::AssetRepresentation &asset) +{ + const BIFIconID preview_icon = asset_preview_icon_id(asset); + if (preview_icon != ICON_NONE) { + return preview_icon; + } + + /* Preview image not found or invalid. Use type icon. */ + return UI_icon_from_idcode(asset.get_id_type()); +} + const bUserAssetLibrary *get_asset_library_from_opptr(PointerRNA &ptr) { const int enum_value = RNA_enum_get(&ptr, "asset_library_reference"); diff --git a/source/blender/editors/include/ED_asset.hh b/source/blender/editors/include/ED_asset.hh index 5fc4cfcec41..adf74eb37f1 100644 --- a/source/blender/editors/include/ED_asset.hh +++ b/source/blender/editors/include/ED_asset.hh @@ -25,6 +25,9 @@ #include "../asset/ED_asset_filter.hh" // IWYU pragma: export #include "../asset/ED_asset_import.hh" // IWYU pragma: export +/** From UI_resources.hh. */ +using BIFIconID = int; + struct PointerRNA; namespace blender::ed::asset { @@ -32,6 +35,9 @@ namespace blender::ed::asset { std::string asset_tooltip(const asset_system::AssetRepresentation &asset, bool include_name = true); +BIFIconID asset_preview_icon_id(const asset_system::AssetRepresentation &asset); +BIFIconID asset_preview_or_icon(const asset_system::AssetRepresentation &asset); + void operatortypes_asset(); /** diff --git a/source/blender/editors/interface/templates/interface_template_asset_view.cc b/source/blender/editors/interface/templates/interface_template_asset_view.cc index fad2811b1a4..f46374298fd 100644 --- a/source/blender/editors/interface/templates/interface_template_asset_view.cc +++ b/source/blender/editors/interface/templates/interface_template_asset_view.cc @@ -58,12 +58,12 @@ static void asset_view_item_but_drag_set(uiBut *but, AssetHandle *asset_handle) UI_but_drag_set_asset(but, asset, import_method, - asset::handle_get_preview_or_type_icon_id(asset_handle), - asset::handle_get_preview_icon_id(asset_handle)); + asset::asset_preview_or_icon(*asset), + asset::asset_preview_icon_id(*asset)); } static void asset_view_draw_item(uiList *ui_list, - const bContext *C, + const bContext * /*C*/, uiLayout *layout, PointerRNA * /*dataptr*/, PointerRNA * /*itemptr*/, @@ -77,6 +77,7 @@ static void asset_view_draw_item(uiList *ui_list, AssetHandle asset_handle = asset::list::asset_handle_get_by_index(&list_data->asset_library_ref, index); + asset_system::AssetRepresentation *asset = asset::handle_get_representation(&asset_handle); PointerRNA file_ptr = RNA_pointer_create_discrete( &list_data->screen->id, @@ -84,28 +85,27 @@ static void asset_view_draw_item(uiList *ui_list, const_cast(asset_handle.file_data)); uiLayoutSetContextPointer(layout, "active_file", &file_ptr); - asset::list::asset_preview_ensure_requested(*C, &list_data->asset_library_ref, &asset_handle); + asset->ensure_previewable(); uiBlock *block = uiLayoutGetBlock(layout); const bool show_names = list_data->show_names; const float size_x = UI_preview_tile_size_x(); const float size_y = show_names ? UI_preview_tile_size_y() : UI_preview_tile_size_y_no_label(); - uiBut *but = uiDefIconTextBut( - block, - UI_BTYPE_PREVIEW_TILE, - 0, - asset::handle_get_preview_icon_id(&asset_handle), - show_names ? asset::handle_get_representation(&asset_handle)->get_name().c_str() : "", - 0, - 0, - size_x, - size_y, - nullptr, - 0, - 0, - ""); + uiBut *but = uiDefIconTextBut(block, + UI_BTYPE_PREVIEW_TILE, + 0, + asset::asset_preview_icon_id(*asset), + show_names ? asset->get_name().c_str() : "", + 0, + 0, + size_x, + size_y, + nullptr, + 0, + 0, + ""); ui_def_but_icon(but, - asset::handle_get_preview_icon_id(&asset_handle), + asset::asset_preview_icon_id(*asset), /* NOLINTNEXTLINE: bugprone-suspicious-enum-usage */ UI_HAS_ICON | UI_BUT_ICON_PREVIEW); but->emboss = UI_EMBOSS_NONE; @@ -256,7 +256,6 @@ void uiTemplateAssetView(uiLayout *layout, } asset::list::storage_fetch(&asset_library_ref, C); - asset::list::previews_fetch(&asset_library_ref, C); const int tot_items = asset::list::size(&asset_library_ref); populate_asset_collection(asset_library_ref, *assets_dataptr, assets_propname); diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc index c7c1527c80b..6de30854c04 100644 --- a/source/blender/editors/space_file/filelist.cc +++ b/source/blender/editors/space_file/filelist.cc @@ -304,12 +304,6 @@ enum { FL_NEED_SORTING = 1 << 4, FL_NEED_FILTERING = 1 << 5, FL_SORT_INVERT = 1 << 6, - /** - * By default, #filelist_file_cache_block() will attempt to load previews around the visible - * "window" of visible files. When this flag is set it won't do so, and each preview has to be - * queried through a #filelist_cache_previews_push() call. - */ - FL_PREVIEWS_NO_AUTO_CACHE = 1 << 7, }; /** #FileList.tags */ @@ -360,8 +354,6 @@ static int groupname_to_code(const char *group); static void filelist_cache_clear(FileListEntryCache *cache, size_t new_size); static bool filelist_intern_entry_is_main_file(const FileListInternEntry *intern_entry); -static bool filelist_cache_previews_push(FileList *filelist, FileDirEntry *entry, const int index); -static bool filelist_file_preview_load_poll(const FileDirEntry *entry); /* ********** Sort helpers ********** */ @@ -1166,35 +1158,6 @@ bool filelist_file_is_preview_pending(const FileList *filelist, const FileDirEnt return !filelist_ready || file->flags & FILE_ENTRY_PREVIEW_LOADING; } -bool filelist_file_ensure_preview_requested(FileList *filelist, FileDirEntry *file) -{ - if (file->preview_icon_id) { - /* Already loaded. */ - return false; - } - - /* Wait with requests until file list reading is done, and previews may be loaded. */ - if (!filelist_cache_previews_enabled(filelist)) { - return false; - } - /* #filelist_cache_previews_push() will repeat this, do here already to avoid lookup below. */ - if (!filelist_file_preview_load_poll(file)) { - return false; - } - - const int numfiles = filelist_files_ensure(filelist); - for (int i = 0; i < numfiles; i++) { - if (filelist->filelist_intern.filtered[i]->uid == file->uid) { - if (filelist_cache_previews_push(filelist, file, i)) { - return true; - } - break; - } - } - - return false; -} - static FileDirEntry *filelist_geticon_get_file(FileList *filelist, const int index) { BLI_assert(G.background == false); @@ -2115,11 +2078,6 @@ void filelist_setrecursion(FileList *filelist, const int recursion_level) } } -void filelist_set_no_preview_auto_cache(FileList *filelist) -{ - filelist->flags |= FL_PREVIEWS_NO_AUTO_CACHE; -} - bool filelist_needs_force_reset(const FileList *filelist) { return (filelist->flags & (FL_FORCE_RESET | FL_FORCE_RESET_MAIN_FILES)) != 0; @@ -2618,7 +2576,7 @@ bool filelist_file_cache_block(FileList *filelist, const int index) // printf("Re-queueing previews...\n"); - if ((cache->flags & FLC_PREVIEWS_ACTIVE) && !(filelist->flags & FL_PREVIEWS_NO_AUTO_CACHE)) { + if (cache->flags & FLC_PREVIEWS_ACTIVE) { /* Note we try to preview first images around given index - i.e. assumed visible ones. */ int block_index = cache->block_cursor + (index - start_index); int offs_max = max_ii(end_index - index, index - start_index); @@ -2641,11 +2599,6 @@ bool filelist_file_cache_block(FileList *filelist, const int index) return true; } -bool filelist_cache_previews_enabled(const FileList *filelist) -{ - return (filelist->filelist_cache.flags & FLC_PREVIEWS_ACTIVE) != 0; -} - void filelist_cache_previews_set(FileList *filelist, const bool use_previews) { FileListEntryCache *cache = &filelist->filelist_cache; @@ -2671,11 +2624,6 @@ void filelist_cache_previews_set(FileList *filelist, const bool use_previews) } } -void filelist_cache_previews_ensure_running(FileList *filelist) -{ - filelist_cache_preview_ensure_running(&filelist->filelist_cache); -} - bool filelist_cache_previews_update(FileList *filelist) { FileListEntryCache *cache = &filelist->filelist_cache; diff --git a/source/blender/editors/space_file/filelist.hh b/source/blender/editors/space_file/filelist.hh index 7083ede9ce8..4c84f779e25 100644 --- a/source/blender/editors/space_file/filelist.hh +++ b/source/blender/editors/space_file/filelist.hh @@ -87,7 +87,6 @@ bool filelist_file_is_preview_pending(const FileList *filelist, const FileDirEnt * \return True if a new preview request was pushed, false otherwise (e.g. because the preview is * already loaded, invalid or not supported). */ -bool filelist_file_ensure_preview_requested(FileList *filelist, FileDirEntry *file); ImBuf *filelist_get_preview_image(FileList *filelist, int index); ImBuf *filelist_file_get_preview_image(const FileDirEntry *file); ImBuf *filelist_geticon_special_file_image_ex(const FileDirEntry *file); @@ -177,8 +176,6 @@ void filelist_file_cache_slidingwindow_set(FileList *filelist, size_t window_siz */ bool filelist_file_cache_block(FileList *filelist, int index); -void filelist_set_no_preview_auto_cache(FileList *filelist); - bool filelist_needs_force_reset(const FileList *filelist); void filelist_tag_force_reset(FileList *filelist); void filelist_tag_force_reset_mainfiles(FileList *filelist); @@ -237,9 +234,7 @@ void filelist_readjob_start(FileList *filelist, int space_notifier, const bConte void filelist_readjob_stop(FileList *filelist, wmWindowManager *wm); int filelist_readjob_running(FileList *filelist, wmWindowManager *wm); -void filelist_cache_previews_ensure_running(FileList *filelist); bool filelist_cache_previews_update(FileList *filelist); -bool filelist_cache_previews_enabled(const FileList *filelist); void filelist_cache_previews_set(FileList *filelist, bool use_previews); bool filelist_cache_previews_running(FileList *filelist); bool filelist_cache_previews_done(FileList *filelist);