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:
authorJacques Lucke <jacques@blender.org>2020-09-10 15:42:39 +0300
committerJacques Lucke <jacques@blender.org>2020-09-10 15:42:54 +0300
commit3679f899fb6048efd47a7325df65d7bcefc92482 (patch)
treed38498a0dfa930fea0a26810f3fb62f51a0a32fa /source
parentfbc12e6cc5ea72215ade0ac3405c50ca7c89e29c (diff)
Refactor: move VFont .blend I/O to IDTypeInfo callbacks
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/font.c31
-rw-r--r--source/blender/blenloader/intern/readfile.c25
-rw-r--r--source/blender/blenloader/intern/writefile.c20
3 files changed, 32 insertions, 44 deletions
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index 604637e2350..88d91cf5640 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -57,6 +57,8 @@
#include "BKE_main.h"
#include "BKE_packedFile.h"
+#include "BLO_read_write.h"
+
static CLG_LogRef LOG = {"bke.data_transfer"};
static ThreadRWMutex vfont_rwlock = BLI_RWLOCK_INITIALIZER;
@@ -120,6 +122,31 @@ static void vfont_free_data(ID *id)
}
}
+static void vfont_blend_write(BlendWriter *writer, ID *id, const void *id_address)
+{
+ VFont *vf = (VFont *)id;
+ if (vf->id.us > 0 || BLO_write_is_undo(writer)) {
+ /* Clean up, important in undo case to reduce false detection of changed datablocks. */
+ vf->data = NULL;
+ vf->temp_pf = NULL;
+
+ /* write LibData */
+ BLO_write_id_struct(writer, VFont, id_address, &vf->id);
+ BKE_id_blend_write(writer, &vf->id);
+
+ /* direct data */
+ BKE_packedfile_blend_write(writer, vf->packedfile);
+ }
+}
+
+static void vfont_blend_read_data(BlendDataReader *reader, ID *id)
+{
+ VFont *vf = (VFont *)id;
+ vf->data = NULL;
+ vf->temp_pf = NULL;
+ BKE_packedfile_blend_read(reader, &vf->packedfile);
+}
+
IDTypeInfo IDType_ID_VF = {
.id_code = ID_VF,
.id_filter = FILTER_ID_VF,
@@ -137,8 +164,8 @@ IDTypeInfo IDType_ID_VF = {
.foreach_id = NULL,
.foreach_cache = NULL,
- .blend_write = NULL,
- .blend_read_data = NULL,
+ .blend_write = vfont_blend_write,
+ .blend_read_data = vfont_blend_read_data,
.blend_read_lib = NULL,
.blend_read_expand = NULL,
};
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 9d0a61c8a1a..4f1cb4e0ecc 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3151,23 +3151,6 @@ static void direct_link_world(BlendDataReader *reader, World *wrld)
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Read ID: VFont
- * \{ */
-
-static void lib_link_vfont(BlendLibReader *UNUSED(reader), VFont *UNUSED(vf))
-{
-}
-
-static void direct_link_vfont(BlendDataReader *reader, VFont *vf)
-{
- vf->data = NULL;
- vf->temp_pf = NULL;
- BKE_packedfile_blend_read(reader, &vf->packedfile);
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
/** \name Read ID: Image
* \{ */
@@ -7413,9 +7396,6 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *
case ID_LA:
direct_link_light(&reader, (Light *)id);
break;
- case ID_VF:
- direct_link_vfont(&reader, (VFont *)id);
- break;
case ID_IP:
direct_link_ipo(&reader, (Ipo *)id);
break;
@@ -7491,6 +7471,7 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *
case ID_NT:
case ID_LS:
case ID_TXT:
+ case ID_VF:
/* Do nothing. Handled by IDTypeInfo callback. */
break;
}
@@ -8162,9 +8143,6 @@ static void lib_link_all(FileData *fd, Main *bmain)
case ID_AR:
lib_link_armature(&reader, (bArmature *)id);
break;
- case ID_VF:
- lib_link_vfont(&reader, (VFont *)id);
- break;
case ID_HA:
lib_link_hair(&reader, (Hair *)id);
break;
@@ -8208,6 +8186,7 @@ static void lib_link_all(FileData *fd, Main *bmain)
case ID_NT:
case ID_LS:
case ID_TXT:
+ case ID_VF:
/* Do nothing. Handled by IDTypeInfo callback. */
break;
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index ab52e2f95b7..6ede8711138 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1393,22 +1393,6 @@ static void write_object(BlendWriter *writer, Object *ob, const void *id_address
}
}
-static void write_vfont(BlendWriter *writer, VFont *vf, const void *id_address)
-{
- if (vf->id.us > 0 || BLO_write_is_undo(writer)) {
- /* Clean up, important in undo case to reduce false detection of changed datablocks. */
- vf->data = NULL;
- vf->temp_pf = NULL;
-
- /* write LibData */
- BLO_write_id_struct(writer, VFont, id_address, &vf->id);
- BKE_id_blend_write(writer, &vf->id);
-
- /* direct data */
- BKE_packedfile_blend_write(writer, vf->packedfile);
- }
-}
-
static void write_key(BlendWriter *writer, Key *key, const void *id_address)
{
if (key->id.us > 0 || BLO_write_is_undo(writer)) {
@@ -3096,9 +3080,6 @@ static bool write_file_handle(Main *mainvar,
case ID_LA:
write_light(&writer, (Light *)id_buffer, id);
break;
- case ID_VF:
- write_vfont(&writer, (VFont *)id_buffer, id);
- break;
case ID_KE:
write_key(&writer, (Key *)id_buffer, id);
break;
@@ -3165,6 +3146,7 @@ static bool write_file_handle(Main *mainvar,
case ID_NT:
case ID_LS:
case ID_TXT:
+ case ID_VF:
/* Do nothing, handled in IDTypeInfo callback. */
break;
case ID_LI: