Fix T103210: Don't Always Clear Glyphs With Zoom

Do not clear all the font's glyph caches with single-step zoom
operators if the area does not change font size when doing so.

See D16785 for more details.

Differential Revision: https://developer.blender.org/D16785

Reviewed by Campbell Barton
This commit is contained in:
Harley Acheson 2023-01-08 13:57:09 -08:00
parent 73a2c79c07
commit d11f3267cd
Notes: blender-bot 2024-05-08 11:36:44 +02:00
Referenced by issue #104274, The execution time of blf.dimension is slow on Node Editor
Referenced by issue #103210, The execution time of blf.dimension is slow on Dope Sheet Editor
1 changed files with 10 additions and 5 deletions

View File

@ -791,9 +791,14 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
* \{ */
/* Cleanup temp custom-data. */
static void view_zoomstep_exit(wmOperator *op)
static void view_zoomstep_exit(bContext *C, wmOperator *op)
{
UI_view2d_zoom_cache_reset();
ScrArea *area = CTX_wm_area(C);
/* Some areas change font sizes when zooming, so clear glyph cache. */
if (area && !ELEM(area->spacetype, SPACE_GRAPH, SPACE_ACTION)) {
UI_view2d_zoom_cache_reset();
}
v2dViewZoomData *vzd = static_cast<v2dViewZoomData *>(op->customdata);
vzd->v2d->flag &= ~V2D_IS_NAVIGATING;
MEM_SAFE_FREE(op->customdata);
@ -816,7 +821,7 @@ static int view_zoomin_exec(bContext *C, wmOperator *op)
/* apply movement, then we're done */
view_zoomstep_apply(C, op);
view_zoomstep_exit(op);
view_zoomstep_exit(C, op);
return OPERATOR_FINISHED;
}
@ -880,7 +885,7 @@ static int view_zoomout_exec(bContext *C, wmOperator *op)
/* apply movement, then we're done */
view_zoomstep_apply(C, op);
view_zoomstep_exit(op);
view_zoomstep_exit(C, op);
return OPERATOR_FINISHED;
}
@ -1477,7 +1482,7 @@ static int view2d_ndof_invoke(bContext *C, wmOperator *op, const wmEvent *event)
view_zoomstep_apply_ex(
C, vzd, do_zoom_xy[0] ? zoom_factor : 0.0f, do_zoom_xy[1] ? zoom_factor : 0.0f);
view_zoomstep_exit(op);
view_zoomstep_exit(C, op);
}
return OPERATOR_FINISHED;