[Tizen] Use default broken image when the url of custom broken is invalid 78/266978/10 accepted/tizen/6.5/unified/20211125.060620 accepted/tizen/6.5/unified/20211129.211953 submit/tizen_6.5/20211124.102337 submit/tizen_6.5/20211124.153736 submit/tizen_6.5/20211124.234723 submit/tizen_6.5/20211129.074532
authortscholb <scholb.kim@samsung.com>
Tue, 23 Nov 2021 07:10:10 +0000 (16:10 +0900)
committertscholb <scholb.kim@samsung.com>
Wed, 24 Nov 2021 10:13:20 +0000 (19:13 +0900)
Change-Id: I21f33392f864996e8419715b40e66a5d16eccb6a

dali-toolkit/internal/visuals/visual-factory-cache.cpp
dali-toolkit/internal/visuals/visual-factory-impl.cpp

index febd285..92acf67 100644 (file)
@@ -401,7 +401,7 @@ Shader VisualFactoryCache::GetNPatchShader(int index)
     yStretchCount = data->GetStretchPixelsY().Count();
   }
 
-  if(DALI_LIKELY((xStretchCount == 0 && yStretchCount == 0)))
+  if(DALI_LIKELY((xStretchCount == 0 && yStretchCount == 0) || (xStretchCount == 1 && yStretchCount == 1)))
   {
     shader = GetShader(VisualFactoryCache::NINE_PATCH_SHADER);
     if(DALI_UNLIKELY(!shader))
@@ -491,8 +491,15 @@ void VisualFactoryCache::ApplyTextureAndUniforms(Renderer& renderer, int index)
 
 void VisualFactoryCache::UpdateBrokenImageRenderer(Renderer& renderer, const Vector2& size)
 {
+
+  bool useDefaultBrokenImage = false;
+  if(mBrokenImageInfoContainer.size() == 1)
+  {
+    useDefaultBrokenImage = true;
+  }
+
   // Load Information for broken image
-  for(uint32_t index = 0; index < mBrokenImageInfoContainer.size(); index++)
+  for(uint32_t index = 0; (index + 1 < mBrokenImageInfoContainer.size()) && !useDefaultBrokenImage; index++)
   {
     if(mBrokenImageInfoContainer[index].width == 0 && mBrokenImageInfoContainer[index].height == 0)
     {
@@ -512,17 +519,35 @@ void VisualFactoryCache::UpdateBrokenImageRenderer(Renderer& renderer, const Vec
           }
           else
           {
-            DALI_LOG_ERROR("Can't update renderer for broken image. maybe image loading is failed [path:%s] \n",mBrokenImageInfoContainer[index].url.c_str());
+            DALI_LOG_ERROR("Can't update renderer for broken image. maybe image loading is failed [index:%d] [path:%s] \n",index, mBrokenImageInfoContainer[index].url.c_str());
+            useDefaultBrokenImage = true;
           }
         }
         else
         {
-          GetBrokenVisualImage(index);
+          if(!GetBrokenVisualImage(index))
+          {
+            DALI_LOG_ERROR("Can't update renderer for broken image. maybe image loading is failed [index:%d] [path:%s] \n",index, mBrokenImageInfoContainer[index].url.c_str());
+            useDefaultBrokenImage = true;
+          }
         }
       }
     }
   }
 
+  if(useDefaultBrokenImage && mBrokenImageInfoContainer.size() > 1)
+  {
+    std::string brokenUrl = mBrokenImageInfoContainer[mBrokenImageInfoContainer.size() -1].url;
+
+    mBrokenImageInfoContainer.clear();
+    mBrokenImageInfoContainer.assign(1, BrokenImageInfo());
+
+    const int defaultBrokenIndex = 0;
+    mBrokenImageInfoContainer[defaultBrokenIndex].url = brokenUrl;
+    VisualUrl visualUrl(mBrokenImageInfoContainer[defaultBrokenIndex].url);
+    mBrokenImageInfoContainer[defaultBrokenIndex].visualType = visualUrl.GetType();
+  }
+
   // Set Texutre to renderer
   int brokenIndex = GetProperBrokenImageIndex(size);
   if(GetBrokenImageVisualType(brokenIndex) == VisualUrl::N_PATCH)
@@ -547,7 +572,7 @@ int32_t VisualFactoryCache::GetProperBrokenImageIndex(const Vector2& size)
 {
   // Sets the default broken type
   int32_t returnIndex = 0;
-  if((size.width == 0 || size.height == 0))
+  if((size.width == 0 || size.height == 0) || (mBrokenImageInfoContainer.size() == 1))
   {
     // To do : Need to add observer about size
     return returnIndex;
index 112fdd3..d99543d 100644 (file)
@@ -377,20 +377,13 @@ void VisualFactory::SetBrokenImageUrl(Toolkit::StyleManager& styleManager)
   if(styleManager)
   {
     customBrokenImageUrlList = Toolkit::DevelStyleManager::GetBrokenImageUrlList(styleManager);
-    if(customBrokenImageUrlList.size() == 0)
-    {
-      Property::Map config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
-      config["brokenImageUrl"].Get(brokenImageUrl);
-      customBrokenImageUrlList.push_back(brokenImageUrl);
-    }
-    mFactoryCache->SetBrokenImageUrl(customBrokenImageUrlList);
-  }
-  else
-  {
-    // Set default image
-    customBrokenImageUrlList.push_back(brokenImageUrl);
-    mFactoryCache->SetBrokenImageUrl(customBrokenImageUrlList);
+    Property::Map config = Toolkit::DevelStyleManager::GetConfigurations(styleManager);
+    config["brokenImageUrl"].Get(brokenImageUrl);
   }
+
+  // Add default image
+  customBrokenImageUrlList.push_back(brokenImageUrl);
+  mFactoryCache->SetBrokenImageUrl(customBrokenImageUrlList);
 }
 
 Internal::VisualFactoryCache& VisualFactory::GetFactoryCache()