From 9afb54e3d6797d86a48266651c5aac29b812a14d Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Sun, 5 Aug 2012 20:48:15 +0200 Subject: [PATCH] make the qt4 frontend to use per-page Splash output devices to enable multi-threaded rendering --- qt4/src/poppler-document.cc | 8 ------- qt4/src/poppler-page.cc | 21 ++++++++++++++---- qt4/src/poppler-private.cc | 2 -- qt4/src/poppler-private.h | 52 --------------------------------------------- test/gtk-test.cc | 2 +- 5 Dateien geändert, 18 Zeilen hinzugefügt(+), 67 Zeilen entfernt(-) diff --git a/qt4/src/poppler-document.cc b/qt4/src/poppler-document.cc index 550e706..60810e6 100644 --- a/qt4/src/poppler-document.cc +++ b/qt4/src/poppler-document.cc @@ -523,14 +523,6 @@ namespace Poppler { m_doc->m_hints |= hint; else m_doc->m_hints &= ~(int)hint; - - // the only way to set antialiasing for Splash is on creation - if ( m_doc->m_backend == Document::SplashBackend && - ( hint & ( Document::Antialiasing || Document::TextAntialiasing || Document::TextHinting ) ) ) - { - delete m_doc->m_outputDev; - m_doc->m_outputDev = NULL; - } } Document::RenderHints Document::renderHints() const diff --git a/qt4/src/poppler-page.cc b/qt4/src/poppler-page.cc index 349a1bb..b8a4666 100644 --- a/qt4/src/poppler-page.cc +++ b/qt4/src/poppler-page.cc @@ -251,10 +251,23 @@ QImage Page::renderToImage(double xres, double yres, int x, int y, int w, int h, case Poppler::Document::SplashBackend: { #if defined(HAVE_SPLASH) - SplashOutputDev *splash_output = static_cast(m_page->parentDoc->getOutputDev()); + SplashColor bgColor; + bgColor[0] = m_page->parentDoc->paperColor.blue(); + bgColor[1] = m_page->parentDoc->paperColor.green(); + bgColor[2] = m_page->parentDoc->paperColor.red(); + GBool AA = m_page->parentDoc->m_hints & Document::TextAntialiasing ? gTrue : gFalse; + + SplashOutputDev * splash_output = new SplashOutputDev(splashModeXBGR8, 4, gFalse, bgColor, gTrue, AA); + + splash_output->setVectorAntialias(m_page->parentDoc->m_hints & Document::Antialiasing ? gTrue : gFalse); + splash_output->setFreeTypeHinting(m_page->parentDoc->m_hints & Document::TextHinting ? gTrue : gFalse, m_page->parentDoc->m_hints & Document::TextSlightHinting ? gTrue : gFalse); + + splash_output->startDoc(m_page->parentDoc->doc); + m_page->parentDoc->doc->displayPageSlice(splash_output, m_page->index + 1, xres, yres, - rotation, false, true, false, x, y, w, h); + rotation, false, true, false, x, y, w, h, + NULL, NULL, NULL, NULL, true); SplashBitmap *bitmap = splash_output->getBitmap(); int bw = bitmap->getWidth(); @@ -281,8 +294,8 @@ QImage Page::renderToImage(double xres, double yres, int x, int y, int w, int h, // construct a qimage SHARING the raw bitmap data in memory QImage tmpimg( dataPtr, bw, bh, QImage::Format_ARGB32 ); img = tmpimg.copy(); - // unload underlying xpdf bitmap - splash_output->startPage( 0, NULL ); + + delete splash_output; #endif break; } diff --git a/qt4/src/poppler-private.cc b/qt4/src/poppler-private.cc index ffb5b92..2d63b3a 100644 --- a/qt4/src/poppler-private.cc +++ b/qt4/src/poppler-private.cc @@ -226,7 +226,6 @@ namespace Debug { qDeleteAll(m_embeddedFiles); delete (OptContentModel *)m_optContentModel; delete doc; - delete m_outputDev; delete m_fontInfoIterator; count --; @@ -241,7 +240,6 @@ namespace Debug { { m_fontInfoIterator = 0; m_backend = Document::SplashBackend; - m_outputDev = 0; paperColor = Qt::white; m_hints = 0; m_optContentModel = 0; diff --git a/qt4/src/poppler-private.h b/qt4/src/poppler-private.h index 6d2ef2a..49c33f0 100644 --- a/qt4/src/poppler-private.h +++ b/qt4/src/poppler-private.h @@ -112,62 +112,11 @@ namespace Poppler { ~DocumentData(); - OutputDev *getOutputDev() - { - if (!m_outputDev) - { - switch (m_backend) - { - case Document::ArthurBackend: - // create a splash backend even in case of the Arthur Backend - case Document::SplashBackend: - { -#if defined(HAVE_SPLASH) - SplashColor bgColor; - bgColor[0] = paperColor.blue(); - bgColor[1] = paperColor.green(); - bgColor[2] = paperColor.red(); - GBool AA = m_hints & Document::TextAntialiasing ? gTrue : gFalse; - SplashOutputDev * splashOutputDev = new SplashOutputDev(splashModeXBGR8, 4, gFalse, bgColor, gTrue, AA); - splashOutputDev->setVectorAntialias(m_hints & Document::Antialiasing ? gTrue : gFalse); - splashOutputDev->setFreeTypeHinting(m_hints & Document::TextHinting ? gTrue : gFalse, m_hints & Document::TextSlightHinting ? gTrue : gFalse); - splashOutputDev->startDoc(doc); - m_outputDev = splashOutputDev; -#endif - break; - } - } - } - return m_outputDev; - } - void addTocChildren( QDomDocument * docSyn, QDomNode * parent, GooList * items ); void setPaperColor(const QColor &color) { - if (color == paperColor) - return; - paperColor = color; - if ( m_outputDev == NULL ) - return; - - switch ( m_backend ) - { - case Document::SplashBackend: - { -#if defined(HAVE_SPLASH) - SplashOutputDev *splash_output = static_cast( m_outputDev ); - SplashColor bgColor; - bgColor[0] = paperColor.blue(); - bgColor[1] = paperColor.green(); - bgColor[2] = paperColor.red(); - splash_output->setPaperColor(bgColor); -#endif - break; - } - default: ; - } } void fillMembers() @@ -191,7 +140,6 @@ namespace Poppler { bool locked; FontIterator *m_fontInfoIterator; Document::RenderBackend m_backend; - OutputDev *m_outputDev; QList m_embeddedFiles; QPointer m_optContentModel; QColor paperColor; diff --git a/test/gtk-test.cc b/test/gtk-test.cc index a5759d7..6deb401 100644 --- a/test/gtk-test.cc +++ b/test/gtk-test.cc @@ -116,7 +116,7 @@ GDKSplashOutputDev::~GDKSplashOutputDev() { void GDKSplashOutputDev::clear() { startDoc(NULL); - startPage(0, NULL); + startPage(0, NULL, NULL); } void GDKSplashOutputDev::endPage() { -- 1.7.11.4