[dali_2.0.40] Merge branch 'devel/master' 49/262849/1
authorDavid Steele <david.steele@samsung.com>
Fri, 20 Aug 2021 11:19:15 +0000 (12:19 +0100)
committerDavid Steele <david.steele@samsung.com>
Fri, 20 Aug 2021 11:19:15 +0000 (12:19 +0100)
Change-Id: I298b622cba2a1c91c11fddf74b664d495c0cdb1b

12 files changed:
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-canvas-renderer.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
dali-toolkit/devel-api/focus-manager/focus-finder.cpp
dali-toolkit/internal/text/text-controller-impl.cpp
dali-toolkit/internal/text/text-controller-impl.h
dali-toolkit/internal/text/text-controller-placeholder-handler.cpp
dali-toolkit/internal/text/text-controller-placeholder-handler.h
dali-toolkit/internal/visuals/image/image-visual.cpp
dali-toolkit/internal/visuals/texture-manager-impl.cpp
dali-toolkit/internal/visuals/visual-url.cpp
dali-toolkit/public-api/dali-toolkit-version.cpp
packaging/dali-toolkit.spec

index f280f6f..56c0cd8 100644 (file)
@@ -103,7 +103,7 @@ public:
   }
 
 
-  bool SetSize(const Vector2& size)
+  bool SetSize(Vector2 size)
   {
     mSize = size;
     // For negative test
@@ -114,10 +114,9 @@ public:
     return true;
   }
 
-  const Vector2& GetSize()
+  Vector2 GetSize() const
   {
-    mSize = Vector2(200, 200);
-    return mSize;
+    return Vector2(200, 200);
   }
 
   bool SetViewBox(const Vector2& viewBox)
@@ -221,12 +220,12 @@ bool CanvasRenderer::RemoveAllDrawables()
   return Internal::Adaptor::GetImplementation(*this).RemoveAllDrawables();
 }
 
-bool CanvasRenderer::SetSize(const Vector2& size)
+bool CanvasRenderer::SetSize(Vector2 size)
 {
   return Internal::Adaptor::GetImplementation(*this).SetSize(size);
 }
 
-const Vector2& CanvasRenderer::GetSize()
+Vector2 CanvasRenderer::GetSize() const
 {
   return Internal::Adaptor::GetImplementation(*this).GetSize();
 }
index d89428a..d00dc75 100644 (file)
@@ -3221,6 +3221,70 @@ int UtcDaliTextFieldSettingPlaceholder(void)
   END_TEST;
 }
 
