diff options
Diffstat (limited to 'src/core/printing/pdfium_document_wrapper_qt.cpp')
-rw-r--r-- | src/core/printing/pdfium_document_wrapper_qt.cpp | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/src/core/printing/pdfium_document_wrapper_qt.cpp b/src/core/printing/pdfium_document_wrapper_qt.cpp index a7433b2cc..a18258d0e 100644 --- a/src/core/printing/pdfium_document_wrapper_qt.cpp +++ b/src/core/printing/pdfium_document_wrapper_qt.cpp @@ -36,11 +36,8 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "pdf/features.h" -#if BUILDFLAG(ENABLE_PDF) #include "pdfium_document_wrapper_qt.h" - #include <QtCore/qhash.h> #include <QtGui/qimage.h> #include <QtGui/qpainter.h> @@ -51,9 +48,9 @@ namespace QtWebEngineCore { int PdfiumDocumentWrapperQt::m_libraryUsers = 0; -class QWEBENGINE_EXPORT PdfiumPageWrapperQt { +class QWEBENGINECORE_PRIVATE_EXPORT PdfiumPageWrapperQt { public: - PdfiumPageWrapperQt(void *data, int pageIndex, int targetWidth, int targetHeight) + PdfiumPageWrapperQt(FPDF_DOCUMENT data, int pageIndex, int targetWidth, int targetHeight) : m_pageData(FPDF_LoadPage(data, pageIndex)) , m_width(FPDF_GetPageWidth(m_pageData)) , m_height(FPDF_GetPageHeight(m_pageData)) @@ -91,7 +88,7 @@ private: if (targetHeight <= 0) targetHeight = m_height; - QImage image(targetWidth, targetHeight, QImage::Format_RGBA8888); + QImage image(targetWidth, targetHeight, QImage::Format_ARGB32); Q_ASSERT(!image.isNull()); image.fill(0xFFFFFFFF); @@ -105,20 +102,11 @@ private: 0, 0); FPDFBitmap_Destroy(bitmap); bitmap = nullptr; - - // Map BGRA to RGBA as PDFium currently does not support RGBA bitmaps directly - for (int i = 0; i < image.height(); i++) { - uchar *pixels = image.scanLine(i); - for (int j = 0; j < image.width(); j++) { - qSwap(pixels[0], pixels[2]); - pixels += 4; - } - } - return image; + return std::move(image); } private: - void *m_pageData; + FPDF_PAGE m_pageData; int m_width; int m_height; int m_index; @@ -136,8 +124,8 @@ PdfiumDocumentWrapperQt::PdfiumDocumentWrapperQt(const void *pdfData, size_t siz if (m_libraryUsers++ == 0) FPDF_InitLibrary(); - m_documentHandle = FPDF_LoadMemDocument(pdfData, static_cast<int>(size), password); - m_pageCount = FPDF_GetPageCount(m_documentHandle); + m_documentHandle = (void *)FPDF_LoadMemDocument(pdfData, static_cast<int>(size), password); + m_pageCount = FPDF_GetPageCount((FPDF_DOCUMENT)m_documentHandle); } QImage PdfiumDocumentWrapperQt::pageAsQImage(size_t index) @@ -152,17 +140,16 @@ QImage PdfiumDocumentWrapperQt::pageAsQImage(size_t index) return QImage(); } - PdfiumPageWrapperQt pageWrapper(m_documentHandle, index, + PdfiumPageWrapperQt pageWrapper((FPDF_DOCUMENT)m_documentHandle, index, m_imageSize.width(), m_imageSize.height()); return pageWrapper.image(); } PdfiumDocumentWrapperQt::~PdfiumDocumentWrapperQt() { - FPDF_CloseDocument(m_documentHandle); + FPDF_CloseDocument((FPDF_DOCUMENT)m_documentHandle); if (--m_libraryUsers == 0) FPDF_DestroyLibrary(); } } -#endif // BUILDFLAG(ENABLE_PDF) |