Tablet example: paint only the changed areas of the canvas
This improves performance significantly. Change-Id: I9a8782148ce03a2bc85759c4e8c1eecb37467cf6 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>bb10
parent
09f59271e6
commit
d2c05b0c85
|
|
@ -148,12 +148,14 @@ void TabletCanvas::initPixmap()
|
|||
m_pixmap = newPixmap;
|
||||
}
|
||||
|
||||
void TabletCanvas::paintEvent(QPaintEvent *)
|
||||
void TabletCanvas::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
if (m_pixmap.isNull())
|
||||
initPixmap();
|
||||
QPainter painter(this);
|
||||
painter.drawPixmap(0, 0, m_pixmap);
|
||||
QRect pixmapPortion = QRect(event->rect().topLeft() * devicePixelRatioF(),
|
||||
event->rect().size() * devicePixelRatioF());
|
||||
painter.drawPixmap(event->rect().topLeft(), m_pixmap, pixmapPortion);
|
||||
}
|
||||
//! [4]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue