Blender V4.3
editfont_undo.cc File Reference
#include <cstdlib>
#include <cstring>
#include "MEM_guardedalloc.h"
#include "CLG_log.h"
#include "BLI_array_utils.h"
#include "BLI_utildefines.h"
#include "DNA_curve_types.h"
#include "DNA_object_types.h"
#include "BKE_context.hh"
#include "BKE_layer.hh"
#include "BKE_main.hh"
#include "BKE_undo_system.hh"
#include "BKE_vfont.hh"
#include "DEG_depsgraph.hh"
#include "ED_curve.hh"
#include "ED_undo.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "BLI_array_store.h"
#include "BLI_array_store_utils.h"
#include "BLI_listbase.h"

Go to the source code of this file.

Classes

struct  UndoFont
 
struct  FontUndoStep
 

Macros

#define USE_ARRAY_STORE
 
#define ARRAY_CHUNK_SIZE   32
 
#define STATE_COMPACT(uf, id, len)
 
#define STATE_EXPAND(uf, id, len)
 
#define STATE_FREE(uf, id)
 

Functions

static void undofont_to_editfont (UndoFont *uf, Curve *cu)
 
static void * undofont_from_editfont (UndoFont *uf, Curve *cu)
 
static void undofont_free_data (UndoFont *uf)
 
static Objecteditfont_object_from_context (bContext *C)
 
Implements ED Undo System
static bool font_undosys_poll (bContext *C)
 
static bool font_undosys_step_encode (bContext *C, Main *bmain, UndoStep *us_p)
 
static void font_undosys_step_decode (bContext *C, Main *bmain, UndoStep *us_p, const eUndoStepDir, bool)
 
static void font_undosys_step_free (UndoStep *us_p)
 
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)
 

Variables

static CLG_LogRef LOG = {"ed.undo.font"}
 

Array Store

struct { 
 
   BArrayStore_AtSize   bs_stride 
 
   int   users 
 
   ListBase   local_links 
 
uf_arraystore = {{nullptr}} 
 
static void uf_arraystore_compact_ex (UndoFont *uf, const UndoFont *uf_ref, bool create)
 
static void uf_arraystore_compact (UndoFont *um, const UndoFont *uf_ref)
 
static void uf_arraystore_compact_with_info (UndoFont *um, const UndoFont *uf_ref)
 
static void uf_arraystore_expand_clear (UndoFont *um)
 
static void uf_arraystore_expand (UndoFont *uf)
 
static void uf_arraystore_free (UndoFont *uf)
 

Macro Definition Documentation

◆ ARRAY_CHUNK_SIZE

#define ARRAY_CHUNK_SIZE   32

Definition at line 43 of file editfont_undo.cc.

◆ STATE_COMPACT

#define STATE_COMPACT ( uf,
id,
len )
Value:
if ((uf)->id) { \
BLI_assert(create == ((uf)->store.id == nullptr)); \
if (create) { \
BArrayState *state_reference = uf_ref ? uf_ref->store.id : nullptr; \
const size_t stride = sizeof(*(uf)->id); \
&uf_arraystore.bs_stride, stride, ARRAY_CHUNK_SIZE); \
(uf)->store.id = BLI_array_store_state_add( \
bs, (uf)->id, size_t(len) * stride, state_reference); \
} \
/* keep uf->len for validation */ \
MEM_freeN((uf)->id); \
(uf)->id = nullptr; \
} \
((void)0)
BArrayState * BLI_array_store_state_add(BArrayStore *bs, const void *data, size_t data_len, const BArrayState *state_reference)
BArrayStore * BLI_array_store_at_size_ensure(struct BArrayStore_AtSize *bs_stride, int stride, int chunk_size)
int len
#define ARRAY_CHUNK_SIZE
static struct @318 uf_arraystore

Referenced by uf_arraystore_compact_ex().

◆ STATE_EXPAND

#define STATE_EXPAND ( uf,
id,
len )
Value:
if ((uf)->store.id) { \
const size_t stride = sizeof(*(uf)->id); \
BArrayState *state = (uf)->store.id; \
size_t state_len; \
*(void **)&(uf)->id = BLI_array_store_state_data_get_alloc(state, &state_len); \
BLI_assert((len) == (state_len / stride)); \
UNUSED_VARS_NDEBUG(stride); \
} \
((void)0)
void * BLI_array_store_state_data_get_alloc(BArrayState *state, size_t *r_data_len)
static ulong state[N]

