Performance tweak - on region pan/scale, only redraw the region itself

instead of the entire area (eg. so panning tool shelf doesn't lag when 3d view 
redrawing is slow).
This commit is contained in:
Matt Ebb 2010-03-30 07:57:07 +00:00
parent 77f55d9cb3
commit c36e00cd52

@ -72,6 +72,7 @@ static int view2d_poll(bContext *C)
typedef struct v2dViewPanData {
bScreen *sc; /* screen where view pan was initiated */
ScrArea *sa; /* area where view pan was initiated */
ARegion *ar; /* region where view pan was initiated */
View2D *v2d; /* view2d we're operating in */
float facx, facy; /* amount to move view relative to zoom */
@ -108,6 +109,7 @@ static int view_pan_init(bContext *C, wmOperator *op)
vpd->sc= CTX_wm_screen(C);
vpd->sa= CTX_wm_area(C);
vpd->v2d= v2d;
vpd->ar = ar;
/* calculate translation factor - based on size of view */
winx= (float)(ar->winrct.xmax - ar->winrct.xmin + 1);
@ -143,7 +145,8 @@ static void view_pan_apply(bContext *C, wmOperator *op)
UI_view2d_curRect_validate(v2d);
/* request updates to be done... */
ED_area_tag_redraw(vpd->sa);
ED_region_tag_redraw(vpd->ar);
UI_view2d_sync(vpd->sc, vpd->sa, v2d, V2D_LOCK_COPY);
WM_event_add_mousemove(C);
@ -503,6 +506,7 @@ void VIEW2D_OT_scroll_up(wmOperatorType *ot)
/* temp customdata for operator */
typedef struct v2dViewZoomData {
View2D *v2d; /* view2d we're operating in */
ARegion *ar;
int lastx, lasty; /* previous x/y values of mouse in window */
float dx, dy; /* running tally of previous delta values (for obtaining final zoom) */
@ -532,6 +536,7 @@ static int view_zoomdrag_init(bContext *C, wmOperator *op)
/* set pointers to owners */
vzd->v2d= v2d;
vzd->ar = ar;
return 1;
}
@ -630,7 +635,7 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op)
UI_view2d_curRect_validate(v2d);
/* request updates to be done... */
ED_area_tag_redraw(CTX_wm_area(C));
ED_region_tag_redraw(vzd->ar);
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
WM_event_add_mousemove(C);
}
@ -820,7 +825,7 @@ static void view_zoomdrag_apply(bContext *C, wmOperator *op)
UI_view2d_curRect_validate(v2d);
/* request updates to be done... */
ED_area_tag_redraw(CTX_wm_area(C));
ED_region_tag_redraw(vzd->ar);
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
WM_event_add_mousemove(C);
}
@ -1089,7 +1094,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
UI_view2d_curRect_validate(v2d);
/* request updates to be done... */
ED_area_tag_redraw(CTX_wm_area(C));
ED_region_tag_redraw(ar);
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
WM_event_add_mousemove(C);
@ -1133,6 +1138,7 @@ void VIEW2D_OT_zoom_border(wmOperatorType *ot)
/* customdata for scroller-invoke data */
typedef struct v2dScrollerMove {
View2D *v2d; /* View2D data that this operation affects */
ARegion *ar; /* region that the scroller is in */
short scroller; /* scroller that mouse is in ('h' or 'v') */
short zone; /* -1 is min zoomer, 0 is bar, 1 is max zoomer */ // XXX find some way to provide visual feedback of this (active colour?)
@ -1224,6 +1230,7 @@ static void scroller_activate_init(bContext *C, wmOperator *op, wmEvent *event,
/* set general data */
vsm->v2d= v2d;
vsm->ar= ar;
vsm->scroller= in_scroller;
/* store mouse-coordinates, and convert mouse/screen coordinates to region coordinates */
@ -1332,7 +1339,7 @@ static void scroller_activate_apply(bContext *C, wmOperator *op)
UI_view2d_curRect_validate(v2d);
/* request updates to be done... */
ED_area_tag_redraw(CTX_wm_area(C));
ED_region_tag_redraw(vsm->ar);
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
WM_event_add_mousemove(C);
}
@ -1522,7 +1529,7 @@ static int reset_exec(bContext *C, wmOperator *op)
UI_view2d_curRect_validate(v2d);
/* request updates to be done... */
ED_area_tag_redraw(CTX_wm_area(C));
ED_region_tag_redraw(ar);
UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
WM_event_add_mousemove(C);