35 #define USE_ARRAY_STORE
37 #ifdef USE_ARRAY_STORE
42 # define ARRAY_CHUNK_SIZE 32
58 #ifdef USE_ARRAY_STORE
68 #ifdef USE_ARRAY_STORE
90 # define STATE_COMPACT(uf, id, len) \
92 BLI_assert(create == ((uf)->store.id == NULL)); \
94 BArrayState *state_reference = uf_ref ? uf_ref->store.id : NULL; \
95 const size_t stride = sizeof(*(uf)->id); \
96 BArrayStore *bs = BLI_array_store_at_size_ensure( \
97 &uf_arraystore.bs_stride, stride, ARRAY_CHUNK_SIZE); \
98 (uf)->store.id = BLI_array_store_state_add( \
99 bs, (uf)->id, (size_t)(len)*stride, state_reference); \
102 MEM_freeN((uf)->id); \
110 # undef STATE_COMPACT
128 size_t size_expanded_prev, size_compacted_prev;
130 &
uf_arraystore.bs_stride, &size_expanded_prev, &size_compacted_prev);
137 size_t size_expanded, size_compacted;
141 const double percent_total = size_expanded ?
142 (((
double)size_compacted / (
double)size_expanded) * 100.0) :
145 size_t size_expanded_step = size_expanded - size_expanded_prev;
146 size_t size_compacted_step = size_compacted - size_compacted_prev;
147 const double percent_step = size_expanded_step ?
148 (((
double)size_compacted_step / (
double)size_expanded_step) *
152 printf(
"overall memory use: %.8f%% of expanded size\n", percent_total);
153 printf(
"step memory use: %.8f%% of expanded size\n", percent_step);
168 # define STATE_EXPAND(uf, id, len) \
169 if ((uf)->store.id) { \
170 const size_t stride = sizeof(*(uf)->id); \
171 BArrayState *state = (uf)->store.id; \
173 (uf)->id = BLI_array_store_state_data_get_alloc(state, &state_len); \
174 BLI_assert((len) == (state_len / stride)); \
175 UNUSED_VARS_NDEBUG(stride); \
187 # define STATE_FREE(uf, id) \
188 if ((uf)->store.id) { \
189 const size_t stride = sizeof(*(uf)->id); \
190 BArrayStore *bs = BLI_array_store_at_size_get(&uf_arraystore.bs_stride, stride); \
191 BArrayState *state = (uf)->store.id; \
192 BLI_array_store_state_remove(bs, state); \
193 (uf)->store.id = NULL; \
208 printf(
"editfont undo store: freeing all data!\n");
225 #ifdef USE_ARRAY_STORE
229 final_size =
sizeof(*ef->
textbuf) * (uf->
len + 1);
240 #ifdef USE_ARRAY_STORE
256 final_size =
sizeof(*uf->
textbuf) * (ef->
len + 1);
269 #ifdef USE_ARRAY_STORE
284 uf->
undo_size = mem_used_prev < mem_used_curr ? mem_used_curr - mem_used_prev :
sizeof(
UndoFont);
291 #ifdef USE_ARRAY_STORE
396 ut->
name =
"Edit Font";
struct Scene * CTX_data_scene(const bContext *C)
struct ViewLayer * CTX_data_view_layer(const bContext *C)
@ UNDOTYPE_FLAG_NEED_CONTEXT_FOR_ENCODE
void(* UndoTypeForEachIDRefFn)(void *user_data, struct UndoRefID *id_ref)
Efficient in-memory storage of multiple similar arrays.
void BLI_array_store_at_size_clear(struct BArrayStore_AtSize *bs_stride)
void BLI_array_store_at_size_calc_memory_usage(struct BArrayStore_AtSize *bs_stride, size_t *r_size_expanded, size_t *r_size_compacted)
Generic array manipulation API.
#define BLI_array_is_zeroed(arr, arr_len)
struct LinkData * BLI_genericNodeN(void *data)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void * BLI_findptr(const struct ListBase *listbase, const void *ptr, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
typedef double(DMatrix)[4][4]
void DEG_id_tag_update(struct ID *id, int flag)
Object is a sort of wrapper for general info.
#define OBEDIT_FROM_VIEW_LAYER(view_layer)
void ED_undo_object_editmode_restore_helper(struct bContext *C, struct Object **object_array, uint object_array_len, uint object_array_stride)
void ED_undo_object_set_active_or_warn(struct Scene *scene, struct ViewLayer *view_layer, struct Object *ob, const char *info, struct CLG_LogRef *log)
Read Guarded memory(de)allocation.
#define STATE_COMPACT(uf, id, len)
static bool font_undosys_step_encode(struct bContext *C, struct Main *bmain, UndoStep *us_p)
static Object * editfont_object_from_context(bContext *C)
static struct @342 uf_arraystore
#define STATE_FREE(uf, id)
static void uf_arraystore_expand(UndoFont *uf)
static void font_undosys_step_free(UndoStep *us_p)
static void uf_arraystore_expand_clear(UndoFont *um)
static void font_undosys_step_decode(struct bContext *C, struct Main *bmain, UndoStep *us_p, const eUndoStepDir UNUSED(dir), bool UNUSED(is_final))
static void undofont_free_data(UndoFont *uf)
static void * undofont_from_editfont(UndoFont *uf, Curve *cu)
static void uf_arraystore_compact_with_info(UndoFont *um, const UndoFont *uf_ref)
static void uf_arraystore_compact(UndoFont *um, const UndoFont *uf_ref)
struct FontUndoStep FontUndoStep
static void uf_arraystore_free(UndoFont *uf)
static bool font_undosys_poll(bContext *C)
struct BArrayStore_AtSize bs_stride
static void font_undosys_foreach_ID_ref(UndoStep *us_p, UndoTypeForEachIDRefFn foreach_ID_ref_fn, void *user_data)
void ED_font_undosys_type(UndoType *ut)
static void undofont_to_editfont(UndoFont *uf, Curve *cu)
#define STATE_EXPAND(uf, id, len)
static void uf_arraystore_compact_ex(UndoFont *uf, const UndoFont *uf_ref, bool create)
void(* MEM_freeN)(void *vmemh)
size_t(* MEM_get_memory_in_use)(void)
void *(* MEM_mallocN)(size_t len, const char *str)
std::unique_ptr< IDProperty, IDPropertyDeleter > create(StringRefNull prop_name, int32_t value)
Allocate a new IDProperty of type IDP_INT, set its name and value.
struct EditFont * editfont
struct CharInfo * textbufinfo
UndoRefID_Object obedit_ref
char is_memfile_undo_flush_needed
struct CharInfo * textbufinfo
BArrayState * textbufinfo
struct UndoFont::@343 store
void(* step_decode)(struct bContext *C, struct Main *bmain, UndoStep *us, eUndoStepDir dir, bool is_final)
bool(* step_encode)(struct bContext *C, struct Main *bmain, UndoStep *us)
void(* step_foreach_ID_ref)(UndoStep *us, UndoTypeForEachIDRefFn foreach_ID_ref_fn, void *user_data)
void(* step_free)(UndoStep *us)
bool(* poll)(struct bContext *C)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)