diff options
author | Bastien Montagne <b.mont29@gmail.com> | 2020-03-09 20:08:55 +0300 |
---|---|---|
committer | Bastien Montagne <b.mont29@gmail.com> | 2020-03-09 20:09:23 +0300 |
commit | e672cf11c3db51ad1e66f678e85bc5879ff714cb (patch) | |
tree | 3d3a72e0bd43f110bad0d6ee28ea6678ad04b7d9 /source/blender/blenkernel/intern | |
parent | 3e9dbe7f627b05f8bfa03c1e9e1efbc87494052c (diff) |
Cleanup: palette: Move to IDTypeInfo and remove unused BKE API.
Diffstat (limited to 'source/blender/blenkernel/intern')
-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 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 79 |
4 files changed, 49 insertions, 42 deletions
diff --git a/source/blender/blenkernel/intern/idtype.c b/source/blender/blenkernel/intern/idtype.c index bf2b949eccf..ff4d06cd011 100644 --- a/source/blender/blenkernel/intern/idtype.c +++ b/source/blender/blenkernel/intern/idtype.c @@ -82,7 +82,7 @@ static void id_type_init(void) INIT_TYPE(ID_MC); INIT_TYPE(ID_MSK); INIT_TYPE(ID_LS); - // INIT_TYPE(ID_PAL); + INIT_TYPE(ID_PAL); INIT_TYPE(ID_PC); INIT_TYPE(ID_CF); INIT_TYPE(ID_WS); diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c index abd12d1f606..3d4e86d0c5c 100644 --- a/source/blender/blenkernel/intern/lib_id.c +++ b/source/blender/blenkernel/intern/lib_id.c @@ -548,9 +548,7 @@ bool BKE_lib_id_make_local(Main *bmain, ID *id, const bool test, const int flags BLI_assert(0); return true; case ID_PAL: - if (!test) { - BKE_palette_make_local(bmain, (Palette *)id, flags); - } + BLI_assert(0); return true; case ID_PC: BLI_assert(0); @@ -750,7 +748,7 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag) BLI_assert(0); break; case ID_PAL: - BKE_palette_copy_data(bmain, (Palette *)*r_newid, (Palette *)id, flag); + BLI_assert(0); break; case ID_PC: BLI_assert(0); @@ -1391,7 +1389,7 @@ void BKE_libblock_init_empty(ID *id) BLI_assert(0); break; case ID_PAL: - BKE_palette_init((Palette *)id); + BLI_assert(0); break; default: BLI_assert(0); /* Should never reach this point... */ diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c index e743f29eeda..0548bb47509 100644 --- a/source/blender/blenkernel/intern/lib_id_delete.c +++ b/source/blender/blenkernel/intern/lib_id_delete.c @@ -232,7 +232,7 @@ void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag)) BLI_assert(0); break; case ID_PAL: - BKE_palette_free((Palette *)id); + BLI_assert(0); break; case ID_PC: BLI_assert(0); diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index e6042b6ad4c..6afa498cf86 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -75,6 +75,50 @@ #include "bmesh.h" +static void palette_init_data(ID *id) +{ + Palette *palette = (Palette *)id; + + BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(palette, id)); + + /* Enable fake user by default. */ + id_fake_user_set(&palette->id); +} + +static void palette_copy_data(Main *UNUSED(bmain), + ID *id_dst, + const ID *id_src, + const int UNUSED(flag)) +{ + Palette *palette_dst = (Palette *)id_dst; + const Palette *palette_src = (const Palette *)id_src; + + BLI_duplicatelist(&palette_dst->colors, &palette_src->colors); +} + +static void palette_free_data(ID *id) +{ + Palette *palette = (Palette *)id; + + BLI_freelistN(&palette->colors); +} + +IDTypeInfo IDType_ID_PAL = { + .id_code = ID_PAL, + .id_filter = FILTER_ID_PAL, + .main_listbase_index = INDEX_ID_PAL, + .struct_size = sizeof(Palette), + .name = "Palette", + .name_plural = "palettes", + .translation_context = BLT_I18NCONTEXT_ID_PALETTE, + .flags = 0, + + .init_data = palette_init_data, + .copy_data = palette_copy_data, + .free_data = palette_free_data, + .make_local = NULL, +}; + static void paint_curve_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, @@ -642,24 +686,6 @@ Palette *BKE_palette_add(Main *bmain, const char *name) return palette; } -/** - * Only copy internal data of Palette 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_palette_copy_data(Main *UNUSED(bmain), - Palette *palette_dst, - const Palette *palette_src, - const int UNUSED(flag)) -{ - BLI_duplicatelist(&palette_dst->colors, &palette_src->colors); -} - Palette *BKE_palette_copy(Main *bmain, const Palette *palette) { Palette *palette_copy; @@ -667,23 +693,6 @@ Palette *BKE_palette_copy(Main *bmain, const Palette *palette) return palette_copy; } -void BKE_palette_make_local(Main *bmain, Palette *palette, const int flags) -{ - BKE_lib_id_make_local_generic(bmain, &palette->id, flags); -} - -void BKE_palette_init(Palette *palette) -{ - /* Enable fake user by default. */ - id_fake_user_set(&palette->id); -} - -/** Free (or release) any data used by this palette (does not free the palette itself). */ -void BKE_palette_free(Palette *palette) -{ - BLI_freelistN(&palette->colors); -} - PaletteColor *BKE_palette_color_add(Palette *palette) { PaletteColor *color = MEM_callocN(sizeof(*color), "Palette Color"); |