Referenced by uf_arraystore_expand().

◆ STATE_FREE

#define STATE_FREE ( uf,
id )
Value:
if ((uf)->store.id) { \
const size_t stride = sizeof(*(uf)->id); \
BArrayState *state = (uf)->store.id; \
BLI_array_store_state_remove(bs, state); \
(uf)->store.id = nullptr; \
} \
((void)0)
BArrayStore * BLI_array_store_at_size_get(struct BArrayStore_AtSize *bs_stride, int stride)

Referenced by uf_arraystore_free().

◆ USE_ARRAY_STORE

#define USE_ARRAY_STORE

Definition at line 36 of file editfont_undo.cc.

Function Documentation

◆ ED_font_undosys_type()

◆ editfont_object_from_context()

◆ font_undosys_foreach_ID_ref()

static void font_undosys_foreach_ID_ref ( UndoStep * us_p,
UndoTypeForEachIDRefFn foreach_ID_ref_fn,
void * user_data )
static

Definition at line 394 of file editfont_undo.cc.

References FontUndoStep::obedit_ref, and FontUndoStep::scene_ref.

Referenced by ED_font_undosys_type().

◆ font_undosys_poll()

static bool font_undosys_poll ( bContext * C)
static

Definition at line 341 of file editfont_undo.cc.

References editfont_object_from_context().

Referenced by ED_font_undosys_type(), and font_undosys_step_decode().

◆ font_undosys_step_decode()

◆ font_undosys_step_encode()

◆ font_undosys_step_free()

static void font_undosys_step_free ( UndoStep * us_p)
static

Definition at line 388 of file editfont_undo.cc.

References FontUndoStep::data, and undofont_free_data().

Referenced by ED_font_undosys_type().

◆ uf_arraystore_compact()

static void uf_arraystore_compact ( UndoFont * um,
const UndoFont * uf_ref )
static

Move data from allocated arrays to de-duplicated states and clear arrays.

Definition at line 121 of file editfont_undo.cc.

References uf_arraystore_compact_ex().

Referenced by uf_arraystore_compact_with_info().

◆ uf_arraystore_compact_ex()

static void uf_arraystore_compact_ex ( UndoFont * uf,
const UndoFont * uf_ref,
bool create )
static
Parameters
createWhen false, only free the arrays. This is done since when reading from an undo state, they must be temporarily expanded. then discarded afterwards, having this argument avoids having 2x code paths.

Definition at line 89 of file editfont_undo.cc.

References UndoFont::len, STATE_COMPACT, and uf_arraystore.

Referenced by uf_arraystore_compact(), and uf_arraystore_expand_clear().

◆ uf_arraystore_compact_with_info()

static void uf_arraystore_compact_with_info ( UndoFont * um,
const UndoFont * uf_ref )
static

◆ uf_arraystore_expand()

static void uf_arraystore_expand ( UndoFont * uf)
static

Definition at line 167 of file editfont_undo.cc.

References UndoFont::len, and STATE_EXPAND.

Referenced by undofont_to_editfont().

◆ uf_arraystore_expand_clear()

static void uf_arraystore_expand_clear ( UndoFont * um)
static

Remove data we only expanded for temporary use.

Definition at line 162 of file editfont_undo.cc.

References uf_arraystore_compact_ex().

Referenced by undofont_to_editfont().

◆ uf_arraystore_free()

static void uf_arraystore_free ( UndoFont * uf)
static

◆ undofont_free_data()

static void undofont_free_data ( UndoFont * uf)
static

◆ undofont_from_editfont()

◆ undofont_to_editfont()

Variable Documentation

◆ bs_stride

◆ local_links

ListBase local_links

Definition at line 80 of file editfont_undo.cc.

◆ LOG

CLG_LogRef LOG = {"ed.undo.font"}
static

Only needed this locally.

Definition at line 47 of file editfont_undo.cc.

Referenced by font_undosys_step_decode().

◆ [struct]

◆ users