From 521631decfa085e9a5acfbdf4b657d3ade8b6a8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sat, 25 Oct 2025 02:52:21 -0300 Subject: [PATCH] Fix ARGB images save when using WebP. Upload artifacts. --- .ecode/project_build.json | 6 +++++ .github/workflows/eepp-linux-build-check.yml | 17 +++++++++++++ .github/workflows/eepp-macos-build-check.yml | 17 +++++++++++++ .../workflows/eepp-windows-build-check.yml | 18 ++++++++++++++ .gitignore | 1 + include/eepp/window/window.hpp | 24 +++++++++++-------- premake4.lua | 2 +- projects/macos/make.sh | 7 ------ projects/macos/make_no_fw.sh | 7 ------ src/eepp/graphics/image.cpp | 2 +- src/eepp/window/backend/SDL2/windowsdl2.cpp | 3 ++- src/tests/unit_tests/fontrendering.cpp | 21 +++++++++------- 12 files changed, 90 insertions(+), 35 deletions(-) diff --git a/.ecode/project_build.json b/.ecode/project_build.json index fb6c399d1..71d8165c1 100644 --- a/.ecode/project_build.json +++ b/.ecode/project_build.json @@ -538,6 +538,12 @@ "command": "${project_root}/bin/ecode", "name": "ecode-release", "working_dir": "${project_root}/bin/" + }, + { + "args": "", + "command": "${project_root}/bin/unit_tests/eepp-unit_tests-debug", + "name": "eepp-unit_test-debug", + "working_dir": "${project_root}/bin/" } ], "var": { diff --git a/.github/workflows/eepp-linux-build-check.yml b/.github/workflows/eepp-linux-build-check.yml index 87a0ac5fe..d5a39b9e5 100644 --- a/.github/workflows/eepp-linux-build-check.yml +++ b/.github/workflows/eepp-linux-build-check.yml @@ -39,3 +39,20 @@ jobs: run: | cd bin/unit_tests xvfb-run ./eepp-unit_tests + - name: Upload test artifacts if folder exists + if: always() + run: | + if [ -d bin/unit_tests/output ]; then + echo "Artifact folder exists (bin/unit_tests/output), uploading..." + exit 0 + else + echo "No artifact folder (bin/unit_tests/output), tests passed, skipping upload." + exit 0 + fi + id: upload-check + - name: Upload artifacts + if: always() && steps.upload-check.outputs.result == '0' && exists('bin/unit_tests/output') + uses: actions/upload-artifact@v4 + with: + name: linux-test-output + path: bin/unit_tests/output/* diff --git a/.github/workflows/eepp-macos-build-check.yml b/.github/workflows/eepp-macos-build-check.yml index 1a13ce35c..2f193950e 100644 --- a/.github/workflows/eepp-macos-build-check.yml +++ b/.github/workflows/eepp-macos-build-check.yml @@ -25,3 +25,20 @@ jobs: run: | cd bin/unit_tests ./eepp-unit_tests + - name: Upload test artifacts if folder exists + if: always() + run: | + if [ -d bin/unit_tests/output ]; then + echo "Artifact folder exists, uploading..." + exit 0 + else + echo "No artifact folder (bin/unit_tests/output), tests passed, skipping upload." + exit 0 + fi + id: upload-check + - name: Upload artifacts + if: always() && steps.upload-check.outputs.result == '0' && exists('bin/unit_tests/output') + uses: actions/upload-artifact@v4 + with: + name: macos-test-output + path: bin/unit_tests/output/* diff --git a/.github/workflows/eepp-windows-build-check.yml b/.github/workflows/eepp-windows-build-check.yml index 02b8491ff..91beaeeff 100644 --- a/.github/workflows/eepp-windows-build-check.yml +++ b/.github/workflows/eepp-windows-build-check.yml @@ -51,3 +51,21 @@ jobs: set LIBGL_ALWAYS_SOFTWARE=1 set GALLIUM_DRIVER=llvmpipe bin\unit_tests\eepp-unit_tests.exe + - name: Upload test artifacts if folder exists + if: always() + shell: cmd + run: | + if exist bin\unit_tests\output ( + echo Artifact folder exists, uploading... + exit 0 + ) else ( + echo No artifact folder (bin\unit_tests\output), tests passed, skipping upload. + exit 0 + ) + id: upload-check + - name: Upload artifacts + if: always() && steps.upload-check.outputs.result == '0' && exists('bin/unit_tests/output') + uses: actions/upload-artifact@v4 + with: + name: windows-test-output + path: bin\unit_tests\output\* diff --git a/.gitignore b/.gitignore index 0c0557754..2935b5222 100644 --- a/.gitignore +++ b/.gitignore @@ -69,6 +69,7 @@ ecode.dmg /compile_commands.json /bin/unit_tests/eepp* /bin/unit_tests/lib* +/bin/unit_tests/output/* /projects/linux/ecode/polyfill-glibc /bin/crashes/* /bin/config/* diff --git a/include/eepp/window/window.hpp b/include/eepp/window/window.hpp index 7501f3a2f..62b07c418 100644 --- a/include/eepp/window/window.hpp +++ b/include/eepp/window/window.hpp @@ -49,7 +49,8 @@ class WindowSettings { Uint32 style = WindowStyle::Default, WindowBackend backend = WindowBackend::Default, Uint32 bpp = 32, const std::string& icon = std::string(), const Float& pixelDensity = 1, - const bool& useScreenKeyboard = EE_SCREEN_KEYBOARD_ENABLED ) : + const bool& useScreenKeyboard = EE_SCREEN_KEYBOARD_ENABLED, + bool disableHiDPI = false ) : Style( style ), Width( width ), Height( height ), @@ -58,7 +59,8 @@ class WindowSettings { Title( title ), Backend( backend ), PixelDensity( pixelDensity ), - UseScreenKeyboard( useScreenKeyboard ) {} + UseScreenKeyboard( useScreenKeyboard ), + DisableHiDPI( disableHiDPI ) {} inline WindowSettings() : Style( WindowStyle::Default ), @@ -67,17 +69,19 @@ class WindowSettings { BitsPerPixel( 32 ), Backend( WindowBackend::Default ), PixelDensity( 1 ), - UseScreenKeyboard( EE_SCREEN_KEYBOARD_ENABLED ) {} + UseScreenKeyboard( EE_SCREEN_KEYBOARD_ENABLED ), + DisableHiDPI( false ) {} - Uint32 Style; - Uint32 Width; //! In screen coordinates (pixels * scale) - Uint32 Height; //! In screen coordinates (pixels * scale) - Uint32 BitsPerPixel; + Uint32 Style{ WindowStyle::Default }; + Uint32 Width{ 800 }; //! In screen coordinates (pixels * scale) + Uint32 Height{ 600 }; //! In screen coordinates (pixels * scale) + Uint32 BitsPerPixel{ 32 }; std::string Icon; std::string Title; - WindowBackend Backend; - Float PixelDensity; - bool UseScreenKeyboard; + WindowBackend Backend{ WindowBackend::Default }; + Float PixelDensity{ 1 }; + bool UseScreenKeyboard{ EE_SCREEN_KEYBOARD_ENABLED }; + bool DisableHiDPI{ false }; }; /** @brief ContextSettings Small class that contains the renderer context information */ diff --git a/premake4.lua b/premake4.lua index 3b3f82906..59b27806b 100644 --- a/premake4.lua +++ b/premake4.lua @@ -1471,7 +1471,7 @@ solution "eepp" set_targetdir("libs/" .. os.get_real() .. "/") build_eepp( "eepp" ) postsymlinklib("../libs/" .. os.get_real() .. "/", "../../bin/", "eepp" ) - postsymlinklib("../libs/" .. os.get_real() .. "/", "../../bin/unit_tests/", "eepp" ) + postsymlinklib("../../libs/" .. os.get_real() .. "/", "../../bin/unit_tests/", "eepp" ) -- Examples project "eepp-external-shader" diff --git a/projects/macos/make.sh b/projects/macos/make.sh index db5bf9502..a438da43b 100755 --- a/projects/macos/make.sh +++ b/projects/macos/make.sh @@ -17,10 +17,3 @@ fi cd ../../make/macosx/ make -j$(sysctl -n hw.ncpu) $@ - -cd ../../bin/ -ln -sf ../libs/macosx/"$USE_ARCH"libeepp.dylib . -ln -sf ../libs/macosx/"$USE_ARCH"libeepp-debug.dylib . -if [ -f ../libs/macosx/"$USE_ARCH"libeepp-maps-debug.dylib ]; then -ln -sf ../libs/macosx/"$USE_ARCH"libeepp-maps-debug.dylib . -fi diff --git a/projects/macos/make_no_fw.sh b/projects/macos/make_no_fw.sh index 7aaadd1f5..39aa5bf80 100755 --- a/projects/macos/make_no_fw.sh +++ b/projects/macos/make_no_fw.sh @@ -17,10 +17,3 @@ fi cd ../../make/macosx/ make -j$(sysctl -n hw.ncpu) $@ - -cd ../../bin/ -ln -sf ../libs/macosx/"$USE_ARCH"libeepp.dylib . -ln -sf ../libs/macosx/"$USE_ARCH"libeepp-debug.dylib . -if [ -f ../libs/macosx/"$USE_ARCH"libeepp-maps-debug.dylib ]; then -ln -sf ../libs/macosx/"$USE_ARCH"libeepp-maps-debug.dylib . -fi diff --git a/src/eepp/graphics/image.cpp b/src/eepp/graphics/image.cpp index c32548f63..63ee8de58 100644 --- a/src/eepp/graphics/image.cpp +++ b/src/eepp/graphics/image.cpp @@ -982,7 +982,7 @@ std::vector webpPacker( const Image& img, Uint32 quality, Uint32 compress if ( img.getChannels() == 3 ) { successImport = WebPPictureImportRGB( &pic, r, 3 * s.getWidth() ); } else { - successImport = WebPPictureImportRGBA( &pic, r, 4 * s.getHeight() ); + successImport = WebPPictureImportRGBA( &pic, r, 4 * s.getWidth() ); } bool successEncode = false; diff --git a/src/eepp/window/backend/SDL2/windowsdl2.cpp b/src/eepp/window/backend/SDL2/windowsdl2.cpp index 9f4c36669..cc65132f4 100644 --- a/src/eepp/window/backend/SDL2/windowsdl2.cpp +++ b/src/eepp/window/backend/SDL2/windowsdl2.cpp @@ -289,7 +289,8 @@ bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) { mWindow.WindowConfig.Height = mWindow.DesktopResolution.getHeight(); } - mWindow.Flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI; + mWindow.Flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | + ( ( !mWindow.WindowConfig.DisableHiDPI ? SDL_WINDOW_ALLOW_HIGHDPI : 0 ) ); if ( mWindow.WindowConfig.Style & WindowStyle::Resize ) { mWindow.Flags |= SDL_WINDOW_RESIZABLE; diff --git a/src/tests/unit_tests/fontrendering.cpp b/src/tests/unit_tests/fontrendering.cpp index 0cd627f53..bc187b352 100644 --- a/src/tests/unit_tests/fontrendering.cpp +++ b/src/tests/unit_tests/fontrendering.cpp @@ -7,7 +7,9 @@ using namespace EE::System; UTEST( FontRendering, fontsTest ) { FileSystem::changeWorkingDirectory( Sys::getProcessPath() ); - auto win = Engine::instance()->createWindow( WindowSettings( 1220, 850, "eepp - Fonts" ) ); + auto win = Engine::instance()->createWindow( + WindowSettings( 1220, 850, "eepp - Fonts", WindowStyle::Default, WindowBackend::Default, 32, + {}, 1, false, true ) ); if ( !win->isOpen() ) { std::cout << "OpenGL context not available, skipping" << std::endl; @@ -104,7 +106,7 @@ UTEST( FontRendering, fontsTest ) { text3.draw( std::floor( ( win->getWidth() - text3.getTextWidth() ) * 0.5f ), 560 ); text4.draw( std::floor( ( win->getWidth() - text4.getTextWidth() ) * 0.5f ), 590 ); text5.draw( std::floor( ( win->getWidth() - text5.getTextWidth() ) * 0.5f ), 640 ); - text6.draw( std::floor( ( win->getWidth() - text6.getTextWidth() ) * 0.5f ), 690 ); + text6.draw( 19 + std::floor( ( win->getWidth() - text6.getTextWidth() ) * 0.5f ), 690 ); { Image::FormatConfiguration fconf; @@ -124,6 +126,9 @@ UTEST( FontRendering, fontsTest ) { Image::DiffResult result = actualImage.diff( expectedImage ); + EXPECT_EQ_MSG( expectedImage.getWidth(), actualImage.getWidth(), "Images width not equal" ); + EXPECT_EQ_MSG( expectedImage.getHeight(), actualImage.getHeight(), + "Images height not equal" ); EXPECT_TRUE( result.areSame() ); if ( !result.areSame() ) { @@ -131,16 +136,16 @@ UTEST( FontRendering, fontsTest ) { << std::endl; std::cerr << "Maximum perceptual difference (Delta E): " << result.maxDeltaE << std::endl; + if ( !FileSystem::fileExists( "output" ) ) + FileSystem::makeDir( "output" ); + std::string actualImagePath = "output/eepp-fonts_actual_output." + saveExt; + actualImage.saveToFile( actualImagePath, saveType ); + std::cerr << "Actual image saved to: " << actualImagePath << std::endl; if ( result.diffImage ) { - std::string actualImagePath = - Sys::getTempPath() + "eepp-fonts_actual_output." + saveExt; - std::string diffImagePath = - Sys::getTempPath() + "eepp-fonts_diff_output." + saveExt; + std::string diffImagePath = "output/eepp-fonts_diff_output." + saveExt; result.diffImage->setImageFormatConfiguration( fconf ); result.diffImage->saveToFile( diffImagePath, saveType ); - actualImage.saveToFile( actualImagePath, saveType ); std::cerr << "Visual diff saved to: " << diffImagePath << std::endl; - std::cerr << "Actual image saved to: " << actualImagePath << std::endl; } } }