From a3c2f831c81d1189538ca45eb8354803a2f4448f Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sat, 16 Jan 2021 20:53:09 +0100 Subject: [PATCH] Clamped the scale factor in NinePatchComponent to avoid artifacts for extreme screen resolutions. --- es-core/src/components/NinePatchComponent.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/es-core/src/components/NinePatchComponent.cpp b/es-core/src/components/NinePatchComponent.cpp index aafff8078..e26d0e1ad 100644 --- a/es-core/src/components/NinePatchComponent.cpp +++ b/es-core/src/components/NinePatchComponent.cpp @@ -51,8 +51,11 @@ void NinePatchComponent::buildVertices() if (mVertices != nullptr) delete[] mVertices; - // Scale the corner size relative to the screen resolution. - mTexture = TextureResource::get(mPath, false, false, true, Renderer::getScreenWidthModifier()); + // Scale the corner size relative to the screen resolution, but keep the scale factor + // within reason as extreme resolutions may cause artifacts. Any "normal" resolution + // (e.g. from 720p to 4K) will be within these boundaries though. + float scaleFactor = Math::clamp(Renderer::getScreenWidthModifier(), 0.4f, 3.0f); + mTexture = TextureResource::get(mPath, false, false, true, scaleFactor); if (mTexture->getSize() == Vector2i::Zero()) { mVertices = nullptr;