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 fb600e661ded939c158b5dc37066d8ebeee6894f Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Wed, 14 Jan 2015 22:18:20 -0200 Subject: [PATCH 5/5] Do not free the membuffer, reuse it. This is an attempt to make less calls to alloc functions when the mouse is moving. we were creating an membuffer, filling it ( malloc / realloc ), then freeing it just after use. but we could simply hold that allocated area and reuse it again. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/profile/divetooltipitem.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/qt-ui/profile/divetooltipitem.cpp b/qt-ui/profile/divetooltipitem.cpp index c56286b..2aa85d5 100644 --- a/qt-ui/profile/divetooltipitem.cpp +++ b/qt-ui/profile/divetooltipitem.cpp @@ -242,14 +242,16 @@ void ToolTipItem::refresh(const QPointF &pos) struct plot_data *entry; static QPixmap tissues(16,60); static QPainter painter(&tissues); + static struct membuffer mb = { 0 }; + int time = timeAxis->valueAt(pos); if (time == lastTime) return; lastTime = time; clear(); - struct membuffer mb = { 0 }; + mb.len = 0; entry = get_plot_details_new(&pInfo, time, &mb); if (entry) { tissues.fill(); @@ -271,7 +273,6 @@ void ToolTipItem::refresh(const QPointF &pos) entryToolTip.first->setPixmap(tissues); entryToolTip.second->setText(QString::fromUtf8(mb.buffer, mb.len)); } - free_buffer(&mb); Q_FOREACH (QGraphicsItem *item, scene()->items(pos, Qt::IntersectsItemBoundingRect ,Qt::DescendingOrder, scene()->views().first()->transform())) { -- 2.2.2
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
