Fix uint16 max issue in TextLabel 75/276475/4
authorBowon Ryu <bowon.ryu@samsung.com>
Fri, 17 Jun 2022 06:16:16 +0000 (15:16 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Mon, 20 Jun 2022 00:49:36 +0000 (09:49 +0900)
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 <bowon.ryu@samsung.com>
automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp

index dab40a2..2ff4a7d 100644 (file)
@@ -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<float>(std::numeric_limits<uint16_t>::max());
+  label.SetProperty(Actor::Property::SIZE, Vector2(max_value, 30.0f));
+  application.SendNotification();
+  application.Render();
+
+
   END_TEST;
 }
 
index 97ccc81..2d2368b 100644 (file)
@@ -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))