Finalization of axial shading

This commit is contained in:
Jakub Melka
2019-08-31 14:37:18 +02:00
parent 7e2d1b266f
commit 36a071886b
10 changed files with 467 additions and 13 deletions

View File

@ -16,6 +16,7 @@
// along with PDFForQt. If not, see <https://www.gnu.org/licenses/>.
#include "pdfpainter.h"
#include "pdfpattern.h"
#include <QPainter>
@ -31,8 +32,7 @@ PDFPainter::PDFPainter(QPainter* painter,
const PDFOptionalContentActivity* optionalContentActivity) :
PDFPageContentProcessor(page, document, fontCache, optionalContentActivity, pagePointToDevicePointMatrix),
m_painter(painter),
m_features(features),
m_pagePointToDevicePointMatrix(pagePointToDevicePointMatrix)
m_features(features)
{
Q_ASSERT(painter);
Q_ASSERT(pagePointToDevicePointMatrix.isInvertible());
@ -60,6 +60,24 @@ void PDFPainter::performPathPainting(const QPainterPath& path, bool stroke, bool
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;
}
// Set antialiasing
const bool antialiasing = (text && m_features.testFlag(PDFRenderer::TextAntialiasing)) || (!text && m_features.testFlag(PDFRenderer::Antialiasing));
m_painter->setRenderHint(QPainter::Antialiasing, antialiasing);
@ -153,7 +171,7 @@ void PDFPainter::performUpdateGraphicsState(const PDFPageContentProcessorState&
// If current transformation matrix has changed, then update it
if (flags.testFlag(PDFPageContentProcessorState::StateCurrentTransformationMatrix))
{
m_painter->setWorldMatrix(state.getCurrentTransformationMatrix() * m_pagePointToDevicePointMatrix, false);
m_painter->setWorldMatrix(getCurrentWorldMatrix(), false);
}
if (flags.testFlag(PDFPageContentProcessorState::StateStrokeColor) ||