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
path: root/source
diff options
context:
space:
mode:
authorBastien Montagne <b.mont29@gmail.com>2020-03-09 20:08:55 +0300
committerBastien Montagne <b.mont29@gmail.com>2020-03-09 20:09:23 +0300
commite672cf11c3db51ad1e66f678e85bc5879ff714cb (patch)
tree3d3a72e0bd43f110bad0d6ee28ea6678ad04b7d9 /source
parent3e9dbe7f627b05f8bfa03c1e9e1efbc87494052c (diff)
Cleanup: palette: Move to IDTypeInfo and remove unused BKE API.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/BKE_idtype.h2
-rw-r--r--source/blender/blenkernel/BKE_paint.h7
-rw-r--r--source/blender/blenkernel/intern/idtype.c2
-rw-r--r--source/blender/blenkernel/intern/lib_id.c8
-rw-r--r--source/blender/blenkernel/intern/lib_id_delete.c2
-rw-r--r--source/blender/blenkernel/intern/paint.c79
6 files changed, 50 insertions, 50 deletions
diff --git a/source/blender/blenkernel/BKE_idtype.h b/source/blender/blenkernel/BKE_idtype.h
index 9504749bb90..9562ace3c51 100644
--- a/source/blender/blenkernel/BKE_idtype.h
+++ b/source/blender/blenkernel/BKE_idtype.h
@@ -155,7 +155,7 @@ extern IDTypeInfo IDType_ID_WM;
extern IDTypeInfo IDType_ID_MC;
extern IDTypeInfo IDType_ID_MSK;
extern IDTypeInfo IDType_ID_LS;
-// extern IDTypeInfo IDType_ID_PAL;
+extern IDTypeInfo IDType_ID_PAL;
extern IDTypeInfo IDType_ID_PC;
extern IDTypeInfo IDType_ID_CF;
extern IDTypeInfo IDType_ID_WS;
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 46fb254a387..9fd732027d1 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -135,15 +135,8 @@ void BKE_paint_reset_overlay_invalid(ePaintOverlayControlFlags flag);
void BKE_paint_set_overlay_override(enum eOverlayFlags flag);
/* palettes */
-void BKE_palette_init(struct Palette *palette);
-void BKE_palette_free(struct Palette *palette);
struct Palette *BKE_palette_add(struct Main *bmain, const char *name);
-void BKE_palette_copy_data(struct Main *bmain,
- struct Palette *palette_dst,
- const struct Palette *palette_src,
- const int flag);
struct Palette *BKE_palette_copy(struct Main *bmain, const struct Palette *palette);
-void BKE_palette_make_local(struct Main *bmain, struct Palette *palette, const int flags);
struct PaletteColor *BKE_palette_color_add(struct Palette *palette);
bool BKE_palette_is_empty(const struct Palette *palette);
void BKE_palette_color_remove(struct Palette *palette, struct PaletteColor *color);
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");