Fix in background sizing when using pixel-density != 1. Updated new background tests due to the windowing size issues in the macOS CI.

This commit is contained in:
Martín Lucas Golini
2026-05-09 00:30:33 -03:00
parent e94550a049
commit 0c3df503b4
4 changed files with 11 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

@@ -710,6 +710,15 @@ Sizef UINodeDrawable::LayerDrawable::calcDrawableSize( const std::string& drawab
size = mSize;
} else {
size = mDrawable->getPixelsSize();
// For Html mode, mOffset (from calcPosition) is in CSSphysical pixels
// (scaled by PixelDensity via convertLength -> dpToPx), but
// getPixelsSize() returns raw image pixels. Scale the intrinsic
// size so both values use the same coordinate system, otherwise
// the visible spriteatlas region drifts when PixelDensity != 1.
if ( mContainer->getBackgroundMode() == BackgroundMode::Html ) {
size = Sizef( size.x * PixelDensity::getPixelDensity(),
size.y * PixelDensity::getPixelDensity() );
}
}
} else if ( drawableSizeEq == "expand" ) {
size = mSize;

View File

@@ -1320,7 +1320,7 @@ UTEST( UIHTML, ContactFormLayout ) {
UTEST( UIBackground, imageAtlasPositioning ) {
auto win = Engine::instance()->createWindow(
WindowSettings( 960, 256, "Background Atlas Test", WindowStyle::Default,
WindowSettings( 1024, 653, "Background Atlas Test", WindowStyle::Default,
WindowBackend::Default, 32, {}, 1, false, true ),
ContextSettings( false, 0, 0, GLv_default, true, false ) );
FileSystem::changeWorkingDirectory( Sys::getProcessPath() );
@@ -1365,7 +1365,7 @@ UTEST( UIBackground, imageAtlasPositioning ) {
UTEST( UIBackground, imageAtlasPositioningPixelDensity2 ) {
auto win = Engine::instance()->createWindow(
WindowSettings( 960, 256, "Background Atlas Test PD2", WindowStyle::Default,
WindowSettings( 1024, 653, "Background Atlas Test PD2", WindowStyle::Default,
WindowBackend::Default, 32, {}, 1, false, true ),
ContextSettings( false, 0, 0, GLv_default, true, false ) );
EE::Graphics::PixelDensity::setPixelDensity( 2.0f );