Fix webp&gif issue 30/274030/2
authorsunghyun kim <scholb.kim@samsung.com>
Tue, 22 Feb 2022 05:13:01 +0000 (14:13 +0900)
committertscholb <scholb.kim@samsung.com>
Wed, 20 Apr 2022 08:12:52 +0000 (17:12 +0900)
1. Change Fitting mode
- animated image visual use FIT_KEEP_ASPECT_RATIO by default, but image visual use FILL.
  i think we need to use same fitting mode by default.

2. use npatch in webp and gif
- if webp and gif use npatch, it need to be change regular type

Change-Id: Ib29234e86d5d2efaa38dce9ef391a79a1065dd5d

automated-tests/src/dali-toolkit-internal/utc-Dali-VisualUrl.cpp
dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp
dali-toolkit/internal/visuals/visual-url.cpp

index 767c1f8..af42955 100644 (file)
@@ -153,8 +153,7 @@ int UtcDaliVisualUrlGif(void)
 
   DALI_TEST_EQUALS( VisualUrl::GIF, VisualUrl(".GiF").GetType(), TEST_LOCATION );
 
-  // GIFs aren't N-patch
-  DALI_TEST_EQUALS( VisualUrl::GIF, VisualUrl("foobar.9.gif").GetType(), TEST_LOCATION );
+  DALI_TEST_EQUALS( VisualUrl::N_PATCH, VisualUrl("foobar.9.gif").GetType(), TEST_LOCATION );
 
   DALI_TEST_EQUALS( VisualUrl::REGULAR_IMAGE, VisualUrl("gif.png").GetType(), TEST_LOCATION );
   DALI_TEST_EQUALS( VisualUrl::REGULAR_IMAGE, VisualUrl("gif.gif1").GetType(), TEST_LOCATION );
index d5dcdaa..be73cca 100644 (file)
@@ -201,7 +201,7 @@ void AnimatedImageVisual::CreateImageCache()
 }
 
 AnimatedImageVisual::AnimatedImageVisual(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory)
-: Visual::Base(factoryCache, Visual::FittingMode::FIT_KEEP_ASPECT_RATIO, Toolkit::Visual::ANIMATED_IMAGE),
+: Visual::Base(factoryCache, Visual::FittingMode::FILL, Toolkit::Visual::ANIMATED_IMAGE),
   mFrameDelayTimer(),
   mPlacementActor(),
   mImageVisualShaderFactory(shaderFactory),
index 0ad5778..af3b04c 100644 (file)
@@ -105,6 +105,7 @@ VisualUrl::Type ResolveType(const std::string& url)
 {
   // if only one char in string, can only be regular image
   const std::size_t count = url.size();
+  VisualUrl::Type  returnType = VisualUrl::REGULAR_IMAGE;
   if(count > 0)
   {
     // parsing from the end for better chance of early outs
@@ -147,18 +148,18 @@ VisualUrl::Type ResolveType(const std::string& url)
       }
       if((offsetFromEnd < sizeof(GIF)) && (currentChar == GIF[offsetFromEnd]))
       {
-        // early out if GIF as can't be used in N patch for now
+        //find type, but need to be check used in N patch
         if(++gifScore == sizeof(GIF))
         {
-          return VisualUrl::GIF;
+          returnType = VisualUrl::GIF;
         }
       }
       if((offsetFromEnd < sizeof(WEBP)) && (currentChar == WEBP[offsetFromEnd]))
       {
-        // early out if WEBP as can't be used in N patch for now
         if(++webpScore == sizeof(WEBP))
         {
-          return VisualUrl::WEBP;
+          //find type, but need to be check used in N patch
+          returnType = VisualUrl::WEBP;
         }
       }
       if((offsetFromEnd < sizeof(JSON)) && (currentChar == JSON[offsetFromEnd]))
@@ -188,7 +189,7 @@ VisualUrl::Type ResolveType(const std::string& url)
           else
           {
             // early out, not a valid N/9-patch URL
-            return VisualUrl::REGULAR_IMAGE;
+            return returnType;
           }
           break;
         }
@@ -201,7 +202,7 @@ VisualUrl::Type ResolveType(const std::string& url)
           else
           {
             // early out, not a valid N/9-patch URL
-            return VisualUrl::REGULAR_IMAGE;
+            return returnType;
           }
           break;
         }
@@ -209,7 +210,7 @@ VisualUrl::Type ResolveType(const std::string& url)
     }
   }
   // if we got here it is a regular image
-  return VisualUrl::REGULAR_IMAGE;
+  return returnType;
 }
 
 } // namespace