From: Michal MalĂ˝ Date: Wed, 4 Mar 2015 00:14:00 +0000 (+0100) Subject: Optimize graph redrawing. X-Git-Tag: 0.4a~12 X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=c3bda12e16d1e5120b25f4236be84ef9136892cb;p=anyanka.git Optimize graph redrawing. --- diff --git a/gui/graphview.cpp b/gui/graphview.cpp index da77da8..36b60e4 100644 --- a/gui/graphview.cpp +++ b/gui/graphview.cpp @@ -162,11 +162,18 @@ void GraphView::mousePressEvent(QMouseEvent* ev) void GraphView::paintEvent(QPaintEvent* ev) { - Q_UNUSED(ev); - - QPainter p(this); - if (m_pixmap != nullptr) - p.drawPixmap(0, 0, dwidth(), dheight(), *m_pixmap); + if (m_pixmap != nullptr) { + QPainter p(this); + const QVector &rects = ev->region().rects(); + + for (const QRect& r : rects) { + const int l = r.left(); + const int t = r.top(); + const int w = r.width(); + const int h = r.height(); + p.drawPixmap(l, t, w, h, *m_pixmap, l, t, w, h); + } + } } void GraphView::resizeEvent(QResizeEvent* ev)