Remove preview-caching from asset-list API

This isn't needed anymore, see previous commit.
This commit is contained in:
Julian Eisel 2022-02-16 18:10:40 +01:00
parent 39eab45c8e
commit eafd98c920
5 changed files with 1 additions and 66 deletions

View File

@ -25,8 +25,6 @@ struct wmNotifier;
*/
void ED_assetlist_storage_fetch(const struct AssetLibraryReference *library_reference,
const struct bContext *C);
void ED_assetlist_ensure_previews_job(const struct AssetLibraryReference *library_reference,
const struct bContext *C);
void ED_assetlist_catalog_filter_set(const struct AssetLibraryReference *,
const struct AssetCatalogFilterSettings *catalog_filter);
void ED_assetlist_clear(const struct AssetLibraryReference *library_reference, struct bContext *C);

View File

@ -76,28 +76,6 @@ class FileListWrapper {
}
};
class PreviewTimer {
/* Non-owning! The Window-Manager registers and owns this. */
wmTimer *timer_ = nullptr;
public:
void ensureRunning(const bContext *C)
{
if (!timer_) {
timer_ = WM_event_add_timer_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_remove_timer_notifier(CTX_wm_manager(C), CTX_wm_window(C), timer_);
timer_ = nullptr;
}
}
};
class AssetList : NonCopyable {
FileListWrapper filelist_;
/** Storage for asset handles, items are lazy-created on request.
@ -105,7 +83,6 @@ class AssetList : NonCopyable {
* inside the map changes as the map changes). */
mutable Map<const FileDirEntry *, std::unique_ptr<AssetHandle>> asset_handle_map_;
AssetLibraryReference library_ref_;
PreviewTimer previews_timer_;
public:
AssetList() = delete;
@ -116,7 +93,6 @@ class AssetList : NonCopyable {
void setup();
void fetch(const bContext &C);
void setCatalogFilterSettings(const AssetCatalogFilterSettings &settings);
void ensurePreviewsJob(const bContext *C);
void clear(bContext *C);
bool needsRefetch() const;
@ -233,30 +209,6 @@ void AssetList::iterate(AssetListIterFn fn) const
}
}
void AssetList::ensurePreviewsJob(const bContext *C)
{
FileList *files = filelist_;
int numfiles = filelist_files_ensure(files);
filelist_cache_previews_set(files, true);
filelist_file_cache_slidingwindow_set(files, 256);
/* TODO fetch all previews for now. */
filelist_file_cache_block(files, numfiles / 2);
filelist_cache_previews_update(files);
{
const bool previews_running = filelist_cache_previews_running(files) &&
!filelist_cache_previews_done(files);
if (previews_running) {
previews_timer_.ensureRunning(C);
}
else {
/* Preview is not running, no need to keep generating update events! */
previews_timer_.stop(C);
}
}
}
void AssetList::clear(bContext *C)
{
/* Based on #ED_fileselect_clear() */
@ -287,7 +239,7 @@ bool AssetList::listen(const wmNotifier &notifier) const
filelist_tag_needs_filtering(filelist_);
return true;
}
if (ELEM(notifier.data, ND_ASSET_LIST_READING, ND_ASSET_LIST_PREVIEW)) {
if (ELEM(notifier.data, ND_ASSET_LIST_READING)) {
return true;
}
if (ELEM(notifier.action, NA_ADDED, NA_REMOVED, NA_EDITED)) {
@ -453,16 +405,6 @@ void ED_assetlist_storage_fetch(const AssetLibraryReference *library_reference,
AssetListStorage::fetch_library(*library_reference, *C);
}
void ED_assetlist_ensure_previews_job(const AssetLibraryReference *library_reference,
const bContext *C)
{
AssetList *list = AssetListStorage::lookup_list(*library_reference);
if (list) {
list->ensurePreviewsJob(C);
}
}
void ED_assetlist_catalog_filter_set(const struct AssetLibraryReference *library_reference,
const struct AssetCatalogFilterSettings *settings)
{

View File

@ -220,7 +220,6 @@ void uiTemplateAssetView(uiLayout *layout,
}
ED_assetlist_storage_fetch(&asset_library_ref, C);
ED_assetlist_ensure_previews_job(&asset_library_ref, C);
const int tot_items = ED_assetlist_size(&asset_library_ref);
asset_view_template_refresh_asset_collection(

View File

@ -106,7 +106,6 @@ void asset_view_create_in_layout(const bContext &C,
UI_block_layout_set_current(block, &layout);
ED_assetlist_storage_fetch(&asset_library_ref, &C);
ED_assetlist_ensure_previews_job(&asset_library_ref, &C);
ED_assetlist_catalog_filter_set(&asset_library_ref, &catalog_filter_settings);
ui::AbstractGridView *grid_view = UI_block_add_view(

View File

@ -448,9 +448,6 @@ typedef struct wmNotifier {
/* Denote that something in the contents of an AssetList may have changed. Triggers re-filtering of
* items. */
#define ND_ASSET_LIST (1 << 16)
/* Denotes that the AssetList is done reading some previews. NOT that the preview generation of
* assets is done. */
#define ND_ASSET_LIST_PREVIEW (2 << 16)
#define ND_ASSET_LIST_READING (3 << 16)
/* Catalog data changed, requiring a redraw of catalog UIs. Note that this doesn't denote a
* reloading of asset libraries & their catalogs should happen. That only happens on explicit user