From 2119bb4e02faee9597f8496c13167738e6d196f3 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Fri, 25 May 2012 21:28:53 +0200 Subject: [PATCH] try to limit pixmap requests --- active/components/pageitem.cpp | 23 +++++++++++++++-------- active/components/pageitem.h | 1 + 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/active/components/pageitem.cpp b/active/components/pageitem.cpp index ecd773372..76a900090 100644 --- a/active/components/pageitem.cpp +++ b/active/components/pageitem.cpp @@ -38,7 +38,8 @@ PageItem::PageItem(QDeclarativeItem *parent) Okular::View( QString::fromLatin1( "PageView" ) ), m_page(0), m_pageNumber(0), - m_smooth(false) + m_smooth(false), + m_intentionalDraw(true) { m_observerId = PAGEVIEW_ID; setFlag(QGraphicsItem::ItemHasNoContents, false); @@ -135,7 +136,9 @@ void PageItem::geometryChanged(const QRectF &newGeometry, return; } - m_redrawTimer->start(REDRAW_TIMEOUT); + if (newGeometry.size() != oldGeometry.size()) { + m_redrawTimer->start(REDRAW_TIMEOUT); + } QDeclarativeItem::geometryChanged(newGeometry, oldGeometry); //Why aren't they automatically emuitted? @@ -158,11 +161,15 @@ void PageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, const int priority = m_observerId == PAGEVIEW_ID ? PAGEVIEW_PRELOAD_PRIO : THUMBNAILS_PRELOAD_PRIO; - QLinkedList< Okular::PixmapRequest * > requestedPixmaps; - requestedPixmaps.push_back( new Okular::PixmapRequest( - m_observerId, m_pageNumber, width(), height(), priority, true ) ); - m_documentItem.data()->document()->requestPixmaps( requestedPixmaps ); - + if (m_intentionalDraw) { + qDebug() << "***************************"; + qDebug() << "grabbing pixmaps!"<< this ; + QLinkedList< Okular::PixmapRequest * > requestedPixmaps; + requestedPixmaps.push_back(new Okular::PixmapRequest(m_observerId, m_pageNumber, width(), height(), priority, true)); + m_documentItem.data()->document()->requestPixmaps( requestedPixmaps ); + qDebug() << "***************************"; + } + m_intentionalDraw = false; const int flags = PagePainter::Accessibility | PagePainter::Highlights | PagePainter::Annotations; PagePainter::paintPageOnPainter(painter, m_page, m_observerId, flags, width(), height(), boundingRect().toRect()); @@ -171,11 +178,11 @@ void PageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, } } - //Protected slots void PageItem::delayedRedraw() { if (m_documentItem && m_page) { + m_intentionalDraw = true; update(); } } diff --git a/active/components/pageitem.h b/active/components/pageitem.h index 5a3e84cb6..93f3bb741 100644 --- a/active/components/pageitem.h +++ b/active/components/pageitem.h @@ -83,6 +83,7 @@ private: const Okular::Page *m_page; int m_pageNumber; bool m_smooth; + bool m_intentionalDraw; QWeakPointer m_documentItem; QTimer *m_redrawTimer; int m_observerId;