From 786b0f8f1ecc9f9fd289d096a5ce12de619fe59e Mon Sep 17 00:00:00 2001 From: John Scipione Date: Fri, 28 Jun 2013 00:38:01 -0400 Subject: [PATCH] DeskCalc: Resize a bit more efficiently. Remove B_FULL_UPDATE_ON_RESIZE flag from view. We already Invalidate() on FrameResized() which redraws the view on resize for us. This reduces the number of times Draw() is called from 3+ in some cases to just one. Unfortunately Draw() is still called multiple times in some cases producing noticable flickering and drawing artifacts but it is marginally better. --- src/apps/deskcalc/CalcView.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/apps/deskcalc/CalcView.cpp b/src/apps/deskcalc/CalcView.cpp index 9e69113fda..b0ceda2f3e 100644 --- a/src/apps/deskcalc/CalcView.cpp +++ b/src/apps/deskcalc/CalcView.cpp @@ -117,8 +117,7 @@ CalcView::Instantiate(BMessage* archive) CalcView::CalcView(BRect frame, rgb_color rgbBaseColor, BMessage* settings) : - BView(frame, "DeskCalc", B_FOLLOW_ALL_SIDES, - B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS), + BView(frame, "DeskCalc", B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS), fColumns(5), fRows(4), @@ -847,14 +846,19 @@ CalcView::SetKeypadMode(uint8 mode) if (width < kMinimumWidthScientific) width = kMinimumWidthScientific; - if (width > kMaximumWidthScientific) + else if (width > kMaximumWidthScientific) width = kMaximumWidthScientific; if (height < kMinimumHeightScientific) height = kMinimumHeightScientific; - if (height > kMaximumHeightScientific) + else if (height > kMaximumHeightScientific) height = kMaximumHeightScientific; - ResizeTo(width, height); + + if (width != fWidth || height != fHeight) + ResizeTo(width, height); + else + Invalidate(); + break; } @@ -871,14 +875,18 @@ CalcView::SetKeypadMode(uint8 mode) if (width < kMinimumWidthBasic) width = kMinimumWidthBasic; - if (width > kMaximumWidthBasic) + else if (width > kMaximumWidthBasic) width = kMaximumWidthBasic; if (height < kMinimumHeightBasic) height = kMinimumHeightBasic; - if (height > kMaximumHeightBasic) + else if (height > kMaximumHeightBasic) height = kMaximumHeightBasic; - ResizeTo(width, height); + + if (width != fWidth || height != fHeight) + ResizeTo(width, height); + else + Invalidate(); } } }