Remove direct displist creation from BKE_vfont_to_curve_ex()

This goes back to ancient era again and such a call isn't
safe for threading and really DAG is to make it sure display
list for dependencies is always there.
This commit is contained in:
Sergey Sharybin 2014-01-10 00:03:49 +06:00
parent 9d88203101
commit f86fbc4ea3
7 changed files with 35 additions and 57 deletions

View File

@ -38,7 +38,6 @@ extern "C" {
#include <wchar.h>
struct VFont;
struct Scene;
struct Object;
struct Curve;
struct objfnt;
@ -85,13 +84,13 @@ void BKE_vfont_free(struct VFont *sc);
struct VFont *BKE_vfont_builtin_get(void);
struct VFont *BKE_vfont_load(struct Main *bmain, const char *name);
bool BKE_vfont_to_curve_ex(struct Main *bmain, struct Scene *scene, struct Object *ob, int mode,
bool BKE_vfont_to_curve_ex(struct Main *bmain, struct Object *ob, int mode,
struct ListBase *r_nubase,
const wchar_t **r_text, int *r_text_len, bool *r_text_free,
struct CharTrans **r_chartransdata);
bool BKE_vfont_to_curve_nubase(struct Main *bmain, struct Scene *scene, struct Object *ob, int mode,
bool BKE_vfont_to_curve_nubase(struct Main *bmain, struct Object *ob, int mode,
struct ListBase *r_nubase);
bool BKE_vfont_to_curve(struct Main *bmain, struct Scene *scene, struct Object *ob, int mode);
bool BKE_vfont_to_curve(struct Main *bmain, struct Object *ob, int mode);
int BKE_vfont_select_get(struct Object *ob, int *r_start, int *r_end);

View File

@ -1619,7 +1619,7 @@ static Object *find_family_object(const char *family, size_t family_len, unsigne
}
static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int persistent_id[MAX_DUPLI_RECUR], int level, short flag)
static void font_duplilist(ListBase *lb, Object *par, int persistent_id[MAX_DUPLI_RECUR], int level, short flag)
{
GHash *family_gh;
Object *ob;
@ -1638,7 +1638,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int persiste
/* in par the family name is stored, use this to find the other objects */
BKE_vfont_to_curve_ex(G.main, scene, par, FO_DUPLI, NULL,
BKE_vfont_to_curve_ex(G.main, par, FO_DUPLI, NULL,
&text, &text_len, &text_free, &chartransdata);
if (text == NULL || chartransdata == NULL) {
@ -1736,7 +1736,7 @@ static void object_duplilist_recursive(EvaluationContext *eval_ctx,
}
else if (ob->type == OB_FONT) {
if (GS(id->name) == ID_SCE) { /* TODO - support dupligroups */
font_duplilist(duplilist, scene, ob, persistent_id, level + 1, flag);
font_duplilist(duplilist, ob, persistent_id, level + 1, flag);
}
}
}

View File

@ -2145,10 +2145,9 @@ void DAG_on_visible_update(Main *bmain, const short do_time)
* remade, tag them so they get remade in the scene update loop,
* note armature poses or object matrices are preserved and do not
* require updates, so we skip those */
dag_scene_flush_layers(scene, lay);
if (scene->set) {
dag_scene_flush_layers(scene->set, lay);
}
for (sce_iter = scene; sce_iter; sce_iter = sce_iter->set)
dag_scene_flush_layers(sce_iter, lay);
BKE_main_id_tag_idcode(bmain, ID_GR, false);
for (SETLOOPER(scene, sce_iter, base)) {

View File

@ -1375,7 +1375,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
ob->curve_cache->path = NULL;
if (ob->type == OB_FONT) {
BKE_vfont_to_curve_nubase(G.main, scene, ob, FO_EDIT, &nubase);
BKE_vfont_to_curve_nubase(G.main, ob, FO_EDIT, &nubase);
}
else {
BKE_nurbList_duplicate(&nubase, BKE_curve_nurbs_get(cu));

View File

@ -520,8 +520,7 @@ static float char_width(Curve *cu, VChar *che, CharInfo *info)
}
}
bool BKE_vfont_to_curve_ex(Main *bmain, Scene *scene, Object *ob, int mode,
ListBase *r_nubase,
bool BKE_vfont_to_curve_ex(Main *bmain, Object *ob, int mode, ListBase *r_nubase,
const wchar_t **r_text, int *r_text_len, bool *r_text_free,
struct CharTrans **r_chartransdata)
{
@ -870,10 +869,8 @@ makebreak:
int oldflag = cucu->flag;
cucu->flag |= (CU_PATH + CU_FOLLOW);
if (cu->textoncurve->curve_cache == NULL || cu->textoncurve->curve_cache->path == NULL) {
BKE_displist_make_curveTypes(scene, cu->textoncurve, 0);
}
BLI_assert(cu->textoncurve->curve_cache != NULL);
if (cu->textoncurve->curve_cache->path) {
float distfac, imat[4][4], imat3[3][3], cmat[3][3];
float minx, maxx, miny, maxy;
@ -1135,21 +1132,17 @@ finally:
}
bool BKE_vfont_to_curve_nubase(Main *bmain, Scene *scene, Object *ob, int mode,
ListBase *r_nubase)
bool BKE_vfont_to_curve_nubase(Main *bmain, Object *ob, int mode, ListBase *r_nubase)
{
BLI_assert(ob->type == OB_FONT);
return BKE_vfont_to_curve_ex(bmain, scene, ob, mode,
r_nubase,
return BKE_vfont_to_curve_ex(bmain, ob, mode, r_nubase,
NULL, NULL, NULL, NULL);
}
bool BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int mode)
bool BKE_vfont_to_curve(Main *bmain, Object *ob, int mode)
{
Curve *cu = ob->data;
return BKE_vfont_to_curve_ex(bmain, scene, ob, mode,
&cu->nurb,
NULL, NULL, NULL, NULL);
return BKE_vfont_to_curve_ex(bmain, ob, mode, &cu->nurb, NULL, NULL, NULL, NULL);
}

View File

@ -248,7 +248,7 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c)
return 0;
}
static void text_update_edited(bContext *C, Scene *scene, Object *obedit, const bool recalc, int mode)
static void text_update_edited(bContext *C, Object *obedit, const bool recalc, int mode)
{
struct Main *bmain = CTX_data_main(C);
Curve *cu = obedit->data;
@ -265,7 +265,7 @@ static void text_update_edited(bContext *C, Scene *scene, Object *obedit, const
}
}
BKE_vfont_to_curve(bmain, scene, obedit, mode);
BKE_vfont_to_curve(bmain, obedit, mode);
if (recalc)
DAG_id_tag_update(obedit->data, 0);
@ -392,7 +392,6 @@ static bool font_paste_utf8(bContext *C, const char *str, const size_t str_len)
static int paste_from_file(bContext *C, ReportList *reports, const char *filename)
{
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
FILE *fp;
char *strp;
@ -438,7 +437,7 @@ static int paste_from_file(bContext *C, ReportList *reports, const char *filenam
if (strp && font_paste_utf8(C, strp, filelen)) {
text_update_edited(C, scene, obedit, 1, FO_EDIT);
text_update_edited(C, obedit, 1, FO_EDIT);
retval = OPERATOR_FINISHED;
}
@ -509,7 +508,6 @@ void FONT_OT_text_paste_from_file(wmOperatorType *ot)
static int paste_from_clipboard(bContext *C, ReportList *reports)
{
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
char *strp;
int filelen;
@ -522,7 +520,7 @@ static int paste_from_clipboard(bContext *C, ReportList *reports)
}
if ((filelen <= MAXTEXT) && font_paste_utf8(C, strp, filelen)) {
text_update_edited(C, scene, obedit, 1, FO_EDIT);
text_update_edited(C, obedit, 1, FO_EDIT);
retval = OPERATOR_FINISHED;
}
else {
@ -806,7 +804,6 @@ void FONT_OT_style_toggle(wmOperatorType *ot)
static int font_select_all_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;
@ -816,7 +813,7 @@ static int font_select_all_exec(bContext *C, wmOperator *UNUSED(op))
ef->selend = ef->len;
ef->pos = ef->len;
text_update_edited(C, scene, obedit, true, FO_SELCHANGE);
text_update_edited(C, obedit, true, FO_SELCHANGE);
return OPERATOR_FINISHED;
}
@ -883,7 +880,6 @@ void FONT_OT_text_copy(wmOperatorType *ot)
static int cut_text_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
int selstart, selend;
@ -893,7 +889,7 @@ static int cut_text_exec(bContext *C, wmOperator *UNUSED(op))
copy_selection(obedit);
kill_selection(obedit, 0);
text_update_edited(C, scene, obedit, 1, FO_EDIT);
text_update_edited(C, obedit, 1, FO_EDIT);
return OPERATOR_FINISHED;
}
@ -932,13 +928,12 @@ static bool paste_selection(Object *obedit, ReportList *reports)
static int paste_text_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
if (!paste_selection(obedit, op->reports))
return OPERATOR_CANCELLED;
text_update_edited(C, scene, obedit, 1, FO_EDIT);
text_update_edited(C, obedit, 1, FO_EDIT);
return OPERATOR_FINISHED;
}
@ -975,7 +970,6 @@ static EnumPropertyItem move_type_items[] = {
static int move_cursor(bContext *C, int type, int select)
{
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;
@ -1068,11 +1062,11 @@ static int move_cursor(bContext *C, int type, int select)
if (ef->selstart) {
struct Main *bmain = CTX_data_main(C);
ef->selstart = ef->selend = 0;
BKE_vfont_to_curve(bmain, scene, obedit, FO_SELCHANGE);
BKE_vfont_to_curve(bmain, obedit, FO_SELCHANGE);
}
}
text_update_edited(C, scene, obedit, select, cursmove);
text_update_edited(C, obedit, select, cursmove);
if (select)
ef->selend = ef->pos;
@ -1136,7 +1130,6 @@ void FONT_OT_move_select(wmOperatorType *ot)
static int change_spacing_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;
@ -1151,7 +1144,7 @@ static int change_spacing_exec(bContext *C, wmOperator *op)
ef->textbufinfo[ef->pos - 1].kern = kern;
text_update_edited(C, scene, obedit, 1, FO_EDIT);
text_update_edited(C, obedit, 1, FO_EDIT);
return OPERATOR_FINISHED;
}
@ -1178,7 +1171,6 @@ void FONT_OT_change_spacing(wmOperatorType *ot)
static int change_character_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;
@ -1196,7 +1188,7 @@ static int change_character_exec(bContext *C, wmOperator *op)
ef->textbuf[ef->pos - 1] = character;
text_update_edited(C, scene, obedit, 1, FO_EDIT);
text_update_edited(C, obedit, 1, FO_EDIT);
return OPERATOR_FINISHED;
}
@ -1223,7 +1215,6 @@ void FONT_OT_change_character(wmOperatorType *ot)
static int line_break_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;
@ -1232,7 +1223,7 @@ static int line_break_exec(bContext *C, wmOperator *UNUSED(op))
ef->selstart = ef->selend = 0;
text_update_edited(C, scene, obedit, 1, FO_EDIT);
text_update_edited(C, obedit, 1, FO_EDIT);
return OPERATOR_FINISHED;
}
@ -1265,7 +1256,6 @@ static EnumPropertyItem delete_type_items[] = {
static int delete_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;
@ -1319,7 +1309,7 @@ static int delete_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
text_update_edited(C, scene, obedit, 1, FO_EDIT);
text_update_edited(C, obedit, 1, FO_EDIT);
return OPERATOR_FINISHED;
}
@ -1346,7 +1336,6 @@ void FONT_OT_delete(wmOperatorType *ot)
static int insert_text_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
char *inserted_utf8;
wchar_t *inserted_text;
@ -1368,14 +1357,13 @@ static int insert_text_exec(bContext *C, wmOperator *op)
MEM_freeN(inserted_utf8);
kill_selection(obedit, 1);
text_update_edited(C, scene, obedit, 1, FO_EDIT);
text_update_edited(C, obedit, 1, FO_EDIT);
return OPERATOR_FINISHED;
}
static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;
@ -1439,12 +1427,12 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
kill_selection(obedit, 1);
text_update_edited(C, scene, obedit, 1, FO_EDIT);
text_update_edited(C, obedit, 1, FO_EDIT);
}
else {
inserted_text[0] = ascii;
insert_into_textbuf(obedit, ascii);
text_update_edited(C, scene, obedit, 1, FO_EDIT);
text_update_edited(C, obedit, 1, FO_EDIT);
}
}
else
@ -1643,7 +1631,6 @@ static EnumPropertyItem case_items[] = {
static int set_case(bContext *C, int ccase)
{
Scene *scene = CTX_data_scene(C);
Object *obedit = CTX_data_edit_object(C);
Curve *cu = obedit->data;
EditFont *ef = cu->editfont;
@ -1673,7 +1660,7 @@ static int set_case(bContext *C, int ccase)
}
}
text_update_edited(C, scene, obedit, 1, FO_EDIT);
text_update_edited(C, obedit, 1, FO_EDIT);
}
return OPERATOR_FINISHED;

View File

@ -1588,7 +1588,7 @@ static int convert_exec(bContext *C, wmOperator *op)
* datablock, but for until we've got granular update
* lets take care by selves.
*/
BKE_vfont_to_curve(bmain, scene, newob, FO_EDIT);
BKE_vfont_to_curve(bmain, newob, FO_EDIT);
newob->type = OB_CURVE;
cu->type = OB_CURVE;