From 1511f7fec594e5c795826034f084e997c457f43b Mon Sep 17 00:00:00 2001 From: Oliver Sander Date: Fri, 11 Aug 2017 22:23:46 +0200 Subject: [PATCH 1/4] Implement ArthurOutputDev::updateBlendMode --- qt5/src/ArthurOutputDev.cc | 52 ++++++++++++++++++++++++++++++++++++++++++++++ qt5/src/ArthurOutputDev.h | 1 + 2 files changed, 53 insertions(+) diff --git a/qt5/src/ArthurOutputDev.cc b/qt5/src/ArthurOutputDev.cc index 3be12672..cd827e0f 100644 --- a/qt5/src/ArthurOutputDev.cc +++ b/qt5/src/ArthurOutputDev.cc @@ -293,6 +293,58 @@ 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 + + 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; + default: + qDebug() << "Unsupported blend mode, falling back to CompositionMode_SourceOver"; + case gfxBlendNormal: + 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 480c7827..bf8cac81 100644 --- a/qt5/src/ArthurOutputDev.h +++ b/qt5/src/ArthurOutputDev.h @@ -114,6 +114,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.14.2