From 533fb778f396877498acf596a4e271e22fcac02a Mon Sep 17 00:00:00 2001 From: David Capello Date: Wed, 12 Jun 2024 17:43:43 -0300 Subject: [PATCH 1/2] Reorganize compilation flags in CMakeLists.txt files * Moved flags that only app-lib uses from add_definitions() to target_compile_definitions() * Curl flags for TLS moved from third_party to root CMakeLists.txt (as they were defined in both places) --- CMakeLists.txt | 17 +++++--- src/CMakeLists.txt | 47 ----------------------- src/app/CMakeLists.txt | 79 +++++++++++++++++++++++--------------- src/dio/CMakeLists.txt | 6 ++- third_party/CMakeLists.txt | 11 ------ 5 files changed, 65 insertions(+), 95 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 72502615e..f17893477 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,13 +82,18 @@ else() set(REQUIRE_CURL OFF) endif() -# Select libcurl's TLS backend according to target platform -if(REQUIRE_CURL AND ENABLE_DRM) - if(APPLE) - option(CMAKE_USE_SECTRANSP "enable Apple OS native SSL/TLS" ON) - endif() +# SSL/TLS support +if(REQUIRE_CURL AND NOT USE_SHARED_CURL) + # Disable OpenSSL (use native libraries only) + set(CMAKE_USE_OPENSSL OFF CACHE BOOL "Use OpenSSL code. Experimental") + set(CMAKE_USE_LIBSSH2 OFF CACHE BOOL "Use libSSH2") + if(WIN32) - set(CMAKE_USE_SCHANNEL "enable Windows native SSL/TLS" ON) + set(CMAKE_USE_SCHANNEL ON CACHE BOOL "enable Windows native SSL/TLS") + elseif(APPLE) + set(CMAKE_USE_SECTRANSP ON CACHE BOOL "enable Apple OS native SSL/TLS") + else() + # TODO Linux? endif() endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3b44e9e55..253a95961 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -28,14 +28,6 @@ else() add_definitions(-Wno-sign-compare) endif() -if(ENABLE_NEWS) - add_definitions(-DENABLE_NEWS) -endif() - -if(ENABLE_UPDATER) - add_definitions(-DENABLE_UPDATER) -endif() - if(WIN32) # Needed to include icons in win32 .rc file include_directories(..) @@ -48,45 +40,6 @@ if(REQUIRE_CURL AND NOT USE_SHARED_CURL AND CURL_STATICLIB) add_definitions(-DCURL_STATICLIB) endif() -###################################################################### -# Special versions (full/trial, devmode, UI/CLI, etc.) - -if(NOT ENABLE_TRIAL_MODE) - add_definitions(-DENABLE_SAVE) -else() - add_definitions(-DENABLE_TRIAL_MODE) -endif() - -if(ENABLE_DRM) - add_definitions(-DENABLE_DRM) - add_definitions(-DENABLE_SAVE) -endif() - -if(ENABLE_DEVMODE) - add_definitions(-DENABLE_DEVMODE) -endif() - -if(ENABLE_UI) - add_definitions(-DENABLE_UI) -endif() - -if(ENABLE_UI AND (NOT ENABLE_TRIAL_MODE OR ENABLE_DRM)) - set(ENABLE_DATA_RECOVERY on) - add_definitions(-DENABLE_DATA_RECOVERY) -else() - set(ENABLE_DATA_RECOVERY off) -endif() - -if(ENABLE_SCRIPTING) - # Needed for "app" and "main" - add_definitions(-DENABLE_SCRIPTING) -endif() - -if(ENABLE_WEBSOCKET) - # Needed for "app" and "main" - add_definitions(-DENABLE_WEBSOCKET) -endif() - ###################################################################### # Aseprite Libraries (in preferred order to be built) diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 63b60a9ae..de7f9bf27 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -87,14 +87,6 @@ add_custom_command( DEPENDS ${GEN_DEP} ${widget_files} ${string_files} "${SOURCE_DATA_DIR}/gui.xml") list(APPEND generated_files ${output_fn}) -if(ENABLE_WEBP) - add_definitions(-DENABLE_WEBP) -endif() - -if(ENABLE_PSD) - add_definitions(-DENABLE_PSD) -endif() - # libarchive definitions add_definitions(-DLIBARCHIVE_STATIC) @@ -113,7 +105,21 @@ else() target_sources(app-lib PRIVATE font_path_unix.cpp) endif() +# Trial-version vs Full version (enable save command) +if(ENABLE_TRIAL_MODE) + target_compile_definitions(app-lib PUBLIC -DENABLE_TRIAL_MODE) +else() + target_compile_definitions(app-lib PUBLIC -DENABLE_SAVE) +endif() + +# Data recovery +if(ENABLE_UI AND (NOT ENABLE_TRIAL_MODE OR ENABLE_DRM)) + set(ENABLE_DATA_RECOVERY on) +else() + set(ENABLE_DATA_RECOVERY off) +endif() if(ENABLE_DATA_RECOVERY) + target_compile_definitions(app-lib PUBLIC -DENABLE_DATA_RECOVERY) target_sources(app-lib PRIVATE crash/backup_observer.cpp crash/data_recovery.cpp @@ -123,6 +129,7 @@ if(ENABLE_DATA_RECOVERY) ui/data_recovery_view.cpp) endif() +# File formats target_sources(app-lib PRIVATE file/ase_format.cpp file/bmp_format.cpp @@ -137,15 +144,32 @@ target_sources(app-lib PRIVATE file/svg_format.cpp file/tga_format.cpp) if(ENABLE_WEBP) + target_compile_definitions(app-lib PUBLIC -DENABLE_WEBP) target_sources(app-lib PRIVATE file/webp_format.cpp) endif() if(ENABLE_PSD) + target_link_libraries(app-lib psd) + target_compile_definitions(app-lib PUBLIC -DENABLE_PSD) target_sources(app-lib PRIVATE file/psd_format.cpp) endif() +# Extras +if(ENABLE_DEVMODE) + target_compile_definitions(app-lib PUBLIC -DENABLE_DEVMODE) +endif() + +# Enable "Check for updates" info +if(ENABLE_UPDATER) + target_compile_definitions(app-lib PUBLIC -DENABLE_UPDATER) +endif() + +# Scripting if(ENABLE_SCRIPTING) + target_link_libraries(app-lib lua lauxlib lualib) + target_compile_definitions(app-lib PUBLIC -DENABLE_SCRIPTING) + if(ENABLE_UI) target_sources(app-lib PRIVATE commands/cmd_developer_console.cpp @@ -153,10 +177,14 @@ if(ENABLE_SCRIPTING) commands/debugger.cpp ui/devconsole_view.cpp) endif() + if(ENABLE_WEBSOCKET) + target_link_libraries(app-lib ixwebsocket) + target_compile_definitions(app-lib PUBLIC -DENABLE_WEBSOCKET) target_sources(app-lib PRIVATE script/websocket_class.cpp) endif() + target_sources(app-lib PRIVATE commands/cmd_run_script.cpp script/app_command_object.cpp @@ -220,7 +248,9 @@ if(ENABLE_SCRIPTING) shell.cpp) endif() +# UI-only files if(ENABLE_UI) + target_compile_definitions(app-lib PUBLIC -DENABLE_UI) target_sources(app-lib PRIVATE app_brushes.cpp app_menus.cpp @@ -431,23 +461,23 @@ if(ENABLE_UI) ui_context.cpp widget_loader.cpp) if(ENABLE_NEWS) + target_compile_definitions(app-lib PUBLIC -DENABLE_NEWS) target_sources(app-lib PRIVATE res/http_loader.cpp ui/news_listbox.cpp) endif() if(ENABLE_DRM) + target_link_libraries(app-lib drm-lib) + target_compile_definitions(app-lib PUBLIC + -DENABLE_DRM + -DENABLE_SAVE) target_sources(app-lib PRIVATE ui/enter_license.cpp ui/aseprite_update.cpp) endif() endif() -if(ENABLE_SENTRY) - target_sources(app-lib PRIVATE sentry_wrapper.cpp) -else() - target_sources(app-lib PRIVATE send_crash.cpp) -endif() - +# Main app sources target_sources(app-lib PRIVATE active_site_handler.cpp app.cpp @@ -734,14 +764,6 @@ target_link_libraries(app-lib tinyexpr qoi) -if(ENABLE_PSD) - target_link_libraries(app-lib psd) -endif() - -if(ENABLE_DRM) - target_link_libraries(app-lib drm-lib) -endif() - # Directory where generated files by "gen" utility will stay. target_include_directories(app-lib PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) @@ -749,14 +771,7 @@ if(REQUIRE_CURL) target_link_libraries(app-lib net-lib) endif() -if(ENABLE_SCRIPTING) - target_link_libraries(app-lib lua lauxlib lualib) - - if(ENABLE_WEBSOCKET) - target_link_libraries(app-lib ixwebsocket) - endif() -endif() - +# Enable loading Steam API if(ENABLE_STEAM) # We need the ENABLE_STEAM flag in main module too so AppOptions are # equal in both modules, app-lib and main (that's why this flag is @@ -765,6 +780,7 @@ if(ENABLE_STEAM) target_link_libraries(app-lib steam-lib) endif() +# Report crashes using Sentry if(ENABLE_SENTRY) target_compile_definitions(app-lib PUBLIC -DENABLE_SENTRY @@ -773,4 +789,7 @@ if(ENABLE_SENTRY) -DSENTRY_ENV="${SENTRY_ENV}") add_subdirectory(${SENTRY_DIR} sentry) target_link_libraries(app-lib sentry) + target_sources(app-lib PRIVATE sentry_wrapper.cpp) +else() + target_sources(app-lib PRIVATE send_crash.cpp) endif() diff --git a/src/dio/CMakeLists.txt b/src/dio/CMakeLists.txt index fab02fbaa..55cb24de5 100644 --- a/src/dio/CMakeLists.txt +++ b/src/dio/CMakeLists.txt @@ -1,5 +1,5 @@ # Aseprite Document IO Library -# Copyright (c) 2022-2023 Igara Studio S.A. +# Copyright (c) 2022-2024 Igara Studio S.A. # Copyright (c) 2016-2018 David Capello add_library(dio-lib @@ -10,6 +10,10 @@ add_library(dio-lib detect_format.cpp stdio.cpp) +if(ENABLE_DEVMODE) + target_compile_definitions(dio-lib PUBLIC -DENABLE_DEVMODE) +endif() + target_link_libraries(dio-lib ${ZLIB_LIBRARIES} fmt diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index 01030d2ee..67d132445 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -62,17 +62,6 @@ if(REQUIRE_CURL AND NOT USE_SHARED_CURL) set(BUILD_RELEASE_DEBUG_DIRS ON BOOL) set(BUILD_CURL_EXE OFF CACHE BOOL "Set to ON to build curl executable.") - # SSL/TLS support (use native libraries only) - set(CMAKE_USE_OPENSSL OFF CACHE BOOL "Use OpenSSL code. Experimental") - set(CMAKE_USE_LIBSSH2 OFF CACHE BOOL "Use libSSH2") - if(WIN32) - set(CMAKE_USE_SCHANNEL ON CACHE BOOL "enable Windows native SSL/TLS") - elseif(APPLE) - set(CMAKE_USE_SECTRANSP ON CACHE BOOL "enable Apple OS native SSL/TLS") - else() - # TODO Linux? - endif() - add_subdirectory(curl) endif() From 2c7fc767bfb90aba0f9f8f6757dc2d3b99f9d527 Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 14 Jun 2024 20:07:05 -0300 Subject: [PATCH 2/2] Update GPU flag correctly on all display when it's changed --- laf | 2 +- src/app/app.cpp | 7 ++++--- src/app/commands/cmd_options.cpp | 10 +++++----- src/app/modules/gui.cpp | 6 +++--- src/app/ui/main_window.cpp | 3 ++- src/ui/manager.cpp | 10 ++++++++-- src/ui/manager.h | 6 ++++-- 7 files changed, 27 insertions(+), 17 deletions(-) diff --git a/laf b/laf index 26994fe6c..968f0e4b9 160000 --- a/laf +++ b/laf @@ -1 +1 @@ -Subproject commit 26994fe6c1210e0989eaddd4b2bdc00422e1ac8a +Subproject commit 968f0e4b935c77ec3701307ec963f5e058254424 diff --git a/src/app/app.cpp b/src/app/app.cpp index 9ed3e5bae..ede32fb19 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -396,19 +396,20 @@ int App::initialize(const AppOptions& options) m_mainWindow->openWindow(); #if LAF_LINUX // TODO check why this is required and we cannot call - // updateAllDisplaysWithNewScale() on Linux/X11 + // updateAllDisplays() on Linux/X11 // Redraw the whole screen. manager->invalidate(); #else // To know the initial manager size we call to - // Manager::updateAllDisplaysWithNewScale(...) so we receive a + // Manager::updateAllDisplays(...) so we receive a // Manager::onNewDisplayConfiguration() (which will update the // bounds of the manager for first time). This is required so if // the OpenFileCommand (called when we're processing the CLI with // OpenBatchOfFiles) shows a dialog to open a sequence of files, // the dialog is centered correctly to the manager bounds. const int scale = Preferences::instance().general.screenScale(); - manager->updateAllDisplaysWithNewScale(scale); + const bool gpu = Preferences::instance().general.gpuAcceleration(); + manager->updateAllDisplays(scale, gpu); #endif } #endif // ENABLE_UI diff --git a/src/app/commands/cmd_options.cpp b/src/app/commands/cmd_options.cpp index c9ad1fcc6..58ed648ab 100644 --- a/src/app/commands/cmd_options.cpp +++ b/src/app/commands/cmd_options.cpp @@ -868,13 +868,13 @@ public: ui::set_mouse_cursor_scale(m_pref.cursor.cursorScale()); bool reset_screen = false; - int newScreenScale = base::convert_to(screenScale()->getValue()); + const int newScreenScale = base::convert_to(screenScale()->getValue()); if (newScreenScale != m_pref.general.screenScale()) { m_pref.general.screenScale(newScreenScale); reset_screen = true; } - int newUIScale = base::convert_to(uiScale()->getValue()); + const int newUIScale = base::convert_to(uiScale()->getValue()); if (newUIScale != m_pref.general.uiScale()) { m_pref.general.uiScale(newUIScale); ui::set_theme(ui::get_theme(), @@ -882,7 +882,7 @@ public: reset_screen = true; } - bool newGpuAccel = gpuAcceleration()->isSelected(); + const bool newGpuAccel = gpuAcceleration()->isSelected(); if (newGpuAccel != m_pref.general.gpuAcceleration()) { m_pref.general.gpuAcceleration(newGpuAccel); reset_screen = true; @@ -1018,8 +1018,8 @@ private: void updateScreenScaling() { ui::Manager* manager = ui::Manager::getDefault(); - os::instance()->setGpuAcceleration(m_pref.general.gpuAcceleration()); - manager->updateAllDisplaysWithNewScale(m_pref.general.screenScale()); + manager->updateAllDisplays(m_pref.general.screenScale(), + m_pref.general.gpuAcceleration()); } void onApply() { diff --git a/src/app/modules/gui.cpp b/src/app/modules/gui.cpp index 17aa033bf..cdee60d55 100644 --- a/src/app/modules/gui.cpp +++ b/src/app/modules/gui.cpp @@ -127,8 +127,6 @@ static bool create_main_window(bool gpuAccel, // executed. int scale = Preferences::instance().general.screenScale(); - os::instance()->setGpuAcceleration(gpuAccel); - try { if (!spec.frame().isEmpty() || !spec.contentRect().isEmpty()) { @@ -164,6 +162,8 @@ static bool create_main_window(bool gpuAccel, if (scale == 0) Preferences::instance().general.screenScale(main_window->scale()); + main_window->setGpuAcceleration(gpuAccel); + if (main_window->isMinimized()) main_window->maximize(); } @@ -655,7 +655,7 @@ bool CustomizedGuiManager::onProcessDevModeKeyDown(KeyMessage* msg) ui::set_theme(ui::get_theme(), uiScale); } if (screenScale != window->scale()) { - updateAllDisplaysWithNewScale(screenScale); + updateAllDisplays(screenScale, window->gpuAcceleration()); } } catch (const std::exception& ex) { diff --git a/src/app/ui/main_window.cpp b/src/app/ui/main_window.cpp index 60f4de8df..81252dec6 100644 --- a/src/app/ui/main_window.cpp +++ b/src/app/ui/main_window.cpp @@ -77,7 +77,8 @@ public: ui::set_theme(ui::get_theme(), newUIScale); Manager::getDefault() - ->updateAllDisplaysWithNewScale(newScreenScale); + ->updateAllDisplays(newScreenScale, + pref.general.gpuAcceleration()); } }; diff --git a/src/ui/manager.cpp b/src/ui/manager.cpp index 1aea164ea..636c15ba0 100644 --- a/src/ui/manager.cpp +++ b/src/ui/manager.cpp @@ -1,5 +1,5 @@ // Aseprite UI Library -// Copyright (C) 2018-2023 Igara Studio S.A. +// Copyright (C) 2018-2024 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This file is released under the terms of the MIT license. @@ -311,10 +311,11 @@ void Manager::flipAllDisplays() } } -void Manager::updateAllDisplaysWithNewScale(int scale) +void Manager::updateAllDisplays(int scale, bool gpu) { os::Window* nativeWindow = m_display.nativeWindow(); nativeWindow->setScale(scale); + nativeWindow->setGpuAcceleration(gpu); if (get_multiple_displays()) { for (auto child : children()) { @@ -322,6 +323,7 @@ void Manager::updateAllDisplaysWithNewScale(int scale) if (window->ownDisplay()) { Display* display = static_cast(child)->display(); display->nativeWindow()->setScale(scale); + display->nativeWindow()->setGpuAcceleration(gpu); onNewDisplayConfiguration(display); } } @@ -1390,6 +1392,7 @@ void Manager::_openWindow(Window* window, bool center) if (get_multiple_displays() && window->shouldCreateNativeWindow()) { const int scale = parentDisplay->nativeWindow()->scale(); + const int gpu = parentDisplay->nativeWindow()->gpuAcceleration(); os::WindowSpec spec; gfx::Rect frame; @@ -1437,6 +1440,9 @@ void Manager::_openWindow(Window* window, bool center) // Set native title bar text newNativeWindow->setTitle(window->text()); + // Same GPU acceleration flag that the parent display + newNativeWindow->setGpuAcceleration(gpu); + // Activate only non-floating windows if (!spec.floating()) newNativeWindow->activate(); diff --git a/src/ui/manager.h b/src/ui/manager.h index 022604789..18a01ee5b 100644 --- a/src/ui/manager.h +++ b/src/ui/manager.h @@ -1,5 +1,5 @@ // Aseprite UI Library -// Copyright (C) 2018-2023 Igara Studio S.A. +// Copyright (C) 2018-2024 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This file is released under the terms of the MIT license. @@ -46,7 +46,9 @@ namespace ui { // Refreshes all real displays with the UI content. void flipAllDisplays(); - void updateAllDisplaysWithNewScale(int scale); + // Updates the scale and GPU acceleration flag of all native + // windows. + void updateAllDisplays(int scale, bool gpu); // Adds the given "msg" message to the queue of messages to be // dispached. "msg" cannot be used after this function, it'll be