Pattern shading refactoring

This commit is contained in:
Jakub Melka
2019-08-31 15:55:59 +02:00
parent 36a071886b
commit 31eae284c2
7 changed files with 151 additions and 49 deletions

View File

@ -47,36 +47,7 @@ PDFPainter::~PDFPainter()
void PDFPainter::performPathPainting(const QPainterPath& path, bool stroke, bool fill, bool text, Qt::FillRule fillRule)
{
// TODO: Implement Pattern features (shading/tiling)
if (isContentSuppressed())
{
// Content is suppressed, do not paint anything
return;
}
if ((!stroke && !fill) || path.isEmpty())
{
// No operation requested - either path is empty, or neither stroking or filling
return;
}
// TODO: Temporary
if (const PDFPatternColorSpace* ps = dynamic_cast<const PDFPatternColorSpace*>(getGraphicState()->getFillColorSpace()))
{
m_painter->save();
const PDFAxialShading* pattern = (PDFAxialShading*)ps->getPattern();
m_painter->setClipPath(path, Qt::IntersectClip);
PDFMeshQualitySettings settings;
settings.deviceSpaceMeshingArea = getPageBoundingRectDeviceSpace();
settings.userSpaceToDeviceSpaceMatrix = getPatternBaseMatrix();
settings.initDefaultResolution();
PDFMesh mesh = pattern->createMesh(settings);
mesh.paint(m_painter);
m_painter->restore();
return;
}
Q_ASSERT(stroke || fill);
// Set antialiasing
const bool antialiasing = (text && m_features.testFlag(PDFRenderer::TextAntialiasing)) || (!text && m_features.testFlag(PDFRenderer::Antialiasing));
@ -164,6 +135,14 @@ void PDFPainter::performImagePainting(const QImage& image)
m_painter->restore();
}
void PDFPainter::performMeshPainting(const PDFMesh& mesh)
{
m_painter->save();
m_painter->setWorldMatrix(QMatrix());
mesh.paint(m_painter);
m_painter->restore();
}
void PDFPainter::performUpdateGraphicsState(const PDFPageContentProcessorState& state)
{
const PDFPageContentProcessorState::StateFlags flags = state.getStateFlags();