From b8cfe8c1eebe7c139133abe53eff740667990e4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Thu, 26 Dec 2024 03:17:42 +0100 Subject: [PATCH 1/5] Linux: support EGL - skia library is now shared (CI/scripts needs fixes) - skia can now be built against EGL (USE_EGL=ON) Last changes for initial wayland support. Ref: #396 --- src/cmake/friction-common.cmake | 23 ++--------------------- src/core/appsupport.cpp | 3 ++- src/engine/CMakeLists.txt | 8 ++++++++ 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/cmake/friction-common.cmake b/src/cmake/friction-common.cmake index 70c4494d4..12c63d1c5 100644 --- a/src/cmake/friction-common.cmake +++ b/src/cmake/friction-common.cmake @@ -69,20 +69,6 @@ if(MSVC) add_definitions("/MP") endif() -if(UNIX AND NOT APPLE) - option(STATIC_FFMPEG "Link against static ffmpeg" OFF) - if(${STATIC_FFMPEG}) - set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-Bsymbolic") - endif() -endif() - -if(NOT WIN32) - if ((NOT ${CMAKE_VERSION} VERSION_LESS 3.11) AND (NOT OpenGL_GL_PREFERENCE)) - set(OpenGL_GL_PREFERENCE "GLVND") - endif() - find_package(OpenGL REQUIRED) -endif() - find_package(PkgConfig QUIET) find_package(QT NAMES Qt5 COMPONENTS Core REQUIRED) find_package( @@ -117,13 +103,8 @@ if(WIN32) add_definitions(-DSKIA_DLL) set(SKIA_LIBRARIES_DIRS ${CMAKE_SOURCE_DIR}/sdk/bin) else() - if(APPLE) - set(SKIA_LIBRARIES skia) - else() - set(SKIA_LIBRARIES - skia - fontconfig - ${OPENGL_LIBRARY}) + set(SKIA_LIBRARIES skia) + if(UNIX AND NOT APPLE) pkg_check_modules(UNWIND REQUIRED libunwind) set(GPERF_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/../gperftools ${UNWIND_INCLUDE_DIRS}) set(GPERF_LIBRARIES tcmalloc_static ${UNWIND_LIBRARIES}) diff --git a/src/core/appsupport.cpp b/src/core/appsupport.cpp index a0c6c4ddb..f65498a93 100644 --- a/src/core/appsupport.cpp +++ b/src/core/appsupport.cpp @@ -991,8 +991,9 @@ void AppSupport::initEnv(const bool &isRenderer) if (isRenderer) { // Force Mesa if Renderer qputenv("LIBGL_ALWAYS_SOFTWARE", "1"); } - // Force XCB on Linux until we support Wayland +#ifdef PROJECT_OFFICIAL qputenv("QT_QPA_PLATFORM", isRenderer ? "offscreen" : "xcb"); +#endif #else Q_UNUSED(isRenderer) #endif diff --git a/src/engine/CMakeLists.txt b/src/engine/CMakeLists.txt index b4afb013a..ac774ad07 100644 --- a/src/engine/CMakeLists.txt +++ b/src/engine/CMakeLists.txt @@ -29,6 +29,10 @@ option(LINUX_DEPLOY "Linux Deploy" OFF) option(MAC_DEPLOY "Mac Deploy" OFF) option(SYNC_SKIA_DEPS "Sync third-party depends" ON) +if(UNIX AND NOT APPLE) + option(USE_EGL "Use EGL in skia" OFF) +endif() + set(SKIA_SRC "${CMAKE_CURRENT_SOURCE_DIR}/skia") set(SKIA_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/skia") @@ -72,6 +76,10 @@ else() endif() set(SKIA_ARGS "ar=\"${CMAKE_AR}\" cc=\"${CMAKE_C_COMPILER}\" cxx=\"${CMAKE_CXX_COMPILER}\"") if(UNIX AND NOT APPLE) + if(${USE_EGL}) + set(SKIA_ARGS "${SKIA_ARGS} skia_use_egl=true") + endif() + set(SKIA_ARGS "${SKIA_ARGS} is_component_build=true") if (${LINUX_DEPLOY}) set(SKIA_ARGS "${SKIA_ARGS} extra_cflags=[\"-Wno-error\"]") else() From 3f73d2f809e38a7f0d7b7d724957e11951c4e6f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Thu, 26 Dec 2024 04:27:55 +0100 Subject: [PATCH 2/5] skia: Linux changes --- src/cmake/friction-common.cmake | 6 +++++- src/engine/CMakeLists.txt | 10 ++++++++++ src/engine/skia | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/cmake/friction-common.cmake b/src/cmake/friction-common.cmake index 12c63d1c5..4f0f5dfc2 100644 --- a/src/cmake/friction-common.cmake +++ b/src/cmake/friction-common.cmake @@ -103,7 +103,11 @@ if(WIN32) add_definitions(-DSKIA_DLL) set(SKIA_LIBRARIES_DIRS ${CMAKE_SOURCE_DIR}/sdk/bin) else() - set(SKIA_LIBRARIES skia) + if(APPLE) + set(SKIA_LIBRARIES skia) + else() + set(SKIA_LIBRARIES skia.friction) + endif() if(UNIX AND NOT APPLE) pkg_check_modules(UNWIND REQUIRED libunwind) set(GPERF_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/../gperftools ${UNWIND_INCLUDE_DIRS}) diff --git a/src/engine/CMakeLists.txt b/src/engine/CMakeLists.txt index ac774ad07..f9ffbd3cd 100644 --- a/src/engine/CMakeLists.txt +++ b/src/engine/CMakeLists.txt @@ -134,6 +134,16 @@ ExternalProject_Add( USES_TERMINAL_BUILD true ) +if(UNIX AND NOT APPLE) + include(GNUInstallDirs) + install( + FILES + ${SKIA_BUILD_DIR}/libskia.friction.so + DESTINATION + ${CMAKE_INSTALL_LIBDIR} + ) +endif() + if(WIN32) add_custom_command(TARGET Engine POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${SKIA_BUILD_DIR}/skia.dll.lib ${SKIA_BUILD_DIR}/skia.lib) endif() diff --git a/src/engine/skia b/src/engine/skia index d375e53b7..1858ae5f3 160000 --- a/src/engine/skia +++ b/src/engine/skia @@ -1 +1 @@ -Subproject commit d375e53b7c1fcd676c6a00e85dc4985b2979c12f +Subproject commit 1858ae5f38348cfecbcd66b6d9f733ef302d9ab3 From 09e648954dc90dc7d9148c51e80ec54245c34cca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Fri, 27 Dec 2024 10:55:28 +0100 Subject: [PATCH 3/5] Update skia --- src/engine/skia | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/skia b/src/engine/skia index 1858ae5f3..835261b1b 160000 --- a/src/engine/skia +++ b/src/engine/skia @@ -1 +1 @@ -Subproject commit 1858ae5f38348cfecbcd66b6d9f733ef302d9ab3 +Subproject commit 835261b1bd114f9047ccb95025466028cd8880b1 From 85e779dc079e5ca7867fe11653f4cb23ce4b2fa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Fri, 27 Dec 2024 12:20:43 +0100 Subject: [PATCH 4/5] Update Linux SDK --- src/scripts/build.sh | 3 +-- src/scripts/build_vfxplatform_friction.sh | 4 ++-- src/scripts/build_vfxplatform_package.sh | 7 +++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/scripts/build.sh b/src/scripts/build.sh index 911243f48..275c3d39b 100755 --- a/src/scripts/build.sh +++ b/src/scripts/build.sh @@ -30,11 +30,10 @@ BUILD_ENGINE=${BUILD_ENGINE:-"OFF"} REL=${REL:-0} APPIMG=20240401 SDK=1.0.0 -SKIA=1.0.0-682c91fa URL=https://github.com/friction2d/friction-sdk/releases/download/v${SDK} APPIMAGE_TAR=friction-appimage-tools-${APPIMG}.tar.xz SDK_TAR=friction-sdk-${SDK}-linux-x86_64.tar.xz -SKIA_TAR=skia-static-${SKIA}-linux-x86_64.tar.xz +SKIA_TAR=skia-friction-09e64895-linux-x86_64.tar.xz mkdir -p distfiles/sdk || true diff --git a/src/scripts/build_vfxplatform_friction.sh b/src/scripts/build_vfxplatform_friction.sh index c3615a5c8..a18e97293 100755 --- a/src/scripts/build_vfxplatform_friction.sh +++ b/src/scripts/build_vfxplatform_friction.sh @@ -111,9 +111,9 @@ cmake --build . if [ "${BUILD_ENGINE}" = "ON" ]; then (cd src/engine ; - tar cf skia-static-${VERSION}-linux-x86_64.tar skia + tar cf skia-friction-${VERSION}-linux-x86_64.tar skia mkdir -p /mnt/builds/${VERSION} || true - mv skia-static-${VERSION}-linux-x86_64.tar /mnt/builds/${VERSION}/ + mv skia-friction-${VERSION}-linux-x86_64.tar /mnt/builds/${VERSION}/ ) fi diff --git a/src/scripts/build_vfxplatform_package.sh b/src/scripts/build_vfxplatform_package.sh index e893a7fdf..96df3192b 100755 --- a/src/scripts/build_vfxplatform_package.sh +++ b/src/scripts/build_vfxplatform_package.sh @@ -29,6 +29,7 @@ FRICTION_PKG=friction-${VERSION} APPIMAGETOOL=bfe6e0c APPIMAGERUNTIME=1bb1157 +SKIA_LIB=${DISTFILES}/skia/libskia.friction.so if [ "${VERSION}" = "" ]; then echo "Missing version" @@ -143,6 +144,12 @@ for so in *.so*; do done ) +PKG_SKIA_LIB=${BUILD}/${FRICTION_PKG}/opt/friction/lib/libskia.friction.so +if [ -f "${SKIA_LIB}" ] && [ ! -f "${PKG_SKIA_LIB}" ]; then + cp -a ${SKIA_LIB} ${BUILD}/${FRICTION_PKG}/opt/friction/lib/ + strip -s ${PKG_SKIA_LIB} +fi + PLUGS=" audio platforminputcontexts From b83e0fb03b5f8c0e89e3ac66e0711bf806d44b60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Fri, 27 Dec 2024 13:07:42 +0100 Subject: [PATCH 5/5] Update appsupport.cpp --- src/core/appsupport.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/core/appsupport.cpp b/src/core/appsupport.cpp index f65498a93..01ab5b50f 100644 --- a/src/core/appsupport.cpp +++ b/src/core/appsupport.cpp @@ -976,8 +976,8 @@ void AppSupport::checkFFmpeg(const bool &isRenderer) void AppSupport::initEnv(const bool &isRenderer) { -#if defined(Q_OS_WIN) Q_UNUSED(isRenderer) +#if defined(Q_OS_WIN) // windows theme integration #if QT_VERSION < QT_VERSION_CHECK(6, 5, 0) // Set window title bar color based on dark/light theme @@ -988,14 +988,9 @@ void AppSupport::initEnv(const bool &isRenderer) if (registry.value("AppsUseLightTheme", 0).toInt() == 0) { qputenv("QT_QPA_PLATFORM", "windows:darkmode=1"); } #endif #elif defined(Q_OS_LINUX) - if (isRenderer) { // Force Mesa if Renderer - qputenv("LIBGL_ALWAYS_SOFTWARE", "1"); - } #ifdef PROJECT_OFFICIAL - qputenv("QT_QPA_PLATFORM", isRenderer ? "offscreen" : "xcb"); + qputenv("QT_QPA_PLATFORM", "xcb"); #endif -#else - Q_UNUSED(isRenderer) #endif }