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:
authorJacques Lucke <jacques@blender.org>2020-09-10 16:59:00 +0300
committerJacques Lucke <jacques@blender.org>2020-09-10 16:59:08 +0300
commitede094f9b207209fbd8e1d52160189ef1ed0a8c1 (patch)
tree4e92cedc0bcbf66ffa9fa72e16f0c1484ed21690 /source/blender/blenloader
parent405a5d3bd7ada5dd5af605b59ba07c7144f144a2 (diff)
Refactor: move Image .blend I/O to IDTypeInfo callbacks
Diffstat (limited to 'source/blender/blenloader')
-rw-r--r--source/blender/blenloader/intern/readfile.c57
-rw-r--r--source/blender/blenloader/intern/writefile.c40
2 files changed, 3 insertions, 94 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 969a28e6b82..ff29ebd9e95 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3023,55 +3023,6 @@ static void direct_link_world(BlendDataReader *reader, World *wrld)
/** \} */
/* -------------------------------------------------------------------- */
-/** \name Read ID: Image
- * \{ */
-
-static void lib_link_image(BlendLibReader *UNUSED(reader), Image *ima)
-{
- /* Images have some kind of 'main' cache, when NULL we should also clear all others. */
- /* Needs to be done *after* cache pointers are restored (call to
- * `foreach_cache`/`blo_cache_storage_entry_restore_in_new`), easier for now to do it in
- * lib_link... */
- if (ima->cache == NULL) {
- BKE_image_free_buffers(ima);
- }
-}
-
-static void direct_link_image(BlendDataReader *reader, Image *ima)
-{
- BLO_read_list(reader, &ima->tiles);
-
- BLO_read_list(reader, &(ima->renderslots));
- if (!BLO_read_data_is_undo(reader)) {
- /* We reset this last render slot index only when actually reading a file, not for undo. */
- ima->last_render_slot = ima->render_slot;
- }
-
- BLO_read_list(reader, &(ima->views));
- BLO_read_list(reader, &(ima->packedfiles));
-
- if (ima->packedfiles.first) {
- LISTBASE_FOREACH (ImagePackedFile *, imapf, &ima->packedfiles) {
- BKE_packedfile_blend_read(reader, &imapf->packedfile);
- }
- ima->packedfile = NULL;
- }
- else {
- BKE_packedfile_blend_read(reader, &ima->packedfile);
- }
-
- BLI_listbase_clear(&ima->anims);
- BLO_read_data_address(reader, &ima->preview);
- BKE_previewimg_blend_read(reader, ima->preview);
- BLO_read_data_address(reader, &ima->stereo3d_format);
- LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) {
- tile->ok = IMA_OK;
- }
-}
-
-/** \} */
-
-/* -------------------------------------------------------------------- */
/** \name Read ID: Curve
* \{ */
@@ -7159,9 +7110,6 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *
case ID_TE:
direct_link_texture(&reader, (Tex *)id);
break;
- case ID_IM:
- direct_link_image(&reader, (Image *)id);
- break;
case ID_LA:
direct_link_light(&reader, (Light *)id);
break;
@@ -7233,6 +7181,7 @@ static bool direct_link_id(FileData *fd, Main *main, const int tag, ID *id, ID *
case ID_PAL:
case ID_PC:
case ID_BR:
+ case ID_IM:
/* Do nothing. Handled by IDTypeInfo callback. */
break;
}
@@ -7910,9 +7859,6 @@ static void lib_link_all(FileData *fd, Main *bmain)
case ID_TE:
lib_link_texture(&reader, (Tex *)id);
break;
- case ID_IM:
- lib_link_image(&reader, (Image *)id);
- break;
case ID_GD:
lib_link_gpencil(&reader, (bGPdata *)id);
break;
@@ -7940,6 +7886,7 @@ static void lib_link_all(FileData *fd, Main *bmain)
case ID_PAL:
case ID_PC:
case ID_BR:
+ case ID_IM:
/* Do nothing. Handled by IDTypeInfo callback. */
break;
}
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 8efc181cbfc..6cab51dd03d 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1505,42 +1505,6 @@ static void write_curve(BlendWriter *writer, Curve *cu, const void *id_address)
}
}
-static void write_image(BlendWriter *writer, Image *ima, const void *id_address)
-{
- if (ima->id.us > 0 || BLO_write_is_undo(writer)) {
- ImagePackedFile *imapf;
-
- /* Some trickery to keep forward compatibility of packed images. */
- BLI_assert(ima->packedfile == NULL);
- if (ima->packedfiles.first != NULL) {
- imapf = ima->packedfiles.first;
- ima->packedfile = imapf->packedfile;
- }
-
- /* write LibData */
- BLO_write_id_struct(writer, Image, id_address, &ima->id);
- BKE_id_blend_write(writer, &ima->id);
-
- for (imapf = ima->packedfiles.first; imapf; imapf = imapf->next) {
- BLO_write_struct(writer, ImagePackedFile, imapf);
- BKE_packedfile_blend_write(writer, imapf->packedfile);
- }
-
- BKE_previewimg_blend_write(writer, ima->preview);
-
- LISTBASE_FOREACH (ImageView *, iv, &ima->views) {
- BLO_write_struct(writer, ImageView, iv);
- }
- BLO_write_struct(writer, Stereo3dFormat, ima->stereo3d_format);
-
- BLO_write_struct_list(writer, ImageTile, &ima->tiles);
-
- ima->packedfile = NULL;
-
- BLO_write_struct_list(writer, RenderSlot, &ima->renderslots);
- }
-}
-
static void write_texture(BlendWriter *writer, Tex *tex, const void *id_address)
{
if (tex->id.us > 0 || BLO_write_is_undo(writer)) {
@@ -2925,9 +2889,6 @@ static bool write_file_handle(Main *mainvar,
case ID_MB:
write_mball(&writer, (MetaBall *)id_buffer, id);
break;
- case ID_IM:
- write_image(&writer, (Image *)id_buffer, id);
- break;
case ID_CA:
write_camera(&writer, (Camera *)id_buffer, id);
break;
@@ -2996,6 +2957,7 @@ static bool write_file_handle(Main *mainvar,
case ID_PC:
case ID_PAL:
case ID_BR:
+ case ID_IM:
/* Do nothing, handled in IDTypeInfo callback. */
break;
case ID_LI: