Blender  V3.3
Classes | Macros | Functions | Variables
editfont_undo.c File Reference
#include <stdlib.h>
#include <string.h>
#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 "DNA_scene_types.h"
#include "BKE_context.h"
#include "BKE_main.h"
#include "BKE_undo_system.h"
#include "BKE_vfont.h"
#include "DEG_depsgraph.h"
#include "ED_curve.h"
#include "ED_object.h"
#include "ED_undo.h"
#include "WM_api.h"
#include "WM_types.h"
#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)
 

Typedefs

Undo Conversion
typedef struct UndoFont UndoFont
 

Functions

static void undofont_to_editfont (UndoFont *uf, Curve *cu)
 
static voidundofont_from_editfont (UndoFont *uf, Curve *cu)
 
static void undofont_free_data (UndoFont *uf)
 
static Objecteditfont_object_from_context (bContext *C)
 

Variables

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

Implements ED Undo System

typedef struct FontUndoStep FontUndoStep
 
static bool font_undosys_poll (bContext *C)
 
static bool font_undosys_step_encode (struct bContext *C, struct Main *bmain, UndoStep *us_p)
 
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 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)
 

Array Store

struct {
   struct BArrayStore_AtSize   bs_stride
 
   int   users
 
   ListBase   local_links
 
uf_arraystore = {{NULL}}
 
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 42 of file editfont_undo.c.

◆ STATE_COMPACT

#define STATE_COMPACT (   uf,
  id,
  len 
)
Value:
if ((uf)->id) { \
BLI_assert(create == ((uf)->store.id == NULL)); \
if (create) { \
BArrayState *state_reference = uf_ref ? uf_ref->store.id : NULL; \
const size_t stride = sizeof(*(uf)->id); \
BArrayStore *bs = BLI_array_store_at_size_ensure( \
(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 = NULL; \
} \
((void)0)
BArrayState * BLI_array_store_state_add(BArrayStore *bs, const void *data, size_t data_len, const BArrayState *state_reference)
Definition: array_store.c:1497
BArrayStore * BLI_array_store_at_size_ensure(struct BArrayStore_AtSize *bs_stride, int stride, int chunk_size)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei stride
SyclQueue void void size_t num_bytes void
int len
Definition: draw_manager.c:108
#define ARRAY_CHUNK_SIZE
Definition: editfont_undo.c:42
static struct @342 uf_arraystore
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.

◆ 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; \
(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)
Definition: array_store.c:1580
const int state

◆ STATE_FREE

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

◆ USE_ARRAY_STORE

#define USE_ARRAY_STORE

Definition at line 35 of file editfont_undo.c.

Typedef Documentation

◆ FontUndoStep

typedef struct FontUndoStep FontUndoStep

◆ UndoFont

typedef struct UndoFont UndoFont

Function Documentation

◆ ED_font_undosys_type()

void ED_font_undosys_type ( struct UndoType ut)

◆ editfont_object_from_context()

static Object* editfont_object_from_context ( bContext C)
static

◆ 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 386 of file editfont_undo.c.

References FontUndoStep::obedit_ref, and user_data.

Referenced by ED_font_undosys_type().

◆ font_undosys_poll()

static bool font_undosys_poll ( bContext C)
static

Definition at line 335 of file editfont_undo.c.

References C, editfont_object_from_context(), and NULL.

Referenced by ED_font_undosys_type(), and font_undosys_step_decode().

◆ font_undosys_step_decode()

static void font_undosys_step_decode ( struct bContext C,
struct Main bmain,
UndoStep us_p,
const eUndoStepDir   UNUSEDdir,
bool   UNUSEDis_final 
)
static

◆ font_undosys_step_encode()

static bool font_undosys_step_encode ( struct bContext C,
struct Main bmain,
UndoStep us_p 
)
static

◆ font_undosys_step_free()

static void font_undosys_step_free ( UndoStep us_p)
static

Definition at line 380 of file editfont_undo.c.

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 120 of file editfont_undo.c.

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 88 of file editfont_undo.c.

References blender::bke::idprop::create(), 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 166 of file editfont_undo.c.

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 161 of file editfont_undo.c.

References NULL, and uf_arraystore_compact_ex().

Referenced by undofont_to_editfont().

◆ uf_arraystore_free()

static void uf_arraystore_free ( UndoFont uf)
static

Definition at line 185 of file editfont_undo.c.

References BLI_array_store_at_size_clear(), BLI_assert, STATE_FREE, and uf_arraystore.

Referenced by undofont_free_data().

◆ undofont_free_data()

static void undofont_free_data ( UndoFont uf)
static

◆ undofont_from_editfont()

static void* undofont_from_editfont ( UndoFont uf,
Curve cu 
)
static

◆ undofont_to_editfont()

static void undofont_to_editfont ( UndoFont uf,
Curve cu 
)
static

Variable Documentation

◆ bs_stride

struct BArrayStore_AtSize bs_stride

◆ local_links

ListBase local_links

Definition at line 79 of file editfont_undo.c.

◆ LOG

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

Only needed this locally.

Definition at line 46 of file editfont_undo.c.

Referenced by font_undosys_step_decode().

◆ 

struct { ... } uf_arraystore

◆ users

int users