From 6925726e62dc1b0ac903d60136d1399d4b147f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jhonny=20G=C3=B6ransson?= Date: Wed, 20 Nov 2024 16:07:47 +0100 Subject: [PATCH] Use only engine display scale (#133) --- defold-rive/src/comp_rive.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/defold-rive/src/comp_rive.cpp b/defold-rive/src/comp_rive.cpp index 62b3156..31f8fdc 100644 --- a/defold-rive/src/comp_rive.cpp +++ b/defold-rive/src/comp_rive.cpp @@ -548,11 +548,11 @@ namespace dmRive if (rive_fit == rive::Fit::layout) { - c->m_ArtboardInstance->width(width); - c->m_ArtboardInstance->height(height); + c->m_ArtboardInstance->width(width / g_DisplayFactor); + c->m_ArtboardInstance->height(height / g_DisplayFactor); } - rive::Mat2D rendererTransform = rive::computeAlignment(rive_fit, rive_align, rive::AABB(0, 0, width, height), bounds); + rive::Mat2D rendererTransform = rive::computeAlignment(rive_fit, rive_align, rive::AABB(0, 0, width, height), bounds, g_DisplayFactor); renderer->transform(rendererTransform); c->m_InverseRendererTransform = rendererTransform.invertOrIdentity(); } @@ -1359,13 +1359,9 @@ namespace dmRive rivectx->m_RenderContext = *(dmRender::HRenderContext*)ctx->m_Contexts.Get(dmHashString64("render")); rivectx->m_MaxInstanceCount = dmConfigFile::GetInt(ctx->m_Config, "rive.max_instance_count", 128); - g_OriginalWindowWidth = dmGraphics::GetWidth(rivectx->m_GraphicsContext); + g_OriginalWindowWidth = dmGraphics::GetWidth(rivectx->m_GraphicsContext); g_OriginalWindowHeight = dmGraphics::GetHeight(rivectx->m_GraphicsContext); - - float scale_factor_width = (float) dmGraphics::GetWindowWidth(rivectx->m_GraphicsContext) / g_OriginalWindowWidth; - float scale_factor_height = (float) dmGraphics::GetWindowHeight(rivectx->m_GraphicsContext) / g_OriginalWindowHeight; - float scale_factor_engine = dmGraphics::GetDisplayScaleFactor(rivectx->m_GraphicsContext); - g_DisplayFactor = dmMath::Max(scale_factor_engine, dmMath::Max(scale_factor_width, scale_factor_height)); + g_DisplayFactor = dmGraphics::GetDisplayScaleFactor(rivectx->m_GraphicsContext); dmLogInfo("Display Factor: %g", g_DisplayFactor);