Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Bakker <jbakker>2021-09-24 09:39:58 +0300
committerJeroen Bakker <jeroen@blender.org>2021-09-24 09:41:40 +0300
commitfc7beac8d6f45d9eca344ec4ae8879c2e73f0731 (patch)
tree25017e4d06a859a1513cdbecaf05e036a9fc4182 /source/blender/blenloader
parent6a88f83d679f281d7adb3798ab4770069a63c2da (diff)
FileBrowser: Reduce Overhead Browsing Libraries.
When Browsing libraries the asset files were opened multiple times. once to determine the needed groups to query and once for each group to query the items in the group. For file browsing this makes sense but for asset browsing this can be reduced. This patch will load the asset files recursively and only opens them once. Another change is that only the assets are requested and not filtered out later in the process. This patch is needed to simplify the library indexing. Where we need access to the full library content. ## The numbers ## Benchmarked by adding scenes of the spring open movie to the default asset library. Refreshing the asset library would recursively load all the files there. | **8bc27c508a** | Processed 317 'directories/libraries' | 7.573986s | | **Patch** | Processed 42 'directories/libraries' | 0.821013s | {F10442811} Reviewed By: mont29, Severin Maniphest Tasks: T91406 Differential Revision: https://developer.blender.org/D12499
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/BLO_readfile.h5
-rw-r--r--source/blender/blenloader/intern/readblenentry.c33
2 files changed, 23 insertions, 15 deletions
diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h
index c8615545df9..4b4311d32bf 100644
--- a/source/blender/blenloader/BLO_readfile.h
+++ b/source/blender/blenloader/BLO_readfile.h
@@ -168,9 +168,8 @@ struct LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh,
const bool use_assets_only,
int *r_tot_names);
-struct LinkNode *BLO_blendhandle_get_datablock_info(BlendHandle *bh,
- int ofblocktype,
- int *r_tot_info_items);
+struct LinkNode * /*BLODataBlockInfo */ BLO_blendhandle_get_datablock_info(
+ BlendHandle *bh, int ofblocktype, const bool use_assets_only, int *r_tot_info_items);
struct LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *r_tot_prev);
struct PreviewImage *BLO_blendhandle_get_preview_for_id(BlendHandle *bh,
int ofblocktype,
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index f88b470809c..3306eb9e454 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -170,17 +170,19 @@ LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh,
}
/**
- * Gets the names and asset-data (if ID is an asset) of all the data-blocks in a file of a certain
- * type (e.g. all the scene names in a file).
+ * Gets the names and asset-data (if ID is an asset) of data-blocks in a file of a certain type.
+ * The data-blocks can be limited to assets.
*
* \param bh: The blendhandle to access.
* \param ofblocktype: The type of names to get.
+ * \param use_assets_only: Limit the result to assets only.
* \param tot_info_items: The length of the returned list.
* \return A BLI_linklist of BLODataBlockInfo *. The links and #BLODataBlockInfo.asset_data should
* be freed with MEM_freeN.
*/
LinkNode *BLO_blendhandle_get_datablock_info(BlendHandle *bh,
int ofblocktype,
+ const bool use_assets_only,
int *r_tot_info_items)
{
FileData *fd = (FileData *)bh;
@@ -189,27 +191,34 @@ LinkNode *BLO_blendhandle_get_datablock_info(BlendHandle *bh,
int tot = 0;
for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
+ if (bhead->code == ENDB) {
+ break;
+ }
if (bhead->code == ofblocktype) {
- struct BLODataBlockInfo *info = MEM_mallocN(sizeof(*info), __func__);
const char *name = blo_bhead_id_name(fd, bhead) + 2;
+ AssetMetaData *asset_meta_data = blo_bhead_id_asset_data_address(fd, bhead);
- STRNCPY(info->name, name);
+ const bool is_asset = asset_meta_data != NULL;
+ const bool skip_datablock = use_assets_only && !is_asset;
+ if (skip_datablock) {
+ continue;
+ }
+ struct BLODataBlockInfo *info = MEM_mallocN(sizeof(*info), __func__);
/* Lastly, read asset data from the following blocks. */
- info->asset_data = blo_bhead_id_asset_data_address(fd, bhead);
- if (info->asset_data) {
- bhead = blo_read_asset_data_block(fd, bhead, &info->asset_data);
- /* blo_read_asset_data_block() reads all DATA heads and already advances bhead to the next
- * non-DATA one. Go back, so the loop doesn't skip the non-DATA head. */
+ if (asset_meta_data) {
+ bhead = blo_read_asset_data_block(fd, bhead, &asset_meta_data);
+ /* blo_read_asset_data_block() reads all DATA heads and already advances bhead to the
+ * next non-DATA one. Go back, so the loop doesn't skip the non-DATA head. */
bhead = blo_bhead_prev(fd, bhead);
}
+ STRNCPY(info->name, name);
+ info->asset_data = asset_meta_data;
+
BLI_linklist_prepend(&infos, info);
tot++;
}
- else if (bhead->code == ENDB) {
- break;
- }
}
*r_tot_info_items = tot;