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:
authorBastien Montagne <b.mont29@gmail.com>2020-03-09 19:51:49 +0300
committerBastien Montagne <b.mont29@gmail.com>2020-03-09 20:09:23 +0300
commit3e9dbe7f627b05f8bfa03c1e9e1efbc87494052c (patch)
treed2ee9f487330ecc01f7d2654e059ee19d709d295
parentc010290e75125a26166ae524d40e383fd3651f7e (diff)
Cleanup: GreasePencil: Move to IDTypeInfo and remove unused BKE API.
-rw-r--r--source/blender/blenkernel/BKE_gpencil.h3
-rw-r--r--source/blender/blenkernel/BKE_idtype.h2
-rw-r--r--source/blender/blenkernel/intern/gpencil.c85
-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
6 files changed, 56 insertions, 46 deletions
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index 9d382775df7..3284896795b 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -112,15 +112,12 @@ struct bGPDlayer *BKE_gpencil_layer_duplicate(const struct bGPDlayer *gpl_src);
void BKE_gpencil_frame_copy_strokes(struct bGPDframe *gpf_src, struct bGPDframe *gpf_dst);
struct bGPDstroke *BKE_gpencil_stroke_duplicate(struct bGPDstroke *gps_src, const bool dup_points);
-void BKE_gpencil_copy_data(struct bGPdata *gpd_dst, const struct bGPdata *gpd_src, const int flag);
struct bGPdata *BKE_gpencil_copy(struct Main *bmain, const struct bGPdata *gpd);
struct bGPdata *BKE_gpencil_data_duplicate(struct Main *bmain,
const struct bGPdata *gpd,
bool internal_copy);
-void BKE_gpencil_make_local(struct Main *bmain, struct bGPdata *gpd, const int flags);
-
void BKE_gpencil_frame_delete_laststroke(struct bGPDlayer *gpl, struct bGPDframe *gpf);
/* materials */
diff --git a/source/blender/blenkernel/BKE_idtype.h b/source/blender/blenkernel/BKE_idtype.h
index 2bd111bea0e..9504749bb90 100644
--- a/source/blender/blenkernel/BKE_idtype.h
+++ b/source/blender/blenkernel/BKE_idtype.h
@@ -150,7 +150,7 @@ extern IDTypeInfo IDType_ID_AC;
extern IDTypeInfo IDType_ID_NT;
extern IDTypeInfo IDType_ID_BR;
extern IDTypeInfo IDType_ID_PA;
-// extern IDTypeInfo IDType_ID_GD;
+extern IDTypeInfo IDType_ID_GD;
extern IDTypeInfo IDType_ID_WM;
extern IDTypeInfo IDType_ID_MC;
extern IDTypeInfo IDType_ID_MSK;
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 0b33eaccb6f..e2f28355ff3 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -59,6 +59,7 @@
#include "BKE_deform.h"
#include "BKE_gpencil.h"
#include "BKE_icons.h"
+#include "BKE_idtype.h"
#include "BKE_image.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
@@ -73,6 +74,54 @@
static CLG_LogRef LOG = {"bke.gpencil"};
+static void greasepencil_copy_data(Main *UNUSED(bmain),
+ ID *id_dst,
+ const ID *id_src,
+ const int UNUSED(flag))
+{
+ bGPdata *gpd_dst = (bGPdata *)id_dst;
+ const bGPdata *gpd_src = (const bGPdata *)id_src;
+
+ /* duplicate material array */
+ if (gpd_src->mat) {
+ gpd_dst->mat = MEM_dupallocN(gpd_src->mat);
+ }
+
+ /* copy layers */
+ BLI_listbase_clear(&gpd_dst->layers);
+ LISTBASE_FOREACH (bGPDlayer *, gpl_src, &gpd_src->layers) {
+ /* make a copy of source layer and its data */
+
+ /* TODO here too could add unused flags... */
+ bGPDlayer *gpl_dst = BKE_gpencil_layer_duplicate(gpl_src);
+
+ BLI_addtail(&gpd_dst->layers, gpl_dst);
+ }
+}
+
+static void greasepencil_free_data(ID *id)
+{
+ /* Really not ideal, but for now will do... In theory custom behaviors like not freeing cache
+ * should be handled through specific API, and not be part of the generic one. */
+ BKE_gpencil_free((bGPdata *)id, true);
+}
+
+IDTypeInfo IDType_ID_GD = {
+ .id_code = ID_GD,
+ .id_filter = FILTER_ID_GD,
+ .main_listbase_index = INDEX_ID_GD,
+ .struct_size = sizeof(bGPdata),
+ .name = "GPencil",
+ .name_plural = "grease_pencils",
+ .translation_context = BLT_I18NCONTEXT_ID_GPENCIL,
+ .flags = 0,
+
+ .init_data = NULL,
+ .copy_data = greasepencil_copy_data,
+ .free_data = greasepencil_free_data,
+ .make_local = NULL,
+};
+
/* ************************************************** */
/* Draw Engine */
@@ -671,35 +720,6 @@ bGPDlayer *BKE_gpencil_layer_duplicate(const bGPDlayer *gpl_src)
return gpl_dst;
}
-/**
- * Only copy internal data of GreasePencil 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_gpencil_copy_data(bGPdata *gpd_dst, const bGPdata *gpd_src, const int UNUSED(flag))
-{
- /* duplicate material array */
- if (gpd_src->mat) {
- gpd_dst->mat = MEM_dupallocN(gpd_src->mat);
- }
-
- /* copy layers */
- BLI_listbase_clear(&gpd_dst->layers);
- LISTBASE_FOREACH (bGPDlayer *, gpl_src, &gpd_src->layers) {
- /* make a copy of source layer and its data */
-
- /* TODO here too could add unused flags... */
- bGPDlayer *gpl_dst = BKE_gpencil_layer_duplicate(gpl_src);
-
- BLI_addtail(&gpd_dst->layers, gpl_dst);
- }
-}
-
/* Standard API to make a copy of GP datablock, separate from copying its data */
bGPdata *BKE_gpencil_copy(Main *bmain, const bGPdata *gpd)
{
@@ -733,17 +753,12 @@ bGPdata *BKE_gpencil_data_duplicate(Main *bmain, const bGPdata *gpd_src, bool in
}
/* Copy internal data (layers, etc.) */
- BKE_gpencil_copy_data(gpd_dst, gpd_src, 0);
+ greasepencil_copy_data(bmain, &gpd_dst->id, &gpd_src->id, 0);
/* return new */
return gpd_dst;
}
-void BKE_gpencil_make_local(Main *bmain, bGPdata *gpd, const int flags)
-{
- BKE_lib_id_make_local_generic(bmain, &gpd->id, flags);
-}
-
/* ************************************************** */
/* GP Stroke API */
diff --git a/source/blender/blenkernel/intern/idtype.c b/source/blender/blenkernel/intern/idtype.c
index 6fbce96c870..bf2b949eccf 100644
--- a/source/blender/blenkernel/intern/idtype.c
+++ b/source/blender/blenkernel/intern/idtype.c
@@ -77,7 +77,7 @@ static void id_type_init(void)
INIT_TYPE(ID_NT);
INIT_TYPE(ID_BR);
INIT_TYPE(ID_PA);
- // INIT_TYPE(ID_GD);
+ INIT_TYPE(ID_GD);
INIT_TYPE(ID_WM);
INIT_TYPE(ID_MC);
INIT_TYPE(ID_MSK);
diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index 17e9adbfba6..abd12d1f606 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -536,9 +536,7 @@ bool BKE_lib_id_make_local(Main *bmain, ID *id, const bool test, const int flags
BLI_assert(0);
return true;
case ID_GD:
- if (!test) {
- BKE_gpencil_make_local(bmain, (bGPdata *)id, flags);
- }
+ BLI_assert(0);
return true;
case ID_MC:
BLI_assert(0);
@@ -740,7 +738,7 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag)
BLI_assert(0);
break;
case ID_GD:
- BKE_gpencil_copy_data((bGPdata *)*r_newid, (bGPdata *)id, flag);
+ BLI_assert(0);
break;
case ID_MC:
BLI_assert(0);
@@ -1368,7 +1366,7 @@ void BKE_libblock_init_empty(ID *id)
BLI_assert(0);
break;
case ID_GD:
- /* Nothing to do. */
+ BLI_assert(0);
break;
case ID_MSK:
BLI_assert(0);
diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c
index fb89aab75fb..e743f29eeda 100644
--- a/source/blender/blenkernel/intern/lib_id_delete.c
+++ b/source/blender/blenkernel/intern/lib_id_delete.c
@@ -220,7 +220,7 @@ void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
BLI_assert(0);
break;
case ID_GD:
- BKE_gpencil_free((bGPdata *)id, true);
+ BLI_assert(0);
break;
case ID_MC:
BLI_assert(0);