diff options
author | Jeroen Bakker <jbakker> | 2020-06-22 22:44:18 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2020-06-22 22:46:04 +0300 |
commit | 2fdca5bd1981cddad16715598b4892a2c6099e2f (patch) | |
tree | 69853ccb8f442a58fce086e88adccf78ff9b96a4 /source/blender/editors/interface/view2d_ops.c | |
parent | 9335daac2a368ad137156f6e656f3654b4db07b9 (diff) |
Refactoring: View2DScrollers memory allocation
View2DScrollers used the memory manager to allocate memory. This isn't a
problem but in a upcoming change the scrollers will be drawn more often
than it used to (See {D8066}). To limit the number of allocations and
frees this patch will use the stack for allocation.
Reviewed By: Campbell Barton
Differential Revision: https://developer.blender.org/D8076
Diffstat (limited to 'source/blender/editors/interface/view2d_ops.c')
-rw-r--r-- | source/blender/editors/interface/view2d_ops.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 34108853c61..0585f7cf7cd 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -2011,7 +2011,7 @@ static void scroller_activate_init(bContext *C, const char in_scroller) { v2dScrollerMove *vsm; - View2DScrollers *scrollers; + View2DScrollers scrollers; ARegion *region = CTX_wm_region(C); View2D *v2d = ®ion->v2d; rctf tot_cur_union; @@ -2032,7 +2032,7 @@ static void scroller_activate_init(bContext *C, /* 'zone' depends on where mouse is relative to bubble * - zooming must be allowed on this axis, otherwise, default to pan */ - scrollers = UI_view2d_scrollers_calc(v2d, NULL); + UI_view2d_scrollers_calc(v2d, NULL, &scrollers); /* Use a union of 'cur' & 'tot' in case the current view is far outside 'tot'. In this cases * moving the scroll bars has far too little effect and the view can get stuck T31476. */ @@ -2049,15 +2049,15 @@ static void scroller_activate_init(bContext *C, /* get 'zone' (i.e. which part of scroller is activated) */ vsm->zone = mouse_in_scroller_handle( - event->mval[0], v2d->hor.xmin, v2d->hor.xmax, scrollers->hor_min, scrollers->hor_max); + event->mval[0], v2d->hor.xmin, v2d->hor.xmax, scrollers.hor_min, scrollers.hor_max); if ((v2d->keepzoom & V2D_LOCKZOOM_X) && ELEM(vsm->zone, SCROLLHANDLE_MIN, SCROLLHANDLE_MAX)) { /* default to scroll, as handles not usable */ vsm->zone = SCROLLHANDLE_BAR; } - vsm->scrollbarwidth = scrollers->hor_max - scrollers->hor_min; - vsm->scrollbar_orig = ((scrollers->hor_max + scrollers->hor_min) / 2) + region->winrct.xmin; + vsm->scrollbarwidth = scrollers.hor_max - scrollers.hor_min; + vsm->scrollbar_orig = ((scrollers.hor_max + scrollers.hor_min) / 2) + region->winrct.xmin; } else { /* vertical scroller - calculate adjustment factor first */ @@ -2069,18 +2069,17 @@ static void scroller_activate_init(bContext *C, /* get 'zone' (i.e. which part of scroller is activated) */ vsm->zone = mouse_in_scroller_handle( - event->mval[1], v2d->vert.ymin, v2d->vert.ymax, scrollers->vert_min, scrollers->vert_max); + event->mval[1], v2d->vert.ymin, v2d->vert.ymax, scrollers.vert_min, scrollers.vert_max); if ((v2d->keepzoom & V2D_LOCKZOOM_Y) && ELEM(vsm->zone, SCROLLHANDLE_MIN, SCROLLHANDLE_MAX)) { /* default to scroll, as handles not usable */ vsm->zone = SCROLLHANDLE_BAR; } - vsm->scrollbarwidth = scrollers->vert_max - scrollers->vert_min; - vsm->scrollbar_orig = ((scrollers->vert_max + scrollers->vert_min) / 2) + region->winrct.ymin; + vsm->scrollbarwidth = scrollers.vert_max - scrollers.vert_min; + vsm->scrollbar_orig = ((scrollers.vert_max + scrollers.vert_min) / 2) + region->winrct.ymin; } - UI_view2d_scrollers_free(scrollers); ED_region_tag_redraw_no_rebuild(region); } |