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 /source/blender/blenkernel/intern/gpencil.c
parentc010290e75125a26166ae524d40e383fd3651f7e (diff)
Cleanup: GreasePencil: Move to IDTypeInfo and remove unused BKE API.
Diffstat (limited to 'source/blender/blenkernel/intern/gpencil.c')
-rw-r--r--source/blender/blenkernel/intern/gpencil.c85
1 files changed, 50 insertions, 35 deletions
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 */