+int UtcDaliTextFieldPlaceholderCoverage(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
+
+  // mPlaceholderFont is created only once, so create a new control for coverage.
+  TextField fieldForCoverage = TextField::New();
+  DALI_TEST_CHECK(fieldForCoverage);
+  application.GetScene().Add(fieldForCoverage);
+
+  // for SetPlaceholderFontFamily() coverage.
+  Property::Map fontFamilyMap;
+  fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
+  fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
+
+  // mPlaceholderFont is created only once, so create a new control for coverage.
+  fieldForCoverage = TextField::New();
+  DALI_TEST_CHECK(fieldForCoverage);
+  application.GetScene().Add(fieldForCoverage);
+
+  // for SetPlaceholderTextFontSize coverage.
+  Property::Map fontSizeMap;
+  fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
+  fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
+
+  // mPlaceholderFont is created only once, so create a new control for coverage.
+  fieldForCoverage = TextField::New();
+  DALI_TEST_CHECK(fieldForCoverage);
+  application.GetScene().Add(fieldForCoverage);
+
+  // for SetPlaceholderTextFontWeight coverage.
+  Property::Map fontStyleWeightMap;
+  Property::Map fontStyleWeightPropertyMap;
+  fontStyleWeightPropertyMap.Insert("weight", "bold");
+  fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
+  fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
+
+  // mPlaceholderFont is created only once, so create a new control for coverage.
+  fieldForCoverage = TextField::New();
+  DALI_TEST_CHECK(fieldForCoverage);
+  application.GetScene().Add(fieldForCoverage);
+
+  // for SetPlaceholderTextFontWidth coverage.
+  Property::Map fontStyleWidthMap;
+  Property::Map fontStyleWidthPropertyMap;
+  fontStyleWidthPropertyMap.Insert("width", "expanded");
+  fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
+  fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
+
+  // mPlaceholderFont is created only once, so create a new control for coverage.
+  fieldForCoverage = TextField::New();
+  DALI_TEST_CHECK(fieldForCoverage);
+  application.GetScene().Add(fieldForCoverage);
+
+  // for SetPlaceholderTextFontSlant coverage.
+  Property::Map fontStyleSlantMap;
+  Property::Map fontStyleSlantPropertyMap;
+  fontStyleSlantPropertyMap.Insert("slant", "italic");
+  fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
+  fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
+
+  END_TEST;
+}
+
 int UtcDaliTextFieldSetPaddingProperty(void)
 {
   ToolkitTestApplication application;
index a7324b8..2679dda 100644 (file)
@@ -188,19 +188,19 @@ static bool IsCandidate(Dali::Rect<float> srcRect, Dali::Rect<float> destRect, D
   {\r
     case Dali::Toolkit::Control::KeyboardFocus::LEFT:\r
     {\r
-      return (srcRect.right > destRect.right || srcRect.left >= destRect.right);\r
+      return (srcRect.right > destRect.right || srcRect.left >= destRect.right) && srcRect.left > destRect.left;\r
     }\r
     case Dali::Toolkit::Control::KeyboardFocus::RIGHT:\r
     {\r
-      return (srcRect.left < destRect.left || srcRect.right <= destRect.left);\r
+      return (srcRect.left < destRect.left || srcRect.right <= destRect.left) && srcRect.right < destRect.right;\r
     }\r
     case Dali::Toolkit::Control::KeyboardFocus::UP:\r
     {\r
-      return (srcRect.bottom > destRect.bottom || srcRect.top >= destRect.bottom);\r
+      return (srcRect.bottom > destRect.bottom || srcRect.top >= destRect.bottom) && srcRect.top > destRect.top;\r
     }\r
     case Dali::Toolkit::Control::KeyboardFocus::DOWN:\r
     {\r
-      return (srcRect.top < destRect.top || srcRect.bottom <= destRect.top);\r
+      return (srcRect.top < destRect.top || srcRect.bottom <= destRect.top) && srcRect.bottom < destRect.bottom;\r
     }\r
     default:\r
     {\r
@@ -344,14 +344,13 @@ bool IsFocusable(Actor& actor)
 {\r
   return (actor.GetProperty<bool>(Actor::Property::KEYBOARD_FOCUSABLE) &&\r
           actor.GetProperty<bool>(Actor::Property::VISIBLE) &&\r
-          actor.GetProperty<bool>(Actor::Property::SENSITIVE) &&\r
           actor.GetProperty<Vector4>(Actor::Property::WORLD_COLOR).a > FULLY_TRANSPARENT);\r
 }\r
 \r
 Actor FindNextFocus(Actor& actor, Actor& focusedActor, Rect<float>& focusedRect, Rect<float>& bestCandidateRect, Toolkit::Control::KeyboardFocus::Direction direction)\r
 {\r
   Actor nearestActor;\r
-  if(actor)\r
+  if(actor && actor.GetProperty<bool>(Actor::Property::VISIBLE))\r
   {\r
     // Recursively children\r
     const auto childCount = actor.GetChildCount();\r
index c31fc93..3fe3322 100644 (file)
@@ -85,7 +85,7 @@ namespace Text
 EventData::EventData(DecoratorPtr decorator, InputMethodContext& inputMethodContext)
 : mDecorator(decorator),
   mInputMethodContext(inputMethodContext),
-  mPlaceholderFont(NULL),
+  mPlaceholderFont(nullptr),
   mPlaceholderTextActive(),
   mPlaceholderTextInactive(),
   mPlaceholderTextColor(0.8f, 0.8f, 0.8f, 0.8f), // This color has been published in the Public API (placeholder-properties.h).
index 84d6193..02fbff8 100644 (file)
@@ -116,12 +116,12 @@ struct EventData
     return (stateToCheck == EDITING || stateToCheck == EDITING_WITH_POPUP || stateToCheck == EDITING_WITH_GRAB_HANDLE || stateToCheck == EDITING_WITH_PASTE_POPUP);
   }
 
-  DecoratorPtr       mDecorator;               ///< Pointer to the decorator.
-  InputMethodContext mInputMethodContext;      ///< The Input Method Framework Manager.
-  FontDefaults*      mPlaceholderFont;         ///< The placeholder default font.
-  std::string        mPlaceholderTextActive;   ///< The text to display when the TextField is empty with key-input focus.
-  std::string        mPlaceholderTextInactive; ///< The text to display when the TextField is empty and inactive.
-  Vector4            mPlaceholderTextColor;    ///< The in/active placeholder text color.
+  DecoratorPtr                  mDecorator;               ///< Pointer to the decorator.
+  InputMethodContext            mInputMethodContext;      ///< The Input Method Framework Manager.
+  std::unique_ptr<FontDefaults> mPlaceholderFont;         ///< The placeholder default font.
+  std::string                   mPlaceholderTextActive;   ///< The text to display when the TextField is empty with key-input focus.
+  std::string                   mPlaceholderTextInactive; ///< The text to display when the TextField is empty and inactive.
+  Vector4                       mPlaceholderTextColor;    ///< The in/active placeholder text color.
 
   /**
    * This is used to delay handling events until after the model has been updated.
index 81d491a..301dbcb 100644 (file)
@@ -111,10 +111,8 @@ void Controller::PlaceholderHandler::SetPlaceholderFontFamily(Controller& contro
 {
   if(NULL != controller.mImpl->mEventData)
   {
-    if(NULL == controller.mImpl->mEventData->mPlaceholderFont)
-    {
-      controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults();
-    }
+    // if mPlaceholderFont is null, create an instance.
+    CreatePlaceholderFont(controller);
 
     controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.family = placeholderTextFontFamily;
     DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::SetPlaceholderFontFamily %s\n", placeholderTextFontFamily.c_str());
@@ -138,10 +136,8 @@ void Controller::PlaceholderHandler::SetPlaceholderTextFontWeight(Controller& co
 {
   if(NULL != controller.mImpl->mEventData)
   {
-    if(NULL == controller.mImpl->mEventData->mPlaceholderFont)
-    {
-      controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults();
-    }
+    // if mPlaceholderFont is null, create an instance.
+    CreatePlaceholderFont(controller);
 
     controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.weight = weight;
     controller.mImpl->mEventData->mPlaceholderFont->weightDefined           = true;
@@ -173,10 +169,8 @@ void Controller::PlaceholderHandler::SetPlaceholderTextFontWidth(Controller& con
 {
   if(NULL != controller.mImpl->mEventData)
   {
-    if(NULL == controller.mImpl->mEventData->mPlaceholderFont)
-    {
-      controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults();
-    }
+    // if mPlaceholderFont is null, create an instance.
+    CreatePlaceholderFont(controller);
 
     controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.width = width;
     controller.mImpl->mEventData->mPlaceholderFont->widthDefined           = true;
@@ -208,10 +202,8 @@ void Controller::PlaceholderHandler::SetPlaceholderTextFontSlant(Controller& con
 {
   if(NULL != controller.mImpl->mEventData)
   {
-    if(NULL == controller.mImpl->mEventData->mPlaceholderFont)
-    {
-      controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults();
-    }
+    // if mPlaceholderFont is null, create an instance.
+    CreatePlaceholderFont(controller);
 
     controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.slant = slant;
     controller.mImpl->mEventData->mPlaceholderFont->slantDefined           = true;
@@ -243,10 +235,8 @@ void Controller::PlaceholderHandler::SetPlaceholderTextFontSize(Controller& cont
 {
   if(NULL != controller.mImpl->mEventData)
   {
-    if(NULL == controller.mImpl->mEventData->mPlaceholderFont)
-    {
-      controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults();
-    }
+    // if mPlaceholderFont is null, create an instance.
+    CreatePlaceholderFont(controller);
 
     switch(type)
     {
@@ -533,6 +523,14 @@ void Controller::PlaceholderHandler::ShowPlaceholderText(Controller& controller)
   }
 }
 
+void Controller::PlaceholderHandler::CreatePlaceholderFont(Controller& controller)
+{
+  if(nullptr == controller.mImpl->mEventData->mPlaceholderFont)
+  {
+    controller.mImpl->mEventData->mPlaceholderFont = std::unique_ptr<FontDefaults>(new FontDefaults());
+  }
+}
+
 } // namespace Text
 
 } // namespace Toolkit
index c69e003..ac2ba1b 100644 (file)
@@ -56,6 +56,7 @@ struct Controller::PlaceholderHandler
   static void               SetPlaceholderProperty(Controller& controller, const Property::Map& map);
   static void               GetPlaceholderProperty(Controller& controller, Property::Map& map);
   static void               ShowPlaceholderText(Controller& controller);
+  static void               CreatePlaceholderFont(Controller& controller);
 };
 
 } // namespace Text
index 16a4a4a..4ae09f6 100644 (file)
@@ -187,6 +187,23 @@ ImageVisual::~ImageVisual()
       }
     }
 
+    if(mImageUrl.IsValid())
+    {
+      // Decrease reference count of External Resources :
+      // EncodedImageBuffer or ExternalTextures.
+      // Ensure the stage is still valid before accessing texture manager.
+      if(mImageUrl.GetProtocolType() == VisualUrl::TEXTURE)
+      {
+        TextureManager& textureManager = mFactoryCache.GetTextureManager();
+        textureManager.RemoveExternalTexture(mImageUrl.GetUrl());
+      }
+      else if(mImageUrl.IsBufferResource())
+      {
+        TextureManager& textureManager = mFactoryCache.GetTextureManager();
+        textureManager.RemoveExternalEncodedImageBuffer(mImageUrl.GetUrl());
+      }
+    }
+
     // ImageVisual destroyed so remove texture unless ReleasePolicy is set to never release
     if((mTextureId != TextureManager::INVALID_TEXTURE_ID) && (mReleasePolicy != Toolkit::ImageVisual::ReleasePolicy::NEVER))
     {
@@ -530,6 +547,15 @@ void ImageVisual::OnInitialize()
     }
   }
 
+  // Increase reference count of External Resources :
+  // EncodedImageBuffer or ExternalTextures.
+  // Reference count will be decreased at destructor of the visual.
+  if(mImageUrl.IsValid() && (mImageUrl.IsBufferResource() || mImageUrl.GetProtocolType() == VisualUrl::TEXTURE))
+  {
+    TextureManager& textureManager = mFactoryCache.GetTextureManager();
+    textureManager.UseExternalResource(mImageUrl.GetUrl());
+  }
+
   Shader shader = GetShader();
 
   // Create the renderer
index c6fc0c2..093954e 100644 (file)
@@ -469,6 +469,10 @@ TextureManager::TextureId TextureManager::RequestLoadInternal(
       if(encodedImageBuffer)
       {
         textureId = targetId;
+
+        // Increase EncodedImageBuffer reference during it contains mTextureInfoContainer.
+        UseExternalResource(url.GetUrl());
+
         // Insert this buffer at mTextureInfoContainer.
         // This buffer will decode at ImageLoaderThread.
         bool preMultiply = (preMultiplyOnLoad == TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD);
@@ -604,6 +608,11 @@ void TextureManager::Remove(const TextureManager::TextureId textureId, TextureUp
       // If the state allows us to remove the TextureInfo data, we do so.
       if(removeTextureInfo)
       {
+        // If url location is BUFFER, decrease reference count of EncodedImageBuffer.
+        if(textureInfo.url.IsBufferResource())
+        {
+          RemoveExternalEncodedImageBuffer(textureInfo.url.GetUrl());
+        }
         // Permanently remove the textureInfo struct.
         mTextureInfoContainer.erase(mTextureInfoContainer.begin() + textureInfoIndex);
       }
index 70c6dc2..30d9c02 100644 (file)
 // EXTERNAL HEADERS
 #include <cstring> // for toupper()
 
-// INTERNAL HEADERS
-#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
-#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
-
 namespace Dali
 {
 namespace Toolkit
@@ -228,14 +224,6 @@ VisualUrl::VisualUrl(const std::string& url)
       // TEXTURE and BUFFER location url doesn't need type resolving, REGULAR_IMAGE is fine
       mType = ResolveType(url);
     }
-    else
-    {
-      Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get();
-      if(factory)
-      {
-        GetImplementation(factory).GetTextureManager().UseExternalResource(*this);
-      }
-    }
   }
 }
 
@@ -244,69 +232,19 @@ VisualUrl::VisualUrl(const VisualUrl& url)
   mType(url.mType),
   mLocation(url.mLocation)
 {
-  if(VisualUrl::TEXTURE == mLocation || VisualUrl::BUFFER == mLocation)
-  {
-    Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get();
-    if(factory)
-    {
-      GetImplementation(factory).GetTextureManager().UseExternalResource(*this);
-    }
-  }
 }
 
 VisualUrl::~VisualUrl()
 {
-  if(VisualUrl::TEXTURE == mLocation)
-  {
-    Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get();
-    if(factory)
-    {
-      GetImplementation(factory).GetTextureManager().RemoveExternalTexture(mUrl);
-    }
-  }
-  else if(VisualUrl::BUFFER == mLocation)
-  {
-    Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get();
-    if(factory)
-    {
-      GetImplementation(factory).GetTextureManager().RemoveExternalEncodedImageBuffer(mUrl);
-    }
-  }
 }
 
 VisualUrl& VisualUrl::operator=(const VisualUrl& url)
 {
   if(&url != this)
   {
-    if(VisualUrl::TEXTURE == mLocation)
-    {
-      Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get();
-      if(factory)
-      {
-        GetImplementation(factory).GetTextureManager().RemoveExternalTexture(mUrl);
-      }
-    }
-    else if(VisualUrl::BUFFER == mLocation)
-    {
-      Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get();
-      if(factory)
-      {
-        GetImplementation(factory).GetTextureManager().RemoveExternalEncodedImageBuffer(mUrl);
-      }
-    }
-
     mUrl      = url.mUrl;
     mType     = url.mType;
     mLocation = url.mLocation;
-
-    if(VisualUrl::TEXTURE == mLocation || VisualUrl::BUFFER == mLocation)
-    {
-      Toolkit::VisualFactory factory = Toolkit::VisualFactory::Get();
-      if(factory)
-      {
-        GetImplementation(factory).GetTextureManager().UseExternalResource(*this);
-      }
-    }
   }
   return *this;
 }
index 71537c6..2f6f7a9 100644 (file)
@@ -29,7 +29,7 @@ namespace Toolkit
 {
 const unsigned int TOOLKIT_MAJOR_VERSION = 2;
 const unsigned int TOOLKIT_MINOR_VERSION = 0;
-const unsigned int TOOLKIT_MICRO_VERSION = 39;
+const unsigned int TOOLKIT_MICRO_VERSION = 40;
 const char* const  TOOLKIT_BUILD_DATE    = __DATE__ " " __TIME__;
 
 #ifdef DEBUG_ENABLED
index a9a7ac0..de44474 100644 (file)
@@ -1,6 +1,6 @@
 Name:       dali2-toolkit
 Summary:    Dali 3D engine Toolkit
-Version:    2.0.39
+Version:    2.0.40
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0 and BSD-3-Clause and MIT