Commit: 449e1d8074f4fa3cf13945f332de17b4902245b1 Author: Bastien Montagne Date: Mon Apr 13 20:22:27 2015 +0200 Branches: asset-engine https://developer.blender.org/rB449e1d8074f4fa3cf13945f332de17b4902245b1
Merge branch 'asset-experiments' into asset-engine Conflicts: source/blender/editors/space_file/filelist.c ... And fixes for code specific to that branch. =================================================================== =================================================================== diff --cc source/blender/editors/space_file/filelist.c index b82a700,6c827f4..7b422ae --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@@ -1230,6 -1232,8 +1182,8 @@@ void filelist_clear(struct FileList *fi filelist_intern_free(&filelist->filelist_intern); - filelist_direntryarr_free(&filelist->filelist); ++ BKE_filedir_entryarr_clear(&filelist->filelist); + if (filelist->selection_state) { BLI_ghash_clear(filelist->selection_state, MEM_freeN, NULL); } @@@ -1393,6 -1362,39 +1347,105 @@@ void filelist_clear_refresh(struct File filelist->force_refresh = false; } ++ ++static FileDirEntry *filelist_file_create_entries_block(FileList *filelist, const int index, const int size); ++ + static FileDirEntry *filelist_file_create_entry(FileList *filelist, const int index) + { - FileListInternEntry *entry = filelist->filelist_intern.filtered[index]; + FileDirEntry *ret; - FileDirEntryRevision *rev; + - ret = MEM_callocN(sizeof(*ret), __func__); - rev = MEM_callocN(sizeof(*rev), __func__); ++ if (filelist->ae) { ++ ret = filelist_file_create_entries_block(filelist, index, 1); ++ ++ BLI_assert(!ret || !ret->next); ++ } ++ else { ++ FileListInternEntry *entry = filelist->filelist_intern.filtered[index]; ++ FileDirEntryRevision *rev; + - rev->size = (uint64_t)entry->st.st_size; - BLI_filelist_entry_size_to_string(&entry->st, rev->size_str); ++ ret = MEM_callocN(sizeof(*ret), __func__); ++ rev = MEM_callocN(sizeof(*rev), __func__); + - rev->time = (int64_t)entry->st.st_mtime; - BLI_filelist_entry_datetime_to_string(&entry->st, rev->time_str, rev->date_str); ++ rev->size = (uint64_t)entry->st.st_size; ++ BLI_filelist_entry_size_to_string(&entry->st, rev->size_str); + - ret->entry = rev; - ret->relpath = BLI_strdup(entry->relpath); - ret->name = BLI_strdup(entry->name); - ret->description = BLI_strdupcat(filelist->filelist.root, entry->relpath); - memcpy(ret->uuid, entry->uuid, sizeof(ret->uuid)); - ret->blentype = entry->blentype; - ret->typeflag = entry->typeflag; ++ rev->time = (int64_t)entry->st.st_mtime; ++ BLI_filelist_entry_datetime_to_string(&entry->st, rev->time_str, rev->date_str); ++ ++ ret->entry = rev; ++ ret->relpath = BLI_strdup(entry->relpath); ++ ret->name = BLI_strdup(entry->name); ++ ret->description = BLI_strdupcat(filelist->filelist.root, entry->relpath); ++ memcpy(ret->uuid, entry->uuid, sizeof(ret->uuid)); ++ ret->blentype = entry->blentype; ++ ret->typeflag = entry->typeflag; ++ } + + BLI_addtail(&filelist->filelist.entries, ret); + return ret; + } + ++static FileDirEntry *filelist_file_create_entries_block(FileList *filelist, const int index, const int size) ++{ ++ FileDirEntry *entry = NULL; ++ FileDirEntryArr tmp_arr; ++ int i; ++ ++ tmp_arr = filelist->filelist; ++ BLI_listbase_clear(&tmp_arr.entries); ++ ++ if (filelist->ae) { ++ if (!filelist->ae->type->entries_block_get) { ++ printf("%s: Asset Engine %s does not implement 'entries_block_get'...\n", __func__, filelist->ae->type->name); ++ return entry; ++ } ++ ++ if (!filelist->ae->type->entries_block_get(filelist->ae, index, index + size, &tmp_arr)) { ++ printf("%s: Failed to get [%d:%d] from AE %s\n", __func__, index, index + size, filelist->ae->type->name); ++ BKE_filedir_entryarr_clear(&tmp_arr); ++ return entry; ++ } ++ ++ for (i = 0, entry = tmp_arr.entries.first; i < size && entry; i++, entry = entry->next) { ++ BLI_assert(!BLI_listbase_is_empty(&entry->variants) && entry->nbr_variants); ++ BLI_assert(entry->act_variant < entry->nbr_variants); ++ if (!entry->name) { ++ char buff[FILE_MAX_LIBEXTRA]; ++ entry->name = BLI_strdup(fileentry_uiname(filelist->filelist.root, ++ entry->relpath, entry->typeflag, buff)); ++ } ++ if (!entry->entry) { ++ FileDirEntryVariant *variant = BLI_findlink(&entry->variants, entry->act_variant); ++ BLI_assert(!BLI_listbase_is_empty(&variant->revisions) && variant->nbr_revisions); ++ BLI_assert(variant->act_revision < variant->nbr_revisions); ++ entry->entry = BLI_findlink(&variant->revisions, variant->act_revision); ++ BLI_assert(entry->entry); ++ } ++ } ++ ++ BLI_assert(i == size && !entry); ++ ++ entry = tmp_arr.entries.first; ++ /* Using filelist->filelist.entries as owner of that mem! */ ++ BLI_movelisttolist(&filelist->filelist.entries, &tmp_arr.entries); ++ } ++#if 0 /* UNUSED */ ++ else { ++ entry = filelist_file_create_entry(filelist, index); ++ for (i = 1, idx = index + 1; i < size; i++, idx++) { ++ filelist_file_create_entry(filelist, idx); ++ } ++ } ++#endif ++ return entry; ++} ++ + static void filelist_file_release_entry(FileList *filelist, FileDirEntry *entry) + { + BLI_remlink(&filelist->filelist.entries, entry); - filelist_entry_free(entry); ++ BKE_filedir_entry_free(entry); + } + static FileDirEntry *filelist_file_ex(struct FileList *filelist, const int index, const bool use_request) { FileDirEntry *ret = NULL, *old; @@@ -1419,66 -1421,20 +1472,22 @@@ printf("requesting file %d (not yet cached)\n", index); /* Else, we have to add new entry to 'misc' cache - and possibly make room for it first! */ - if (filelist->ae) { - FileDirEntryArr tmp_arr; - - if (!filelist->ae->type->entries_block_get) { - printf("%s: Asset Engine %s does not implement 'entries_block_get'...\n", __func__, filelist->ae->type->name); - return NULL; - } - - tmp_arr = filelist->filelist; - BLI_listbase_clear(&tmp_arr.entries); - if (!filelist->ae->type->entries_block_get(filelist->ae, index, index + 1, &tmp_arr)) { - printf("%s: Failed to get [%d:%d] from AE %s\n", __func__, index, index + 1, filelist->ae->type->name); - BKE_filedir_entryarr_clear(&tmp_arr); - return NULL; - } - - ret = tmp_arr.entries.first; - BLI_assert(!BLI_listbase_is_empty(&ret->variants) && ret->nbr_variants); - BLI_assert(ret->act_variant < ret->nbr_variants); - if (!ret->name) { - char buff[FILE_MAX_LIBEXTRA]; - ret->name = BLI_strdup(fileentry_uiname(filelist->filelist.root, - ret->relpath, ret->typeflag, buff)); - } - if (!ret->entry) { - FileDirEntryVariant *variant = BLI_findlink(&ret->variants, ret->act_variant); - BLI_assert(!BLI_listbase_is_empty(&variant->revisions) && variant->nbr_revisions); - BLI_assert(variant->act_revision < variant->nbr_revisions); - ret->entry = BLI_findlink(&variant->revisions, variant->act_revision); - BLI_assert(ret->entry); - } - - old_index = cache->misc_entries_indices[cache->misc_cursor]; - if ((old = BLI_ghash_popkey(cache->misc_entries, SET_INT_IN_POINTER(old_index), NULL))) { - BLI_remlink(&filelist->filelist.entries, old); - BKE_filedir_entry_free(old); - } - BLI_ghash_insert(cache->misc_entries, SET_INT_IN_POINTER(index), ret); - cache->misc_entries_indices[cache->misc_cursor] = index; - cache->misc_cursor = (cache->misc_cursor + 1) % FILELIST_ENTRYCACHESIZE; - - /* Using filelist->filelist.entries as owner of that mem! */ - BLI_movelisttolist(&filelist->filelist.entries, &tmp_arr.entries); - } - else { - ret = filelist_intern_create_entry(filelist, index); + ret = filelist_file_create_entry(filelist, index); - old_index = cache->misc_entries_indices[cache->misc_cursor]; - if ((old = BLI_ghash_popkey(cache->misc_entries, SET_INT_IN_POINTER(old_index), NULL))) { - filelist_file_release_entry(filelist, old); - } - BLI_ghash_insert(cache->misc_entries, SET_INT_IN_POINTER(index), ret); - cache->misc_entries_indices[cache->misc_cursor] = index; - cache->misc_cursor = (cache->misc_cursor + 1) % FILELIST_ENTRYCACHESIZE; ++ if (ret) { + old_index = cache->misc_entries_indices[cache->misc_cursor]; + if ((old = BLI_ghash_popkey(cache->misc_entries, SET_INT_IN_POINTER(old_index), NULL))) { - filelist_intern_release_entry(filelist, old); ++ filelist_file_release_entry(filelist, old); + } + BLI_ghash_insert(cache->misc_entries, SET_INT_IN_POINTER(index), ret); + cache->misc_entries_indices[cache->misc_cursor] = index; + cache->misc_cursor = (cache->misc_cursor + 1) % FILELIST_ENTRYCACHESIZE; - } #if 0 /* Actually no, only block cached entries should have preview imho. */ -- if (cache->previews_pool) { -- filelist_cache_previews_push(filelist, ret, index); -- } ++ if (cache->previews_pool) { ++ filelist_cache_previews_push(filelist, ret, index); ++ } #endif ++ } return ret; } @@@ -1534,48 -1490,7 +1543,19 @@@ static bool filelist_file_cache_block_c { FileListEntryCache *cache = &filelist->filelist_cache; - { + if (filelist->ae) { - FileDirEntryArr tmp_arr; + FileDirEntry *tmp_entry; + int i; + - if (!filelist->ae->type->entries_block_get) { - printf("%s: Asset Engine %s does not implement 'entries_block_get'...\n", __func__, filelist->ae->type->name); - return false; - } - - tmp_arr = filelist->filelist; - BLI_listbase_clear(&tmp_arr.entries); - if (!filelist->ae->type->entries_block_get(filelist->ae, start_index, start_index + size, &tmp_arr)) { - printf("%s: Failed to get [%d:%d] from AE %s\n", __func__, start_index, start_index + size, filelist->ae->type->name); - BKE_filedir_entryarr_clear(&tmp_arr); - return false; - } - - for (i = 0, tmp_entry = tmp_arr.entries.first; i < size; i++, cursor++, tmp_entry = tmp_entry->next) { - BLI_assert(!BLI_listbase_is_empty(&tmp_entry->variants) && tmp_entry->nbr_variants); - BLI_assert(tmp_entry->act_variant < tmp_entry->nbr_variants); - if (!tmp_entry->name) { - char buff[FILE_MAX_LIBEXTRA]; - tmp_entry->name = BLI_strdup(fileentry_uiname(filelist->filelist.root, - tmp_entry->relpath, tmp_entry->typeflag, buff)); - } - if (!tmp_entry->entry) { - FileDirEntryVariant *variant = BLI_findlink(&tmp_entry->variants, tmp_entry->act_variant); - BLI_assert(!BLI_listbase_is_empty(&variant->revisions) && variant->nbr_revisions); - BLI_assert(variant->act_revision < variant->nbr_revisions); - tmp_entry->entry = BLI_findlink(&variant->revisions, variant->act_revision); - @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs