From: Heeyong Song Date: Fri, 31 Jan 2020 07:52:07 +0000 (+0900) Subject: [Tizen] Emit ResourceReady signal in SvgVisual in case of loading failure X-Git-Tag: accepted/tizen/5.5/unified/20200206.060322^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=915bd643ebaf235ae17a4600c1543c6f7985854d;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git [Tizen] Emit ResourceReady signal in SvgVisual in case of loading failure Change-Id: I0f52fb5f298b5cfe1b5e13eb78c330b044d55149 --- diff --git a/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp index 7d709d8..127a314 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp @@ -2400,3 +2400,60 @@ int UtcDaliImageViewReloadFailedOnResourceReadySignal(void) END_TEST; } + +int UtcDaliImageViewSvgLoadingFailure(void) +{ + ToolkitTestApplication application; + + // Local svg file + { + gResourceReadySignalFired = false; + + ImageView imageView = ImageView::New( TEST_RESOURCE_DIR "/Kid1.svg" ); + imageView.SetSize( 200.f, 200.f ); + imageView.ResourceReadySignal().Connect( &ResourceReadySignal); + + DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION ); + + Stage::GetCurrent().Add( imageView ); + + application.SendNotification(); + + // loading started, this waits for the loader thread + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(16); + + DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION ); + DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION ); + DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION ); + } + + // Remote svg file + { + gResourceReadySignalFired = false; + + ImageView imageView = ImageView::New( "https://bar.org/foobar.svg" ); + imageView.SetSize( 200.f, 200.f ); + imageView.ResourceReadySignal().Connect( &ResourceReadySignal); + + DALI_TEST_EQUALS( imageView.IsResourceReady(), false, TEST_LOCATION ); + + Stage::GetCurrent().Add( imageView ); + + application.SendNotification(); + + // loading started, this waits for the loader thread + DALI_TEST_EQUALS( Test::WaitForEventThreadTrigger( 1 ), true, TEST_LOCATION ); + + application.SendNotification(); + application.Render(16); + + DALI_TEST_EQUALS( gResourceReadySignalFired, true, TEST_LOCATION ); + DALI_TEST_EQUALS( imageView.IsResourceReady(), true, TEST_LOCATION ); + DALI_TEST_EQUALS( imageView.GetVisualResourceStatus( ImageView::Property::IMAGE ), Visual::ResourceStatus::FAILED, TEST_LOCATION ); + } + + END_TEST; +} diff --git a/dali-toolkit/internal/visuals/svg/svg-visual.cpp b/dali-toolkit/internal/visuals/svg/svg-visual.cpp index e5fbcac..d08f3c8 100644 --- a/dali-toolkit/internal/visuals/svg/svg-visual.cpp +++ b/dali-toolkit/internal/visuals/svg/svg-visual.cpp @@ -290,6 +290,10 @@ void SvgVisual::ApplyRasterizedImage( NSVGimage* parsedSvg, PixelData rasterized // Svg loaded and ready to display ResourceReady( Toolkit::Visual::ResourceStatus::READY ); } + else if( !mParsedImage ) + { + ResourceReady( Toolkit::Visual::ResourceStatus::FAILED ); + } } void SvgVisual::OnSetTransform() @@ -311,6 +315,12 @@ void SvgVisual::OnSetTransform() } } +bool SvgVisual::IsResourceReady() const +{ + return ( mImpl->mResourceStatus == Toolkit::Visual::ResourceStatus::READY || + mImpl->mResourceStatus == Toolkit::Visual::ResourceStatus::FAILED ); +} + } // namespace Internal } // namespace Toolkit diff --git a/dali-toolkit/internal/visuals/svg/svg-visual.h b/dali-toolkit/internal/visuals/svg/svg-visual.h index 87e9d43..81bfb5d 100644 --- a/dali-toolkit/internal/visuals/svg/svg-visual.h +++ b/dali-toolkit/internal/visuals/svg/svg-visual.h @@ -135,6 +135,11 @@ protected: */ void OnSetTransform() override; + /** + * @copydoc Visual::Base::IsResourceReady + */ + bool IsResourceReady() const override; + public: /**