diff options
author | Bastien Montagne <b.mont29@gmail.com> | 2020-03-09 14:21:45 +0300 |
---|---|---|
committer | Bastien Montagne <b.mont29@gmail.com> | 2020-03-09 14:49:04 +0300 |
commit | b57d3afb764fffd55d17502075e8f49fdf95f7a1 (patch) | |
tree | 3ba847be0b32e5a2b6c1f4ddf6f1fb3f086e4171 /source | |
parent | 613148ce5bf887ecf700db0c25aafa45ee9b7a63 (diff) |
Cleanup: CacheFile: Move to IDTypeInfo and remove unused BKE API.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_cachefile.h | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_idtype.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/cachefile.c | 100 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/idtype.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lib_id.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lib_id_delete.c | 2 |
6 files changed, 58 insertions, 66 deletions
diff --git a/source/blender/blenkernel/BKE_cachefile.h b/source/blender/blenkernel/BKE_cachefile.h index 1f720b03fc9..596085f9c6f 100644 --- a/source/blender/blenkernel/BKE_cachefile.h +++ b/source/blender/blenkernel/BKE_cachefile.h @@ -39,18 +39,8 @@ void BKE_cachefiles_exit(void); void *BKE_cachefile_add(struct Main *bmain, const char *name); -void BKE_cachefile_init(struct CacheFile *cache_file); - -void BKE_cachefile_free(struct CacheFile *cache_file); - -void BKE_cachefile_copy_data(struct Main *bmain, - struct CacheFile *cache_file_dst, - const struct CacheFile *cache_file_src, - const int flag); struct CacheFile *BKE_cachefile_copy(struct Main *bmain, const struct CacheFile *cache_file); -void BKE_cachefile_make_local(struct Main *bmain, struct CacheFile *cache_file, const int flags); - void BKE_cachefile_reload(struct Depsgraph *depsgraph, struct CacheFile *cache_file); void BKE_cachefile_eval(struct Main *bmain, diff --git a/source/blender/blenkernel/BKE_idtype.h b/source/blender/blenkernel/BKE_idtype.h index 1c10ebbc5d5..c6f9471ec42 100644 --- a/source/blender/blenkernel/BKE_idtype.h +++ b/source/blender/blenkernel/BKE_idtype.h @@ -157,7 +157,7 @@ extern IDTypeInfo IDType_ID_WM; // extern IDTypeInfo IDType_ID_LS; // extern IDTypeInfo IDType_ID_PAL; // extern IDTypeInfo IDType_ID_PC; -// extern IDTypeInfo IDType_ID_CF; +extern IDTypeInfo IDType_ID_CF; extern IDTypeInfo IDType_ID_WS; extern IDTypeInfo IDType_ID_LP; diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c index df15031b7bc..b92a9b0c453 100644 --- a/source/blender/blenkernel/intern/cachefile.c +++ b/source/blender/blenkernel/intern/cachefile.c @@ -37,8 +37,11 @@ #include "BLI_string.h" #include "BLI_threads.h" +#include "BLT_translation.h" + #include "BKE_animsys.h" #include "BKE_cachefile.h" +#include "BKE_idtype.h" #include "BKE_lib_id.h" #include "BKE_main.h" #include "BKE_modifier.h" @@ -50,6 +53,54 @@ # include "ABC_alembic.h" #endif +static void cachefile_handle_free(CacheFile *cache_file); + +static void cache_file_init_data(ID *id) +{ + CacheFile *cache_file = (CacheFile *)id; + + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(cache_file, id)); + + cache_file->scale = 1.0f; +} + +static void cache_file_copy_data(Main *UNUSED(bmain), + ID *id_dst, + const ID *id_src, + const int UNUSED(flag)) +{ + CacheFile *cache_file_dst = (CacheFile *)id_dst; + const CacheFile *cache_file_src = (const CacheFile *)id_src; + + cache_file_dst->handle = NULL; + cache_file_dst->handle_readers = NULL; + BLI_duplicatelist(&cache_file_dst->object_paths, &cache_file_src->object_paths); +} + +static void cache_file_free_data(ID *id) +{ + CacheFile *cache_file = (CacheFile *)id; + BKE_animdata_free((ID *)cache_file, false); + cachefile_handle_free(cache_file); + BLI_freelistN(&cache_file->object_paths); +} + +IDTypeInfo IDType_ID_CF = { + .id_code = ID_CF, + .id_filter = FILTER_ID_CF, + .main_listbase_index = INDEX_ID_CF, + .struct_size = sizeof(CacheFile), + .name = "CacheFile", + .name_plural = "cache_files", + .translation_context = BLT_I18NCONTEXT_ID_CACHEFILE, + .flags = 0, + + .init_data = cache_file_init_data, + .copy_data = cache_file_copy_data, + .free_data = cache_file_free_data, + .make_local = NULL, +}; + /* TODO: make this per cache file to avoid global locks. */ static SpinLock spin; @@ -157,53 +208,11 @@ void *BKE_cachefile_add(Main *bmain, const char *name) { CacheFile *cache_file = BKE_libblock_alloc(bmain, ID_CF, name, 0); - BKE_cachefile_init(cache_file); + cache_file_init_data(&cache_file->id); return cache_file; } -void BKE_cachefile_init(CacheFile *cache_file) -{ - cache_file->filepath[0] = '\0'; - cache_file->override_frame = false; - cache_file->frame = 0.0f; - cache_file->is_sequence = false; - cache_file->scale = 1.0f; - BLI_listbase_clear(&cache_file->object_paths); - - cache_file->handle = NULL; - cache_file->handle_filepath[0] = '\0'; - cache_file->handle_readers = NULL; -} - -/** Free (or release) any data used by this cachefile (does not free the cachefile itself). */ -void BKE_cachefile_free(CacheFile *cache_file) -{ - BKE_animdata_free((ID *)cache_file, false); - cachefile_handle_free(cache_file); - BLI_freelistN(&cache_file->object_paths); -} - -/** - * Only copy internal data of CacheFile ID from source to already - * allocated/initialized destination. - * You probably never want to use that directly, - * use #BKE_id_copy or #BKE_id_copy_ex for typical needs. - * - * WARNING! This function will not handle ID user count! - * - * \param flag: Copying options (see BKE_lib_id.h's LIB_ID_COPY_... flags for more). - */ -void BKE_cachefile_copy_data(Main *UNUSED(bmain), - CacheFile *cache_file_dst, - const CacheFile *UNUSED(cache_file_src), - const int UNUSED(flag)) -{ - cache_file_dst->handle = NULL; - cache_file_dst->handle_readers = NULL; - BLI_duplicatelist(&cache_file_dst->object_paths, &cache_file_dst->object_paths); -} - CacheFile *BKE_cachefile_copy(Main *bmain, const CacheFile *cache_file) { CacheFile *cache_file_copy; @@ -211,11 +220,6 @@ CacheFile *BKE_cachefile_copy(Main *bmain, const CacheFile *cache_file) return cache_file_copy; } -void BKE_cachefile_make_local(Main *bmain, CacheFile *cache_file, const int flags) -{ - BKE_lib_id_make_local_generic(bmain, &cache_file->id, flags); -} - void BKE_cachefile_reload(Depsgraph *depsgraph, CacheFile *cache_file) { /* To force reload, free the handle and tag depsgraph to load it again. */ diff --git a/source/blender/blenkernel/intern/idtype.c b/source/blender/blenkernel/intern/idtype.c index 0e72b20e035..7bdb824eedd 100644 --- a/source/blender/blenkernel/intern/idtype.c +++ b/source/blender/blenkernel/intern/idtype.c @@ -84,7 +84,7 @@ static void id_type_init(void) // INIT_TYPE(ID_LS); // INIT_TYPE(ID_PAL); // INIT_TYPE(ID_PC); - // INIT_TYPE(ID_CF); + INIT_TYPE(ID_CF); INIT_TYPE(ID_WS); INIT_TYPE(ID_LP); diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c index 22496f47345..fa6996d8701 100644 --- a/source/blender/blenkernel/intern/lib_id.c +++ b/source/blender/blenkernel/intern/lib_id.c @@ -568,9 +568,7 @@ bool BKE_lib_id_make_local(Main *bmain, ID *id, const bool test, const int flags } return true; case ID_CF: - if (!test) { - BKE_cachefile_make_local(bmain, (CacheFile *)id, flags); - } + BLI_assert(0); return true; case ID_WS: case ID_SCR: @@ -772,7 +770,7 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag) BKE_paint_curve_copy_data(bmain, (PaintCurve *)*r_newid, (PaintCurve *)id, flag); break; case ID_CF: - BKE_cachefile_copy_data(bmain, (CacheFile *)*r_newid, (CacheFile *)id, flag); + BLI_assert(0); break; case ID_SO: BLI_assert(0); @@ -1391,7 +1389,7 @@ void BKE_libblock_init_empty(ID *id) BKE_linestyle_init((FreestyleLineStyle *)id); break; case ID_CF: - BKE_cachefile_init((CacheFile *)id); + BLI_assert(0); break; case ID_KE: /* Shapekeys are a complex topic too - they depend on their 'user' data type... diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c index f9df36a71cc..ecaf0e4cb9d 100644 --- a/source/blender/blenkernel/intern/lib_id_delete.c +++ b/source/blender/blenkernel/intern/lib_id_delete.c @@ -238,7 +238,7 @@ void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag)) BKE_paint_curve_free((PaintCurve *)id); break; case ID_CF: - BKE_cachefile_free((CacheFile *)id); + BLI_assert(0); break; case ID_WS: BLI_assert(0); |