From d1c8d297d29cea77aebeda2e852a7c969d7165f2 Mon Sep 17 00:00:00 2001 From: Oliver Sander Date: Thu, 5 Oct 2017 18:32:40 +0200 Subject: [PATCH 3/3] Properly implement saveState / restoreState Not all of the internal state was actually saved/restored in those methods, which lead to inconsistencies between the ArthurOutputDev state and the GfxState object. --- qt5/src/ArthurOutputDev.cc | 14 ++++++++++++++ qt5/src/ArthurOutputDev.h | 9 +++++++++ 2 files changed, 23 insertions(+) diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc index 54e6e551..3c8ded4f 100644 --- a/qt5/src/ArthurOutputDev.cc +++ b/qt5/src/ArthurOutputDev.cc @@ -142,12 +142,26 @@ void ArthurOutputDev::endPage() { void ArthurOutputDev::saveState(GfxState *state) { + m_currentPenStack.push(m_currentPen); + m_currentBrushStack.push(m_currentBrush); + m_rawFontStack.push(m_rawFont); + m_codeToGIDStack.push(m_codeToGID); + m_painter->save(); } void ArthurOutputDev::restoreState(GfxState *state) { m_painter->restore(); + + m_codeToGID = m_codeToGIDStack.top(); + m_codeToGIDStack.pop(); + m_rawFont = m_rawFontStack.top(); + m_rawFontStack.pop(); + m_currentBrush = m_currentBrushStack.top(); + m_currentBrushStack.pop(); + m_currentPen = m_currentPenStack.top(); + m_currentPenStack.pop(); } void ArthurOutputDev::updateAll(GfxState *state) diff --git a/qt5/src/ArthurOutputDev.h b/qt5/src/ArthurOutputDev.h index 3c93b4f8..bf8cac81 100644 --- a/qt5/src/ArthurOutputDev.h +++ b/qt5/src/ArthurOutputDev.h @@ -36,6 +36,7 @@ #include #include +#include #include "goo/gtypes.h" #include "OutputDev.h" @@ -173,14 +174,21 @@ public: private: QPainter *m_painter; FontHinting m_fontHinting; + QPen m_currentPen; + // The various stacks are used to implement the 'saveState' and 'restoreState' methods + std::stack m_currentPenStack; + QBrush m_currentBrush; + std::stack m_currentBrushStack; + GBool m_needFontUpdate; // set when the font needs to be updated SplashFontEngine *m_fontEngine; XRef *xref; // xref table for current document // The current font in use QRawFont* m_rawFont; + std::stack m_rawFontStack; // Identify a font by its 'Ref' and its font size struct ArthurFontID @@ -200,6 +208,7 @@ private: // The table that maps character codes to glyph indexes int* m_codeToGID; + std::stack m_codeToGIDStack; }; #endif -- 2.14.1