Asynchronous page rendering (compilig of pages)

This commit is contained in:
Jakub Melka
2019-12-14 19:09:34 +01:00
parent 0277a9f059
commit 1f09c83700
16 changed files with 473 additions and 61 deletions

View File

@ -51,6 +51,7 @@ PDFWidget::PDFWidget(RendererEngine engine, int samplesCount, QWidget* parent) :
m_proxy->init(this);
connect(m_proxy, &PDFDrawWidgetProxy::renderingError, this, &PDFWidget::onRenderingError);
connect(m_proxy, &PDFDrawWidgetProxy::repaintNeeded, m_drawWidget->getWidget(), QOverload<>::of(&QWidget::update));
connect(m_proxy, &PDFDrawWidgetProxy::pageImageChanged, this, &PDFWidget::onPageImageChanged);
}
PDFWidget::~PDFWidget()
@ -111,6 +112,28 @@ void PDFWidget::onRenderingError(PDFInteger pageIndex, const QList<PDFRenderErro
emit pageRenderingErrorsChanged(pageIndex, errors.size());
}
void PDFWidget::onPageImageChanged(bool all, const std::vector<PDFInteger>& pages)
{
if (all)
{
m_drawWidget->getWidget()->update();
}
else
{
std::vector<PDFInteger> currentPages = m_drawWidget->getCurrentPages();
Q_ASSERT(std::is_sorted(pages.cbegin(), pages.cend()));
for (PDFInteger pageIndex : currentPages)
{
if (std::binary_search(pages.cbegin(), pages.cend(), pageIndex))
{
m_drawWidget->getWidget()->update();
return;
}
}
}
}
IDrawWidget* PDFWidget::createDrawWidget(RendererEngine rendererEngine, int samplesCount)
{
switch (rendererEngine)