[dali_2.1.37] Merge branch 'devel/master' 15/280315/1
authorDavid Steele <david.steele@samsung.com>
Fri, 26 Aug 2022 11:15:53 +0000 (12:15 +0100)
committerDavid Steele <david.steele@samsung.com>
Fri, 26 Aug 2022 11:15:53 +0000 (12:15 +0100)
Change-Id: I7c368cc667089291edffb6c7b3e513d8790021cd

15 files changed:
automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextLabel.cpp
dali-scene3d/public-api/loader/bvh-loader.cpp
dali-toolkit/internal/controls/canvas-view/canvas-view-impl.cpp
dali-toolkit/internal/controls/popup/popup-impl.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.cpp
dali-toolkit/internal/controls/text-controls/text-label-impl.h
dali-toolkit/internal/graphics/shaders/color-visual-shader.frag
dali-toolkit/internal/graphics/shaders/gradient-visual-shader.frag
dali-toolkit/internal/graphics/shaders/image-visual-shader.frag
dali-toolkit/internal/graphics/shaders/image-visual-shader.vert
dali-toolkit/internal/text/text-geometry.cpp
dali-toolkit/public-api/dali-toolkit-version.cpp
packaging/dali-toolkit.spec

index b95f6c7..fac21a0 100644 (file)
@@ -5124,6 +5124,44 @@ int utcDaliTextEditorGeometryOneGlyph(void)
   END_TEST;
 }
 
+int utcDaliTextEditorGeometryNullPtr(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("utcDaliTextEditorGeometryNullPtr");
+
+  TextEditor editor = TextEditor::New();
+  DALI_TEST_CHECK(editor);
+
+  application.GetScene().Add(editor);
+
+  editor.SetProperty(TextEditor::Property::POINT_SIZE, 7.f);
+  editor.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+  editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+  editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+  editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
+  editor.SetProperty(TextEditor::Property::TEXT, "");
+
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+  unsigned int expectedCount = 0;
+  unsigned int startIndex    = 0;
+  unsigned int endIndex      = 0;
+
+  Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
+  Vector<Vector2> sizeList      = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
+  DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
+
+  END_TEST;
+}
+
+
 int utcDaliTextEditorSelectionClearedSignal(void)
 {
   ToolkitTestApplication application;
index f762e8d..df1c60b 100644 (file)
@@ -513,7 +513,7 @@ int UtcDaliToolkitTextFieldCopyConstructorP(void)
 
   TextField copy(textField);
   DALI_TEST_CHECK(copy);
-  DALI_TEST_CHECK(copy.GetProperty<std::string>(TextLabel::Property::TEXT) == textField.GetProperty<std::string>(TextLabel::Property::TEXT));
+  DALI_TEST_CHECK(copy.GetProperty<std::string>(TextField::Property::TEXT) == textField.GetProperty<std::string>(TextField::Property::TEXT));
   END_TEST;
 }
 
@@ -4875,6 +4875,44 @@ int utcDaliTextFieldGeometryGlyphMiddle(void)
   END_TEST;
 }
 
+
+int utcDaliTextFieldGeometryNullPtr(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("utcDaliTextFieldGeometryNullPtr");
+
+  TextField field = TextField::New();
+  DALI_TEST_CHECK(field);
+
+  application.GetScene().Add(field);
+
+  field.SetProperty(TextField::Property::POINT_SIZE, 7.f);
+  field.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+  field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+  field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+  field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
+  field.SetProperty(TextField::Property::TEXT, "");
+
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+  unsigned int expectedCount = 0;
+  unsigned int startIndex    = 0;
+  unsigned int endIndex      = 0;
+
+  Vector<Vector2> positionsList = DevelTextField::GetTextPosition(field, startIndex, endIndex);
+  Vector<Vector2> sizeList      = DevelTextField::GetTextSize(field, startIndex, endIndex);
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
+  DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
+
+  END_TEST;
+}
+
 int utcDaliTextFieldSelectionClearedSignal(void)
 {
   ToolkitTestApplication application;
index 0ece717..23febac 100644 (file)
@@ -1508,6 +1508,45 @@ int UtcDaliToolkitTextlabelScrollingN(void)
   const bool enabled = label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>();
   DALI_TEST_CHECK(!enabled);
 
+
+  label.SetProperty(TextLabel::Property::MULTI_LINE, false);
+  label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 1);
+  label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 9999.0f);
+  label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
+
+  try
+  {
+    // Render the text.
+    application.SendNotification();
+    application.Render(1000);
+
+    application.GetScene().Remove(label);
+    application.SendNotification();
+    application.Render();
+
+    DALI_TEST_CHECK(!label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
+
+    label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
+    application.GetScene().Add(label);
+
+    application.SendNotification();
+    application.Render();
+
+    DALI_TEST_CHECK(label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
+
+    label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, (Toolkit::TextLabel::AutoScrollStopMode::Type)2); // invalid type
+    label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
+
+    application.SendNotification();
+    application.Render();
+
+    DALI_TEST_CHECK(label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
+  }
+  catch(...)
+  {
+    tet_result(TET_FAIL);
+  }
+
   END_TEST;
 }
 
@@ -2637,6 +2676,44 @@ int utcDaliTextLabelGeometryOneGlyph(void)
   END_TEST;
 }
 
+
+int utcDaliTextLabelGeometryNullPtr(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("utcDaliTextLabelGeometryNullPtr");
+
+  TextLabel label = TextLabel::New();
+  DALI_TEST_CHECK(label);
+
+  application.GetScene().Add(label);
+
+  label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
+  label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
+  label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
+  label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
+  label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
+  label.SetProperty(TextLabel::Property::TEXT, "");
+
+  // Avoid a crash when core load gl resources.
+  application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
+
+  unsigned int expectedCount = 0;
+  unsigned int startIndex    = 0;
+  unsigned int endIndex      = 0;
+
+  Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
+  Vector<Vector2> sizeList      = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
+
+  // Render and notify
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
+  DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
+
+  END_TEST;
+}
+
 int UtcDaliToolkitTextlabelEllipsisPositionProperty(void)
 {
   ToolkitTestApplication application;
index fc6815d..7d3b775 100644 (file)
@@ -317,7 +317,7 @@ AnimationDefinition GenerateAnimation(const std::string& animationName, std::sha
       rotationProperty.mKeyFrames    = Dali::KeyFrames::New();
       for(uint32_t j = 0; j < frameCount; ++j)
       {
-        translationProperty.mKeyFrames.Add(static_cast<float>(j) * keyFrameInterval, (jointList[i]->translations[j] / scale));
+        translationProperty.mKeyFrames.Add(static_cast<float>(j) * keyFrameInterval, (jointList[i]->translations[j] * scale));
         rotationProperty.mKeyFrames.Add(static_cast<float>(j) * keyFrameInterval, jointList[i]->rotations[j]);
       }
     }
index 39253d0..e298f10 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include "canvas-view-impl.h"
 
 // EXTERNAL INCLUDES
+#include <dali/devel-api/rendering/texture-devel.h>
 #include <dali/devel-api/scripting/scripting.h>
 #include <dali/integration-api/adaptor-framework/adaptor.h>
 #include <dali/public-api/object/type-registry-helper.h>
 #include <dali/public-api/object/type-registry.h>
-#include <dali/devel-api/rendering/texture-devel.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/devel-api/controls/control-devel.h>
@@ -73,7 +73,7 @@ CanvasView::~CanvasView()
 
   if(Adaptor::IsAvailable())
   {
-    Adaptor::Get().UnregisterProcessor(*this);
+    Adaptor::Get().UnregisterProcessor(*this, true);
   }
 }
 
