try to cache the rendered page to see if zooming speed improves

This commit is contained in:
Marco Martin 2012-05-21 20:09:14 +02:00
parent dd561b55e3
commit abca7780ad
3 changed files with 10 additions and 3 deletions

View file

@ -91,6 +91,7 @@ PlasmaComponents.Page {
height: parent.height
Component.onCompleted: pageNumber = documentItem.currentPage
}
SequentialAnimation {
id: switchAnimation
NumberAnimation {

View file

@ -144,7 +144,7 @@ void PageItem::geometryChanged(const QRectF &newGeometry,
void PageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
if (!m_documentItem || !m_page) {
if (!m_documentItem || !m_page || m_pixmap.isNull()) {
QDeclarativeItem::paint(painter, option, widget);
return;
}
@ -154,8 +154,7 @@ void PageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
painter->setRenderHint(QPainter::Antialiasing, true);
}
int flags = PagePainter::Accessibility | PagePainter::Highlights | PagePainter::Annotations;
PagePainter::paintPageOnPainter(painter, m_page, m_observerId, flags, option->rect.width(), option->rect.height(), option->rect);
painter->drawPixmap(m_pixmap.rect(), m_pixmap, option->rect);
if (m_smooth) {
painter->restore();
@ -176,6 +175,12 @@ void PageItem::delayedRedraw()
requestedPixmaps.push_back( new Okular::PixmapRequest(
m_observerId, m_pageNumber, width(), height(), priority, true ) );
m_documentItem.data()->document()->requestPixmaps( requestedPixmaps );
m_pixmap = QPixmap(QSize(width(), height()));
QPainter p(&m_pixmap);
int flags = PagePainter::Accessibility | PagePainter::Highlights | PagePainter::Annotations;
PagePainter::paintPageOnPainter(&p, m_page, m_observerId, flags, width(), height(), boundingRect().toRect());
p.end();
update();
}

View file

@ -86,6 +86,7 @@ private:
QWeakPointer<DocumentItem> m_documentItem;
QTimer *m_redrawTimer;
int m_observerId;
QPixmap m_pixmap;
friend class ThumbnailItem;
};