qt5/demos/viewer.cpp | 2 qt5/src/CMakeLists.txt | 2 qt5/src/QPainterOutputDev.cc | 102 ++++++++++++++++++------------------- qt5/src/QPainterOutputDev.h | 26 ++++----- qt5/src/poppler-document.cc | 7 +- qt5/src/poppler-page.cc | 34 ++++++------ qt5/src/poppler-qt5.h | 7 +- qt5/tests/check_stroke_opacity.cpp | 2 qt5/tests/test-poppler-qt5.cpp | 20 +++---- qt5/tests/test-render-to-file.cpp | 10 +-- qt6/demos/viewer.cpp | 2 qt6/src/CMakeLists.txt | 2 qt6/src/QPainterOutputDev.cc | 102 ++++++++++++++++++------------------- qt6/src/QPainterOutputDev.h | 26 ++++----- qt6/src/poppler-document.cc | 4 - qt6/src/poppler-page.cc | 34 ++++++------ qt6/src/poppler-qt6.h | 6 +- qt6/tests/check_stroke_opacity.cpp | 2 qt6/tests/test-poppler-qt6.cpp | 20 +++---- qt6/tests/test-render-to-file.cpp | 10 +-- 20 files changed, 211 insertions(+), 209 deletions(-)
New commits: commit 99346560791c935f74d77405dd35bef0f5823d1b Author: Oliver Sander <[email protected]> Date: Fri Oct 16 23:01:42 2020 +0200 Rename ArthurOutputDev to QPainterOutputDev The Qt rendering system hasn't been called 'Arthur' for a long time, let's adapt the code to that. For backward compatibility, the ArthurBackend enum value remains in the files poppler-qt5.h and poppler-qt6.h. These shouldn't be used anymore. diff --git a/qt5/demos/viewer.cpp b/qt5/demos/viewer.cpp index a7c18079..be7dad7a 100644 --- a/qt5/demos/viewer.cpp +++ b/qt5/demos/viewer.cpp @@ -79,7 +79,7 @@ PdfViewer::PdfViewer(QWidget *parent) : QMainWindow(parent), m_currentPage(0), m act->setChecked(true); act->setData(QVariant::fromValue(0)); m_settingsRenderBackendGrp->addAction(act); - act = settingsRenderMenu->addAction(tr("Arthur")); + act = settingsRenderMenu->addAction(tr("QPainter")); act->setCheckable(true); act->setData(QVariant::fromValue(1)); m_settingsRenderBackendGrp->addAction(act); diff --git a/qt5/src/CMakeLists.txt b/qt5/src/CMakeLists.txt index 0247fa3f..403458e5 100644 --- a/qt5/src/CMakeLists.txt +++ b/qt5/src/CMakeLists.txt @@ -36,7 +36,7 @@ set(poppler_qt5_SRCS poppler-page-transition.cc poppler-media.cc poppler-outline.cc - ArthurOutputDev.cc + QPainterOutputDev.cc poppler-version.cpp ) add_library(poppler-qt5 ${poppler_qt5_SRCS}) diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/QPainterOutputDev.cc similarity index 90% rename from qt5/src/ArthurOutputDev.cc rename to qt5/src/QPainterOutputDev.cc index a5a856b5..645b3cad 100644 --- a/qt5/src/ArthurOutputDev.cc +++ b/qt5/src/QPainterOutputDev.cc @@ -1,6 +1,6 @@ //======================================================================== // -// ArthurOutputDev.cc +// QPainterOutputDev.cc // // Copyright 2003 Glyph & Cog, LLC // @@ -50,7 +50,7 @@ #include "FontEncodingTables.h" #include <fofi/FoFiTrueType.h> #include <fofi/FoFiType1C.h> -#include "ArthurOutputDev.h" +#include "QPainterOutputDev.h" #include "Page.h" #include "Gfx.h" #include "PDFDoc.h" @@ -61,10 +61,10 @@ #include <QtGui/QPainterPath> #include <QPicture> -class ArthurType3Font +class QPainterOutputDevType3Font { public: - ArthurType3Font(PDFDoc *doc, Gfx8BitFont *font); + QPainterOutputDevType3Font(PDFDoc *doc, Gfx8BitFont *font); const QPicture &getGlyph(int gid) const; @@ -78,7 +78,7 @@ public: std::vector<int> codeToGID; }; -ArthurType3Font::ArthurType3Font(PDFDoc *doc, Gfx8BitFont *font) : m_doc(doc), m_font(font) +QPainterOutputDevType3Font::QPainterOutputDevType3Font(PDFDoc *doc, Gfx8BitFont *font) : m_doc(doc), m_font(font) { char *name; const Dict *charProcs = font->getCharProcs(); @@ -103,7 +103,7 @@ ArthurType3Font::ArthurType3Font(PDFDoc *doc, Gfx8BitFont *font) : m_doc(doc), m } } -const QPicture &ArthurType3Font::getGlyph(int gid) const +const QPicture &QPainterOutputDevType3Font::getGlyph(int gid) const { if (!glyphs[gid]) { @@ -118,7 +118,7 @@ const QPicture &ArthurType3Font::getGlyph(int gid) const QPainter glyphPainter; glyphs[gid] = std::make_unique<QPicture>(); glyphPainter.begin(glyphs[gid].get()); - auto output_dev = std::make_unique<ArthurOutputDev>(&glyphPainter); + auto output_dev = std::make_unique<QPainterOutputDev>(&glyphPainter); auto gfx = std::make_unique<Gfx>(m_doc, output_dev.get(), resDict, &box, // pagebox @@ -140,10 +140,10 @@ const QPicture &ArthurType3Font::getGlyph(int gid) const } //------------------------------------------------------------------------ -// ArthurOutputDev +// QPainterOutputDev //------------------------------------------------------------------------ -ArthurOutputDev::ArthurOutputDev(QPainter *painter) : m_lastTransparencyGroupPicture(nullptr), m_hintingPreference(QFont::PreferDefaultHinting) +QPainterOutputDev::QPainterOutputDev(QPainter *painter) : m_lastTransparencyGroupPicture(nullptr), m_hintingPreference(QFont::PreferDefaultHinting) { m_painter.push(painter); m_currentBrush = QBrush(Qt::SolidPattern); @@ -159,7 +159,7 @@ ArthurOutputDev::ArthurOutputDev(QPainter *painter) : m_lastTransparencyGroupPic m_useCIDs = major > 2 || (major == 2 && (minor > 1 || (minor == 1 && patch > 7))); } -ArthurOutputDev::~ArthurOutputDev() +QPainterOutputDev::~QPainterOutputDev() { for (auto &codeToGID : m_codeToGIDCache) { gfree(const_cast<int *>(codeToGID.second)); @@ -168,7 +168,7 @@ ArthurOutputDev::~ArthurOutputDev() FT_Done_FreeType(m_ftLibrary); } -void ArthurOutputDev::startDoc(PDFDoc *doc) +void QPainterOutputDev::startDoc(PDFDoc *doc) { xref = doc->getXRef(); m_doc = doc; @@ -179,11 +179,11 @@ void ArthurOutputDev::startDoc(PDFDoc *doc) m_codeToGIDCache.clear(); } -void ArthurOutputDev::startPage(int pageNum, GfxState *state, XRef *) { } +void QPainterOutputDev::startPage(int pageNum, GfxState *state, XRef *) { } -void ArthurOutputDev::endPage() { } +void QPainterOutputDev::endPage() { } -void ArthurOutputDev::saveState(GfxState *state) +void QPainterOutputDev::saveState(GfxState *state) { m_currentPenStack.push(m_currentPen); m_currentBrushStack.push(m_currentBrush); @@ -194,7 +194,7 @@ void ArthurOutputDev::saveState(GfxState *state) m_painter.top()->save(); } -void ArthurOutputDev::restoreState(GfxState *state) +void QPainterOutputDev::restoreState(GfxState *state) { m_painter.top()->restore(); @@ -210,21 +210,21 @@ void ArthurOutputDev::restoreState(GfxState *state) m_currentPenStack.pop(); } -void ArthurOutputDev::updateAll(GfxState *state) +void QPainterOutputDev::updateAll(GfxState *state) { OutputDev::updateAll(state); m_needFontUpdate = true; } // Set CTM (Current Transformation Matrix) to a fixed matrix -void ArthurOutputDev::setDefaultCTM(const double *ctm) +void QPainterOutputDev::setDefaultCTM(const double *ctm) { m_painter.top()->setTransform(QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5])); } // Update the CTM (Current Transformation Matrix), i.e., compose the old // CTM with a new matrix. -void ArthurOutputDev::updateCTM(GfxState *state, double m11, double m12, double m21, double m22, double m31, double m32) +void QPainterOutputDev::updateCTM(GfxState *state, double m11, double m12, double m21, double m22, double m31, double m32) { updateLineDash(state); updateLineJoin(state); @@ -237,7 +237,7 @@ void ArthurOutputDev::updateCTM(GfxState *state, double m11, double m12, double m_painter.top()->setTransform(update, true); } -void ArthurOutputDev::updateLineDash(GfxState *state) +void QPainterOutputDev::updateLineDash(GfxState *state) { double *dashPattern; int dashLength; @@ -272,12 +272,12 @@ void ArthurOutputDev::updateLineDash(GfxState *state) m_painter.top()->setPen(m_currentPen); } -void ArthurOutputDev::updateFlatness(GfxState *state) +void QPainterOutputDev::updateFlatness(GfxState *state) { // qDebug() << "updateFlatness"; } -void ArthurOutputDev::updateLineJoin(GfxState *state) +void QPainterOutputDev::updateLineJoin(GfxState *state) { switch (state->getLineJoin()) { case 0: @@ -296,7 +296,7 @@ void ArthurOutputDev::updateLineJoin(GfxState *state) m_painter.top()->setPen(m_currentPen); } -void ArthurOutputDev::updateLineCap(GfxState *state) +void QPainterOutputDev::updateLineCap(GfxState *state) { switch (state->getLineCap()) { case 0: @@ -312,13 +312,13 @@ void ArthurOutputDev::updateLineCap(GfxState *state) m_painter.top()->setPen(m_currentPen); } -void ArthurOutputDev::updateMiterLimit(GfxState *state) +void QPainterOutputDev::updateMiterLimit(GfxState *state) { m_currentPen.setMiterLimit(state->getMiterLimit()); m_painter.top()->setPen(m_currentPen); } -void ArthurOutputDev::updateLineWidth(GfxState *state) +void QPainterOutputDev::updateLineWidth(GfxState *state) { m_currentPen.setWidthF(state->getLineWidth()); m_painter.top()->setPen(m_currentPen); @@ -329,7 +329,7 @@ void ArthurOutputDev::updateLineWidth(GfxState *state) updateLineDash(state); } -void ArthurOutputDev::updateFillColor(GfxState *state) +void QPainterOutputDev::updateFillColor(GfxState *state) { GfxRGB rgb; QColor brushColour = m_currentBrush.color(); @@ -338,7 +338,7 @@ void ArthurOutputDev::updateFillColor(GfxState *state) m_currentBrush.setColor(brushColour); } -void ArthurOutputDev::updateStrokeColor(GfxState *state) +void QPainterOutputDev::updateStrokeColor(GfxState *state) { GfxRGB rgb; QColor penColour = m_currentPen.color(); @@ -348,7 +348,7 @@ void ArthurOutputDev::updateStrokeColor(GfxState *state) m_painter.top()->setPen(m_currentPen); } -void ArthurOutputDev::updateBlendMode(GfxState *state) +void QPainterOutputDev::updateBlendMode(GfxState *state) { GfxBlendMode blendMode = state->getBlendMode(); @@ -400,14 +400,14 @@ void ArthurOutputDev::updateBlendMode(GfxState *state) } } -void ArthurOutputDev::updateFillOpacity(GfxState *state) +void QPainterOutputDev::updateFillOpacity(GfxState *state) { QColor brushColour = m_currentBrush.color(); brushColour.setAlphaF(state->getFillOpacity()); m_currentBrush.setColor(brushColour); } -void ArthurOutputDev::updateStrokeOpacity(GfxState *state) +void QPainterOutputDev::updateStrokeOpacity(GfxState *state) { QColor penColour = m_currentPen.color(); penColour.setAlphaF(state->getStrokeOpacity()); @@ -415,7 +415,7 @@ void ArthurOutputDev::updateStrokeOpacity(GfxState *state) m_painter.top()->setPen(m_currentPen); } -void ArthurOutputDev::updateFont(GfxState *state) +void QPainterOutputDev::updateFont(GfxState *state) { GfxFont *gfxFont = state->getFont(); if (!gfxFont) { @@ -423,7 +423,7 @@ void ArthurOutputDev::updateFont(GfxState *state) } // The key to look in the font caches - ArthurFontID fontID = { *gfxFont->getID(), state->getFontSize() }; + QPainterFontID fontID = { *gfxFont->getID(), state->getFontSize() }; // Current font is a type3 font if (gfxFont->getType() == fontType3) { @@ -436,8 +436,8 @@ void ArthurOutputDev::updateFont(GfxState *state) } else { - m_currentType3Font = new ArthurType3Font(m_doc, (Gfx8BitFont *)gfxFont); - m_type3FontCache.insert(std::make_pair(fontID, std::unique_ptr<ArthurType3Font>(m_currentType3Font))); + m_currentType3Font = new QPainterOutputDevType3Font(m_doc, (Gfx8BitFont *)gfxFont); + m_type3FontCache.insert(std::make_pair(fontID, std::unique_ptr<QPainterOutputDevType3Font>(m_currentType3Font))); } return; @@ -694,22 +694,22 @@ static QPainterPath convertPath(GfxState *state, const GfxPath *path, Qt::FillRu return qPath; } -void ArthurOutputDev::stroke(GfxState *state) +void QPainterOutputDev::stroke(GfxState *state) { m_painter.top()->strokePath(convertPath(state, state->getPath(), Qt::OddEvenFill), m_currentPen); } -void ArthurOutputDev::fill(GfxState *state) +void QPainterOutputDev::fill(GfxState *state) { m_painter.top()->fillPath(convertPath(state, state->getPath(), Qt::WindingFill), m_currentBrush); } -void ArthurOutputDev::eoFill(GfxState *state) +void QPainterOutputDev::eoFill(GfxState *state) { m_painter.top()->fillPath(convertPath(state, state->getPath(), Qt::OddEvenFill), m_currentBrush); } -bool ArthurOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) +bool QPainterOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) { double x0, y0, x1, y1; shading->getCoords(&x0, &y0, &x1, &y1); @@ -835,17 +835,17 @@ bool ArthurOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading, return true; } -void ArthurOutputDev::clip(GfxState *state) +void QPainterOutputDev::clip(GfxState *state) { m_painter.top()->setClipPath(convertPath(state, state->getPath(), Qt::WindingFill), Qt::IntersectClip); } -void ArthurOutputDev::eoClip(GfxState *state) +void QPainterOutputDev::eoClip(GfxState *state) { m_painter.top()->setClipPath(convertPath(state, state->getPath(), Qt::OddEvenFill), Qt::IntersectClip); } -void ArthurOutputDev::clipToStrokePath(GfxState *state) +void QPainterOutputDev::clipToStrokePath(GfxState *state) { QPainterPath clipPath = convertPath(state, state->getPath(), Qt::WindingFill); @@ -863,7 +863,7 @@ void ArthurOutputDev::clipToStrokePath(GfxState *state) m_painter.top()->setClipPath(clipPathOutline, Qt::IntersectClip); } -void ArthurOutputDev::drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, int nBytes, const Unicode *u, int uLen) +void QPainterOutputDev::drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, int nBytes, const Unicode *u, int uLen) { // First handle type3 fonts @@ -969,13 +969,13 @@ void ArthurOutputDev::drawChar(GfxState *state, double x, double y, double dx, d } } -void ArthurOutputDev::type3D0(GfxState *state, double wx, double wy) { } +void QPainterOutputDev::type3D0(GfxState *state, double wx, double wy) { } -void ArthurOutputDev::type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury) { } +void QPainterOutputDev::type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury) { } -void ArthurOutputDev::endTextObject(GfxState *state) { } +void QPainterOutputDev::endTextObject(GfxState *state) { } -void ArthurOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool interpolate, bool inlineImg) +void QPainterOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool interpolate, bool inlineImg) { auto imgStr = std::make_unique<ImageStream>(str, width, 1, // numPixelComps @@ -1012,7 +1012,7 @@ void ArthurOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, i } // TODO: lots more work here. -void ArthurOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, const int *maskColors, bool inlineImg) +void QPainterOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, const int *maskColors, bool inlineImg) { unsigned int *data; unsigned int *line; @@ -1060,8 +1060,8 @@ void ArthurOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, int w m_painter.top()->drawImage(QRect(0, 0, 1, 1), image); } -void ArthurOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap, - bool maskInterpolate) +void QPainterOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap, + bool maskInterpolate) { // Bail out if the image size doesn't match the mask size. I don't know // what to do in this case. @@ -1115,7 +1115,7 @@ void ArthurOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream * m_painter.top()->drawImage(QRect(0, 0, 1, 1), image); } -void ArthurOutputDev::beginTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/, GfxColorSpace * /*blendingColorSpace*/, bool /*isolated*/, bool /*knockout*/, bool /*forSoftMask*/) +void QPainterOutputDev::beginTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/, GfxColorSpace * /*blendingColorSpace*/, bool /*isolated*/, bool /*knockout*/, bool /*forSoftMask*/) { // The entire transparency group will be painted into a // freshly created QPicture object. Since an existing painter @@ -1125,7 +1125,7 @@ void ArthurOutputDev::beginTransparencyGroup(GfxState * /*state*/, const double m_painter.push(new QPainter(m_qpictures.top())); } -void ArthurOutputDev::endTransparencyGroup(GfxState * /*state*/) +void QPainterOutputDev::endTransparencyGroup(GfxState * /*state*/) { // Stop painting into the group m_painter.top()->end(); @@ -1144,7 +1144,7 @@ void ArthurOutputDev::endTransparencyGroup(GfxState * /*state*/) m_qpictures.pop(); } -void ArthurOutputDev::paintTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/) +void QPainterOutputDev::paintTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/) { // Actually draw the transparency group m_painter.top()->drawPicture(0, 0, *m_lastTransparencyGroupPicture); diff --git a/qt6/src/ArthurOutputDev.h b/qt5/src/QPainterOutputDev.h similarity index 92% rename from qt6/src/ArthurOutputDev.h rename to qt5/src/QPainterOutputDev.h index 141191b1..0ad858a6 100644 --- a/qt6/src/ArthurOutputDev.h +++ b/qt5/src/QPainterOutputDev.h @@ -1,6 +1,6 @@ //======================================================================== // -// ArthurOutputDev.h +// QPainterOutputDev.h // // Copyright 2003 Glyph & Cog, LLC // @@ -27,8 +27,8 @@ // //======================================================================== -#ifndef ARTHUROUTPUTDEV_H -#define ARTHUROUTPUTDEV_H +#ifndef QPAINTEROUTPUTDEV_H +#define QPAINTEROUTPUTDEV_H #include <memory> #include <map> @@ -47,20 +47,20 @@ class PDFDoc; class QRawFont; -class ArthurType3Font; +class QPainterOutputDevType3Font; //------------------------------------------------------------------------ -// ArthurOutputDev - QPainter renderer +// QPainterOutputDev - Qt 5 QPainter renderer //------------------------------------------------------------------------ -class ArthurOutputDev : public OutputDev +class QPainterOutputDev : public OutputDev { public: // Constructor. - ArthurOutputDev(QPainter *painter); + QPainterOutputDev(QPainter *painter); // Destructor. - ~ArthurOutputDev() override; + ~QPainterOutputDev() override; void setHintingPreference(QFont::HintingPreference hintingPreference) { m_hintingPreference = hintingPreference; } @@ -185,13 +185,13 @@ private: QRawFont *m_rawFont; std::stack<QRawFont *> m_rawFontStack; - ArthurType3Font *m_currentType3Font; - std::stack<ArthurType3Font *> m_type3FontStack; + QPainterOutputDevType3Font *m_currentType3Font; + std::stack<QPainterOutputDevType3Font *> m_type3FontStack; // Cache all fonts by their Ref and font size - using ArthurFontID = std::pair<Ref, double>; - std::map<ArthurFontID, std::unique_ptr<QRawFont>> m_rawFontCache; - std::map<ArthurFontID, std::unique_ptr<ArthurType3Font>> m_type3FontCache; + using QPainterFontID = std::pair<Ref, double>; + std::map<QPainterFontID, std::unique_ptr<QRawFont>> m_rawFontCache; + std::map<QPainterFontID, std::unique_ptr<QPainterOutputDevType3Font>> m_type3FontCache; std::map<Ref, const int *> m_codeToGIDCache; // The table that maps character codes to glyph indexes diff --git a/qt5/src/poppler-document.cc b/qt5/src/poppler-document.cc index 6828da4d..8c449d1e 100644 --- a/qt5/src/poppler-document.cc +++ b/qt5/src/poppler-document.cc @@ -13,7 +13,7 @@ * Copyright (C) 2017 Adrian Johnson <[email protected]> * Copyright (C) 2017 Suzuki Toshiya <[email protected]> * Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <[email protected]>. Work sponsored by the LiMux project of the city of Munich - * Copyright (C) 2019 Oliver Sander <[email protected]> + * Copyright (C) 2019, 2020 Oliver Sander <[email protected]> * Copyright (C) 2019 Alexander Volkov <[email protected]> * Copyright (C) 2020 Philipp Knechtges <[email protected]> * @@ -674,7 +674,7 @@ QColor Document::paperColor() const void Document::setRenderBackend(Document::RenderBackend backend) { // no need to delete the outputdev as for the moment we always create a splash one - // as the arthur one does not allow "precaching" due to it's signature + // as the QPainter one does not allow "precaching" due to it's signature // delete m_doc->m_outputDev; // m_doc->m_outputDev = NULL; m_doc->m_backend = backend; @@ -691,7 +691,8 @@ QSet<Document::RenderBackend> Document::availableRenderBackends() #if defined(HAVE_SPLASH) ret << Document::SplashBackend; #endif - ret << Document::ArthurBackend; + ret << Document::QPainterBackend; + ret << Document::ArthurBackend; // For backward compatibility return ret; } diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc index af7e4a11..1670bc68 100644 --- a/qt5/src/poppler-page.cc +++ b/qt5/src/poppler-page.cc @@ -57,7 +57,7 @@ #include <TextOutputDev.h> #include <Annot.h> #include <Link.h> -#include <ArthurOutputDev.h> +#include <QPainterOutputDev.h> #include <Rendition.h> #if defined(HAVE_SPLASH) # include <SplashOutputDev.h> @@ -164,10 +164,10 @@ private: bool ignorePaperColor; }; -class QImageDumpingArthurOutputDev : public ArthurOutputDev, public OutputDevCallbackHelper +class QImageDumpingQPainterOutputDev : public QPainterOutputDev, public OutputDevCallbackHelper { public: - QImageDumpingArthurOutputDev(QPainter *painter, QImage *i) : ArthurOutputDev(painter), image(i) { } + QImageDumpingQPainterOutputDev(QPainter *painter, QImage *i) : QPainterOutputDev(painter), image(i) { } void dump() override { @@ -417,7 +417,7 @@ static auto shouldAbortExtractionInternalCallback = [](void *user_data) { // Needed to make the ternary operator happy. static bool (*nullAbortCallBack)(void *user_data) = nullptr; -static bool renderToArthur(QImageDumpingArthurOutputDev *arthur_output, QPainter *painter, PageData *page, double xres, double yres, int x, int y, int w, int h, Page::Rotation rotate, Page::PainterFlags flags) +static bool renderToQPainter(QImageDumpingQPainterOutputDev *qpainter_output, QPainter *painter, PageData *page, double xres, double yres, int x, int y, int w, int h, Page::Rotation rotate, Page::PainterFlags flags) { const bool savePainter = !(flags & Page::DontSaveAndRestore); if (savePainter) @@ -428,12 +428,12 @@ static bool renderToArthur(QImageDumpingArthurOutputDev *arthur_output, QPainter painter->setRenderHint(QPainter::TextAntialiasing); painter->translate(x == -1 ? 0 : -x, y == -1 ? 0 : -y); - arthur_output->startDoc(page->parentDoc->doc); + qpainter_output->startDoc(page->parentDoc->doc); const bool hideAnnotations = page->parentDoc->m_hints & Document::HideAnnotations; - OutputDevCallbackHelper *abortHelper = arthur_output; - page->parentDoc->doc->displayPageSlice(arthur_output, page->index + 1, xres, yres, (int)rotate * 90, false, true, false, x, y, w, h, abortHelper->shouldAbortRenderCallback ? shouldAbortRenderInternalCallback : nullAbortCallBack, + OutputDevCallbackHelper *abortHelper = qpainter_output; + page->parentDoc->doc->displayPageSlice(qpainter_output, page->index + 1, xres, yres, (int)rotate * 90, false, true, false, x, y, w, h, abortHelper->shouldAbortRenderCallback ? shouldAbortRenderInternalCallback : nullAbortCallBack, abortHelper, (hideAnnotations) ? annotDisplayDecideCbk : nullAnnotCallBack, nullptr, true); if (savePainter) painter->restore(); @@ -533,7 +533,7 @@ QImage Page::renderToImage(double xres, double yres, int xPos, int yPos, int w, #endif break; } - case Poppler::Document::ArthurBackend: { + case Poppler::Document::QPainterBackend: { QSize size = pageSize(); QImage tmpimg(w == -1 ? qRound(size.width() * xres / 72.0) : w, h == -1 ? qRound(size.height() * yres / 72.0) : h, QImage::Format_ARGB32); @@ -542,16 +542,16 @@ QImage Page::renderToImage(double xres, double yres, int xPos, int yPos, int w, tmpimg.fill(bgColor); QPainter painter(&tmpimg); - QImageDumpingArthurOutputDev arthur_output(&painter, &tmpimg); + QImageDumpingQPainterOutputDev qpainter_output(&painter, &tmpimg); - arthur_output.setHintingPreference(QFontHintingFromPopplerHinting(m_page->parentDoc->m_hints)); + qpainter_output.setHintingPreference(QFontHintingFromPopplerHinting(m_page->parentDoc->m_hints)); #ifdef USE_CMS - arthur_output.setDisplayProfile(m_page->parentDoc->m_displayProfile); + qpainter_output.setDisplayProfile(m_page->parentDoc->m_displayProfile); #endif - arthur_output.setCallbacks(partialUpdateCallback, shouldDoPartialUpdateCallback, shouldAbortRenderCallback, payload); - renderToArthur(&arthur_output, &painter, m_page, xres, yres, xPos, yPos, w, h, rotate, DontSaveAndRestore); + qpainter_output.setCallbacks(partialUpdateCallback, shouldDoPartialUpdateCallback, shouldAbortRenderCallback, payload); + renderToQPainter(&qpainter_output, &painter, m_page, xres, yres, xPos, yPos, w, h, rotate, DontSaveAndRestore); painter.end(); img = tmpimg; break; @@ -572,12 +572,12 @@ bool Page::renderToPainter(QPainter *painter, double xres, double yres, int x, i switch (m_page->parentDoc->m_backend) { case Poppler::Document::SplashBackend: return false; - case Poppler::Document::ArthurBackend: { - QImageDumpingArthurOutputDev arthur_output(painter, nullptr); + case Poppler::Document::QPainterBackend: { + QImageDumpingQPainterOutputDev qpainter_output(painter, nullptr); - arthur_output.setHintingPreference(QFontHintingFromPopplerHinting(m_page->parentDoc->m_hints)); + qpainter_output.setHintingPreference(QFontHintingFromPopplerHinting(m_page->parentDoc->m_hints)); - return renderToArthur(&arthur_output, painter, m_page, xres, yres, x, y, w, h, rotate, flags); + return renderToQPainter(&qpainter_output, painter, m_page, xres, yres, x, y, w, h, rotate, flags); } } return false; diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h index 5e78c9e5..6c167b65 100644 --- a/qt5/src/poppler-qt5.h +++ b/qt5/src/poppler-qt5.h @@ -16,7 +16,7 @@ * Copyright (C) 2012, 2013 Thomas Freitag <[email protected]> * Copyright (C) 2013 Anthony Granger <[email protected]> * Copyright (C) 2016 Jakub Alba <[email protected]> - * Copyright (C) 2017 Oliver Sander <[email protected]> + * Copyright (C) 2017, 2020 Oliver Sander <[email protected]> * Copyright (C) 2017, 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <[email protected]>. Work sponsored by the LiMux project of the city of Munich * Copyright (C) 2018 Nelson Benítez León <[email protected]> * Copyright (C) 2019 Jan Grulich <[email protected]> @@ -695,7 +695,7 @@ rather unexpected results. \returns whether the painting succeeded - \note This method is only supported for Arthur + \note This method is only supported for the QPainterOutputDev \since 0.16 */ @@ -1166,7 +1166,8 @@ public: enum RenderBackend { SplashBackend, ///< Splash backend - ArthurBackend ///< Arthur (Qt) backend + ArthurBackend, ///< \deprecated The old name of the QPainter backend + QPainterBackend = ArthurBackend ///< @since 20.11 }; /** diff --git a/qt5/tests/check_stroke_opacity.cpp b/qt5/tests/check_stroke_opacity.cpp index afdb223d..63ecaa6e 100644 --- a/qt5/tests/check_stroke_opacity.cpp +++ b/qt5/tests/check_stroke_opacity.cpp @@ -22,7 +22,7 @@ void TestStrokeOpacity::checkStrokeOpacity_data() QTest::addColumn<int>("backendType"); QTest::newRow("splash") << (int)Poppler::Document::SplashBackend; - QTest::newRow("qpainter") << (int)Poppler::Document::ArthurBackend; + QTest::newRow("qpainter") << (int)Poppler::Document::QPainterBackend; } void TestStrokeOpacity::checkStrokeOpacity() diff --git a/qt5/tests/test-poppler-qt5.cpp b/qt5/tests/test-poppler-qt5.cpp index 5788b7cd..182e5eae 100644 --- a/qt5/tests/test-poppler-qt5.cpp +++ b/qt5/tests/test-poppler-qt5.cpp @@ -15,7 +15,7 @@ class PDFDisplay : public QWidget // picture display widget { Q_OBJECT public: - PDFDisplay(Poppler::Document *d, bool arthur, QWidget *parent = nullptr); + PDFDisplay(Poppler::Document *d, bool qpainter, QWidget *parent = nullptr); ~PDFDisplay() override; void setShowTextRects(bool show); void display(); @@ -34,14 +34,14 @@ private: QList<Poppler::TextBox *> textRects; }; -PDFDisplay::PDFDisplay(Poppler::Document *d, bool arthur, QWidget *parent) : QWidget(parent) +PDFDisplay::PDFDisplay(Poppler::Document *d, bool qpainter, QWidget *parent) : QWidget(parent) { showTextRects = false; doc = d; m_currentPage = 0; - if (arthur) { - backendString = QStringLiteral("Arthur"); - doc->setRenderBackend(Poppler::Document::ArthurBackend); + if (qpainter) { + backendString = QStringLiteral("QPainter"); + doc->setRenderBackend(Poppler::Document::QPainterBackend); } else { backendString = QStringLiteral("Splash"); doc->setRenderBackend(Poppler::Document::SplashBackend); @@ -132,9 +132,9 @@ int main(int argc, char **argv) { QApplication a(argc, argv); // QApplication required! - if (argc < 2 || (argc == 3 && strcmp(argv[2], "-extract") != 0 && strcmp(argv[2], "-arthur") != 0 && strcmp(argv[2], "-textRects") != 0) || argc > 3) { + if (argc < 2 || (argc == 3 && strcmp(argv[2], "-extract") != 0 && strcmp(argv[2], "-qpainter") != 0 && strcmp(argv[2], "-textRects") != 0) || argc > 3) { // use argument as file name - qWarning() << "usage: test-poppler-qt5 filename [-extract|-arthur|-textRects]"; + qWarning() << "usage: test-poppler-qt5 filename [-extract|-qpainter|-textRects]"; exit(1); } @@ -195,9 +195,9 @@ int main(int argc, char **argv) } } - if (argc == 2 || (argc == 3 && strcmp(argv[2], "-arthur") == 0) || (argc == 3 && strcmp(argv[2], "-textRects") == 0)) { - bool useArthur = (argc == 3 && strcmp(argv[2], "-arthur") == 0); - PDFDisplay test(doc, useArthur); // create picture display + if (argc == 2 || (argc == 3 && strcmp(argv[2], "-qpainter") == 0) || (argc == 3 && strcmp(argv[2], "-textRects") == 0)) { + bool useQPainter = (argc == 3 && strcmp(argv[2], "-qpainter") == 0); + PDFDisplay test(doc, useQPainter); // create picture display test.setWindowTitle(QStringLiteral("Poppler-Qt5 Test")); test.setShowTextRects(argc == 3 && strcmp(argv[2], "-textRects") == 0); test.display(); diff --git a/qt5/tests/test-render-to-file.cpp b/qt5/tests/test-render-to-file.cpp index bfe8fb99..0cba2126 100644 --- a/qt5/tests/test-render-to-file.cpp +++ b/qt5/tests/test-render-to-file.cpp @@ -9,9 +9,9 @@ int main(int argc, char **argv) { QGuiApplication a(argc, argv); // QApplication required! - if (argc < 2 || (argc == 3 && strcmp(argv[2], "-arthur") != 0) || argc > 3) { + if (argc < 2 || (argc == 3 && strcmp(argv[2], "-qpainter") != 0) || argc > 3) { // use argument as file name - qWarning() << "usage: test-render-to-file-qt5 filename [-arthur]"; + qWarning() << "usage: test-render-to-file-qt5 filename [-qpainter]"; exit(1); } @@ -33,9 +33,9 @@ int main(int argc, char **argv) } QString backendString; - if (argc == 3 && strcmp(argv[2], "-arthur") == 0) { - backendString = QStringLiteral("Arthur"); - doc->setRenderBackend(Poppler::Document::ArthurBackend); + if (argc == 3 && strcmp(argv[2], "-qpainter") == 0) { + backendString = QStringLiteral("QPainter"); + doc->setRenderBackend(Poppler::Document::QPainterBackend); } else { backendString = QStringLiteral("Splash"); doc->setRenderBackend(Poppler::Document::SplashBackend); diff --git a/qt6/demos/viewer.cpp b/qt6/demos/viewer.cpp index 73410611..6bba6e04 100644 --- a/qt6/demos/viewer.cpp +++ b/qt6/demos/viewer.cpp @@ -77,7 +77,7 @@ PdfViewer::PdfViewer(QWidget *parent) : QMainWindow(parent), m_currentPage(0), m act->setChecked(true); act->setData(QVariant::fromValue(0)); m_settingsRenderBackendGrp->addAction(act); - act = settingsRenderMenu->addAction(tr("Arthur")); + act = settingsRenderMenu->addAction(tr("QPainter")); act->setCheckable(true); act->setData(QVariant::fromValue(1)); m_settingsRenderBackendGrp->addAction(act); diff --git a/qt6/src/CMakeLists.txt b/qt6/src/CMakeLists.txt index 3ea54420..f5042c52 100644 --- a/qt6/src/CMakeLists.txt +++ b/qt6/src/CMakeLists.txt @@ -33,7 +33,7 @@ set(poppler_qt6_SRCS poppler-page-transition.cc poppler-media.cc poppler-outline.cc - ArthurOutputDev.cc + QPainterOutputDev.cc poppler-version.cpp ) add_library(poppler-qt6 ${poppler_qt6_SRCS}) diff --git a/qt6/src/ArthurOutputDev.cc b/qt6/src/QPainterOutputDev.cc similarity index 90% rename from qt6/src/ArthurOutputDev.cc rename to qt6/src/QPainterOutputDev.cc index a5a856b5..645b3cad 100644 --- a/qt6/src/ArthurOutputDev.cc +++ b/qt6/src/QPainterOutputDev.cc @@ -1,6 +1,6 @@ //======================================================================== // -// ArthurOutputDev.cc +// QPainterOutputDev.cc // // Copyright 2003 Glyph & Cog, LLC // @@ -50,7 +50,7 @@ #include "FontEncodingTables.h" #include <fofi/FoFiTrueType.h> #include <fofi/FoFiType1C.h> -#include "ArthurOutputDev.h" +#include "QPainterOutputDev.h" #include "Page.h" #include "Gfx.h" #include "PDFDoc.h" @@ -61,10 +61,10 @@ #include <QtGui/QPainterPath> #include <QPicture> -class ArthurType3Font +class QPainterOutputDevType3Font { public: - ArthurType3Font(PDFDoc *doc, Gfx8BitFont *font); + QPainterOutputDevType3Font(PDFDoc *doc, Gfx8BitFont *font); const QPicture &getGlyph(int gid) const; @@ -78,7 +78,7 @@ public: std::vector<int> codeToGID; }; -ArthurType3Font::ArthurType3Font(PDFDoc *doc, Gfx8BitFont *font) : m_doc(doc), m_font(font) +QPainterOutputDevType3Font::QPainterOutputDevType3Font(PDFDoc *doc, Gfx8BitFont *font) : m_doc(doc), m_font(font) { char *name; const Dict *charProcs = font->getCharProcs(); @@ -103,7 +103,7 @@ ArthurType3Font::ArthurType3Font(PDFDoc *doc, Gfx8BitFont *font) : m_doc(doc), m } } -const QPicture &ArthurType3Font::getGlyph(int gid) const +const QPicture &QPainterOutputDevType3Font::getGlyph(int gid) const { if (!glyphs[gid]) { @@ -118,7 +118,7 @@ const QPicture &ArthurType3Font::getGlyph(int gid) const QPainter glyphPainter; glyphs[gid] = std::make_unique<QPicture>(); glyphPainter.begin(glyphs[gid].get()); - auto output_dev = std::make_unique<ArthurOutputDev>(&glyphPainter); + auto output_dev = std::make_unique<QPainterOutputDev>(&glyphPainter); auto gfx = std::make_unique<Gfx>(m_doc, output_dev.get(), resDict, &box, // pagebox @@ -140,10 +140,10 @@ const QPicture &ArthurType3Font::getGlyph(int gid) const } //------------------------------------------------------------------------ -// ArthurOutputDev +// QPainterOutputDev //------------------------------------------------------------------------ -ArthurOutputDev::ArthurOutputDev(QPainter *painter) : m_lastTransparencyGroupPicture(nullptr), m_hintingPreference(QFont::PreferDefaultHinting) +QPainterOutputDev::QPainterOutputDev(QPainter *painter) : m_lastTransparencyGroupPicture(nullptr), m_hintingPreference(QFont::PreferDefaultHinting) { m_painter.push(painter); m_currentBrush = QBrush(Qt::SolidPattern); @@ -159,7 +159,7 @@ ArthurOutputDev::ArthurOutputDev(QPainter *painter) : m_lastTransparencyGroupPic m_useCIDs = major > 2 || (major == 2 && (minor > 1 || (minor == 1 && patch > 7))); } -ArthurOutputDev::~ArthurOutputDev() +QPainterOutputDev::~QPainterOutputDev() { for (auto &codeToGID : m_codeToGIDCache) { gfree(const_cast<int *>(codeToGID.second)); @@ -168,7 +168,7 @@ ArthurOutputDev::~ArthurOutputDev() FT_Done_FreeType(m_ftLibrary); } -void ArthurOutputDev::startDoc(PDFDoc *doc) +void QPainterOutputDev::startDoc(PDFDoc *doc) { xref = doc->getXRef(); m_doc = doc; @@ -179,11 +179,11 @@ void ArthurOutputDev::startDoc(PDFDoc *doc) m_codeToGIDCache.clear(); } -void ArthurOutputDev::startPage(int pageNum, GfxState *state, XRef *) { } +void QPainterOutputDev::startPage(int pageNum, GfxState *state, XRef *) { } -void ArthurOutputDev::endPage() { } +void QPainterOutputDev::endPage() { } -void ArthurOutputDev::saveState(GfxState *state) +void QPainterOutputDev::saveState(GfxState *state) { m_currentPenStack.push(m_currentPen); m_currentBrushStack.push(m_currentBrush); @@ -194,7 +194,7 @@ void ArthurOutputDev::saveState(GfxState *state) m_painter.top()->save(); } -void ArthurOutputDev::restoreState(GfxState *state) +void QPainterOutputDev::restoreState(GfxState *state) { m_painter.top()->restore(); @@ -210,21 +210,21 @@ void ArthurOutputDev::restoreState(GfxState *state) m_currentPenStack.pop(); } -void ArthurOutputDev::updateAll(GfxState *state) +void QPainterOutputDev::updateAll(GfxState *state) { OutputDev::updateAll(state); m_needFontUpdate = true; } // Set CTM (Current Transformation Matrix) to a fixed matrix -void ArthurOutputDev::setDefaultCTM(const double *ctm) +void QPainterOutputDev::setDefaultCTM(const double *ctm) { m_painter.top()->setTransform(QTransform(ctm[0], ctm[1], ctm[2], ctm[3], ctm[4], ctm[5])); } // Update the CTM (Current Transformation Matrix), i.e., compose the old // CTM with a new matrix. -void ArthurOutputDev::updateCTM(GfxState *state, double m11, double m12, double m21, double m22, double m31, double m32) +void QPainterOutputDev::updateCTM(GfxState *state, double m11, double m12, double m21, double m22, double m31, double m32) { updateLineDash(state); updateLineJoin(state); @@ -237,7 +237,7 @@ void ArthurOutputDev::updateCTM(GfxState *state, double m11, double m12, double m_painter.top()->setTransform(update, true); } -void ArthurOutputDev::updateLineDash(GfxState *state) +void QPainterOutputDev::updateLineDash(GfxState *state) { double *dashPattern; int dashLength; @@ -272,12 +272,12 @@ void ArthurOutputDev::updateLineDash(GfxState *state) m_painter.top()->setPen(m_currentPen); } -void ArthurOutputDev::updateFlatness(GfxState *state) +void QPainterOutputDev::updateFlatness(GfxState *state) { // qDebug() << "updateFlatness"; } -void ArthurOutputDev::updateLineJoin(GfxState *state) +void QPainterOutputDev::updateLineJoin(GfxState *state) { switch (state->getLineJoin()) { case 0: @@ -296,7 +296,7 @@ void ArthurOutputDev::updateLineJoin(GfxState *state) m_painter.top()->setPen(m_currentPen); } -void ArthurOutputDev::updateLineCap(GfxState *state) +void QPainterOutputDev::updateLineCap(GfxState *state) { switch (state->getLineCap()) { case 0: @@ -312,13 +312,13 @@ void ArthurOutputDev::updateLineCap(GfxState *state) m_painter.top()->setPen(m_currentPen); } -void ArthurOutputDev::updateMiterLimit(GfxState *state) +void QPainterOutputDev::updateMiterLimit(GfxState *state) { m_currentPen.setMiterLimit(state->getMiterLimit()); m_painter.top()->setPen(m_currentPen); } -void ArthurOutputDev::updateLineWidth(GfxState *state) +void QPainterOutputDev::updateLineWidth(GfxState *state) { m_currentPen.setWidthF(state->getLineWidth()); m_painter.top()->setPen(m_currentPen); @@ -329,7 +329,7 @@ void ArthurOutputDev::updateLineWidth(GfxState *state) updateLineDash(state); } -void ArthurOutputDev::updateFillColor(GfxState *state) +void QPainterOutputDev::updateFillColor(GfxState *state) { GfxRGB rgb; QColor brushColour = m_currentBrush.color(); @@ -338,7 +338,7 @@ void ArthurOutputDev::updateFillColor(GfxState *state) m_currentBrush.setColor(brushColour); } -void ArthurOutputDev::updateStrokeColor(GfxState *state) +void QPainterOutputDev::updateStrokeColor(GfxState *state) { GfxRGB rgb; QColor penColour = m_currentPen.color(); @@ -348,7 +348,7 @@ void ArthurOutputDev::updateStrokeColor(GfxState *state) m_painter.top()->setPen(m_currentPen); } -void ArthurOutputDev::updateBlendMode(GfxState *state) +void QPainterOutputDev::updateBlendMode(GfxState *state) { GfxBlendMode blendMode = state->getBlendMode(); @@ -400,14 +400,14 @@ void ArthurOutputDev::updateBlendMode(GfxState *state) } } -void ArthurOutputDev::updateFillOpacity(GfxState *state) +void QPainterOutputDev::updateFillOpacity(GfxState *state) { QColor brushColour = m_currentBrush.color(); brushColour.setAlphaF(state->getFillOpacity()); m_currentBrush.setColor(brushColour); } -void ArthurOutputDev::updateStrokeOpacity(GfxState *state) +void QPainterOutputDev::updateStrokeOpacity(GfxState *state) { QColor penColour = m_currentPen.color(); penColour.setAlphaF(state->getStrokeOpacity()); @@ -415,7 +415,7 @@ void ArthurOutputDev::updateStrokeOpacity(GfxState *state) m_painter.top()->setPen(m_currentPen); } -void ArthurOutputDev::updateFont(GfxState *state) +void QPainterOutputDev::updateFont(GfxState *state) { GfxFont *gfxFont = state->getFont(); if (!gfxFont) { @@ -423,7 +423,7 @@ void ArthurOutputDev::updateFont(GfxState *state) } // The key to look in the font caches - ArthurFontID fontID = { *gfxFont->getID(), state->getFontSize() }; + QPainterFontID fontID = { *gfxFont->getID(), state->getFontSize() }; // Current font is a type3 font if (gfxFont->getType() == fontType3) { @@ -436,8 +436,8 @@ void ArthurOutputDev::updateFont(GfxState *state) } else { - m_currentType3Font = new ArthurType3Font(m_doc, (Gfx8BitFont *)gfxFont); - m_type3FontCache.insert(std::make_pair(fontID, std::unique_ptr<ArthurType3Font>(m_currentType3Font))); + m_currentType3Font = new QPainterOutputDevType3Font(m_doc, (Gfx8BitFont *)gfxFont); + m_type3FontCache.insert(std::make_pair(fontID, std::unique_ptr<QPainterOutputDevType3Font>(m_currentType3Font))); } return; @@ -694,22 +694,22 @@ static QPainterPath convertPath(GfxState *state, const GfxPath *path, Qt::FillRu return qPath; } -void ArthurOutputDev::stroke(GfxState *state) +void QPainterOutputDev::stroke(GfxState *state) { m_painter.top()->strokePath(convertPath(state, state->getPath(), Qt::OddEvenFill), m_currentPen); } -void ArthurOutputDev::fill(GfxState *state) +void QPainterOutputDev::fill(GfxState *state) { m_painter.top()->fillPath(convertPath(state, state->getPath(), Qt::WindingFill), m_currentBrush); } -void ArthurOutputDev::eoFill(GfxState *state) +void QPainterOutputDev::eoFill(GfxState *state) { m_painter.top()->fillPath(convertPath(state, state->getPath(), Qt::OddEvenFill), m_currentBrush); } -bool ArthurOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) +bool QPainterOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading, double tMin, double tMax) { double x0, y0, x1, y1; shading->getCoords(&x0, &y0, &x1, &y1); @@ -835,17 +835,17 @@ bool ArthurOutputDev::axialShadedFill(GfxState *state, GfxAxialShading *shading, return true; } -void ArthurOutputDev::clip(GfxState *state) +void QPainterOutputDev::clip(GfxState *state) { m_painter.top()->setClipPath(convertPath(state, state->getPath(), Qt::WindingFill), Qt::IntersectClip); } -void ArthurOutputDev::eoClip(GfxState *state) +void QPainterOutputDev::eoClip(GfxState *state) { m_painter.top()->setClipPath(convertPath(state, state->getPath(), Qt::OddEvenFill), Qt::IntersectClip); } -void ArthurOutputDev::clipToStrokePath(GfxState *state) +void QPainterOutputDev::clipToStrokePath(GfxState *state) { QPainterPath clipPath = convertPath(state, state->getPath(), Qt::WindingFill); @@ -863,7 +863,7 @@ void ArthurOutputDev::clipToStrokePath(GfxState *state) m_painter.top()->setClipPath(clipPathOutline, Qt::IntersectClip); } -void ArthurOutputDev::drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, int nBytes, const Unicode *u, int uLen) +void QPainterOutputDev::drawChar(GfxState *state, double x, double y, double dx, double dy, double originX, double originY, CharCode code, int nBytes, const Unicode *u, int uLen) { // First handle type3 fonts @@ -969,13 +969,13 @@ void ArthurOutputDev::drawChar(GfxState *state, double x, double y, double dx, d } } -void ArthurOutputDev::type3D0(GfxState *state, double wx, double wy) { } +void QPainterOutputDev::type3D0(GfxState *state, double wx, double wy) { } -void ArthurOutputDev::type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury) { } +void QPainterOutputDev::type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury) { } -void ArthurOutputDev::endTextObject(GfxState *state) { } +void QPainterOutputDev::endTextObject(GfxState *state) { } -void ArthurOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool interpolate, bool inlineImg) +void QPainterOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, int width, int height, bool invert, bool interpolate, bool inlineImg) { auto imgStr = std::make_unique<ImageStream>(str, width, 1, // numPixelComps @@ -1012,7 +1012,7 @@ void ArthurOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str, i } // TODO: lots more work here. -void ArthurOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, const int *maskColors, bool inlineImg) +void QPainterOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, const int *maskColors, bool inlineImg) { unsigned int *data; unsigned int *line; @@ -1060,8 +1060,8 @@ void ArthurOutputDev::drawImage(GfxState *state, Object *ref, Stream *str, int w m_painter.top()->drawImage(QRect(0, 0, 1, 1), image); } -void ArthurOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap, - bool maskInterpolate) +void QPainterOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str, int width, int height, GfxImageColorMap *colorMap, bool interpolate, Stream *maskStr, int maskWidth, int maskHeight, GfxImageColorMap *maskColorMap, + bool maskInterpolate) { // Bail out if the image size doesn't match the mask size. I don't know // what to do in this case. @@ -1115,7 +1115,7 @@ void ArthurOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream * m_painter.top()->drawImage(QRect(0, 0, 1, 1), image); } -void ArthurOutputDev::beginTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/, GfxColorSpace * /*blendingColorSpace*/, bool /*isolated*/, bool /*knockout*/, bool /*forSoftMask*/) +void QPainterOutputDev::beginTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/, GfxColorSpace * /*blendingColorSpace*/, bool /*isolated*/, bool /*knockout*/, bool /*forSoftMask*/) { // The entire transparency group will be painted into a // freshly created QPicture object. Since an existing painter @@ -1125,7 +1125,7 @@ void ArthurOutputDev::beginTransparencyGroup(GfxState * /*state*/, const double m_painter.push(new QPainter(m_qpictures.top())); } -void ArthurOutputDev::endTransparencyGroup(GfxState * /*state*/) +void QPainterOutputDev::endTransparencyGroup(GfxState * /*state*/) { // Stop painting into the group m_painter.top()->end(); @@ -1144,7 +1144,7 @@ void ArthurOutputDev::endTransparencyGroup(GfxState * /*state*/) m_qpictures.pop(); } -void ArthurOutputDev::paintTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/) +void QPainterOutputDev::paintTransparencyGroup(GfxState * /*state*/, const double * /*bbox*/) { // Actually draw the transparency group m_painter.top()->drawPicture(0, 0, *m_lastTransparencyGroupPicture); diff --git a/qt5/src/ArthurOutputDev.h b/qt6/src/QPainterOutputDev.h similarity index 92% rename from qt5/src/ArthurOutputDev.h rename to qt6/src/QPainterOutputDev.h index 6f998f69..d15579be 100644 --- a/qt5/src/ArthurOutputDev.h +++ b/qt6/src/QPainterOutputDev.h @@ -1,6 +1,6 @@ //======================================================================== // -// ArthurOutputDev.h +// QPainterOutputDev.h // // Copyright 2003 Glyph & Cog, LLC // @@ -27,8 +27,8 @@ // //======================================================================== -#ifndef ARTHUROUTPUTDEV_H -#define ARTHUROUTPUTDEV_H +#ifndef QPAINTEROUTPUTDEV_H +#define QPAINTEROUTPUTDEV_H #include <memory> #include <map> @@ -47,20 +47,20 @@ class PDFDoc; class QRawFont; -class ArthurType3Font; +class QPainterOutputDevType3Font; //------------------------------------------------------------------------ -// ArthurOutputDev - Qt 5 QPainter renderer +// QPainterOutputDev - QPainter renderer //------------------------------------------------------------------------ -class ArthurOutputDev : public OutputDev +class QPainterOutputDev : public OutputDev { public: // Constructor. - ArthurOutputDev(QPainter *painter); + QPainterOutputDev(QPainter *painter); // Destructor. - ~ArthurOutputDev() override; + ~QPainterOutputDev() override; void setHintingPreference(QFont::HintingPreference hintingPreference) { m_hintingPreference = hintingPreference; } @@ -185,13 +185,13 @@ private: QRawFont *m_rawFont; std::stack<QRawFont *> m_rawFontStack; - ArthurType3Font *m_currentType3Font; - std::stack<ArthurType3Font *> m_type3FontStack; + QPainterOutputDevType3Font *m_currentType3Font; + std::stack<QPainterOutputDevType3Font *> m_type3FontStack; // Cache all fonts by their Ref and font size - using ArthurFontID = std::pair<Ref, double>; - std::map<ArthurFontID, std::unique_ptr<QRawFont>> m_rawFontCache; - std::map<ArthurFontID, std::unique_ptr<ArthurType3Font>> m_type3FontCache; + using QPainterFontID = std::pair<Ref, double>; + std::map<QPainterFontID, std::unique_ptr<QRawFont>> m_rawFontCache; + std::map<QPainterFontID, std::unique_ptr<QPainterOutputDevType3Font>> m_type3FontCache; std::map<Ref, const int *> m_codeToGIDCache; // The table that maps character codes to glyph indexes diff --git a/qt6/src/poppler-document.cc b/qt6/src/poppler-document.cc index 55b1858f..d014e253 100644 --- a/qt6/src/poppler-document.cc +++ b/qt6/src/poppler-document.cc @@ -657,7 +657,7 @@ QColor Document::paperColor() const void Document::setRenderBackend(Document::RenderBackend backend) { // no need to delete the outputdev as for the moment we always create a splash one - // as the arthur one does not allow "precaching" due to it's signature + // as the QPainter one does not allow "precaching" due to its signature // delete m_doc->m_outputDev; // m_doc->m_outputDev = NULL; m_doc->m_backend = backend; @@ -674,7 +674,7 @@ QSet<Document::RenderBackend> Document::availableRenderBackends() #if defined(HAVE_SPLASH) ret << Document::SplashBackend; #endif - ret << Document::ArthurBackend; + ret << Document::QPainterBackend; return ret; } diff --git a/qt6/src/poppler-page.cc b/qt6/src/poppler-page.cc index 61fd8898..7153c514 100644 --- a/qt6/src/poppler-page.cc +++ b/qt6/src/poppler-page.cc @@ -57,7 +57,7 @@ #include <TextOutputDev.h> #include <Annot.h> #include <Link.h> -#include <ArthurOutputDev.h> +#include <QPainterOutputDev.h> #include <Rendition.h> #if defined(HAVE_SPLASH) # include <SplashOutputDev.h> @@ -164,10 +164,10 @@ private: bool ignorePaperColor; }; -class QImageDumpingArthurOutputDev : public ArthurOutputDev, public OutputDevCallbackHelper +class QImageDumpingQPainterOutputDev : public QPainterOutputDev, public OutputDevCallbackHelper { public: - QImageDumpingArthurOutputDev(QPainter *painter, QImage *i) : ArthurOutputDev(painter), image(i) { } + QImageDumpingQPainterOutputDev(QPainter *painter, QImage *i) : QPainterOutputDev(painter), image(i) { } void dump() override { @@ -417,7 +417,7 @@ static auto shouldAbortExtractionInternalCallback = [](void *user_data) { // Needed to make the ternary operator happy. static bool (*nullAbortCallBack)(void *user_data) = nullptr; -static bool renderToArthur(QImageDumpingArthurOutputDev *arthur_output, QPainter *painter, PageData *page, double xres, double yres, int x, int y, int w, int h, Page::Rotation rotate, Page::PainterFlags flags) +static bool renderToQPainter(QImageDumpingQPainterOutputDev *qpainter_output, QPainter *painter, PageData *page, double xres, double yres, int x, int y, int w, int h, Page::Rotation rotate, Page::PainterFlags flags) { const bool savePainter = !(flags & Page::DontSaveAndRestore); if (savePainter) @@ -428,12 +428,12 @@ static bool renderToArthur(QImageDumpingArthurOutputDev *arthur_output, QPainter painter->setRenderHint(QPainter::TextAntialiasing); painter->translate(x == -1 ? 0 : -x, y == -1 ? 0 : -y); - arthur_output->startDoc(page->parentDoc->doc); + qpainter_output->startDoc(page->parentDoc->doc); const bool hideAnnotations = page->parentDoc->m_hints & Document::HideAnnotations; - OutputDevCallbackHelper *abortHelper = arthur_output; - page->parentDoc->doc->displayPageSlice(arthur_output, page->index + 1, xres, yres, (int)rotate * 90, false, true, false, x, y, w, h, abortHelper->shouldAbortRenderCallback ? shouldAbortRenderInternalCallback : nullAbortCallBack, + OutputDevCallbackHelper *abortHelper = qpainter_output; + page->parentDoc->doc->displayPageSlice(qpainter_output, page->index + 1, xres, yres, (int)rotate * 90, false, true, false, x, y, w, h, abortHelper->shouldAbortRenderCallback ? shouldAbortRenderInternalCallback : nullAbortCallBack, abortHelper, (hideAnnotations) ? annotDisplayDecideCbk : nullAnnotCallBack, nullptr, true); if (savePainter) painter->restore(); @@ -533,7 +533,7 @@ QImage Page::renderToImage(double xres, double yres, int xPos, int yPos, int w, #endif break; } - case Poppler::Document::ArthurBackend: { + case Poppler::Document::QPainterBackend: { QSize size = pageSize(); QImage tmpimg(w == -1 ? qRound(size.width() * xres / 72.0) : w, h == -1 ? qRound(size.height() * yres / 72.0) : h, QImage::Format_ARGB32); @@ -542,16 +542,16 @@ QImage Page::renderToImage(double xres, double yres, int xPos, int yPos, int w, tmpimg.fill(bgColor); QPainter painter(&tmpimg); - QImageDumpingArthurOutputDev arthur_output(&painter, &tmpimg); + QImageDumpingQPainterOutputDev qpainter_output(&painter, &tmpimg); - arthur_output.setHintingPreference(QFontHintingFromPopplerHinting(m_page->parentDoc->m_hints)); + qpainter_output.setHintingPreference(QFontHintingFromPopplerHinting(m_page->parentDoc->m_hints)); #ifdef USE_CMS - arthur_output.setDisplayProfile(m_page->parentDoc->m_displayProfile); + qpainter_output.setDisplayProfile(m_page->parentDoc->m_displayProfile); #endif - arthur_output.setCallbacks(partialUpdateCallback, shouldDoPartialUpdateCallback, shouldAbortRenderCallback, payload); - renderToArthur(&arthur_output, &painter, m_page, xres, yres, xPos, yPos, w, h, rotate, DontSaveAndRestore); + qpainter_output.setCallbacks(partialUpdateCallback, shouldDoPartialUpdateCallback, shouldAbortRenderCallback, payload); + renderToQPainter(&qpainter_output, &painter, m_page, xres, yres, xPos, yPos, w, h, rotate, DontSaveAndRestore); painter.end(); img = tmpimg; break; @@ -572,12 +572,12 @@ bool Page::renderToPainter(QPainter *painter, double xres, double yres, int x, i switch (m_page->parentDoc->m_backend) { case Poppler::Document::SplashBackend: return false; - case Poppler::Document::ArthurBackend: { - QImageDumpingArthurOutputDev arthur_output(painter, nullptr); + case Poppler::Document::QPainterBackend: { + QImageDumpingQPainterOutputDev qpainter_output(painter, nullptr); - arthur_output.setHintingPreference(QFontHintingFromPopplerHinting(m_page->parentDoc->m_hints)); + qpainter_output.setHintingPreference(QFontHintingFromPopplerHinting(m_page->parentDoc->m_hints)); - return renderToArthur(&arthur_output, painter, m_page, xres, yres, x, y, w, h, rotate, flags); + return renderToQPainter(&qpainter_output, painter, m_page, xres, yres, x, y, w, h, rotate, flags); } } return false; diff --git a/qt6/src/poppler-qt6.h b/qt6/src/poppler-qt6.h index b129db94..c3c3f631 100644 --- a/qt6/src/poppler-qt6.h +++ b/qt6/src/poppler-qt6.h @@ -16,7 +16,7 @@ * Copyright (C) 2012, 2013 Thomas Freitag <[email protected]> * Copyright (C) 2013 Anthony Granger <[email protected]> * Copyright (C) 2016 Jakub Alba <[email protected]> - * Copyright (C) 2017 Oliver Sander <[email protected]> + * Copyright (C) 2017, 2020 Oliver Sander <[email protected]> * Copyright (C) 2017, 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <[email protected]>. Work sponsored by the LiMux project of the city of Munich * Copyright (C) 2018 Nelson Benítez León <[email protected]> * Copyright (C) 2019 Jan Grulich <[email protected]> @@ -668,7 +668,7 @@ rather unexpected results. \returns whether the painting succeeded - \note This method is only supported for Arthur + \note This method is only supported for the QPainterOutputDev */ bool renderToPainter(QPainter *painter, double xres = 72.0, double yres = 72.0, int x = -1, int y = -1, int w = -1, int h = -1, Rotation rotate = Rotate0, PainterFlags flags = NoPainterFlags) const; @@ -1083,7 +1083,7 @@ public: enum RenderBackend { SplashBackend, ///< Splash backend - ArthurBackend ///< Arthur (Qt) backend + QPainterBackend ///< Qt backend }; /** diff --git a/qt6/tests/check_stroke_opacity.cpp b/qt6/tests/check_stroke_opacity.cpp index 05b7dff2..4ea3e1a9 100644 --- a/qt6/tests/check_stroke_opacity.cpp +++ b/qt6/tests/check_stroke_opacity.cpp @@ -22,7 +22,7 @@ void TestStrokeOpacity::checkStrokeOpacity_data() QTest::addColumn<int>("backendType"); QTest::newRow("splash") << (int)Poppler::Document::SplashBackend; - QTest::newRow("qpainter") << (int)Poppler::Document::ArthurBackend; + QTest::newRow("qpainter") << (int)Poppler::Document::QPainterBackend; } void TestStrokeOpacity::checkStrokeOpacity() diff --git a/qt6/tests/test-poppler-qt6.cpp b/qt6/tests/test-poppler-qt6.cpp index b7c0f66a..be5b1027 100644 --- a/qt6/tests/test-poppler-qt6.cpp +++ b/qt6/tests/test-poppler-qt6.cpp @@ -15,7 +15,7 @@ class PDFDisplay : public QWidget // picture display widget { Q_OBJECT public: - PDFDisplay(Poppler::Document *d, bool arthur, QWidget *parent = nullptr); + PDFDisplay(Poppler::Document *d, bool qpainter, QWidget *parent = nullptr); ~PDFDisplay() override; void setShowTextRects(bool show); void display(); @@ -34,14 +34,14 @@ private: QList<Poppler::TextBox *> textRects; }; -PDFDisplay::PDFDisplay(Poppler::Document *d, bool arthur, QWidget *parent) : QWidget(parent) +PDFDisplay::PDFDisplay(Poppler::Document *d, bool qpainter, QWidget *parent) : QWidget(parent) { showTextRects = false; doc = d; m_currentPage = 0; - if (arthur) { - backendString = QStringLiteral("Arthur"); - doc->setRenderBackend(Poppler::Document::ArthurBackend); + if (qpainter) { + backendString = QStringLiteral("QPainter"); + doc->setRenderBackend(Poppler::Document::QPainterBackend); } else { backendString = QStringLiteral("Splash"); doc->setRenderBackend(Poppler::Document::SplashBackend); @@ -132,9 +132,9 @@ int main(int argc, char **argv) { QApplication a(argc, argv); // QApplication required! - if (argc < 2 || (argc == 3 && strcmp(argv[2], "-extract") != 0 && strcmp(argv[2], "-arthur") != 0 && strcmp(argv[2], "-textRects") != 0) || argc > 3) { + if (argc < 2 || (argc == 3 && strcmp(argv[2], "-extract") != 0 && strcmp(argv[2], "-qpainter") != 0 && strcmp(argv[2], "-textRects") != 0) || argc > 3) { // use argument as file name - qWarning() << "usage: test-poppler-qt6 filename [-extract|-arthur|-textRects]"; + qWarning() << "usage: test-poppler-qt6 filename [-extract|-qpainter|-textRects]"; exit(1); } @@ -195,9 +195,9 @@ int main(int argc, char **argv) } } - if (argc == 2 || (argc == 3 && strcmp(argv[2], "-arthur") == 0) || (argc == 3 && strcmp(argv[2], "-textRects") == 0)) { - bool useArthur = (argc == 3 && strcmp(argv[2], "-arthur") == 0); - PDFDisplay test(doc, useArthur); // create picture display + if (argc == 2 || (argc == 3 && strcmp(argv[2], "-qpainter") == 0) || (argc == 3 && strcmp(argv[2], "-textRects") == 0)) { + bool useQPainter = (argc == 3 && strcmp(argv[2], "-qpainter") == 0); + PDFDisplay test(doc, useQPainter); // create picture display test.setWindowTitle(QStringLiteral("Poppler-Qt6 Test")); test.setShowTextRects(argc == 3 && strcmp(argv[2], "-textRects") == 0); test.display(); diff --git a/qt6/tests/test-render-to-file.cpp b/qt6/tests/test-render-to-file.cpp index b5f73b99..08063c3d 100644 --- a/qt6/tests/test-render-to-file.cpp +++ b/qt6/tests/test-render-to-file.cpp @@ -9,9 +9,9 @@ int main(int argc, char **argv) { QGuiApplication a(argc, argv); // QApplication required! - if (argc < 2 || (argc == 3 && strcmp(argv[2], "-arthur") != 0) || argc > 3) { + if (argc < 2 || (argc == 3 && strcmp(argv[2], "-qpainter") != 0) || argc > 3) { // use argument as file name - qWarning() << "usage: test-render-to-file-qt6 filename [-arthur]"; + qWarning() << "usage: test-render-to-file-qt6 filename [-qpainter]"; exit(1); } @@ -33,9 +33,9 @@ int main(int argc, char **argv) } QString backendString; - if (argc == 3 && strcmp(argv[2], "-arthur") == 0) { - backendString = QStringLiteral("Arthur"); - doc->setRenderBackend(Poppler::Document::ArthurBackend); + if (argc == 3 && strcmp(argv[2], "-qpainter") == 0) { + backendString = QStringLiteral("QPainter"); + doc->setRenderBackend(Poppler::Document::QPainterBackend); } else { backendString = QStringLiteral("Splash"); doc->setRenderBackend(Poppler::Document::SplashBackend); _______________________________________________ poppler mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/poppler
