Commit c9958ecb authored by Oliver Sander's avatar Oliver Sander Committed by Albert Astals Cid
Browse files

ArthurOutputDev: Rudimentary support for transparency groups

This patch adds minimal support for transparency groups.  With it,
the Arthur backend can render highlight annotations.
parent bda1d76f
......@@ -55,6 +55,8 @@
#include <QRawFont>
#include <QGlyphRun>
#include <QtGui/QPainterPath>
#include <QPicture>
......@@ -89,6 +91,7 @@ private:
ArthurOutputDev::ArthurOutputDev(QPainter *painter):
......@@ -990,3 +993,46 @@ void ArthurOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *>drawImage( QRect(0,0,1,1), image );
void ArthurOutputDev::beginTransparencyGroup(GfxState * /*state*/, double * /*bbox*/,
GfxColorSpace * /*blendingColorSpace*/,
GBool /*isolated*/, GBool /*knockout*/,
GBool /*forSoftMask*/)
// The entire transparency group will be painted into a
// freshly created QPicture object. Since an existing painter
// cannot change its paint device, we need to construct a
// new QPainter object as well.
m_qpictures.push(new QPicture);
m_painter.push(new QPainter(;
void ArthurOutputDev::endTransparencyGroup(GfxState * /*state*/)
// Stop painting into the group>end();
// Kill the painter that has been used for the transparency group
// Store the QPicture object that holds the result of the transparency group
// painting. It will be painted and deleted in the method paintTransparencyGroup.
if (m_lastTransparencyGroupPicture)
qDebug() << "Found a transparency group that has not been painted";
m_lastTransparencyGroupPicture =;
void ArthurOutputDev::paintTransparencyGroup(GfxState * /*state*/, double * /*bbox*/)
// Actually draw the transparency group>drawPicture(0,0,*m_lastTransparencyGroupPicture);
// And delete it
m_lastTransparencyGroupPicture = nullptr;
......@@ -164,6 +164,14 @@ public:
void type3D1(GfxState *state, double wx, double wy,
double llx, double lly, double urx, double ury) override;
//----- transparency groups and soft masks
virtual void beginTransparencyGroup(GfxState *state, double *bbox,
GfxColorSpace *blendingColorSpace,
GBool isolated, GBool knockout,
GBool forSoftMask) override;
virtual void endTransparencyGroup(GfxState *state) override;
virtual void paintTransparencyGroup(GfxState *state, double *bbox) override;
//----- special access
// Called to indicate that a new PDF document has been loaded.
......@@ -178,6 +186,13 @@ private:
// It is popped again when the transparency group ends.
std::stack<QPainter*> m_painter;
// This is the corresponding stack of QPicture objects
std::stack<QPicture*> m_qpictures;
// endTransparencyGroup removes a QPicture from the stack, but stores
// it here for later use in paintTransparencyGroup.
QPicture* m_lastTransparencyGroupPicture;
FontHinting m_fontHinting;
QPen m_currentPen;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment