From 9732b4bf9dda8fe31a56b83e81a925d6e030a9bb Mon Sep 17 00:00:00 2001 From: sunghyun kim Date: Tue, 22 Feb 2022 14:13:01 +0900 Subject: [PATCH] Fix webp&gif issue 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 --- .../src/dali-toolkit-internal/utc-Dali-VisualUrl.cpp | 3 +-- .../visuals/animated-image/animated-image-visual.cpp | 2 +- dali-toolkit/internal/visuals/visual-url.cpp | 15 ++++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-VisualUrl.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-VisualUrl.cpp index 767c1f8..af42955 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-VisualUrl.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-VisualUrl.cpp @@ -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 ); diff --git a/dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp b/dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp index d5dcdaa..be73cca 100644 --- a/dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp +++ b/dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp @@ -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), diff --git a/dali-toolkit/internal/visuals/visual-url.cpp b/dali-toolkit/internal/visuals/visual-url.cpp index 0ad5778..af3b04c 100644 --- a/dali-toolkit/internal/visuals/visual-url.cpp +++ b/dali-toolkit/internal/visuals/visual-url.cpp @@ -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 -- 2.7.4