mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 06:05:38 +00:00
(Android) Made PDF rendering work correctly using Poppler
This commit is contained in:
parent
a4f5c82203
commit
854cef60cb
|
@ -221,7 +221,8 @@ if(APPLE AND CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 15.0.0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -llog")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
|
||||||
|
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -llog")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(EMSCRIPTEN)
|
if(EMSCRIPTEN)
|
||||||
|
@ -442,7 +443,8 @@ set(COMMON_INCLUDE_DIRS ${CURL_INCLUDE_DIR}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/external/lunasvg/include
|
${CMAKE_CURRENT_SOURCE_DIR}/external/lunasvg/include
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/external/rapidjson/include
|
${CMAKE_CURRENT_SOURCE_DIR}/external/rapidjson/include
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/external/rlottie/inc
|
${CMAKE_CURRENT_SOURCE_DIR}/external/rlottie/inc
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/es-core/src)
|
${CMAKE_CURRENT_SOURCE_DIR}/es-core/src
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/es-pdf-converter/src)
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(COMMON_INCLUDE_DIRS ${COMMON_INCLUDE_DIRS}
|
set(COMMON_INCLUDE_DIRS ${COMMON_INCLUDE_DIRS}
|
||||||
|
@ -572,11 +574,15 @@ elseif(ANDROID)
|
||||||
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libswscale.so
|
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libswscale.so
|
||||||
# Other dependencies.
|
# Other dependencies.
|
||||||
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libcurl.so
|
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libcurl.so
|
||||||
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libfreeimage.a
|
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libcrypto.so
|
||||||
|
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libfreeimage.so
|
||||||
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libfreetype.so
|
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libfreetype.so
|
||||||
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libgit2.so
|
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libgit2.so
|
||||||
|
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libjpeg.so
|
||||||
|
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libpoppler.so
|
||||||
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libpugixml.a
|
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libpugixml.a
|
||||||
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libSDL2.so)
|
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libSDL2.so
|
||||||
|
${PROJECT_SOURCE_DIR}/android/libs/${ANDROID_CPU_ARCH}/libssl.so)
|
||||||
elseif(EMSCRIPTEN)
|
elseif(EMSCRIPTEN)
|
||||||
set(COMMON_LIBRARIES ${COMMON_LIBRARIES}
|
set(COMMON_LIBRARIES ${COMMON_LIBRARIES}
|
||||||
# FFmpeg core libraries.
|
# FFmpeg core libraries.
|
||||||
|
@ -673,18 +679,14 @@ set(EXECUTABLE_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE)
|
||||||
set(LIBRARY_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE)
|
set(LIBRARY_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE)
|
||||||
|
|
||||||
# Add each component.
|
# Add each component.
|
||||||
if(NOT ANDROID)
|
add_subdirectory(es-pdf-converter)
|
||||||
add_subdirectory(es-pdf-converter)
|
|
||||||
endif()
|
|
||||||
add_subdirectory(external)
|
add_subdirectory(external)
|
||||||
add_subdirectory(es-core)
|
add_subdirectory(es-core)
|
||||||
add_subdirectory(es-app)
|
add_subdirectory(es-app)
|
||||||
|
|
||||||
if(NOT ANDROID)
|
# Make sure that es-pdf-convert is built first, and then that rlottie is built before es-core.
|
||||||
# Make sure that es-pdf-convert is built first, and then that rlottie is built before es-core.
|
# Also set lottie2gif to not be built.
|
||||||
# Also set lottie2gif to not be built.
|
add_dependencies(lunasvg es-pdf-convert)
|
||||||
add_dependencies(lunasvg es-pdf-convert)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_dependencies(es-core rlottie)
|
add_dependencies(es-core rlottie)
|
||||||
set_target_properties(lottie2gif PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1)
|
set_target_properties(lottie2gif PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1)
|
||||||
|
|
|
@ -134,9 +134,8 @@ elseif(WIN32)
|
||||||
set_target_properties(EmulationStation PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
|
set_target_properties(EmulationStation PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||||
elseif(ANDROID)
|
elseif(ANDROID)
|
||||||
include_directories(${COMMON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
include_directories(${COMMON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||||
add_library(main SHARED ${ES_SOURCES} ${ES_HEADERS})
|
add_library(main MODULE ${ES_SOURCES} ${ES_HEADERS})
|
||||||
target_link_libraries(main ${COMMON_LIBRARIES} ${CMAKE_DL_LIBS} es-core)
|
target_link_libraries(main PRIVATE ${COMMON_LIBRARIES} ${CMAKE_DL_LIBS} es-core es-pdf-convert)
|
||||||
set_target_properties(main PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
||||||
else()
|
else()
|
||||||
include_directories(${COMMON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
include_directories(${COMMON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||||
add_executable(emulationstation ${ES_SOURCES} ${ES_HEADERS})
|
add_executable(emulationstation ${ES_SOURCES} ${ES_HEADERS})
|
||||||
|
|
|
@ -20,6 +20,10 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
#include "ConvertPDF.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define DEBUG_PDF_CONVERSION false
|
#define DEBUG_PDF_CONVERSION false
|
||||||
|
|
||||||
#define KEY_REPEAT_START_DELAY 600
|
#define KEY_REPEAT_START_DELAY 600
|
||||||
|
@ -51,6 +55,7 @@ bool PDFViewer::startPDFViewer(FileData* game)
|
||||||
{
|
{
|
||||||
ViewController::getInstance()->pauseViewVideos();
|
ViewController::getInstance()->pauseViewVideos();
|
||||||
|
|
||||||
|
#if !defined(__ANDROID__)
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
const std::string convertBinary {"/es-pdf-converter/es-pdf-convert.exe"};
|
const std::string convertBinary {"/es-pdf-converter/es-pdf-convert.exe"};
|
||||||
#else
|
#else
|
||||||
|
@ -67,6 +72,7 @@ bool PDFViewer::startPDFViewer(FileData* game)
|
||||||
ViewController::getInstance()->startViewVideos();
|
ViewController::getInstance()->startViewVideos();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif // !__ANDROID__
|
||||||
|
|
||||||
mGame = game;
|
mGame = game;
|
||||||
mManualPath = mGame->getManualPath();
|
mManualPath = mGame->getManualPath();
|
||||||
|
@ -298,6 +304,8 @@ bool PDFViewer::getDocumentInfo()
|
||||||
// Close process and thread handles.
|
// Close process and thread handles.
|
||||||
CloseHandle(pi.hProcess);
|
CloseHandle(pi.hProcess);
|
||||||
CloseHandle(pi.hThread);
|
CloseHandle(pi.hThread);
|
||||||
|
#elif defined(__ANDROID__)
|
||||||
|
ConvertPDF::processFile(mManualPath, "-fileinfo", 0, 0, 0, commandOutput);
|
||||||
#else
|
#else
|
||||||
FILE* commandPipe;
|
FILE* commandPipe;
|
||||||
std::array<char, 512> buffer {};
|
std::array<char, 512> buffer {};
|
||||||
|
@ -439,6 +447,13 @@ void PDFViewer::convertPage(int pageNum)
|
||||||
CloseHandle(childStdoutRead);
|
CloseHandle(childStdoutRead);
|
||||||
WaitForSingleObject(pi.hThread, INFINITE);
|
WaitForSingleObject(pi.hThread, INFINITE);
|
||||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||||
|
#elif (__ANDROID__)
|
||||||
|
ConvertPDF::processFile(mManualPath, "-convert", pageNum,
|
||||||
|
static_cast<int>(mPages[pageNum].width),
|
||||||
|
static_cast<int>(mPages[pageNum].height), imageData);
|
||||||
|
mPages[pageNum].imageData.insert(mPages[pageNum].imageData.end(),
|
||||||
|
std::make_move_iterator(imageData.begin()),
|
||||||
|
std::make_move_iterator(imageData.end()));
|
||||||
#else
|
#else
|
||||||
FILE* commandPipe;
|
FILE* commandPipe;
|
||||||
std::array<char, 512> buffer {};
|
std::array<char, 512> buffer {};
|
||||||
|
@ -461,6 +476,8 @@ void PDFViewer::convertPage(int pageNum)
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
if (!processReturnValue || (static_cast<int>(imageDataSize) <
|
if (!processReturnValue || (static_cast<int>(imageDataSize) <
|
||||||
mPages[pageNum].width * mPages[pageNum].height * 4)) {
|
mPages[pageNum].width * mPages[pageNum].height * 4)) {
|
||||||
|
#elif defined(__ANDROID__)
|
||||||
|
if (static_cast<int>(imageDataSize) < mPages[pageNum].width * mPages[pageNum].height * 4) {
|
||||||
#else
|
#else
|
||||||
if (returnValue != 0 || (static_cast<int>(imageDataSize) <
|
if (returnValue != 0 || (static_cast<int>(imageDataSize) <
|
||||||
mPages[pageNum].width * mPages[pageNum].height * 4)) {
|
mPages[pageNum].width * mPages[pageNum].height * 4)) {
|
||||||
|
|
|
@ -169,6 +169,11 @@ set(CORE_SOURCES
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/utils/TimeUtil.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/src/utils/TimeUtil.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(ANDROID)
|
||||||
|
set(CORE_HEADERS ${CORE_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/src/utils/PlatformUtilAndroid.h)
|
||||||
|
set(CORE_SOURCES ${CORE_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/src/utils/PlatformUtilAndroid.cpp)
|
||||||
|
endif()
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------------------------
|
||||||
# Miscellaneous configuration.
|
# Miscellaneous configuration.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue