From f93b33f24879b7375ae7bced4f6244ebed174b86 Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 9 Nov 2021 11:07:18 -0300 Subject: [PATCH 1/2] Migrate to Skia m96 API --- CMakeLists.txt | 14 ++++++++++++-- laf | 2 +- src/app/app.cpp | 4 +++- src/app/ui/skin/skin_theme.cpp | 2 ++ src/app/ui/tabs.cpp | 2 ++ src/app/widget_loader.cpp | 5 ++++- src/ui/overlay.cpp | 1 + third_party/CMakeLists.txt | 12 ++++++++++++ third_party/harfbuzz | 2 +- third_party/libwebp | 2 +- 10 files changed, 39 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 317e982ab..3119661d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -277,8 +277,18 @@ include_directories(${FREETYPE_INCLUDE_DIRS}) if(USE_SHARED_HARFBUZZ) find_package(HarfBuzz) else() - set(HARFBUZZ_LIBRARIES harfbuzz) - set(HARFBUZZ_INCLUDE_DIRS ${HARFBUZZ_DIR}/src) + if(LAF_BACKEND STREQUAL "skia") + # Use the Skia harfbuzz (it's a modified version with C++11 + # mutexes). + add_definitions(-DHAVE_CONFIG_OVERRIDE_H=1) + set(HARFBUZZ_LIBRARIES ${SKIA_HARFBUZZ_LIBRARY}) + set(HARFBUZZ_INCLUDE_DIRS + ${SKIA_DIR}/third_party/harfbuzz + ${SKIA_DIR}/third_party/externals/harfbuzz/src) + else() + set(HARFBUZZ_LIBRARIES harfbuzz) + set(HARFBUZZ_INCLUDE_DIRS ${HARFBUZZ_DIR}/src) + endif() endif() include_directories(${HARFBUZZ_INCLUDE_DIRS}) diff --git a/laf b/laf index 6eefcb859..aa613ed84 160000 --- a/laf +++ b/laf @@ -1 +1 @@ -Subproject commit 6eefcb859bfbf00a3d993d7bac6a44af93e00bd9 +Subproject commit aa613ed84cc9d896e4aef8beea836376a39e8875 diff --git a/src/app/app.cpp b/src/app/app.cpp index 5a6e31174..a84b1084b 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -391,8 +391,10 @@ void App::run() rf.includeDataDir(fmt::format("icons/ase{0}.png", size).c_str()); if (rf.findFirst()) { os::SurfaceRef surf = os::instance()->loadRgbaSurface(rf.filename().c_str()); - if (surf) + if (surf) { + surf->setImmutable(); icons.push_back(surf); + } } } diff --git a/src/app/ui/skin/skin_theme.cpp b/src/app/ui/skin/skin_theme.cpp index d42a93927..94b17b2bc 100644 --- a/src/app/ui/skin/skin_theme.cpp +++ b/src/app/ui/skin/skin_theme.cpp @@ -340,6 +340,7 @@ void SkinTheme::loadSheet() m_sheet = newSheet; if (m_sheet) m_sheet->applyScale(guiscale()); + m_sheet->setImmutable(); // Reset sprite sheet and font of all layer styles (to avoid // dangling pointers to os::Surface or os::Font). @@ -756,6 +757,7 @@ os::SurfaceRef SkinTheme::sliceSheet(os::SurfaceRef sur, const gfx::Rect& bounds os::SurfaceLock lockSrc(m_sheet.get()); os::SurfaceLock lockDst(sur.get()); m_sheet->blitTo(sur.get(), bounds.x, bounds.y, 0, 0, bounds.w, bounds.h); + sur->setImmutable(); } else { ASSERT(!sur); diff --git a/src/app/ui/tabs.cpp b/src/app/ui/tabs.cpp index 26e793b9d..1e693f7a0 100644 --- a/src/app/ui/tabs.cpp +++ b/src/app/ui/tabs.cpp @@ -948,6 +948,8 @@ void Tabs::createFloatingOverlay(Tab* tab) drawTab(&g, g.getClipBounds(), tab, 0, true, true); } + surface->setImmutable(); + m_floatingOverlay = base::make_ref( surface, gfx::Point(), (ui::Overlay::ZOrder)(Overlay::MouseZOrder-1)); diff --git a/src/app/widget_loader.cpp b/src/app/widget_loader.cpp index 54dd57f61..25f0ef84d 100644 --- a/src/app/widget_loader.cpp +++ b/src/app/widget_loader.cpp @@ -500,7 +500,10 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget try { os::SurfaceRef sur = os::instance()->loadRgbaSurface(rf.filename().c_str()); - widget = new ImageView(sur, 0); + if (sur) { + sur->setImmutable(); + widget = new ImageView(sur, 0); + } } catch (...) { throw base::Exception("Error loading %s file", file); diff --git a/src/ui/overlay.cpp b/src/ui/overlay.cpp index 18be98fb4..729057304 100644 --- a/src/ui/overlay.cpp +++ b/src/ui/overlay.cpp @@ -99,6 +99,7 @@ void Overlay::captureOverlappedArea(os::Surface* screen) os::SurfaceLock lock(m_overlap.get()); screen->blitTo(m_overlap.get(), m_pos.x, m_pos.y, 0, 0, m_overlap->width(), m_overlap->height()); + m_overlap->setImmutable(); m_captured = screen; } diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index cfc5d8924..893bb4879 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -35,6 +35,15 @@ endif() if(WITH_WEBP_SUPPORT) set(WEBP_BUILD_EXTRAS OFF CACHE BOOL "Build extras.") + set(WEBP_BUILD_ANIM_UTILS OFF CACHE BOOL "Build animation utilities.") + set(WEBP_BUILD_CWEBP OFF CACHE BOOL "Build the cwebp command line tool.") + set(WEBP_BUILD_DWEBP OFF CACHE BOOL "Build the dwebp command line tool.") + set(WEBP_BUILD_GIF2WEBP OFF CACHE BOOL "Build the gif2webp conversion tool.") + set(WEBP_BUILD_IMG2WEBP OFF CACHE BOOL "Build the img2webp animation tool.") + set(WEBP_BUILD_VWEBP OFF CACHE BOOL "Build the vwebp viewer tool.") + set(WEBP_BUILD_WEBPINFO OFF CACHE BOOL "Build the webpinfo command line tool.") + set(WEBP_BUILD_WEBPMUX OFF CACHE BOOL "Build the webpmux command line tool.") + add_subdirectory(libwebp) if(NOT USE_SHARED_LIBPNG) @@ -113,7 +122,10 @@ add_subdirectory(json11) set(ENABLE_WERROR OFF CACHE BOOL "Treat warnings as errors - default is ON for Debug, OFF otherwise.") set(ENABLE_TEST OFF CACHE BOOL "Enable unit and regression tests") set(ENABLE_COVERAGE OFF CACHE BOOL "Enable code coverage (GCC only, automatically sets ENABLE_TEST to ON)") +set(ENABLE_LZ4 OFF CACHE BOOL "Enable the use of the system LZ4 library if found") +set(ENABLE_LZO OFF CACHE BOOL "Enable the use of the system LZO library if found") set(ENABLE_LZMA OFF CACHE BOOL "Enable the use of the system LZMA library if found") +set(ENABLE_ZSTD OFF CACHE BOOL "Enable the use of the system zstd library if found") set(ENABLE_CNG OFF CACHE BOOL "Enable the use of CNG(Crypto Next Generation)") set(ENABLE_BZip2 OFF CACHE BOOL "Enable the use of the system BZip2 library if found") set(ENABLE_LIBXML2 OFF CACHE BOOL "Enable the use of the system libxml2 library if found") diff --git a/third_party/harfbuzz b/third_party/harfbuzz index 2040a2998..a52c6df38 160000 --- a/third_party/harfbuzz +++ b/third_party/harfbuzz @@ -1 +1 @@ -Subproject commit 2040a29984a1d47bc9dd309995bfc1d8d51238d3 +Subproject commit a52c6df38a38c4e36ff991dfb4b7d92e48a44553 diff --git a/third_party/libwebp b/third_party/libwebp index 69776e383..9ce5843db 160000 --- a/third_party/libwebp +++ b/third_party/libwebp @@ -1 +1 @@ -Subproject commit 69776e3832fba9969cf9da2513330f500f94e101 +Subproject commit 9ce5843dbabcfd3f7c39ec7ceba9cbeb213cbfdf From 82d93a8697c8f5521b5f1e45f7e865cb7fc4afef Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 16 Nov 2021 21:20:00 -0300 Subject: [PATCH 2/2] Update build instructions for Skia m96 & Apple Silicon (#2451) --- CMakeLists.txt | 25 ++++++++++++++----------- INSTALL.md | 29 +++++++++++++++++++++++++++-- third_party/CMakeLists.txt | 2 +- 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3119661d2..71d9f4b98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,8 +31,9 @@ set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ${CMAKE_CURRENT_SOURCE_DIR}/laf/cmake/cxx project(aseprite C CXX) if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") - # As we compile with CMAKE_OSX_DEPLOYMENT_TARGET=10.7, we have to - # explicitly say that we want to use libc++ instead of the GNU libstdc++ + # As we compile with CMAKE_OSX_DEPLOYMENT_TARGET=10.9, we have to + # explicitly say that we want to use libc++ instead of the GNU + # libstdc++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") endif() @@ -277,15 +278,7 @@ include_directories(${FREETYPE_INCLUDE_DIRS}) if(USE_SHARED_HARFBUZZ) find_package(HarfBuzz) else() - if(LAF_BACKEND STREQUAL "skia") - # Use the Skia harfbuzz (it's a modified version with C++11 - # mutexes). - add_definitions(-DHAVE_CONFIG_OVERRIDE_H=1) - set(HARFBUZZ_LIBRARIES ${SKIA_HARFBUZZ_LIBRARY}) - set(HARFBUZZ_INCLUDE_DIRS - ${SKIA_DIR}/third_party/harfbuzz - ${SKIA_DIR}/third_party/externals/harfbuzz/src) - else() + if(NOT LAF_BACKEND STREQUAL "skia") set(HARFBUZZ_LIBRARIES harfbuzz) set(HARFBUZZ_INCLUDE_DIRS ${HARFBUZZ_DIR}/src) endif() @@ -348,6 +341,16 @@ set(LAF_WITH_TESTS ${ENABLE_TESTS} CACHE BOOL "Enable LAF tests") set(UNDO_TESTS ${ENABLE_TESTS} CACHE BOOL "Enable undo tests") add_subdirectory(laf) + +# Use the Skia harfbuzz (it's a modified version with C++11 mutexes). +if(LAF_BACKEND STREQUAL "skia") + add_definitions(-DHAVE_CONFIG_OVERRIDE_H=1) + set(HARFBUZZ_LIBRARIES ${SKIA_HARFBUZZ_LIBRARY}) + set(HARFBUZZ_INCLUDE_DIRS + ${SKIA_DIR}/third_party/harfbuzz + ${SKIA_DIR}/third_party/externals/harfbuzz/src) +endif() + add_subdirectory(src) ###################################################################### diff --git a/INSTALL.md b/INSTALL.md index 38f593ebc..3ed97a1ad 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -163,7 +163,7 @@ Run `cmake` with the following parameters and then `ninja`: -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DCMAKE_OSX_ARCHITECTURES=x86_64 \ -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 \ - -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk \ + -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk \ -DLAF_BACKEND=skia \ -DSKIA_DIR=$HOME/deps/skia \ -DSKIA_LIBRARY_DIR=$HOME/deps/skia/out/Release-x64 \ @@ -175,9 +175,28 @@ Run `cmake` with the following parameters and then `ninja`: In this case, `$HOME/deps/skia` is the directory where Skia was compiled or downloaded. Make sure that `CMAKE_OSX_SYSROOT` is pointing to the correct SDK directory (in this case -`/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk`), +`/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk`), but it could be different in your Mac. +### Apple Silicon + +If you running macOS on an ARM64/AArch64/Apple Silicon Mac (e.g. M1), +you can compile a native ARM64 version of Aseprite following the same +steps as above but when we call `cmake`, we have some differences: + + cmake \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_OSX_ARCHITECTURES=arm64 \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 \ + -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk \ + -DLAF_BACKEND=skia \ + -DSKIA_DIR=$HOME/deps/skia \ + -DSKIA_LIBRARY_DIR=$HOME/deps/skia/out/Release-arm64 \ + -DSKIA_LIBRARY=$HOME/deps/skia/out/Release-arm64/libskia.a \ + -DPNG_ARM_NEON:STRING=on \ + -G Ninja \ + .. + ### Issues with Retina displays If you have a Retina display, check the following issue: @@ -204,6 +223,12 @@ Run `cmake` with the following parameters and then `ninja`: In this case, `$HOME/deps/skia` is the directory where Skia was compiled or uncompressed. +### GCC compiler + +In case that you are using the pre-compiled Skia version, you will +need to use the Clang compiler to compile Aseprite. Only if you +compile Skia with GCC, you will be able to compile Aseprite with GCC. + # Using shared third party libraries If you don't want to use the embedded code of third party libraries diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index 893bb4879..95e897a84 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -90,7 +90,7 @@ if(NOT USE_SHARED_FREETYPE) endif() endif() -if(NOT USE_SHARED_HARFBUZZ) +if(NOT USE_SHARED_HARFBUZZ AND NOT LAF_BACKEND STREQUAL "skia") if(NOT USE_SHARED_FREETYPE) set(ENV{FREETYPE_DIR} ${FREETYPE_DIR}) endif()