49 #define USE_ARRAY_STORE
51 #ifdef USE_ARRAY_STORE
56 # define ARRAY_CHUNK_SIZE 32
72 #ifdef USE_ARRAY_STORE
82 #ifdef USE_ARRAY_STORE
104 # define STATE_COMPACT(uf, id, len) \
106 BLI_assert(create == ((uf)->store.id == NULL)); \
108 BArrayState *state_reference = uf_ref ? uf_ref->store.id : NULL; \
109 const size_t stride = sizeof(*(uf)->id); \
110 BArrayStore *bs = BLI_array_store_at_size_ensure( \
111 &uf_arraystore.bs_stride, stride, ARRAY_CHUNK_SIZE); \
112 (uf)->store.id = BLI_array_store_state_add( \
113 bs, (uf)->id, (size_t)(len)*stride, state_reference); \
116 MEM_freeN((uf)->id); \
124 # undef STATE_COMPACT
142 size_t size_expanded_prev, size_compacted_prev;
144 &
uf_arraystore.bs_stride, &size_expanded_prev, &size_compacted_prev);
151 size_t size_expanded, size_compacted;
155 const double percent_total = size_expanded ?
156 (((
double)size_compacted / (
double)size_expanded) * 100.0) :
159 size_t size_expanded_step = size_expanded - size_expanded_prev;
160 size_t size_compacted_step = size_compacted - size_compacted_prev;
161 const double percent_step = size_expanded_step ?
162 (((
double)size_compacted_step / (
double)size_expanded_step) *
166 printf(
"overall memory use: %.8f%% of expanded size\n", percent_total);
167 printf(
"step memory use: %.8f%% of expanded size\n", percent_step);
182 # define STATE_EXPAND(uf, id, len) \
183 if ((uf)->store.id) { \
184 const size_t stride = sizeof(*(uf)->id); \
185 BArrayState *state = (uf)->store.id; \
187 (uf)->id = BLI_array_store_state_data_get_alloc(state, &state_len); \
188 BLI_assert((len) == (state_len / stride)); \
189 UNUSED_VARS_NDEBUG(stride); \
201 # define STATE_FREE(uf, id) \
202 if ((uf)->store.id) { \
203 const size_t stride = sizeof(*(uf)->id); \
204 BArrayStore *bs = BLI_array_store_at_size_get(&uf_arraystore.bs_stride, stride); \
205 BArrayState *state = (uf)->store.id; \
206 BLI_array_store_state_remove(bs, state); \
207 (uf)->store.id = NULL; \
222 printf(
"editfont undo store: freeing all data!\n");
239 #ifdef USE_ARRAY_STORE
243 final_size =
sizeof(*ef->
textbuf) * (uf->
len + 1);
254 #ifdef USE_ARRAY_STORE
270 final_size =
sizeof(*uf->
textbuf) * (ef->
len + 1);
283 #ifdef USE_ARRAY_STORE
298 uf->
undo_size = mem_used_prev < mem_used_curr ? mem_used_curr - mem_used_prev :
sizeof(
UndoFont);
305 #ifdef USE_ARRAY_STORE
411 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, const 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)
#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 struct @318 uf_arraystore
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)
struct EditFont * editfont
struct CharInfo * textbufinfo
UndoRefID_Object obedit_ref
char is_memfile_undo_flush_needed
struct CharInfo * textbufinfo
BArrayState * textbufinfo
struct UndoFont::@319 store
void(* step_decode)(struct bContext *C, struct Main *bmain, UndoStep *us, const 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)