|
Blender V4.5
|
#include <cerrno>#include <climits>#include <cstdio>#include <cstdlib>#include <cstring>#include <fcntl.h>#include <iomanip>#include <sstream>#include <unistd.h>#include <fmt/format.h>#include "BLI_utildefines.h"#include "CLG_log.h"#include "DNA_fileglobal_types.h"#include "DNA_genfile.h"#include "DNA_key_types.h"#include "DNA_print.hh"#include "DNA_sdna_types.h"#include "DNA_userdef_types.h"#include "BLI_endian_defines.h"#include "BLI_endian_switch.h"#include "BLI_fileops.hh"#include "BLI_implicit_sharing.hh"#include "BLI_math_base.h"#include "BLI_multi_value_map.hh"#include "BLI_path_utils.hh"#include "BLI_set.hh"#include "BLI_string.h"#include "BLI_threads.h"#include "MEM_guardedalloc.h"#include "BKE_asset.hh"#include "BKE_blender_version.h"#include "BKE_bpath.hh"#include "BKE_global.hh"#include "BKE_idprop.hh"#include "BKE_idtype.hh"#include "BKE_layer.hh"#include "BKE_lib_id.hh"#include "BKE_lib_override.hh"#include "BKE_lib_query.hh"#include "BKE_library.hh"#include "BKE_main.hh"#include "BKE_main_namemap.hh"#include "BKE_node.hh"#include "BKE_packedFile.hh"#include "BKE_preferences.h"#include "BKE_report.hh"#include "BKE_workspace.hh"#include "DRW_engine.hh"#include "BLO_blend_validate.hh"#include "BLO_read_write.hh"#include "BLO_readfile.hh"#include "BLO_undofile.hh"#include "BLO_writefile.hh"#include "readfile.hh"#include <zstd.h>Go to the source code of this file.
Classes | |
| struct | ZstdFrame |
| class | WriteWrap |
| class | RawWriteWrap |
| class | ZstdWriteWrap |
| struct | ZstdWriteWrap::ZstdWriteBlockTask |
| struct | WriteData |
| struct | BlendWriter |
| struct | RenderInfo |
Macros | |
| #define | DNA_DEPRECATED_ALLOW |
| #define | U (*((const UserDef *)&U)) |
| #define | GENERATE_DEBUG_BLEND_FILE 0 |
| #define | DEBUG_BLEND_FILE_SUFFIX ".debug.txt" |
| #define | MEM_BUFFER_SIZE MEM_SIZE_OPTIMAL(1 << 17) /* 128kb */ |
| #define | MEM_CHUNK_SIZE MEM_SIZE_OPTIMAL(1 << 15) /* ~32kb */ |
| #define | ZSTD_BUFFER_SIZE (1 << 21) /* 2mb */ |
| #define | ZSTD_CHUNK_SIZE (1 << 20) /* 1mb */ |
| #define | ZSTD_COMPRESSION_LEVEL 3 |
Functions | |
Write Data Type & Functions | |
| static WriteData * | writedata_new (WriteWrap *ww) |
| static void | writedata_do_write (WriteData *wd, const void *mem, const size_t memlen) |
| static void | writedata_free (WriteData *wd) |
Local Writing API 'mywrite' | |
| static void | mywrite_flush (WriteData *wd) |
| static void | mywrite (WriteData *wd, const void *adr, size_t len) |
| static WriteData * | mywrite_begin (WriteWrap *ww, MemFile *compare, MemFile *current) |
| static bool | mywrite_end (WriteData *wd) |
| static void | mywrite_id_begin (WriteData *wd, ID *id) |
| static void | mywrite_id_end (WriteData *wd, ID *) |
Typed DNA File Writing | |
These functions are used by blender's .blend system for file saving/loading. | |
| static void | current_screen_compat (Main *mainvar, const bool use_active_win, bScreen **r_screen, Scene **r_scene, ViewLayer **r_view_layer) |
| static void | write_renderinfo (WriteData *wd, Main *mainvar) |
| static void | write_keymapitem (BlendWriter *writer, const wmKeyMapItem *kmi) |
| static void | write_userdef (BlendWriter *writer, const UserDef *userdef) |
| static void | write_id (WriteData *wd, ID *id) |
| static void | write_id_placeholder (WriteData *wd, ID *id) |
| static void | write_libraries (WriteData *wd, Main *bmain) |
| static void | write_global (WriteData *wd, const int fileflags, Main *mainvar) |
| static void | write_thumb (WriteData *wd, const BlendThumbnail *thumb) |
File Writing (Private) | |
| static int | write_id_direct_linked_data_process_cb (LibraryIDLinkCallbackData *cb_data) |
| static std::string | get_blend_file_header () |
| static void | write_blend_file_header (WriteData *wd) |
| static blender::Vector< ID * > | gather_local_ids_to_write (Main *bmain, const bool is_undo) |
| static bool | write_file_handle (Main *mainvar, WriteWrap *ww, MemFile *compare, MemFile *current, const int write_flags, const bool use_userdef, const BlendThumbnail *thumb, std::ostream *debug_dst) |
| static bool | do_history (const char *filepath, ReportList *reports) |
| static void | write_file_main_validate_pre (Main *bmain, ReportList *reports) |
| static void | write_file_main_validate_post (Main *bmain, ReportList *reports) |
| static bool | BLO_write_file_impl (Main *mainvar, const char *filepath, const int write_flags, const BlendFileWriteParams *params, ReportList *reports, WriteWrap &ww) |
File Writing (Public) | |
| bool | BLO_write_file (Main *mainvar, const char *filepath, const int write_flags, const BlendFileWriteParams *params, ReportList *reports) |
| bool | BLO_write_file_mem (Main *mainvar, MemFile *compare, MemFile *current, const int write_flags) |
| void | BLO_write_raw (BlendWriter *writer, const size_t size_in_bytes, const void *data_ptr) |
| void | BLO_write_struct_by_name (BlendWriter *writer, const char *struct_name, const void *data_ptr) |
| void | BLO_write_struct_array_by_name (BlendWriter *writer, const char *struct_name, const int64_t array_size, const void *data_ptr) |
| void | BLO_write_struct_by_id (BlendWriter *writer, const int struct_id, const void *data_ptr) |
| void | BLO_write_struct_at_address_by_id (BlendWriter *writer, const int struct_id, const void *address, const void *data_ptr) |
| void | BLO_write_struct_at_address_by_id_with_filecode (BlendWriter *writer, const int filecode, const int struct_id, const void *address, const void *data_ptr) |
| void | BLO_write_struct_array_by_id (BlendWriter *writer, const int struct_id, const int64_t array_size, const void *data_ptr) |
| void | BLO_write_struct_array_at_address_by_id (BlendWriter *writer, const int struct_id, const int64_t array_size, const void *address, const void *data_ptr) |
| void | BLO_write_struct_list_by_id (BlendWriter *writer, const int struct_id, const ListBase *list) |
| void | BLO_write_struct_list_by_name (BlendWriter *writer, const char *struct_name, ListBase *list) |
| void | blo_write_id_struct (BlendWriter *writer, const int struct_id, const void *id_address, const ID *id) |
| int | BLO_get_struct_id_by_name (const BlendWriter *writer, const char *struct_name) |
| void | BLO_write_char_array (BlendWriter *writer, const int64_t num, const char *data_ptr) |
| void | BLO_write_int8_array (BlendWriter *writer, const int64_t num, const int8_t *data_ptr) |
| void | BLO_write_int16_array (BlendWriter *writer, const int64_t num, const int16_t *data_ptr) |
| void | BLO_write_uint8_array (BlendWriter *writer, const int64_t num, const uint8_t *data_ptr) |
| void | BLO_write_int32_array (BlendWriter *writer, const int64_t num, const int32_t *data_ptr) |
| void | BLO_write_uint32_array (BlendWriter *writer, const int64_t num, const uint32_t *data_ptr) |
| void | BLO_write_float_array (BlendWriter *writer, const int64_t num, const float *data_ptr) |
| void | BLO_write_double_array (BlendWriter *writer, const int64_t num, const double *data_ptr) |
| void | BLO_write_pointer_array (BlendWriter *writer, const int64_t num, const void *data_ptr) |
| void | BLO_write_float3_array (BlendWriter *writer, const int64_t num, const float *data_ptr) |
| void | BLO_write_string (BlendWriter *writer, const char *data_ptr) |
| void | BLO_write_shared (BlendWriter *writer, const void *data, const size_t approximate_size_in_bytes, const blender::ImplicitSharingInfo *sharing_info, const blender::FunctionRef< void()> write_fn) |
| bool | BLO_write_is_undo (BlendWriter *writer) |
Variables | |
| static CLG_LogRef | LOG = {"blo.writefile"} |
Generic DNA File Writing | |
| #define | writestruct_at_address(wd, filecode, struct_id, nr, adr, data) |
| #define | writestruct(wd, filecode, struct_id, nr, adr) |
| static bool | write_at_address_validate (WriteData *wd, const int filecode, const void *address) |
| static void | write_bhead (WriteData *wd, const BHead &bhead) |
| static void | writestruct_at_address_nr (WriteData *wd, const int filecode, const int struct_nr, const int64_t nr, const void *adr, const void *data) |
| static void | writestruct_nr (WriteData *wd, const int filecode, const int struct_nr, const int64_t nr, const void *adr) |
| static void | write_raw_data_in_debug_file (WriteData *wd, const size_t len, const void *adr) |
| static void | writedata (WriteData *wd, const int filecode, const size_t len, const void *adr) |
| static void | writelist_nr (WriteData *wd, const int filecode, const int struct_nr, const ListBase *lb) |
| #define DEBUG_BLEND_FILE_SUFFIX ".debug.txt" |
Definition at line 146 of file writefile.cc.
Referenced by BLO_write_file_impl().
| #define DNA_DEPRECATED_ALLOW |
IFF-style structure (but not IFF compatible!)
Start file:
`BLENDER_V100` `12` bytes (version 1.00 is just an example).
`V` = big endian, `v` = little endian.
`_` = 4 byte pointer, `-` = 8 byte pointer.
data-blocks: (also see struct BHead).
`bh.code` `char[4]` see `BLO_core_bhead.hh` for a list of known types. `bh.len` `int32` length data after BHead in bytes. `bh.old` `void *` old pointer (the address at the time of writing the file). `bh.SDNAnr` `int32` struct index of structs stored in #DNA1 data. `bh.nr` `int32` in case of array: number of structs. data ... ...
Almost all data in Blender are structures. Each struct saved gets a BHead header. With BHead the struct can be linked again and compared with #StructDNA.
Preferred writing order: (not really a must, but why would you do it random?) Any case: direct data is ALWAYS after the lib block.
(Local file data)
Definition at line 85 of file writefile.cc.
| #define GENERATE_DEBUG_BLEND_FILE 0 |
Generate an additional file next to every saved .blend file that contains the file content in a more human readable form.
Definition at line 145 of file writefile.cc.
| #define MEM_BUFFER_SIZE MEM_SIZE_OPTIMAL(1 << 17) /* 128kb */ |
Definition at line 151 of file writefile.cc.
Referenced by writedata_new().
| #define MEM_CHUNK_SIZE MEM_SIZE_OPTIMAL(1 << 15) /* ~32kb */ |
Definition at line 152 of file writefile.cc.
Referenced by writedata_new().
| #define U (*((const UserDef *)&U)) |
Definition at line 139 of file writefile.cc.
| #define writestruct | ( | wd, | |
| filecode, | |||
| struct_id, | |||
| nr, | |||
| adr ) |
Definition at line 923 of file writefile.cc.
Referenced by BKE_modifier_blend_write(), write_global(), and write_userdef().
| #define writestruct_at_address | ( | wd, | |
| filecode, | |||
| struct_id, | |||
| nr, | |||
| adr, | |||
| data ) |
Definition at line 919 of file writefile.cc.
Referenced by write_id_placeholder().
| #define ZSTD_BUFFER_SIZE (1 << 21) /* 2mb */ |
Definition at line 154 of file writefile.cc.
Referenced by writedata_new().
| #define ZSTD_CHUNK_SIZE (1 << 20) /* 1mb */ |
Definition at line 155 of file writefile.cc.
Referenced by writedata_new().
| #define ZSTD_COMPRESSION_LEVEL 3 |
Definition at line 157 of file writefile.cc.
| int BLO_get_struct_id_by_name | ( | const BlendWriter * | writer, |
| const char * | struct_name ) |
Mapping between names and ids.
Definition at line 2004 of file writefile.cc.
References DNA_struct_find_with_alias(), WriteData::sdna, and BlendWriter::wd.
Referenced by BLO_write_struct_array_by_name(), and BLO_write_struct_list_by_name().
| void BLO_write_char_array | ( | BlendWriter * | writer, |
| int64_t | num, | ||
| const char * | data_ptr ) |
Slightly 'safer' code to write arrays of basic types data.
Definition at line 2010 of file writefile.cc.
References BLO_write_raw(), and num.
Referenced by console_space_blend_write(), IDP_WriteString(), and object_blend_write().
| void BLO_write_double_array | ( | BlendWriter * | writer, |
| const int64_t | num, | ||
| const double * | data_ptr ) |
Definition at line 2045 of file writefile.cc.
References BLO_write_raw(), and num.
Referenced by IDP_WriteArray(), and write_ui_data().
| bool BLO_write_file | ( | Main * | mainvar, |
| const char * | filepath, | ||
| int | write_flags, | ||
| const BlendFileWriteParams * | params, | ||
| ReportList * | reports ) |
Definition at line 1888 of file writefile.cc.
References BLO_write_file_impl(), G_FILE_COMPRESS, params, and reports.
Referenced by BKE_blendfile_userdef_write(), BKE_memfile_undo_encode(), WM_autosave_write(), WM_exit_ex(), wm_file_write(), wm_homefile_write_exec(), blender::bke::blendfile::PartialWriteContext::write(), and write_crash_blend().
|
static |
Definition at line 1708 of file writefile.cc.
References BKE_bpath_absolute_convert(), BKE_BPATH_FOREACH_PATH_SKIP_LINKED, BKE_BPATH_FOREACH_PATH_SKIP_MULTIFILE, BKE_bpath_list_backup(), BKE_bpath_list_free(), BKE_bpath_list_restore(), BKE_bpath_relative_convert(), BKE_bpath_relative_rebase(), BKE_report(), BKE_reportf(), BLI_assert, BLI_assert_unreachable, BLI_path_cmp, BLI_path_is_abs_from_cwd(), BLI_path_is_rel(), BLI_path_normalize(), BLI_path_split_dir_part(), BLI_rename_overwrite(), BLO_WRITE_PATH_REMAP_ABSOLUTE, BLO_WRITE_PATH_REMAP_NONE, BLO_WRITE_PATH_REMAP_RELATIVE, BLO_WRITE_PATH_REMAP_RELATIVE_ALL, WriteWrap::close(), DEBUG_BLEND_FILE_SUFFIX, do_history(), FILE_MAX, Main::filepath, G, G_FILE_ASSET_EDIT_FILE, Main::is_asset_edit_file, Main::is_global_main, WriteWrap::open(), params, reports, RPT_ERROR, SNPRINTF, STRNCPY(), UNLIKELY, write_file_handle(), write_file_main_validate_post(), and write_file_main_validate_pre().
Referenced by BLO_write_file().
Definition at line 1904 of file writefile.cc.
References write_file_handle().
Referenced by BKE_memfile_undo_encode().
| void BLO_write_float3_array | ( | BlendWriter * | writer, |
| const int64_t | num, | ||
| const float * | data_ptr ) |
Definition at line 2055 of file writefile.cc.
References BLO_write_raw(), and num.
Referenced by blend_write(), blend_write(), blend_write(), blend_write(), lightprobe_grid_cache_frame_blend_write(), blender::bke::write_array_data(), and write_mdisps().
| void BLO_write_float_array | ( | BlendWriter * | writer, |
| const int64_t | num, | ||
| const float * | data_ptr ) |
Definition at line 2040 of file writefile.cc.
References BLO_write_raw(), and num.
Referenced by BKE_constraint_blend_write(), BKE_fmodifiers_blend_write(), BKE_ptcache_blend_write(), blend_write(), blend_write_layer_data(), curve_blend_write(), IDP_WriteArray(), lightprobe_grid_cache_frame_blend_write(), mask_blend_write(), blender::bke::write_array_data(), and write_grid_paint_mask().
| void blo_write_id_struct | ( | BlendWriter * | writer, |
| int | struct_id, | ||
| const void * | id_address, | ||
| const ID * | id ) |
Write id struct.
Definition at line 1996 of file writefile.cc.
References GS, ID::name, BlendWriter::wd, and writestruct_at_address_nr().
| void BLO_write_int16_array | ( | BlendWriter * | writer, |
| const int64_t | num, | ||
| const int16_t * | data_ptr ) |
Definition at line 2020 of file writefile.cc.
References BLO_write_raw(), and num.
Referenced by blender::bke::write_array_data().
| void BLO_write_int32_array | ( | BlendWriter * | writer, |
| const int64_t | num, | ||
| const int32_t * | data_ptr ) |
Definition at line 2030 of file writefile.cc.
References BLO_write_raw(), and num.
Referenced by blend_write(), blend_write(), IDP_WriteArray(), blender::bke::write_array_data(), write_layer(), and write_ui_data().
| void BLO_write_int8_array | ( | BlendWriter * | writer, |
| const int64_t | num, | ||
| const int8_t * | data_ptr ) |
Definition at line 2015 of file writefile.cc.
References BLO_write_raw(), and num.
Referenced by IDP_WriteArray(), lightprobe_grid_cache_frame_blend_write(), blender::bke::write_array_data(), write_mdisps(), and write_ui_data().
| bool BLO_write_is_undo | ( | BlendWriter * | writer | ) |
Sometimes different data is written depending on whether the file is saved to disk or used for undo. This function returns true when the current file-writing is done for undo.
Definition at line 2100 of file writefile.cc.
References WriteData::use_memfile, and BlendWriter::wd.
Referenced by blender::bke::action_blend_write(), blend_write(), blend_write(), blend_write(), blend_write(), blender::blend_write(), blend_write_layer_data(), BLO_Write_IDBuffer::BLO_Write_IDBuffer(), BLO_write_shared(), camera_blend_write(), CustomData_blend_write(), image_blend_write(), library_blend_write_data(), mesh_blend_write(), blender::bke::node_blend_write_storage(), blender::bke::node_tree_blend_write(), blender::bke::ntree_blend_write(), object_blend_write(), scene_blend_write(), shapekey_blend_write(), sound_blend_write(), vfont_blend_write(), and volume_blend_write().
| void BLO_write_pointer_array | ( | BlendWriter * | writer, |
| const int64_t | num, | ||
| const void * | data_ptr ) |
Definition at line 2050 of file writefile.cc.
References BLO_write_raw(), and num.
Referenced by curve_blend_write(), curves_blend_write(), greasepencil_blend_write(), IDP_WriteArray(), blender::bke::node_interface::item_types::item_write_data(), metaball_blend_write(), object_blend_write(), blender::ed::spreadsheet::spreadsheet_blend_write(), blender::ed::spreadsheet::spreadsheet_table_blend_write(), volume_blend_write(), blender::bke::write_channelbag(), write_drawing_array(), blender::bke::write_layers(), write_moviePlaneTracks(), blender::bke::write_slots(), blender::bke::write_strip_keyframe_data(), blender::bke::write_strip_keyframe_data_array(), and blender::bke::write_strips().
| void BLO_write_raw | ( | BlendWriter * | writer, |
| size_t | size_in_bytes, | ||
| const void * | data_ptr ) |
Write raw data.
Definition at line 1918 of file writefile.cc.
References BLO_CODE_DATA, BlendWriter::wd, and writedata().
Referenced by BLO_write_char_array(), BLO_write_double_array(), BLO_write_float3_array(), BLO_write_float_array(), BLO_write_int16_array(), BLO_write_int32_array(), BLO_write_int8_array(), BLO_write_pointer_array(), BLO_write_string(), BLO_write_uint32_array(), BLO_write_uint8_array(), and shapekey_blend_write().
| void BLO_write_shared | ( | BlendWriter * | writer, |
| const void * | data, | ||
| size_t | approximate_size_in_bytes, | ||
| const blender::ImplicitSharingInfo * | sharing_info, | ||
| blender::FunctionRef< void()> | write_fn ) |
Check if the data can be written more efficiently by making use of implicit-sharing. If yes, the user count of the sharing-info is increased making the data immutable. The provided callback should serialize the potentially shared data. It is only called when necessary.
| approximate_size_in_bytes | Used to be able to approximate how large the undo step is in total. |
| write_fn | Use the #BlendWrite to serialize the potentially shared data. |
Definition at line 2067 of file writefile.cc.
References Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), blender::ImplicitSharingInfo::add_user(), BLO_write_is_undo(), data, MemFileSharedStorage::map, WriteData::mem, WriteData::per_id_written_shared_addresses, MemFile::shared_storage, MemFile::size, blender::ImplicitSharingInfo::strong_users(), BlendWriter::wd, and MemFileWriteData::written_memfile.
Referenced by BKE_packedfile_blend_write(), blender::bke::CurvesGeometry::blend_write(), CustomData_blend_write(), and blender::bke::write_shared_array().
| void BLO_write_string | ( | BlendWriter * | writer, |
| const char * | data_ptr ) |
Write a null terminated string.
Definition at line 2060 of file writefile.cc.
References BLO_write_raw().
Referenced by BKE_animdata_blend_write(), BKE_asset_catalog_path_list_blend_write(), BKE_asset_metadata_write(), BKE_asset_weak_reference_write(), BKE_fcurve_blend_write_data(), BKE_id_blend_write(), BKE_keyingsets_blend_write(), BKE_paint_blend_write(), BKE_preferences_extension_repo_write_data(), BKE_viewer_path_blend_write(), blender::bke::AttributeStorage::blend_write(), blender::blend_write(), blender::nodes::BakeItemsAccessor::blend_write_item(), blender::nodes::CaptureAttributeItemsAccessor::blend_write_item(), blender::nodes::ClosureInputItemsAccessor::blend_write_item(), blender::nodes::ClosureOutputItemsAccessor::blend_write_item(), blender::nodes::CombineBundleItemsAccessor::blend_write_item(), blender::nodes::EvaluateClosureInputItemsAccessor::blend_write_item(), blender::nodes::EvaluateClosureOutputItemsAccessor::blend_write_item(), blender::nodes::ForeachGeometryElementGenerationItemsAccessor::blend_write_item(), blender::nodes::ForeachGeometryElementInputItemsAccessor::blend_write_item(), blender::nodes::ForeachGeometryElementMainItemsAccessor::blend_write_item(), blender::nodes::FormatStringItemsAccessor::blend_write_item(), blender::nodes::MenuSwitchItemsAccessor::blend_write_item(), blender::nodes::RepeatItemsAccessor::blend_write_item(), blender::nodes::SeparateBundleItemsAccessor::blend_write_item(), blender::nodes::SimulationItemsAccessor::blend_write_item(), camera_blend_write(), curve_blend_write(), curves_blend_write(), blender::bke::node_interface::item_types::item_write_data(), blender::nodes::node_fn_input_string_cc::node_blend_write(), blender::bke::node_blend_write_storage(), blender::bke::node_tree_blend_write(), blender::ed::asset::shelf::settings_blend_write(), blender::ed::spreadsheet::spreadsheet_blend_write(), blender::ed::spreadsheet::spreadsheet_column_blend_write(), blender::ed::spreadsheet::spreadsheet_column_id_blend_write(), text_blend_write(), write_layer(), write_layer_tree_group(), blender::bke::forward_compat::write_node_socket_interface(), write_panel_list(), and write_ui_data().
| void BLO_write_struct_array_at_address_by_id | ( | BlendWriter * | writer, |
| int | struct_id, | ||
| int64_t | array_size, | ||
| const void * | address, | ||
| const void * | data_ptr ) |
Write struct array at address.
Definition at line 1972 of file writefile.cc.
References BLO_CODE_DATA, BlendWriter::wd, and writestruct_at_address_nr().
| void BLO_write_struct_array_by_id | ( | BlendWriter * | writer, |
| const int | struct_id, | ||
| const int64_t | array_size, | ||
| const void * | data_ptr ) |
Definition at line 1964 of file writefile.cc.
References BLO_CODE_DATA, BlendWriter::wd, and writestruct_nr().
Referenced by blender::nodes::socket_items::blend_write(), and BLO_write_struct_array_by_name().
| void BLO_write_struct_array_by_name | ( | BlendWriter * | writer, |
| const char * | struct_name, | ||
| int64_t | array_size, | ||
| const void * | data_ptr ) |
Write struct array.
Definition at line 1928 of file writefile.cc.
References BLO_get_struct_id_by_name(), BLO_write_struct_array_by_id(), CLOG_ERROR, LOG, and UNLIKELY.
Referenced by blender::bke::AttributeStorage::blend_write(), blend_write_layer_data(), and BLO_write_struct_by_name().
| void BLO_write_struct_at_address_by_id | ( | BlendWriter * | writer, |
| int | struct_id, | ||
| const void * | address, | ||
| const void * | data_ptr ) |
Write single struct at address.
Definition at line 1946 of file writefile.cc.
References BLO_CODE_DATA, and BLO_write_struct_at_address_by_id_with_filecode().
| void BLO_write_struct_at_address_by_id_with_filecode | ( | BlendWriter * | writer, |
| int | filecode, | ||
| int | struct_id, | ||
| const void * | address, | ||
| const void * | data_ptr ) |
Write single struct at address and specify a file-code.
Definition at line 1955 of file writefile.cc.
References BlendWriter::wd, and writestruct_at_address_nr().
Referenced by BLO_write_struct_at_address_by_id().
| void BLO_write_struct_by_id | ( | BlendWriter * | writer, |
| const int | struct_id, | ||
| const void * | data_ptr ) |
Definition at line 1941 of file writefile.cc.
References BLO_CODE_DATA, BlendWriter::wd, and writestruct_nr().
Referenced by write_linestyle_alpha_modifiers(), write_linestyle_color_modifiers(), write_linestyle_geometry_modifiers(), and write_linestyle_thickness_modifiers().
| void BLO_write_struct_by_name | ( | BlendWriter * | writer, |
| const char * | struct_name, | ||
| const void * | data_ptr ) |
Write single struct.
Definition at line 1923 of file writefile.cc.
References BLO_write_struct_array_by_name().
Referenced by BKE_constraint_blend_write(), BKE_fmodifiers_blend_write(), BKE_modifier_blend_write(), BKE_pose_blend_write(), BKE_shaderfx_blend_write(), blender::seq::modifier_blend_write(), blender::bke::node_blend_write_storage(), and blender::bke::forward_compat::write_compositor_legacy_storage().
| void BLO_write_struct_list_by_id | ( | BlendWriter * | writer, |
| const int | struct_id, | ||
| const ListBase * | list ) |
Definition at line 1981 of file writefile.cc.
References BLO_CODE_DATA, BlendWriter::wd, and writelist_nr().
Referenced by BLO_write_struct_list_by_name().
| void BLO_write_struct_list_by_name | ( | BlendWriter * | writer, |
| const char * | struct_name, | ||
| ListBase * | list ) |
Write struct list.
Definition at line 1986 of file writefile.cc.
References BLO_get_struct_id_by_name(), BLO_write_struct_list_by_id(), CLOG_ERROR, LOG, and UNLIKELY.
| void BLO_write_uint32_array | ( | BlendWriter * | writer, |
| const int64_t | num, | ||
| const uint32_t * | data_ptr ) |
Definition at line 2035 of file writefile.cc.
References BLO_write_raw(), and num.
Referenced by BKE_previewimg_blend_write(), BKE_ptcache_blend_write(), and blend_write().
| void BLO_write_uint8_array | ( | BlendWriter * | writer, |
| const int64_t | num, | ||
| const uint8_t * | data_ptr ) |
Definition at line 2025 of file writefile.cc.
References BLO_write_raw(), and num.
Referenced by blend_write_layer_data(), and blender::bke::write_array_data().
|
static |
Take care using 'use_active_win', since we won't want the currently active window to change which scene renders (currently only used for undo).
Definition at line 938 of file writefile.cc.
References wmWindow::active, BKE_view_layer_find(), BKE_workspace_active_screen_get(), ListBase::first, wmWindow::next, wmWindow::scene, wmWindow::view_layer_name, wmWindowManager::windows, Main::wm, and wmWindow::workspace_hook.
Referenced by write_global(), and write_renderinfo().
|
static |
Do reverse file history: .blend1 -> .blend2, .blend -> .blend1 ... etc.
Definition at line 1630 of file writefile.cc.
References BKE_report(), BLI_exists(), BLI_rename_overwrite(), FILE_MAX, min_ii(), reports, RPT_ERROR, SNPRINTF, and U.
Referenced by BLO_write_file_impl().
|
static |
Gathers all local IDs that should be written to the file.
Definition at line 1436 of file writefile.cc.
References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), BKE_idtype_get_info_from_id(), BLI_assert, IDTypeInfo::flags, FOREACH_MAIN_ID_BEGIN, FOREACH_MAIN_ID_END, Key::from, GS, ID_IS_LINKED, ID_KE, ID_LI, ID_TAG_NO_MAIN, ID_TAG_NO_USER_REFCOUNT, ID_TAG_NOT_ALLOCATED, ID_TAG_RUNTIME, IDTYPE_FLAGS_NEVER_UNUSED, ID::name, ID::tag, UNUSED_VARS_NDEBUG, and ID::us.
Referenced by write_file_handle().
|
static |
Definition at line 1392 of file writefile.cc.
References B_ENDIAN, BLEND_FILE_FORMAT_VERSION_1, BLENDER_FILE_VERSION, BLI_assert, ENDIAN_ORDER, SIZEOFBLENDERHEADER_VERSION_0, SIZEOFBLENDERHEADER_VERSION_1, SYSTEM_SUPPORTS_WRITING_FILE_VERSION_1, U, and USER_EXPERIMENTAL_TEST.
Referenced by write_blend_file_header().
|
static |
Low level WRITE(2) wrapper that buffers data
| adr | Pointer to new chunk of data |
| len | Length of new chunk of data |
Definition at line 551 of file writefile.cc.
References BLI_assert, WriteData::buf, WriteData::buffer, WriteData::chunk_size, WriteData::critical_error, len, WriteData::max_size, UNLIKELY, WriteData::used_len, WriteData::validation_data, and writedata_do_write().
Referenced by write_bhead(), write_blend_file_header(), writedata(), and writestruct_at_address_nr().
BeGiN initializer for mywrite
| ww | File write wrapper. |
| compare | Previous memory file (can be nullptr). |
| current | The current memory file (can be nullptr). |
Definition at line 607 of file writefile.cc.
References BLO_memfile_write_init(), WriteData::mem, WriteData::use_memfile, and writedata_new().
Referenced by write_file_handle().
|
static |
END the mywrite wrapper
Definition at line 625 of file writefile.cc.
References BLO_memfile_write_finalize(), WriteData::buf, WriteData::buffer, WriteData::critical_error, WriteData::mem, WriteData::use_memfile, WriteData::used_len, WriteData::validation_data, writedata_do_write(), and writedata_free().
Referenced by write_file_handle().
|
static |
Flush helps the de-duplicating memory for undo-save by logically segmenting data, so differences in one part of memory won't cause unrelated data to be duplicated.
Definition at line 538 of file writefile.cc.
References WriteData::buf, WriteData::buffer, WriteData::used_len, and writedata_do_write().
Referenced by mywrite_id_end(), write_file_handle(), and write_libraries().
Start writing of data related to a single ID.
Only does something when storing an undo step.
Definition at line 647 of file writefile.cc.
References BLI_assert, MemFileWriteData::current_id_session_uid, MemFileChunk::id_session_uid, MemFileWriteData::id_session_uid_mapping, Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::is_empty(), WriteData::is_writing_id, Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::lookup_default(), WriteData::mem, WriteData::per_id_addresses_set, MemFileChunk::prev, MemFileWriteData::reference_current_chunk, ID::session_uid, WriteData::use_memfile, and WriteData::validation_data.
Referenced by write_id(), and write_id_placeholder().
Start writing of data related to a single ID.
Only does something when storing an undo step.
Definition at line 684 of file writefile.cc.
References BLI_assert, Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::clear(), MemFileWriteData::current_id_session_uid, WriteData::is_writing_id, MAIN_ID_SESSION_UID_UNSET, WriteData::mem, mywrite_flush(), WriteData::per_id_addresses_set, WriteData::per_id_written_shared_addresses, WriteData::use_memfile, and WriteData::validation_data.
Referenced by write_id(), and write_id_placeholder().
|
static |
Return false if the given 'old' address is not valid in current context. The block should not be written in that case.
Definition at line 713 of file writefile.cc.
References Set< Key, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::add(), BLO_CODE_DATA, CLOG_ERROR, WriteData::is_writing_id, LOG, WriteData::per_id_addresses_set, WriteData::use_memfile, and WriteData::validation_data.
Referenced by writedata(), and writestruct_at_address_nr().
Definition at line 731 of file writefile.cc.
References CLOG_ERROR, BHead4::code, BHead::code, SmallBHead8::code, BHead4::len, BHead::len, SmallBHead8::len, LOG, max, mywrite(), BHead4::nr, BHead::nr, SmallBHead8::nr, BHead4::old, BHead::old, SmallBHead8::old, BHead4::SDNAnr, BHead::SDNAnr, SmallBHead8::SDNAnr, SYSTEM_SUPPORTS_WRITING_FILE_VERSION_1, U, and USER_EXPERIMENTAL_TEST.
Referenced by write_file_handle(), writedata(), and writestruct_at_address_nr().
|
static |
Definition at line 1427 of file writefile.cc.
References get_blend_file_header(), and mywrite().
Referenced by write_file_handle().
|
static |
When MemFile arguments are non-null, this is a file-safe to memory.
| compare | Previous memory file (can be nullptr). |
| current | The current memory file (can be nullptr). |
Definition at line 1507 of file writefile.cc.
References BKE_idtype_idcode_is_linkable(), BKE_lib_override_library_operations_create(), BKE_library_foreach_ID_link(), BKE_main_id_refcount_recompute(), BLO_CODE_DNA1, BLO_CODE_ENDB, BHead::code, SDNA::data, SDNA::data_size, WriteData::debug_dst, FOREACH_MAIN_ID_BEGIN, FOREACH_MAIN_ID_END, gather_local_ids_to_write(), GS, ID_IS_LINKED, ID_IS_OVERRIDE_LIBRARY_REAL, ID_IS_OVERRIDE_LIBRARY_VIRTUAL, id_lib_extern(), ID_SCE, ID_TAG_EXTERN, ID_TAG_INDIRECT, IDWALK_INCLUDE_UI, IDWALK_READONLY, mywrite_begin(), mywrite_end(), mywrite_flush(), ID::name, WriteData::sdna, ID::tag, U, WriteData::use_memfile, USER_EXPERIMENTAL_TEST, write_bhead(), write_blend_file_header(), write_global(), write_id(), write_id_direct_linked_data_process_cb(), write_libraries(), write_renderinfo(), write_thumb(), write_userdef(), and writedata().
Referenced by BLO_write_file_impl(), and BLO_write_file_mem().
|
static |
Definition at line 1695 of file writefile.cc.
References BKE_report(), BLO_main_validate_libraries(), G, G_DEBUG_IO, Main::lock, reports, and RPT_DEBUG.
Referenced by BLO_write_file_impl().
|
static |
Definition at line 1671 of file writefile.cc.
References BKE_main_namemap_validate_and_fix(), BKE_report(), BLO_main_validate_libraries(), BLO_main_validate_shapekeys(), G, G_DEBUG_IO, Main::lock, reports, RPT_DEBUG, and RPT_ERROR.
Referenced by BLO_write_file_impl().
Context is usually defined by WM, two cases where no WM is available:
Definition at line 1221 of file writefile.cc.
References FileGlobal::_pad, FileGlobal::_pad1, BLENDER_FILE_MIN_SUBVERSION, BLENDER_FILE_MIN_VERSION, BLENDER_FILE_SUBVERSION, BLO_CODE_GLOB, build_commit_timestamp, FileGlobal::build_commit_timestamp, build_hash, FileGlobal::build_hash, FileGlobal::cur_view_layer, current_screen_compat(), FileGlobal::curscene, FileGlobal::curscreen, FileGlobal::fileflags, FileGlobal::filepath, Main::filepath, G, G_FILE_COMPRESS, G_FILE_FLAG_ALL_RUNTIME, G_FILE_RECOVER_WRITE, FileGlobal::globalf, FileGlobal::minsubversion, FileGlobal::minversion, SNPRINTF, STRNCPY(), FileGlobal::subversion, FileGlobal::subvstr, WriteData::use_memfile, and writestruct.
Referenced by write_file_handle().
Writes ID and all its direct data to the file.
Definition at line 1114 of file writefile.cc.
References BKE_idtype_get_info_from_id(), IDTypeInfo::blend_write, BLO_Write_IDBuffer::get(), mywrite_id_begin(), mywrite_id_end(), and WriteData::use_memfile.
Referenced by write_file_handle(), and write_libraries().
|
static |
Definition at line 1358 of file writefile.cc.
References BKE_idtype_idcode_is_linkable(), BLI_assert, LibraryIDLinkCallbackData::cb_flag, GS, ID_IS_LINKED, id_lib_extern(), id_lib_indirect_weak_link(), LibraryIDLinkCallbackData::id_pointer, ID_TAG_RUNTIME, IDWALK_CB_DIRECT_WEAK_LINK, IDWALK_CB_INDIRECT_USAGE, IDWALK_RET_NOP, ID::name, LibraryIDLinkCallbackData::self_id, and ID::tag.
Referenced by write_file_handle().
Definition at line 1126 of file writefile.cc.
References ID_LINK_PLACEHOLDER, mywrite_id_begin(), mywrite_id_end(), WriteData::use_memfile, and writestruct_at_address.
Referenced by write_libraries().
|
static |
Definition at line 1011 of file writefile.cc.
References BLO_write_struct, IDP_BlendWrite(), and wmKeyMapItem::properties.
Referenced by write_userdef().
Keep it last of write_*_data functions.
Definition at line 1139 of file writefile.cc.
References blender::MultiValueMap< Key, Value >::add(), blender::Vector< T, InlineBufferCapacity, Allocator >::append(), BKE_idtype_idcode_is_linkable(), BLI_assert, CLOG_ERROR, FOREACH_MAIN_ID_BEGIN, FOREACH_MAIN_ID_END, GS, Library::id, ID_FLAG_INDIRECT_WEAK_LINK, ID_IS_LINKED, ID_TAG_EXTERN, ID_TAG_INDIRECT, blender::Vector< T, InlineBufferCapacity, Allocator >::is_empty(), ID::lib, Main::libraries, LISTBASE_FOREACH, LOG, blender::MultiValueMap< Key, Value >::lookup(), mywrite_flush(), Library::packedfile, Library::runtime, WriteData::use_memfile, write_id(), and write_id_placeholder().
Referenced by write_file_handle().
|
static |
Definition at line 820 of file writefile.cc.
References WriteData::debug_dst, i, and len.
Referenced by writedata().
This was originally added for the historic render-daemon feature, now write because it can be easily extracted without reading the whole blend file.
See: scripts/modules/blend_render_info.py
Definition at line 988 of file writefile.cc.
References BLO_CODE_REND, current_screen_compat(), data, ID_IS_LINKED, LISTBASE_FOREACH, R_BG_RENDER, Main::scenes, STRNCPY(), and writedata().
Referenced by write_file_handle().
|
static |
Preview image, first 2 values are width and height second are an RGBA image (uchar).
Definition at line 1276 of file writefile.cc.
References BLEN_THUMB_MEMSIZE_FILE, BLO_CODE_TEST, BlendThumbnail::height, BlendThumbnail::width, and writedata().
Referenced by write_file_handle().
|
static |
Definition at line 1019 of file writefile.cc.
References UserDef::addons, UserDef::asset_libraries, UserDef::asset_shelves_settings, UserDef::autoexec_paths, BKE_asset_catalog_path_list_blend_write(), BKE_preferences_extension_repo_write_data(), BLO_CODE_USER, BLO_write_struct, UserDef::extension_repos, IDP_BlendWrite(), LISTBASE_FOREACH, bUserMenuItem_Op::prop, UserDef::script_directories, UserDef::themes, UserDef::uistyles, UserDef::user_keyconfig_prefs, UserDef::user_keymaps, USER_MENU_TYPE_MENU, USER_MENU_TYPE_OPERATOR, USER_MENU_TYPE_PROP, UserDef::user_menus, BlendWriter::wd, write_keymapitem(), and writestruct.
Referenced by write_file_handle().
|
static |
Definition at line 849 of file writefile.cc.
References BLI_assert_msg, BLI_STATIC_ASSERT, BHead::code, WriteData::debug_dst, BHead::len, len, mywrite(), BHead::nr, BHead::old, SDNA_RAW_DATA_STRUCT_INDEX, BHead::SDNAnr, SYSTEM_SUPPORTS_WRITING_FILE_VERSION_1, U, USER_EXPERIMENTAL_TEST, write_at_address_validate(), write_bhead(), and write_raw_data_in_debug_file().
Referenced by BLO_write_raw(), write_file_handle(), write_renderinfo(), and write_thumb().
|
static |
Definition at line 494 of file writefile.cc.
References BLI_assert_msg, BLO_memfile_chunk_add(), WriteData::critical_error, WriteData::mem, UNLIKELY, WriteData::use_memfile, WriteData::validation_data, WriteWrap::write(), and WriteData::ww.
Referenced by mywrite(), mywrite_end(), and mywrite_flush().
|
static |
Definition at line 520 of file writefile.cc.
References WriteData::buf, WriteData::buffer, and MEM_freeN().
Referenced by mywrite_end().
Definition at line 471 of file writefile.cc.
References WriteData::buf, WriteData::buffer, WriteData::chunk_size, DNA_sdna_current_get(), WriteData::max_size, MEM_BUFFER_SIZE, MEM_CHUNK_SIZE, MEM_malloc_arrayN(), WriteData::sdna, WriteWrap::use_buf, WriteData::ww, ZSTD_BUFFER_SIZE, and ZSTD_CHUNK_SIZE.
Referenced by mywrite_begin().
|
static |
Use this to force writing of lists in same order as reading (using link_list).
Definition at line 886 of file writefile.cc.
References ListBase::first, Link::next, and writestruct_nr().
Referenced by BLO_write_struct_list_by_id().
|
static |
Definition at line 768 of file writefile.cc.
References BLI_assert, CLOG_ERROR, BHead::code, data, WriteData::debug_dst, DNA_struct_size(), INT32_MAX, BHead::len, LOG, mywrite(), BHead::nr, BHead::old, blender::dna::print_structs_at_address(), WriteData::sdna, blender::dna::sdna_struct_id_get_max(), BHead::SDNAnr, SYSTEM_SUPPORTS_WRITING_FILE_VERSION_1, U, USER_EXPERIMENTAL_TEST, write_at_address_validate(), and write_bhead().
Referenced by blo_write_id_struct(), BLO_write_struct_array_at_address_by_id(), BLO_write_struct_at_address_by_id_with_filecode(), and writestruct_nr().
|
static |
Definition at line 814 of file writefile.cc.
References writestruct_at_address_nr().
Referenced by BLO_write_struct_array_by_id(), BLO_write_struct_by_id(), and writelist_nr().
|
static |
Definition at line 159 of file writefile.cc.