From bbe59c6014535b125e39f7466ee0930a07116571 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Tue, 11 Jan 2022 14:07:40 -0800 Subject: BLF: Reduction of use of BLF_DRAW_STR_DUMMY_MAX Reduction of the number of uses of the define BLF_DRAW_STR_DUMMY_MAX by using actual sizes of static character arrays. See D13793 for more details. Differential Revision: https://developer.blender.org/D13793 Reviewed by Campbell Barton --- source/blender/blenkernel/intern/image.c | 26 ++++++++--------- .../blender/editors/interface/interface_widgets.c | 2 +- source/blender/editors/space_node/node_draw.cc | 2 +- source/blender/editors/util/ed_draw.c | 34 +++++++++++----------- source/blender/sequencer/intern/effects.c | 4 +-- 5 files changed, 34 insertions(+), 34 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 4899c3671aa..23b1054f814 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -2446,7 +2446,7 @@ void BKE_image_stamp_buf(Scene *scene, /* and draw the text. */ BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.file, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw_buffer(mono, stamp_data.file, sizeof(stamp_data.file)); /* the extra pixel for background. */ y -= BUFF_MARGIN_Y * 2; @@ -2469,7 +2469,7 @@ void BKE_image_stamp_buf(Scene *scene, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.date, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw_buffer(mono, stamp_data.date, sizeof(stamp_data.date)); /* the extra pixel for background. */ y -= BUFF_MARGIN_Y * 2; @@ -2492,7 +2492,7 @@ void BKE_image_stamp_buf(Scene *scene, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.rendertime, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw_buffer(mono, stamp_data.rendertime, sizeof(stamp_data.rendertime)); /* the extra pixel for background. */ y -= BUFF_MARGIN_Y * 2; @@ -2515,7 +2515,7 @@ void BKE_image_stamp_buf(Scene *scene, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.memory, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw_buffer(mono, stamp_data.memory, sizeof(stamp_data.memory)); /* the extra pixel for background. */ y -= BUFF_MARGIN_Y * 2; @@ -2538,7 +2538,7 @@ void BKE_image_stamp_buf(Scene *scene, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.hostname, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw_buffer(mono, stamp_data.hostname, sizeof(stamp_data.hostname)); /* the extra pixel for background. */ y -= BUFF_MARGIN_Y * 2; @@ -2562,7 +2562,7 @@ void BKE_image_stamp_buf(Scene *scene, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs + (h - h_fixed), 0.0); - BLF_draw_buffer(mono, stamp_data.note, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw_buffer(mono, stamp_data.note, sizeof(stamp_data.note)); } BLF_disable(mono, BLF_WORD_WRAP); @@ -2586,7 +2586,7 @@ void BKE_image_stamp_buf(Scene *scene, /* and pad the text. */ BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.marker, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw_buffer(mono, stamp_data.marker, sizeof(stamp_data.marker)); /* space width. */ x += w + pad; @@ -2609,7 +2609,7 @@ void BKE_image_stamp_buf(Scene *scene, /* and pad the text. */ BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.time, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw_buffer(mono, stamp_data.time, sizeof(stamp_data.time)); /* space width. */ x += w + pad; @@ -2631,7 +2631,7 @@ void BKE_image_stamp_buf(Scene *scene, /* and pad the text. */ BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.frame, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw_buffer(mono, stamp_data.frame, sizeof(stamp_data.frame)); /* space width. */ x += w + pad; @@ -2651,7 +2651,7 @@ void BKE_image_stamp_buf(Scene *scene, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.camera, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw_buffer(mono, stamp_data.camera, sizeof(stamp_data.camera)); /* space width. */ x += w + pad; @@ -2671,7 +2671,7 @@ void BKE_image_stamp_buf(Scene *scene, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.cameralens, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw_buffer(mono, stamp_data.cameralens, sizeof(stamp_data.cameralens)); } if (TEXT_SIZE_CHECK(stamp_data.scene, w, h)) { @@ -2693,7 +2693,7 @@ void BKE_image_stamp_buf(Scene *scene, /* and pad the text. */ BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.scene, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw_buffer(mono, stamp_data.scene, sizeof(stamp_data.scene)); } if (TEXT_SIZE_CHECK(stamp_data.strip, w, h)) { @@ -2715,7 +2715,7 @@ void BKE_image_stamp_buf(Scene *scene, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); - BLF_draw_buffer(mono, stamp_data.strip, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw_buffer(mono, stamp_data.strip, sizeof(stamp_data.strip)); } /* cleanup the buffer. */ diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index ad8c0842657..06de4f09d06 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -5421,7 +5421,7 @@ void ui_draw_menu_item(const uiFontStyle *fstyle, &(struct uiFontStyleDraw_Params){ .align = UI_STYLE_TEXT_LEFT, }, - BLF_DRAW_STR_DUMMY_MAX, + sizeof(drawstr), &xofs, &yofs, &info); diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 2d3c42b16d1..e9a385c525b 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -2452,7 +2452,7 @@ static void frame_node_draw_label(const bNodeTree &ntree, const bool has_label = node.label[0] != '\0'; if (has_label) { BLF_position(fontid, x, y, 0); - BLF_draw(fontid, label, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw(fontid, label, sizeof(label)); } /* draw text body */ diff --git a/source/blender/editors/util/ed_draw.c b/source/blender/editors/util/ed_draw.c index ccbde07f5b1..3e85862a847 100644 --- a/source/blender/editors/util/ed_draw.c +++ b/source/blender/editors/util/ed_draw.c @@ -599,9 +599,9 @@ static void metadata_custom_draw_fields(const char *field, const char *value, vo } MetadataCustomDrawContext *ctx = (MetadataCustomDrawContext *)ctx_v; char temp_str[MAX_METADATA_STR]; - BLI_snprintf(temp_str, MAX_METADATA_STR, "%s: %s", field, value); + SNPRINTF(temp_str, "%s: %s", field, value); BLF_position(ctx->fontid, ctx->xmin, ctx->ymin + ctx->current_y, 0.0f); - BLF_draw(ctx->fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw(ctx->fontid, temp_str, sizeof(temp_str)); ctx->current_y += ctx->vertical_offset; } @@ -625,18 +625,18 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const /* first line */ if (i == 0) { bool do_newline = false; - int len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[0]); + int len = SNPRINTF_RLEN(temp_str, "%s: ", meta_data_list[0]); if (metadata_is_valid(ibuf, temp_str, 0, len)) { BLF_position(fontid, xmin, ymax - vertical_offset, 0.0f); - BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw(fontid, temp_str, sizeof(temp_str)); do_newline = true; } - len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[1]); + len = SNPRINTF_RLEN(temp_str, "%s: ", meta_data_list[1]); if (metadata_is_valid(ibuf, temp_str, 1, len)) { - int line_width = BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX); + int line_width = BLF_width(fontid, temp_str, sizeof(temp_str)); BLF_position(fontid, xmax - line_width, ymax - vertical_offset, 0.0f); - BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw(fontid, temp_str, sizeof(temp_str)); do_newline = true; } @@ -645,32 +645,32 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const } } /* Strip */ else if (ELEM(i, 1, 2)) { - int len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]); + int len = SNPRINTF_RLEN(temp_str, "%s: ", meta_data_list[i + 1]); if (metadata_is_valid(ibuf, temp_str, i + 1, len)) { BLF_position(fontid, xmin, ymax - vertical_offset - ofs_y, 0.0f); - BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw(fontid, temp_str, sizeof(temp_str)); ofs_y += vertical_offset; } } /* Note (wrapped) */ else if (i == 3) { - int len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]); + int len = SNPRINTF_RLEN(temp_str, "%s: ", meta_data_list[i + 1]); if (metadata_is_valid(ibuf, temp_str, i + 1, len)) { struct ResultBLF info; BLF_enable(fontid, BLF_WORD_WRAP); BLF_wordwrap(fontid, ibuf->x - (margin * 2)); BLF_position(fontid, xmin, ymax - vertical_offset - ofs_y, 0.0f); - BLF_draw_ex(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX, &info); + BLF_draw_ex(fontid, temp_str, sizeof(temp_str), &info); BLF_wordwrap(fontid, 0); BLF_disable(fontid, BLF_WORD_WRAP); ofs_y += vertical_offset * info.lines; } } else { - int len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]); + int len = SNPRINTF_RLEN(temp_str, "%s: ", meta_data_list[i + 1]); if (metadata_is_valid(ibuf, temp_str, i + 1, len)) { - int line_width = BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX); + int line_width = BLF_width(fontid, temp_str, sizeof(temp_str)); BLF_position(fontid, xmax - line_width, ymax - vertical_offset - ofs_y, 0.0f); - BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw(fontid, temp_str, sizeof(temp_str)); ofs_y += vertical_offset; } } @@ -687,12 +687,12 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const int ofs_x = 0; ofs_y = ctx.current_y; for (int i = 5; i < 10; i++) { - int len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i]); + int len = SNPRINTF_RLEN(temp_str, "%s: ", meta_data_list[i]); if (metadata_is_valid(ibuf, temp_str, i, len)) { BLF_position(fontid, xmin + ofs_x, ymin + ofs_y, 0.0f); - BLF_draw(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw(fontid, temp_str, sizeof(temp_str)); - ofs_x += BLF_width(fontid, temp_str, BLF_DRAW_STR_DUMMY_MAX) + UI_UNIT_X; + ofs_x += BLF_width(fontid, temp_str, sizeof(temp_str)) + UI_UNIT_X; } } } diff --git a/source/blender/sequencer/intern/effects.c b/source/blender/sequencer/intern/effects.c index 8776bc63cf0..a35e83a8632 100644 --- a/source/blender/sequencer/intern/effects.c +++ b/source/blender/sequencer/intern/effects.c @@ -3344,12 +3344,12 @@ static ImBuf *do_text_effect(const SeqRenderData *context, fonty = line_height; BLF_position(font, x + max_ii(fontx / 55, 1), y - max_ii(fonty / 30, 1), 0.0f); BLF_buffer_col(font, data->shadow_color); - BLF_draw_buffer(font, data->text, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw_buffer(font, data->text, sizeof(data->text)); } BLF_position(font, x, y, 0.0f); BLF_buffer_col(font, data->color); - BLF_draw_buffer(font, data->text, BLF_DRAW_STR_DUMMY_MAX); + BLF_draw_buffer(font, data->text, sizeof(data->text)); BLF_buffer(font, NULL, NULL, 0, 0, 0, NULL); -- cgit v1.2.3