mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 09:32:12 +01:00
More memory efficient and faster preview generation.
There is no need to allocate a very large image buffer, just enough for the thumbnail preview. For a little filtering, use the two-stage scaling. See http://labs.qt.nokia.com/2009/01/26/creating-thumbnail-preview/ for the details. This tecnique is adopted from my live preview implementation for Arora: http://ariya.ofilabs.com/2008/07/be-my-mirror-my-sword-and-shield.html.
This commit is contained in:
parent
35ab9cb25f
commit
7d1f8a4ae4
|
@ -264,16 +264,21 @@ QPixmap WebTab::renderTabPreview()
|
||||||
renderWidth -= verticalScrollBarWidth;
|
renderWidth -= verticalScrollBarWidth;
|
||||||
renderHeight -= horizontalScrollBarHeight;
|
renderHeight -= horizontalScrollBarHeight;
|
||||||
|
|
||||||
QPixmap pageImage(renderWidth, renderHeight);
|
const int previewWidth = 230;
|
||||||
|
const int previewHeight = 150;
|
||||||
|
qreal scalingFactor = 2 * static_cast<qreal>(previewWidth) / renderWidth;
|
||||||
|
|
||||||
|
QPixmap pageImage(2 * previewWidth, 2 * previewHeight);
|
||||||
pageImage.fill(Qt::transparent);
|
pageImage.fill(Qt::transparent);
|
||||||
|
|
||||||
QPainter p(&pageImage);
|
QPainter p(&pageImage);
|
||||||
|
p.scale(scalingFactor, scalingFactor);
|
||||||
m_view->page()->mainFrame()->render(&p, QWebFrame::ContentsLayer);
|
m_view->page()->mainFrame()->render(&p, QWebFrame::ContentsLayer);
|
||||||
p.end();
|
p.end();
|
||||||
|
|
||||||
page->setViewportSize(oldSize);
|
page->setViewportSize(oldSize);
|
||||||
|
|
||||||
return pageImage.scaled(230, 150, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
return pageImage.scaled(previewWidth, previewHeight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebTab::showNotification(QWidget* notif)
|
void WebTab::showNotification(QWidget* notif)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user