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

@@ -24,7 +24,6 @@
int main(int argc, char *argv[])
{
QGuiApplication a(argc, argv);
QGuiApplication::setAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity, true);
QCoreApplication::setOrganizationName("MelkaJ");
QCoreApplication::setApplicationName("PdfTool");
QCoreApplication::setApplicationVersion(pdf::PDF_LIBRARY_VERSION);

View File

@@ -847,12 +847,12 @@ PDFToolOptions PDFToolAbstractApplication::getOptions(QCommandLineParser* parser
}
}
QString textValue = parser->value("render-hw-accel");
QString textValue = parser->value("render-software");
bool ok = false;
bool value = textValue.toInt(&ok);
if (ok)
{
options.renderUseHardwareRendering = value;
options.renderUseSoftwareRendering = value;
}
else
{

View File

@@ -135,7 +135,7 @@ struct PDFToolOptions
// For option 'RenderFlags'
pdf::PDFRenderer::Features renderFeatures = pdf::PDFRenderer::getDefaultFeatures();
bool renderUseHardwareRendering = true;
bool renderUseSoftwareRendering = true;
bool renderShowPageStatistics = false;
int renderMSAAsamples = 4;
int renderRasterizerCount = pdf::PDFRasterizerPool::getDefaultRasterizerCount();

View File

@@ -180,21 +180,11 @@ int PDFToolRenderBase::execute(const PDFToolOptions& options)
fontCache.setDocument(md);
fontCache.setCacheShrinkEnabled(nullptr, false);
QSurfaceFormat surfaceFormat;
if (options.renderUseHardwareRendering)
{
surfaceFormat = QSurfaceFormat::defaultFormat();
surfaceFormat.setProfile(QSurfaceFormat::CoreProfile);
surfaceFormat.setSamples(options.renderMSAAsamples);
surfaceFormat.setColorSpace(QColorSpace(QColorSpace::SRgb));
surfaceFormat.setSwapBehavior(QSurfaceFormat::DefaultSwapBehavior);
}
m_pageInfo.resize(document.getCatalog()->getPageCount());
pdf::PDFRasterizerPool rasterizerPool(&document, &fontCache, &cmsManager,
&optionalContentActivity, options.renderFeatures, meshQualitySettings,
pdf::PDFRasterizerPool::getCorrectedRasterizerCount(options.renderRasterizerCount),
options.renderUseHardwareRendering, surfaceFormat, nullptr);
options.renderUseSoftwareRendering ? pdf::RendererEngine::QPainter : pdf::RendererEngine::Blend2D, nullptr);
auto onRenderError = [this](pdf::PDFInteger pageIndex, pdf::PDFRenderError error)
{