Cleanup: Mask: Move to IDTypeInfo and remove unused BKE API.
This commit is contained in:
@@ -153,7 +153,7 @@ extern IDTypeInfo IDType_ID_PA;
|
||||
// extern IDTypeInfo IDType_ID_GD;
|
||||
extern IDTypeInfo IDType_ID_WM;
|
||||
extern IDTypeInfo IDType_ID_MC;
|
||||
// extern IDTypeInfo IDType_ID_MSK;
|
||||
extern IDTypeInfo IDType_ID_MSK;
|
||||
// extern IDTypeInfo IDType_ID_LS;
|
||||
// extern IDTypeInfo IDType_ID_PAL;
|
||||
extern IDTypeInfo IDType_ID_PC;
|
||||
|
||||
@@ -142,15 +142,9 @@ void BKE_mask_point_select_set_handle(struct MaskSplinePoint *point,
|
||||
|
||||
/* general */
|
||||
struct Mask *BKE_mask_new(struct Main *bmain, const char *name);
|
||||
void BKE_mask_copy_data(struct Main *bmain,
|
||||
struct Mask *mask_dst,
|
||||
const struct Mask *mask_src,
|
||||
const int flag);
|
||||
struct Mask *BKE_mask_copy_nolib(struct Mask *mask);
|
||||
struct Mask *BKE_mask_copy(struct Main *bmain, const struct Mask *mask);
|
||||
|
||||
void BKE_mask_make_local(struct Main *bmain, struct Mask *mask, const int flags);
|
||||
|
||||
void BKE_mask_free(struct Mask *mask);
|
||||
|
||||
void BKE_mask_coord_from_frame(float r_co[2], const float co[2], const float frame_size[2]);
|
||||
|
||||
@@ -80,7 +80,7 @@ static void id_type_init(void)
|
||||
// INIT_TYPE(ID_GD);
|
||||
INIT_TYPE(ID_WM);
|
||||
INIT_TYPE(ID_MC);
|
||||
// INIT_TYPE(ID_MSK);
|
||||
INIT_TYPE(ID_MSK);
|
||||
// INIT_TYPE(ID_LS);
|
||||
// INIT_TYPE(ID_PAL);
|
||||
INIT_TYPE(ID_PC);
|
||||
|
||||
@@ -544,9 +544,7 @@ bool BKE_lib_id_make_local(Main *bmain, ID *id, const bool test, const int flags
|
||||
BLI_assert(0);
|
||||
return true;
|
||||
case ID_MSK:
|
||||
if (!test) {
|
||||
BKE_mask_make_local(bmain, (Mask *)id, flags);
|
||||
}
|
||||
BLI_assert(0);
|
||||
return true;
|
||||
case ID_LS:
|
||||
if (!test) {
|
||||
@@ -750,7 +748,7 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag)
|
||||
BLI_assert(0);
|
||||
break;
|
||||
case ID_MSK:
|
||||
BKE_mask_copy_data(bmain, (Mask *)*r_newid, (Mask *)id, flag);
|
||||
BLI_assert(0);
|
||||
break;
|
||||
case ID_LS:
|
||||
BKE_linestyle_copy_data(
|
||||
@@ -1376,7 +1374,7 @@ void BKE_libblock_init_empty(ID *id)
|
||||
/* Nothing to do. */
|
||||
break;
|
||||
case ID_MSK:
|
||||
/* Nothing to do. */
|
||||
BLI_assert(0);
|
||||
break;
|
||||
case ID_LS:
|
||||
BKE_linestyle_init((FreestyleLineStyle *)id);
|
||||
|
||||
@@ -226,7 +226,7 @@ void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
|
||||
BLI_assert(0);
|
||||
break;
|
||||
case ID_MSK:
|
||||
BKE_mask_free((Mask *)id);
|
||||
BLI_assert(0);
|
||||
break;
|
||||
case ID_LS:
|
||||
BKE_linestyle_free((FreestyleLineStyle *)id);
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
|
||||
#include "BKE_animsys.h"
|
||||
#include "BKE_curve.h"
|
||||
#include "BKE_idtype.h"
|
||||
|
||||
#include "BKE_lib_id.h"
|
||||
#include "BKE_main.h"
|
||||
@@ -59,6 +60,49 @@
|
||||
|
||||
static CLG_LogRef LOG = {"bke.mask"};
|
||||
|
||||
static void mask_copy_data(Main *UNUSED(bmain),
|
||||
ID *id_dst,
|
||||
const ID *id_src,
|
||||
const int UNUSED(flag))
|
||||
{
|
||||
Mask *mask_dst = (Mask *)id_dst;
|
||||
const Mask *mask_src = (const Mask *)id_src;
|
||||
|
||||
BLI_listbase_clear(&mask_dst->masklayers);
|
||||
|
||||
/* TODO add unused flag to those as well. */
|
||||
BKE_mask_layer_copy_list(&mask_dst->masklayers, &mask_src->masklayers);
|
||||
|
||||
/* enable fake user by default */
|
||||
id_fake_user_set(&mask_dst->id);
|
||||
}
|
||||
|
||||
static void mask_free_data(ID *id)
|
||||
{
|
||||
Mask *mask = (Mask *)id;
|
||||
|
||||
BKE_animdata_free((ID *)mask, false);
|
||||
|
||||
/* free mask data */
|
||||
BKE_mask_layer_free_list(&mask->masklayers);
|
||||
}
|
||||
|
||||
IDTypeInfo IDType_ID_MSK = {
|
||||
.id_code = ID_MSK,
|
||||
.id_filter = FILTER_ID_MSK,
|
||||
.main_listbase_index = INDEX_ID_MSK,
|
||||
.struct_size = sizeof(Mask),
|
||||
.name = "Mask",
|
||||
.name_plural = "masks",
|
||||
.translation_context = BLT_I18NCONTEXT_ID_MASK,
|
||||
.flags = 0,
|
||||
|
||||
.init_data = NULL,
|
||||
.copy_data = mask_copy_data,
|
||||
.free_data = mask_free_data,
|
||||
.make_local = NULL,
|
||||
};
|
||||
|
||||
static struct {
|
||||
ListBase splines;
|
||||
struct GHash *id_hash;
|
||||
@@ -875,30 +919,6 @@ Mask *BKE_mask_copy_nolib(Mask *mask)
|
||||
return mask_new;
|
||||
}
|
||||
|
||||
/**
|
||||
* Only copy internal data of Mask ID from source
|
||||
* to already allocated/initialized destination.
|
||||
* You probably never want to use that directly,
|
||||
* use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
|
||||
*
|
||||
* WARNING! This function will not handle ID user count!
|
||||
*
|
||||
* \param flag: Copying options (see BKE_lib_id.h's LIB_ID_COPY_... flags for more).
|
||||
*/
|
||||
void BKE_mask_copy_data(Main *UNUSED(bmain),
|
||||
Mask *mask_dst,
|
||||
const Mask *mask_src,
|
||||
const int UNUSED(flag))
|
||||
{
|
||||
BLI_listbase_clear(&mask_dst->masklayers);
|
||||
|
||||
/* TODO add unused flag to those as well. */
|
||||
BKE_mask_layer_copy_list(&mask_dst->masklayers, &mask_src->masklayers);
|
||||
|
||||
/* enable fake user by default */
|
||||
id_fake_user_set(&mask_dst->id);
|
||||
}
|
||||
|
||||
Mask *BKE_mask_copy(Main *bmain, const Mask *mask)
|
||||
{
|
||||
Mask *mask_copy;
|
||||
@@ -906,11 +926,6 @@ Mask *BKE_mask_copy(Main *bmain, const Mask *mask)
|
||||
return mask_copy;
|
||||
}
|
||||
|
||||
void BKE_mask_make_local(Main *bmain, Mask *mask, const int flags)
|
||||
{
|
||||
BKE_lib_id_make_local_generic(bmain, &mask->id, flags);
|
||||
}
|
||||
|
||||
void BKE_mask_point_free(MaskSplinePoint *point)
|
||||
{
|
||||
if (point->uw) {
|
||||
@@ -1059,10 +1074,7 @@ void BKE_mask_layer_free_list(ListBase *masklayers)
|
||||
/** Free (or release) any data used by this mask (does not free the mask itself). */
|
||||
void BKE_mask_free(Mask *mask)
|
||||
{
|
||||
BKE_animdata_free((ID *)mask, false);
|
||||
|
||||
/* free mask data */
|
||||
BKE_mask_layer_free_list(&mask->masklayers);
|
||||
mask_free_data(&mask->id);
|
||||
}
|
||||
|
||||
void BKE_mask_coord_from_frame(float r_co[2], const float co[2], const float frame_size[2])
|
||||
|
||||
Reference in New Issue
Block a user