Asynchronous image redraw

This commit is contained in:
Jakub Melka
2021-02-13 19:20:05 +01:00
parent f020098435
commit 9da1efe4ef
2 changed files with 96 additions and 8 deletions

View File

@ -23,6 +23,8 @@
#include "pdftransparencyrenderer.h"
#include <QDialog>
#include <QFuture>
#include <QFutureWatcher>
namespace Ui
{
@ -41,14 +43,29 @@ public:
virtual ~OutputPreviewDialog() override;
virtual void resizeEvent(QResizeEvent* event) override;
virtual void closeEvent(QCloseEvent* event) override;
virtual void showEvent(QShowEvent* event) override;
private:
void updateImage();
struct RenderedImage
{
QImage image;
};
void updatePageImage();
void onPageImageRendered();
RenderedImage renderPage(const pdf::PDFPage* page, QSize renderSize);
bool isRenderingDone() const;
Ui::OutputPreviewDialog* ui;
pdf::PDFInkMapper m_inkMapper;
const pdf::PDFDocument* m_document;
pdf::PDFWidget* m_widget;
bool m_needUpdateImage;
QFuture<RenderedImage> m_future;
QFutureWatcher<RenderedImage>* m_futureWatcher;
};
} // namespace pdf