From 66b6b6963d8f8516956550e73f042e686dcec06b Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Fri, 17 Jun 2022 15:16:16 +0900 Subject: [PATCH] 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 --- automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp | 7 +++++++ dali-toolkit/internal/controls/text-controls/text-label-impl.cpp | 7 +++++++ 2 files changed, 14 insertions(+) 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)) -- 2.7.4