@@ -196,7 +196,7 @@ void CanvasView::AddRasterizationTask()
 
 void CanvasView::ApplyRasterizedImage(Texture rasterizedTexture)
 {
-  if (rasterizedTexture && rasterizedTexture.GetWidth() != 0 && rasterizedTexture.GetHeight() != 0)
+  if(rasterizedTexture && rasterizedTexture.GetWidth() != 0 && rasterizedTexture.GetHeight() != 0)
   {
     if(!mTextureSet)
     {
index f7ebcf4..1606bfb 100644 (file)
@@ -343,8 +343,6 @@ void Popup::OnInitialize()
 
   SetupTouch();
 
-  DevelControl::AppendAccessibilityAttribute(Toolkit::Control::DownCast(self), "sub-role", "Alert");
-
   self.SetProperty(DevelControl::Property::ACCESSIBILITY_ROLE, Dali::Accessibility::Role::DIALOG);
 }
 
index 2d2368b..d9e413f 100644 (file)
@@ -351,6 +351,7 @@ void TextLabel::SetProperty(BaseObject* object, Property::Index index, const Pro
       case Toolkit::TextLabel::Property::ENABLE_AUTO_SCROLL:
       {
         const bool enableAutoScroll = value.Get<bool>();
+        impl.mLastAutoScrollEnabled = enableAutoScroll;
         // If request to auto scroll is the same as current state then do nothing.
         if(enableAutoScroll != impl.mController->IsAutoScrollEnabled())
         {
@@ -1008,6 +1009,32 @@ void TextLabel::OnPropertySet(Property::Index index, const Property::Value& prop
   }
 }
 
+void TextLabel::OnSceneConnection(int depth)
+{
+  if(mController->IsAutoScrollEnabled() || mLastAutoScrollEnabled)
+  {
+    mController->SetAutoScrollEnabled(true);
+  }
+  Control::OnSceneConnection(depth);
+}
+
+void TextLabel::OnSceneDisconnection()
+{
+  if(mTextScroller)
+  {
+    if(mLastAutoScrollEnabled && !mController->IsAutoScrollEnabled())
+    {
+      mLastAutoScrollEnabled = false;
+    }
+
+    const Toolkit::TextLabel::AutoScrollStopMode::Type stopMode = mTextScroller->GetStopMode();
+    mTextScroller->SetStopMode(Toolkit::TextLabel::AutoScrollStopMode::IMMEDIATE);
+    mTextScroller->StopScrolling();
+    mTextScroller->SetStopMode(stopMode);
+  }
+  Control::OnSceneDisconnection();
+}
+
 void TextLabel::OnRelayout(const Vector2& size, RelayoutContainer& container)
 {
   DALI_LOG_INFO(gLogFilter, Debug::General, "TextLabel::OnRelayout\n");
@@ -1190,7 +1217,8 @@ void TextLabel::OnAccessibilityStatusChanged()
 TextLabel::TextLabel(ControlBehaviour additionalBehavior)
 : Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT | additionalBehavior)),
   mRenderingBackend(DEFAULT_RENDERING_BACKEND),
-  mTextUpdateNeeded(false)
+  mTextUpdateNeeded(false),
+  mLastAutoScrollEnabled(false)
 {
 }
 
index f4dac1d..31167d8 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 // EXTERNAL INCLUDES
+#include <dali/devel-api/actors/actor-devel.h>
 #include <dali/devel-api/atspi-interfaces/hypertext.h>
 #include <dali/devel-api/atspi-interfaces/text.h>
 #include <dali/public-api/object/property-map.h>
@@ -165,6 +166,16 @@ private: // From Control
    */
   void OnPropertySet(Property::Index index, const Property::Value& propertyValue) override;
 
+  /**
+   * @copydoc Control::OnSceneConnection()
+   */
+  void OnSceneConnection(int depth) override;
+
+  /**
+   * @copydoc Control::OnSceneDisconnection()
+   */
+  void OnSceneDisconnection() override;
+
   // From ControlInterface
 
   /**
@@ -247,6 +258,7 @@ private: // Data
 
   int  mRenderingBackend;
   bool mTextUpdateNeeded : 1;
+  bool mLastAutoScrollEnabled : 1;
 
 protected:
   /**
index 36a4104..662121e 100644 (file)
@@ -71,7 +71,8 @@ void calculatePotential()
 
 void setupMinMaxPotential()
 {
-  gPotentialRange = 1.0;
+  // Set soft anti-alias range at most 2% of visual size
+  gPotentialRange = min(1.0, max(vRectSize.x, vRectSize.y) * 0.02);
 
   gMaxOutlinePotential = gRadius + gPotentialRange;
   gMinOutlinePotential = gRadius - gPotentialRange;
@@ -118,7 +119,7 @@ lowp vec4 convertBorderlineColor(lowp vec4 textureColor)
     borderlineOpacity = smoothstep(gMinInlinePotential, gMaxInlinePotential, potential);
 
     // Muliply borderlineWidth to resolve very thin borderline
-    borderlineOpacity *= min(1.0, borderlineWidth);
+    borderlineOpacity *= min(1.0, borderlineWidth / gPotentialRange);
   }
 
   lowp vec3  borderlineColorRGB   = borderlineColor.rgb * uActorColor.rgb;
index 1812cd3..0d24481 100644 (file)
@@ -69,7 +69,8 @@ void calculatePotential()
 
 void setupMinMaxPotential()
 {
-  gPotentialRange = 1.0;
+  // Set soft anti-alias range at most 2% of visual size
+  gPotentialRange = min(1.0, max(vRectSize.x, vRectSize.y) * 0.02);
 
   gMaxOutlinePotential = gRadius + gPotentialRange;
   gMinOutlinePotential = gRadius - gPotentialRange;
@@ -113,7 +114,7 @@ lowp vec4 convertBorderlineColor(lowp vec4 textureColor)
     borderlineOpacity = smoothstep(gMinInlinePotential, gMaxInlinePotential, potential);
 
     // Muliply borderlineWidth to resolve very thin borderline
-    borderlineOpacity *= min(1.0, borderlineWidth);
+    borderlineOpacity *= min(1.0, borderlineWidth / gPotentialRange);
   }
 
   lowp vec3  borderlineColorRGB   = borderlineColor.rgb * uActorColor.rgb;
index a0f39d9..cb5e765 100644 (file)
@@ -99,7 +99,8 @@ void calculatePotential()
 
 void setupMinMaxPotential()
 {
-  gPotentialRange = 1.0;
+  // Set soft anti-alias range at most 2% of visual size
+  gPotentialRange = min(1.0, max(vRectSize.x, vRectSize.y) * 0.02);
 
   gMaxOutlinePotential = gRadius + gPotentialRange;
   gMinOutlinePotential = gRadius - gPotentialRange;
@@ -142,7 +143,7 @@ lowp vec4 convertBorderlineColor(lowp vec4 textureColor)
     borderlineOpacity = smoothstep(gMinInlinePotential, gMaxInlinePotential, potential);
 
     // Muliply borderlineWidth to resolve very thin borderline
-    borderlineOpacity *= min(1.0, borderlineWidth);
+    borderlineOpacity *= min(1.0, borderlineWidth / gPotentialRange);
   }
 
   lowp vec3  borderlineColorRGB   = borderlineColor.rgb * uActorColor.rgb;
index 7443aa1..ceedb74 100644 (file)
@@ -44,9 +44,14 @@ vec4 ComputeVertexPosition()
   vOptRectSize = vRectSize;
 #endif
 
+#ifdef IS_REQUIRED_BORDERLINE
+  // Extend size of visual by borderline.
+  mediump float outerBorderlineSize = (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth;
+#endif
+
 #ifdef IS_REQUIRED_ROUNDED_CORNER
 #ifdef IS_REQUIRED_BORDERLINE
-  mediump float minSize = min(visualSize.x, visualSize.y) + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth;
+  mediump float minSize = min(visualSize.x, visualSize.y) + outerBorderlineSize;
 #else
   mediump float minSize = min(visualSize.x, visualSize.y);
 #endif
@@ -58,8 +63,8 @@ vec4 ComputeVertexPosition()
 #endif
 
 #ifdef IS_REQUIRED_BORDERLINE
-  vPosition = aPosition * (visualSize + (1.0 + clamp(borderlineOffset, -1.0, 1.0)) * borderlineWidth);
-  vOptRectSize -= (1.0 - clamp(borderlineOffset, -1.0, 1.0)) * 0.5 * borderlineWidth + 1.0;
+  vPosition = aPosition * (visualSize + outerBorderlineSize);
+  vOptRectSize -= (borderlineWidth - outerBorderlineSize * 0.5) + 1.0;
 #elif defined(IS_REQUIRED_ROUNDED_CORNER)
   vPosition = aPosition * visualSize;
 #else
@@ -74,9 +79,17 @@ vec4 ComputeVertexPosition()
                             pixelArea.zw * maskTextureRatio
                        ),
                        cropToMask);
-  vMaskTexCoord = pixelArea.xy + pixelArea.zw * (vPosition.xy / max(vec2(1.0), visualSize) + vec2(0.5));
+  vMaskTexCoord = pixelArea.xy + pixelArea.zw * (vec2(0.5) + aPosition.xy
+#ifdef IS_REQUIRED_BORDERLINE
+                                                  * (1.0 +  outerBorderlineSize / visualSize)
+#endif
+                                                );
+#endif
+  vTexCoord = finalPixelArea.xy + finalPixelArea.zw * (vec2(0.5) + aPosition.xy
+#ifdef IS_REQUIRED_BORDERLINE
+                                                        * (1.0 + outerBorderlineSize / visualSize)
 #endif
-  vTexCoord = finalPixelArea.xy + finalPixelArea.zw * (vPosition.xy / max(vec2(1.0), visualSize) + vec2(0.5));
+                                                      );
 
   return vec4(vPosition + anchorPoint * visualSize + visualOffset + origin * uSize.xy, 0.0, 1.0);
 }
index 6c90665..6f173cb 100644 (file)
@@ -68,14 +68,29 @@ void GetTextGeometry(ModelPtr textModel, CharacterIndex startIndex, CharacterInd
   const CharacterIndex* const     glyphToCharacterBuffer         = visualModel->mGlyphsToCharacters.Begin();
   const CharacterDirection* const modelCharacterDirectionsBuffer = (0u != logicalModel->mCharacterDirections.Count()) ? logicalModel->mCharacterDirections.Begin() : NULL;
 
+  //Clear the lists
+  sizesList.Clear();
+  positionsList.Clear();
+
+  if(charactersToGlyphBuffer == nullptr || glyphsPerCharacterBuffer  == nullptr || charactersPerGlyphBuffer  == nullptr || glyphToCharacterBuffer == nullptr )
+  {
+    return;
+  }
+
   if(startIndex >= logicalModel->mText.Count() && endIndex >= logicalModel->mText.Count())
+  {
     return;
+  }
 
   if(startIndex >= logicalModel->mText.Count())
+  {
     startIndex = logicalModel->mText.Count() - 1;
+  }
 
   if(endIndex >= logicalModel->mText.Count())
+  {
     endIndex = logicalModel->mText.Count() - 1;
+  }
 
   if(startIndex > endIndex)
   {
index 5e08bba..a3bdd3c 100644 (file)
@@ -29,7 +29,7 @@ namespace Toolkit
 {
 const unsigned int TOOLKIT_MAJOR_VERSION = 2;
 const unsigned int TOOLKIT_MINOR_VERSION = 1;
-const unsigned int TOOLKIT_MICRO_VERSION = 36;
+const unsigned int TOOLKIT_MICRO_VERSION = 37;
 const char* const  TOOLKIT_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index 064a36e..93d710d 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali2-toolkit
 Summary:    Dali 3D engine Toolkit
-Version:    2.1.36
+Version:    2.1.37
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0 and BSD-3-Clause and MIT