This patch remove some of uneeded animation calls.

On Wed, Jan 14, 2015 at 10:26 PM, Tomaz Canabrava <[email protected]>
wrote:

> Well, another one here.
> we were creating / removing the biggest tooltip string ( that can have up
> to 16 lines sometimes ) by allocking / freeing it *every* pixel moved.
> now we cache it and do not free.
>
> On Wed, Jan 14, 2015 at 6:23 PM, Lubomir I. Ivanov <[email protected]>
> wrote:
>
>> On 14 January 2015 at 22:08, Lubomir I. Ivanov <[email protected]>
>> wrote:
>> > i suspect that if we rasterize the whole tooltip (i.e. use QPainter's
>> > methods on a surface) and disable the animation, it will be times
>> > faster.
>> >
>>
>> and by that i mean override ::paint() and do all the calculations and
>> drawing in there and possibly only re-draw if the input data changed
>> etc...
>> that's a much larger re-work, but i think that custom drawing might be
>> the most optimal way for the tooltip to perform well.
>>
>> lubomir
>> --
>>
>
>
From 65408056ff5377d595b7247146483d5b417de170 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Wed, 14 Jan 2015 22:30:14 -0200
Subject: [PATCH 6/6] Only update the rectangle if it changed.

Very often the rectangle of the ToolTip doesn't needs to change
but we were calling and firing an animation for it for *every*
mouse movement, even when we didn't really needed it. now it will
only fire something if the rectangles are indeed different.

From my tests we reduced the number of calls to the animatior
in about 20% using the real divelog as test.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/profile/divetooltipitem.cpp | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/qt-ui/profile/divetooltipitem.cpp b/qt-ui/profile/divetooltipitem.cpp
index 2aa85d5..fdbde1d 100644
--- a/qt-ui/profile/divetooltipitem.cpp
+++ b/qt-ui/profile/divetooltipitem.cpp
@@ -133,11 +133,13 @@ void ToolTipItem::expand()
 	nextRectangle.setWidth(width);
 	nextRectangle.setHeight(height);
 
-	QPropertyAnimation *animation = new QPropertyAnimation(this, "rect", this);
-	animation->setDuration(100);
-	animation->setStartValue(rectangle);
-	animation->setEndValue(nextRectangle);
-	animation->start(QAbstractAnimation::DeleteWhenStopped);
+	if (nextRectangle != rectangle) {
+		QPropertyAnimation *animation = new QPropertyAnimation(this, "rect", this);
+		animation->setDuration(100);
+		animation->setStartValue(rectangle);
+		animation->setEndValue(nextRectangle);
+		animation->start(QAbstractAnimation::DeleteWhenStopped);
+	}
 
 	status = EXPANDED;
 }
-- 
2.2.2

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to