Issue #123: Alternative software rendering backend

This commit is contained in:
Jakub Melka
2024-02-04 18:05:38 +01:00
parent 87cedf01dc
commit d314683d38
48 changed files with 872 additions and 761 deletions

View File

@ -22,10 +22,13 @@
#include "pdfcolorspaces.h"
#include "pdfexecutionpolicy.h"
#include "pdfconstants.h"
#include "pdfpainterutils.h"
#include <QMutex>
#include <QPainter>
#include <Blend2d.h>
#include "pdfdbgheap.h"
#include <execution>
@ -1359,6 +1362,45 @@ void PDFMesh::paint(QPainter* painter, PDFReal alpha) const
painter->restore();
}
void PDFMesh::paint(BLContext& context, PDFReal alpha) const
{
if (m_triangles.empty())
{
return;
}
context.save();
PDFPainterHelper::setBLPen(context, Qt::NoPen);
if (!m_backgroundPath.isEmpty() && m_backgroundColor.isValid())
{
QColor backgroundColor = m_backgroundColor;
backgroundColor.setAlphaF(alpha);
PDFPainterHelper::setBLBrush(context, QBrush(backgroundColor, Qt::SolidPattern));
context.fillPath(PDFPainterHelper::getBLPath(m_backgroundPath));
}
QColor color;
// Draw all triangles
for (const Triangle& triangle : m_triangles)
{
if (color != triangle.color)
{
QColor newColor(triangle.color);
newColor.setAlphaF(alpha);
PDFPainterHelper::setBLBrush(context, QBrush(newColor, Qt::SolidPattern));
color = newColor;
}
context.fillTriangle(m_vertices[triangle.v1].x(), m_vertices[triangle.v1].y(),
m_vertices[triangle.v2].x(), m_vertices[triangle.v2].y(),
m_vertices[triangle.v3].x(), m_vertices[triangle.v3].y());
}
context.restore();
}
void PDFMesh::transform(const QTransform& matrix)
{
for (QPointF& vertex : m_vertices)