36#define USE_ARRAY_STORE
43# define ARRAY_CHUNK_SIZE 32
95# define STATE_COMPACT(uf, id, len) \
97 BLI_assert(create == ((uf)->store.id == nullptr)); \
99 const BArrayState *state_reference = uf_ref ? uf_ref->store.id : nullptr; \
100 const size_t stride = sizeof(*(uf)->id); \
101 BArrayStore *bs = BLI_array_store_at_size_ensure( \
102 &uf_arraystore.bs_stride, stride, ARRAY_CHUNK_SIZE); \
103 (uf)->store.id = BLI_array_store_state_add( \
104 bs, (uf)->id, size_t(len) * stride, state_reference); \
107 MEM_delete((uf)->id); \
108 (uf)->id = nullptr; \
133 size_t size_expanded_prev, size_compacted_prev;
135 &
uf_arraystore.bs_stride, &size_expanded_prev, &size_compacted_prev);
142 size_t size_expanded, size_compacted;
146 const double percent_total = size_expanded ?
147 ((double(size_compacted) / double(size_expanded)) * 100.0) :
150 size_t size_expanded_step = size_expanded - size_expanded_prev;
151 size_t size_compacted_step = size_compacted - size_compacted_prev;
152 const double percent_step = size_expanded_step ?
153 ((double(size_compacted_step) / double(size_expanded_step)) *
157 printf(
"overall memory use: %.8f%% of expanded size\n", percent_total);
158 printf(
"step memory use: %.8f%% of expanded size\n", percent_step);
173# define STATE_EXPAND(uf, id, len) \
174 if ((uf)->store.id) { \
175 const size_t stride = sizeof(*(uf)->id); \
176 const BArrayState *state = (uf)->store.id; \
178 *(void **)&(uf)->id = BLI_array_store_state_data_get_alloc(state, &state_len); \
179 BLI_assert((len) == (state_len / stride)); \
180 UNUSED_VARS_NDEBUG(stride); \
192# define STATE_FREE(uf, id) \
193 if ((uf)->store.id) { \
194 const size_t stride = sizeof(*(uf)->id); \
195 BArrayStore *bs = BLI_array_store_at_size_get(&uf_arraystore.bs_stride, stride); \
196 BArrayState *state = (uf)->store.id; \
197 BLI_array_store_state_remove(bs, state); \
198 (uf)->store.id = nullptr; \
213 printf(
"editfont undo store: freeing all data!\n");
234#ifdef USE_ARRAY_STORE
238 final_size =
sizeof(*ef->
textbuf) * (uf->
len + 1);
249#ifdef USE_ARRAY_STORE
262 size_t alloc_len = ef->
len + 1;
268 uf->
textbufinfo = MEM_new_array<CharInfo>(alloc_len, __func__);
276#ifdef USE_ARRAY_STORE
290 uf->
undo_size = mem_used_prev < mem_used_curr ? mem_used_curr - mem_used_prev :
sizeof(
UndoFont);
297#ifdef USE_ARRAY_STORE
323 const Curve *cu = id_cast<Curve *>(obedit->
data);
380 Curve *cu = id_cast<Curve *>(obedit->
data);
Efficient in-memory storage of multiple similar arrays.
Generic array manipulation API.
#define BLI_array_is_zeroed(arr, arr_len)
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define STATE_COMPACT(uf, id, len)
#define STATE_FREE(uf, id)
#define STATE_EXPAND(uf, id, len)
void * BLI_findptr(const ListBase *listbase, const void *ptr, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void ED_font_undosys_type(UndoType *ut)
static void uf_arraystore_compact_ex(UndoFont *uf, const UndoFont *uf_ref, bool create)
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
@ UNDOTYPE_FLAG_NEED_CONTEXT_FOR_ENCODE
@ UNDOTYPE_FLAG_ENCODE_PRE_MEMFILE_SUPPORTED
static void uf_arraystore_expand_clear(UndoFont *um)
void ED_undo_object_set_active_or_warn(const Main &bmain, Scene *scene, ViewLayer *view_layer, Object *ob, const char *info, CLG_LogRef *log)
static bool font_undosys_step_encode(bContext *C, Main *bmain, UndoStep *us_p)
static void uf_arraystore_expand(UndoFont *uf)
static void font_undosys_foreach_ID_ref(UndoStep *us_p, UndoTypeForEachIDRefFn foreach_ID_ref_fn, void *user_data)
ViewLayer * CTX_data_view_layer(const bContext *C)
size_t(*) MEM_get_memory_in_use()
void BLI_array_store_at_size_calc_memory_usage(const struct BArrayStore_AtSize *bs_stride, size_t *r_size_expanded, size_t *r_size_compacted)
static void uf_arraystore_compact(UndoFont *um, const UndoFont *uf_ref)
static void undofont_to_editfont(UndoFont *uf, Curve *cu)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Object * BKE_view_layer_edit_object_get(const ViewLayer *view_layer)
void DEG_id_tag_update(ID *id, unsigned int flags)
BMesh const char void * data
wmWindowManager * CTX_wm_manager(const bContext *C)
static void undofont_free_data(UndoFont *uf)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
LinkData * BLI_genericNodeN(void *data)
static Object * editfont_object_from_context(bContext *C)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
static void uf_arraystore_free(UndoFont *uf)
static void uf_arraystore_compact_with_info(UndoFont *um, const UndoFont *uf_ref)
static void * undofont_from_editfont(UndoFont *uf, Curve *cu)
static void font_undosys_step_free(UndoStep *us_p)
void BLI_array_store_at_size_clear(struct BArrayStore_AtSize *bs_stride)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Main * CTX_data_main(const bContext *C)
void ED_undo_object_editmode_restore_helper(Scene *scene, ViewLayer *view_layer, Object **object_array, uint object_array_len, uint object_array_stride)
void(*)(void *user_data, UndoRefID *id_ref) UndoTypeForEachIDRefFn
Scene * CTX_data_scene(const bContext *C)
static struct blender::@242310203126017303145171221064117234336261275223 uf_arraystore
static void font_undosys_step_decode(bContext *C, Main *bmain, UndoStep *us_p, const eUndoStepDir, bool)
static bool font_undosys_poll(bContext *C)
void ED_undo_object_editmode_validate_scene_from_windows(wmWindowManager *wm, const Scene *scene_ref, Scene **scene_p, ViewLayer **view_layer_p)
struct EditFont * editfont
UndoRefID_Object obedit_ref
UndoRefID_Scene scene_ref
bool is_memfile_undo_flush_needed
BArrayState * textbufinfo
struct blender::UndoFont::@117034065220130327136050171372377364323132157076 store
bool(*) poll(bContext *C)
void(*) step_free(UndoStep *us)
void(*) step_decode(bContext *C, Main *bmain, UndoStep *us, eUndoStepDir dir, bool is_final)
void(*) step_foreach_ID_ref(UndoStep *us, UndoTypeForEachIDRefFn foreach_ID_ref_fn, void *user_data)
bool(*) step_encode(bContext *C, Main *bmain, UndoStep *us)
BArrayStore_AtSize bs_stride
ListBaseT< LinkData > local_links