From f4c1b9f0018b14f43de9bde1775eaf9a90c11c8b Mon Sep 17 00:00:00 2001 From: Mihai Niculescu Date: Fri, 4 Aug 2017 14:46:46 +0200 Subject: [PATCH] Implement ArthurOutputDev::updateBlendMode Taken from Mihai Niculescu's larger patch at https://lists.freedesktop.org/archives/poppler/2013-June/010370.html --- qt5/src/ArthurOutputDev.cc | 52 ++++++++++++++++++++++++++++++++++++++++++++++ qt5/src/ArthurOutputDev.h | 2 ++ 2 files changed, 54 insertions(+) diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc index 8f3da502..4c46a0ca 100644 --- a/qt5/src/ArthurOutputDev.cc +++ b/qt5/src/ArthurOutputDev.cc @@ -22,6 +22,7 @@ // Copyright (C) 2011 Andreas Hartmetz // Copyright (C) 2013 Thomas Freitag // Copyright (C) 2013 Dominik Haumann +// Copyright (C) 2013 Mihai Niculescu // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -251,6 +252,57 @@ void ArthurOutputDev::updateStrokeColor(GfxState *state) m_painter->setPen(m_currentPen); } +void ArthurOutputDev::updateBlendMode(GfxState * state) +{ + GfxBlendMode blendMode = state->getBlendMode(); + + // missing composition modes in QPainter: + // - CompositionMode_Hue + // - CompositionMode_Color + // - CompositionMode_Luminosity + // - CompositionMode_Saturation + qDebug() << "updateBlendMode, " << blendMode; + switch(blendMode){ + case gfxBlendMultiply: + m_painter->setCompositionMode(QPainter::CompositionMode_Multiply); + break; + case gfxBlendScreen: + m_painter->setCompositionMode(QPainter::CompositionMode_Screen); + break; + case gfxBlendDarken: + m_painter->setCompositionMode(QPainter::CompositionMode_Darken); + break; + case gfxBlendLighten: + m_painter->setCompositionMode(QPainter::CompositionMode_Lighten); + break; + case gfxBlendColorDodge: + m_painter->setCompositionMode(QPainter::CompositionMode_ColorDodge); + break; + case gfxBlendColorBurn: + m_painter->setCompositionMode(QPainter::CompositionMode_ColorBurn); + break; + case gfxBlendHardLight: + m_painter->setCompositionMode(QPainter::CompositionMode_HardLight); + break; + case gfxBlendSoftLight: + m_painter->setCompositionMode(QPainter::CompositionMode_SoftLight); + break; + case gfxBlendDifference: + m_painter->setCompositionMode(QPainter::CompositionMode_Difference); + break; + case gfxBlendExclusion: + m_painter->setCompositionMode(QPainter::CompositionMode_Exclusion); + break; + case gfxBlendColor: + m_painter->setCompositionMode(QPainter::CompositionMode_Plus); + break; + case gfxBlendNormal: + default: + m_painter->setCompositionMode(QPainter::CompositionMode_SourceOver); + break; + } +} + void ArthurOutputDev::updateFillOpacity(GfxState *state) { QColor brushColour= m_currentBrush.color(); diff --git a/qt5/src/ArthurOutputDev.h b/qt5/src/ArthurOutputDev.h index 61ec9290..4c077b32 100644 --- a/qt5/src/ArthurOutputDev.h +++ b/qt5/src/ArthurOutputDev.h @@ -18,6 +18,7 @@ // Copyright (C) 2009, 2011 Carlos Garcia Campos // Copyright (C) 2010 Pino Toscano // Copyright (C) 2011 Andreas Hartmetz +// Copyright (C) 2013 Mihai Niculescu // Copyright (C) 2013 Thomas Freitag // // To see a description of the changes please see the Changelog file that @@ -108,6 +109,7 @@ public: void updateLineWidth(GfxState *state) override; void updateFillColor(GfxState *state) override; void updateStrokeColor(GfxState *state) override; + void updateBlendMode(GfxState *state) override; void updateFillOpacity(GfxState *state) override; void updateStrokeOpacity(GfxState *state) override; -- 2.13.2