From: Bowon Ryu Date: Fri, 17 Jun 2022 06:16:16 +0000 (+0900) Subject: Fix uint16 max issue in TextLabel X-Git-Tag: dali_2.1.28~2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F75%2F276475%2F4;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git Fix uint16 max issue in TextLabel If the size of TextLabel is bigger than uint16 max value, there is a problem that assert occurs in Texture::New. We can avoid the assert by setting the VisualTransform size to uint16 max, but this also doesn't guaranteed rendering behavior. To guaranteed the behavior, VisualTransform size is limitted to maxTextureSize. Change-Id: I68523c89aecc71a9158e59948bca037d5c73c95a Signed-off-by: Bowon Ryu --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp index dab40a2..2ff4a7d 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp @@ -2087,6 +2087,13 @@ int UtcDaliToolkitTextlabelMaxTextureSet(void) // Check if the number of renderers is greater than 1. DALI_TEST_CHECK(label.GetRendererCount() > 1u); + // Coverage test for case of layoutSize is bigger than maxTextureSize + float max_value = static_cast(std::numeric_limits::max()); + label.SetProperty(Actor::Property::SIZE, Vector2(max_value, 30.0f)); + application.SendNotification(); + application.Render(); + + END_TEST; } diff --git a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp index 97ccc81..2d2368b 100644 --- a/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-label-impl.cpp @@ -1062,6 +1062,13 @@ void TextLabel::OnRelayout(const Vector2& size, RelayoutContainer& container) alignmentOffset.x = 0.0f; alignmentOffset.y = (contentSize.y - layoutSize.y) * VERTICAL_ALIGNMENT_TABLE[mController->GetVerticalAlignment()]; + const int maxTextureSize = Dali::GetMaxTextureSize(); + if(layoutSize.width > maxTextureSize) + { + DALI_LOG_WARNING("layoutSize(%f) > maxTextureSize(%d): To guarantee the behavior of Texture::New, layoutSize must not be bigger than maxTextureSize\n", layoutSize.width, maxTextureSize); + layoutSize.width = maxTextureSize; + } + Property::Map visualTransform; visualTransform.Add(Toolkit::Visual::Transform::Property::SIZE, layoutSize) .Add(Toolkit::Visual::Transform::Property::SIZE_POLICY, Vector2(Toolkit::Visual::Transform::Policy::ABSOLUTE, Toolkit::Visual::Transform::Policy::ABSOLUTE))