diff options
author | Paul Gideon Dann | 2018-04-04 16:56:10 +0100 |
---|---|---|
committer | Paul Gideon Dann | 2018-04-04 16:56:35 +0100 |
commit | f3f1e9b1124dc2481cb0e7646267fe27613d1afb (patch) | |
tree | e92cf2e6d125eeac73b0cd07c277176160ed9d59 /0001-Cairo-backend-added-to-Qt5-wrapper.patch | |
parent | 482fb0dc7dd1b242756c84460f45acbcf4dee69a (diff) | |
download | aur-f3f1e9b1124dc2481cb0e7646267fe27613d1afb.tar.gz |
Update for Poppler 0.63.0
Diffstat (limited to '0001-Cairo-backend-added-to-Qt5-wrapper.patch')
-rw-r--r-- | 0001-Cairo-backend-added-to-Qt5-wrapper.patch | 202 |
1 files changed, 202 insertions, 0 deletions
diff --git a/0001-Cairo-backend-added-to-Qt5-wrapper.patch b/0001-Cairo-backend-added-to-Qt5-wrapper.patch new file mode 100644 index 000000000000..5f0cfdcff2c6 --- /dev/null +++ b/0001-Cairo-backend-added-to-Qt5-wrapper.patch @@ -0,0 +1,202 @@ +From fb0f060b9528e38122026fc5c5074b742a712cd8 Mon Sep 17 00:00:00 2001 +From: Paul Gideon Dann <pdgiddie@gmail.com> +Date: Wed, 4 Apr 2018 16:36:56 +0100 +Subject: [PATCH 1/4] Cairo backend added to Qt5 wrapper + +--- + qt5/src/CMakeLists.txt | 15 ++++++++++ + qt5/src/poppler-document.cc | 3 ++ + qt5/src/poppler-page.cc | 70 +++++++++++++++++++++++++++++++++++++++++++++ + qt5/src/poppler-qt5.h | 3 +- + qt5/tests/CMakeLists.txt | 5 ++++ + 5 files changed, 95 insertions(+), 1 deletion(-) + +diff --git a/qt5/src/CMakeLists.txt b/qt5/src/CMakeLists.txt +index 5ae42f52..04e3fcdf 100644 +--- a/qt5/src/CMakeLists.txt ++++ b/qt5/src/CMakeLists.txt +@@ -7,6 +7,11 @@ include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ) + ++if (HAVE_CAIRO) ++ include_directories(${CAIRO_INCLUDE_DIRS}) ++ add_definitions(${CAIRO_CFLAGS}) ++endif (HAVE_CAIRO) ++ + set(poppler_qt5_SRCS + poppler-annotation.cc + poppler-document.cc +@@ -29,6 +34,13 @@ set(poppler_qt5_SRCS + poppler-media.cc + ArthurOutputDev.cc + ) ++if (HAVE_CAIRO) ++ set(poppler_qt5_SRCS ${poppler_qt5_SRCS} ++ ${CMAKE_SOURCE_DIR}/poppler/CairoOutputDev.cc ++ ${CMAKE_SOURCE_DIR}/poppler/CairoRescaleBox.cc ++ ${CMAKE_SOURCE_DIR}/poppler/CairoFontEngine.cc ++ ) ++endif(HAVE_CAIRO) + add_library(poppler-qt5 ${poppler_qt5_SRCS}) + set_target_properties(poppler-qt5 PROPERTIES VERSION 1.13.0 SOVERSION 1) + if(MINGW) +@@ -36,6 +48,9 @@ if(MINGW) + set_target_properties(poppler-qt5 PROPERTIES SUFFIX "-${POPPLER_QT5_SOVERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}") + endif() + target_link_libraries(poppler-qt5 poppler ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Xml_LIBRARIES}) ++if (HAVE_CAIRO) ++ target_link_libraries(poppler-qt5 ${CAIRO_LIBRARIES}) ++endif (HAVE_CAIRO) + if(MSVC) + target_link_libraries(poppler-qt5 poppler ${poppler_LIBS}) + endif() +diff --git a/qt5/src/poppler-document.cc b/qt5/src/poppler-document.cc +index 0eeb923f..e1b7a71c 100644 +--- a/qt5/src/poppler-document.cc ++++ b/qt5/src/poppler-document.cc +@@ -672,6 +672,9 @@ namespace Poppler { + ret << Document::SplashBackend; + #endif + ret << Document::ArthurBackend; ++#if defined(HAVE_CAIRO) ++ ret << Document::CairoBackend; ++#endif + return ret; + } + +diff --git a/qt5/src/poppler-page.cc b/qt5/src/poppler-page.cc +index 381a608b..21e96fe2 100644 +--- a/qt5/src/poppler-page.cc ++++ b/qt5/src/poppler-page.cc +@@ -45,6 +45,7 @@ + #include <QtGui/QPainter> + + #include <config.h> ++#include <math.h> + #include <PDFDoc.h> + #include <Catalog.h> + #include <Form.h> +@@ -58,6 +59,9 @@ + #include <SplashOutputDev.h> + #include <splash/SplashBitmap.h> + #endif ++#if defined(HAVE_CAIRO) ++#include <CairoOutputDev.h> ++#endif + + #include "poppler-private.h" + #include "poppler-page-transition-private.h" +@@ -596,6 +600,70 @@ QImage Page::renderToImage(double xres, double yres, int x, int y, int w, int h, + img = tmpimg; + break; + } ++ case Poppler::Document::CairoBackend: ++ { ++#if defined(HAVE_CAIRO) ++ CairoOutputDev *output_dev = new CairoOutputDev(); ++ output_dev->startDoc(m_page->parentDoc->doc); ++ int buffer_width, buffer_height, rotate; ++ cairo_surface_t *surface; ++ cairo_t *cairo; ++ ++ // If w or h are -1, that indicates the whole page, so we need to ++ // calculate how many pixels that corresponds to. Otherwise, we can use w ++ // or h directly for our buffer size. ++ const QSize pageSize = this->pageSize(); ++ if (w == -1) { ++ const double xscale = xres / 72.0; ++ const double width = pageSize.width();; ++ buffer_width = (int) ceil(width * xscale); ++ } else { ++ buffer_width = w; ++ } ++ if (h == -1) { ++ const double yscale = yres / 72.0; ++ const double height = pageSize.height(); ++ buffer_height = (int) ceil(height * yscale); ++ } else { ++ buffer_height = h; ++ } ++ ++ rotate = rotation + m_page->page->getRotate(); ++ ++ // FIXME: Okular never provides a rotation value, so I don't have any way ++ // of testing this right now. The result is that subpixels are ordered ++ // incorrectly when the page is rotated. ++ ++ //if (rotate == 90 || rotate == 270) { ++ // const double temp = height; ++ // height = width; ++ // width = temp; ++ //} ++ ++ img = QImage(buffer_width, buffer_height, QImage::Format_ARGB32); ++ img.fill(Qt::white); // Never transparent ++ ++ surface = cairo_image_surface_create_for_data( ++ img.bits(), ++ CAIRO_FORMAT_ARGB32, ++ buffer_width, buffer_height, ++ img.bytesPerLine()); ++ ++ cairo = cairo_create(surface); ++ output_dev->setCairo(cairo); ++ ++ m_page->parentDoc->doc->displayPageSlice( ++ output_dev, m_page->index + 1, xres, yres, rotation, false, true, ++ false, x, y, w, h); ++ ++ // Clean up ++ output_dev->setCairo(NULL); ++ cairo_destroy(cairo); ++ cairo_surface_destroy(surface); ++ delete output_dev; ++#endif ++ break; ++ } + } + + if (shouldAbortRenderCallback && shouldAbortRenderCallback(payload)) +@@ -618,6 +686,8 @@ bool Page::renderToPainter(QPainter* painter, double xres, double yres, int x, i + QImageDumpingArthurOutputDev arthur_output(painter, nullptr); + return renderToArthur(&arthur_output, painter, m_page, xres, yres, x, y, w, h, rotate, flags); + } ++ case Poppler::Document::CairoBackend: ++ return false; + } + return false; + } +diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h +index 3adbf02f..5422482a 100644 +--- a/qt5/src/poppler-qt5.h ++++ b/qt5/src/poppler-qt5.h +@@ -1054,7 +1054,8 @@ delete it; + */ + enum RenderBackend { + SplashBackend, ///< Splash backend +- ArthurBackend ///< Arthur (Qt) backend ++ ArthurBackend, ///< Arthur (Qt) backend ++ CairoBackend ///< Cairo backend + }; + + /** +diff --git a/qt5/tests/CMakeLists.txt b/qt5/tests/CMakeLists.txt +index 1e67e6ec..9131568d 100644 +--- a/qt5/tests/CMakeLists.txt ++++ b/qt5/tests/CMakeLists.txt +@@ -11,6 +11,11 @@ include_directories( + ${Qt5Widgets_INCLUDE_DIRS} + ) + ++if (HAVE_CAIRO) ++ include_directories(${CAIRO_INCLUDE_DIRS}) ++ add_definitions(${CAIRO_CFLAGS}) ++endif (HAVE_CAIRO) ++ + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Gui_EXECUTABLE_COMPILE_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Xml_EXECUTABLE_COMPILE_FLAGS}") +-- +2.16.3 + |