Merge "ImageVisualShaderFactory refactoring" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / image / image-visual.cpp
index 8adcb32..0f18783 100644 (file)
@@ -27,6 +27,7 @@
 #include <dali/devel-api/scripting/scripting.h>
 #include <dali/integration-api/debug.h>
 #include <dali/public-api/actors/layer.h>
+#include <dali/public-api/adaptor-framework/async-task-manager.h>
 #include <dali/public-api/rendering/decorated-visual-renderer.h>
 #include <cstring> // for strlen()
 
@@ -35,6 +36,7 @@
 #include <dali-toolkit/internal/texture-manager/texture-manager-impl.h>
 #include <dali-toolkit/internal/visuals/image-atlas-manager.h>
 #include <dali-toolkit/internal/visuals/image-visual-shader-factory.h>
+#include <dali-toolkit/internal/visuals/image-visual-shader-feature-builder.h>
 #include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
@@ -151,6 +153,7 @@ ImageVisual::ImageVisual(VisualFactoryCache&       factoryCache,
                          Dali::SamplingMode::Type  samplingMode)
 : Visual::Base(factoryCache, Visual::FittingMode::FILL, Toolkit::Visual::IMAGE),
   mPixelArea(FULL_TEXTURE_RECT),
+  mPixelAreaIndex(Property::INVALID_INDEX),
   mPlacementActor(),
   mImageUrl(imageUrl),
   mMaskingData(),
@@ -168,7 +171,8 @@ ImageVisual::ImageVisual(VisualFactoryCache&       factoryCache,
   mAtlasRectSize(0, 0),
   mLoadState(TextureManager::LoadState::NOT_STARTED),
   mAttemptAtlasing(false),
-  mOrientationCorrection(true)
+  mOrientationCorrection(true),
+  mEnableBrokenImage(true)
 {
   EnablePreMultipliedAlpha(mFactoryCache.GetPreMultiplyOnLoad());
 }
@@ -199,6 +203,8 @@ ImageVisual::~ImageVisual()
     {
       RemoveTexture();
     }
+
+    ResetFastTrackLoadingTask();
   }
 }
 
@@ -266,6 +272,10 @@ void ImageVisual::DoSetProperties(const Property::Map& propertyMap)
       {
         DoSetProperty(Toolkit::DevelImageVisual::Property::MASKING_TYPE, keyValue.second);
       }
+      else if(keyValue.first == ENABLE_BROKEN_IMAGE)
+      {
+        DoSetProperty(Toolkit::DevelImageVisual::Property::ENABLE_BROKEN_IMAGE, keyValue.second);
+      }
       else if(keyValue.first == LOAD_POLICY_NAME)
       {
         DoSetProperty(Toolkit::ImageVisual::Property::LOAD_POLICY, keyValue.second);
@@ -278,6 +288,10 @@ void ImageVisual::DoSetProperties(const Property::Map& propertyMap)
       {
         DoSetProperty(Toolkit::ImageVisual::Property::ORIENTATION_CORRECTION, keyValue.second);
       }
+      else if(keyValue.first == FAST_TRACK_UPLOADING_NAME)
+      {
+        DoSetProperty(Toolkit::DevelImageVisual::Property::FAST_TRACK_UPLOADING, keyValue.second);
+      }
     }
   }
   // Load image immediately if LOAD_POLICY requires it
@@ -360,6 +374,13 @@ void ImageVisual::DoSetProperty(Property::Index index, const Property::Value& va
     case Toolkit::ImageVisual::Property::PIXEL_AREA:
     {
       value.Get(mPixelArea);
+
+      if(DALI_UNLIKELY(mImpl->mRenderer))
+      {
+        // Unusual case. SetProperty called after OnInitialize().
+        // Assume that DoAction call UPDATE_PROPERTY.
+        mPixelAreaIndex = mImpl->mRenderer.RegisterProperty(mPixelAreaIndex, PIXEL_AREA_UNIFORM_NAME, mPixelArea);
+      }
       break;
     }
 
@@ -438,6 +459,16 @@ void ImageVisual::DoSetProperty(Property::Index index, const Property::Value& va
       break;
     }
 
+    case Toolkit::DevelImageVisual::Property::ENABLE_BROKEN_IMAGE:
+    {
+      bool enableBrokenImage(mEnableBrokenImage);
+      if(value.Get(enableBrokenImage))
+      {
+        mEnableBrokenImage = enableBrokenImage;
+      }
+      break;
+    }
+
     case Toolkit::ImageVisual::Property::RELEASE_POLICY:
     {
       int releasePolicy = 0;
@@ -462,6 +493,16 @@ void ImageVisual::DoSetProperty(Property::Index index, const Property::Value& va
       }
       break;
     }
+
+    case Toolkit::DevelImageVisual::Property::FAST_TRACK_UPLOADING:
+    {
+      bool fastTrackUploading = false;
+      if(value.Get(fastTrackUploading))
+      {
+        mUseFastTrackUploading = fastTrackUploading;
+      }
+      break;
+    }
   }
 }
 
@@ -619,9 +660,92 @@ void ImageVisual::LoadTexture(bool& atlasing, Vector4& atlasRect, TextureSet& te
                              : TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
 
   bool synchronousLoading = IsSynchronousLoadingRequired();
-  bool loadingStatus;
+  bool loadingStatus      = false;
+
+  // Remove previous loading task.
+  ResetFastTrackLoadingTask();
+
+  // Rare case. If someone call LoadTexture during fast track loading task running, (Ex : Action::RELOAD)
+  // we should remove previously added renderer now.
+  if(mRendererAdded)
+  {
+    Actor actor = mPlacementActor.GetHandle();
+    if(actor)
+    {
+      actor.RemoveRenderer(mImpl->mRenderer);
+      mRendererAdded = false;
+    }
+  }
+
+  /**
+   * @brief Check whether FastTrackUploading is avaliable or not.
+   * @return True if we can use fast track uploading feature. False otherwise.
+   */
+  auto IsFastTrackUploadingAvailable = [&]() {
+    if(mUseFastTrackUploading &&
+       mLoadPolicy == Toolkit::ImageVisual::LoadPolicy::ATTACHED &&
+       mReleasePolicy == Toolkit::ImageVisual::ReleasePolicy::DETACHED &&
+       forceReload == TextureManager::ReloadPolicy::CACHED &&
+       (mImageUrl.GetProtocolType() == VisualUrl::LOCAL || mImageUrl.GetProtocolType() == VisualUrl::REMOTE) &&
+       !synchronousLoading &&
+       !atlasing &&
+       !mImpl->mCustomShader &&
+       !(mMaskingData && mMaskingData->mAlphaMaskUrl.IsValid()))
+    {
+      return true;
+    }
+    else if(mUseFastTrackUploading)
+    {
+      DALI_LOG_DEBUG_INFO("FastTrack : Fail to load fast track. mUrl : [%s]%s%s%s%s%s%s%s%s\n",
+                          mImageUrl.GetUrl().c_str(),
+                          (mLoadPolicy != Toolkit::ImageVisual::LoadPolicy::ATTACHED) ? "/ mLoadPolicy != ATTACHED" : "",
+                          (mReleasePolicy != Toolkit::ImageVisual::ReleasePolicy::DETACHED) ? "/ mReleasePolicy != DETACHED" : "",
+                          (forceReload != TextureManager::ReloadPolicy::CACHED) ? "/ forceReload != CACHED" : "",
+                          (!(mImageUrl.GetProtocolType() == VisualUrl::LOCAL || mImageUrl.GetProtocolType() == VisualUrl::REMOTE)) ? "/ url is not image" : "",
+                          (synchronousLoading) ? "/ synchronousLoading" : "",
+                          (atlasing) ? "/ atlasing" : "",
+                          (mImpl->mCustomShader) ? "/ use customs shader" : "",
+                          (mMaskingData && mMaskingData->mAlphaMaskUrl.IsValid()) ? "/ use masking url" : "");
+    }
+    return false;
+  };
+
+  if(IsFastTrackUploadingAvailable())
+  {
+    // Enable PremultipliedAlpha first.
+    EnablePreMultipliedAlpha(preMultiplyOnLoad == TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD);
+
+    // Set new TextureSet with fast track loading task
+    mFastTrackLoadingTask = new FastTrackLoadingTask(mImageUrl, mDesiredSize, mFittingMode, mSamplingMode, mOrientationCorrection, preMultiplyOnLoad == TextureManager::MultiplyOnLoad::MULTIPLY_ON_LOAD ? DevelAsyncImageLoader::PreMultiplyOnLoad::ON : DevelAsyncImageLoader::PreMultiplyOnLoad::OFF, mFactoryCache.GetLoadYuvPlanes(), MakeCallback(this, &ImageVisual::FastLoadComplete));
+
+    TextureSet textureSet = TextureSet::New();
+    if(!mFastTrackLoadingTask->mLoadPlanesAvaliable)
+    {
+      DALI_ASSERT_ALWAYS(mFastTrackLoadingTask->mTextures.size() >= 1u);
+      textureSet.SetTexture(0u, mFastTrackLoadingTask->mTextures[0]);
+    }
+    else
+    {
+      DALI_ASSERT_ALWAYS(mFastTrackLoadingTask->mTextures.size() >= 3u);
+      textureSet.SetTexture(0u, mFastTrackLoadingTask->mTextures[0]);
+      textureSet.SetTexture(1u, mFastTrackLoadingTask->mTextures[1]);
+      textureSet.SetTexture(2u, mFastTrackLoadingTask->mTextures[2]);
+
+      // We cannot determine what kind of shader will be used.
+      // Just use unified shader, and then change shader after load completed.
+      mNeedUnifiedYuvAndRgb = true;
+      UpdateShader();
+    }
+    mImpl->mRenderer.SetTextures(textureSet);
 
-  textures = textureManager.LoadTexture(mImageUrl, mDesiredSize, mFittingMode, mSamplingMode, mMaskingData, synchronousLoading, mTextureId, atlasRect, mAtlasRectSize, atlasing, loadingStatus, textureObserver, atlasUploadObserver, atlasManager, mOrientationCorrection, forceReload, preMultiplyOnLoad);
+    Dali::AsyncTaskManager::Get().AddTask(mFastTrackLoadingTask);
+
+    mLoadState = TextureManager::LoadState::LOADING;
+  }
+  else
+  {
+    textures = textureManager.LoadTexture(mImageUrl, mDesiredSize, mFittingMode, mSamplingMode, mMaskingData, synchronousLoading, mTextureId, atlasRect, mAtlasRectSize, atlasing, loadingStatus, textureObserver, atlasUploadObserver, atlasManager, mOrientationCorrection, forceReload, preMultiplyOnLoad);
+  }
 
   if(textures)
   {
@@ -749,12 +873,13 @@ void ImageVisual::DoSetOnScene(Actor& actor)
 
   if(mPixelArea != FULL_TEXTURE_RECT)
   {
-    mImpl->mRenderer.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, mPixelArea);
+    mPixelAreaIndex = mImpl->mRenderer.RegisterProperty(mPixelAreaIndex, PIXEL_AREA_UNIFORM_NAME, mPixelArea);
   }
 
   if(mLoadState == TextureManager::LoadState::LOAD_FINISHED)
   {
     actor.AddRenderer(mImpl->mRenderer);
+    mRendererAdded = true;
     mPlacementActor.Reset();
 
     // Image loaded and ready to display
@@ -762,18 +887,16 @@ void ImageVisual::DoSetOnScene(Actor& actor)
   }
   else if(mLoadState == TextureManager::LoadState::LOAD_FAILED)
   {
-    Vector2 imageSize = Vector2::ZERO;
-    if(actor)
+    ShowBrokenImage();
+    ResourceReady(Toolkit::Visual::ResourceStatus::FAILED);
+  }
+  else
+  {
+    if(mFastTrackLoadingTask)
     {
-      imageSize           = actor.GetProperty(Actor::Property::SIZE).Get<Vector2>();
-      mPlacementActorSize = imageSize;
+      actor.AddRenderer(mImpl->mRenderer);
+      mRendererAdded = true;
     }
-
-    mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize);
-    actor.AddRenderer(mImpl->mRenderer);
-    mPlacementActor.Reset();
-
-    ResourceReady(Toolkit::Visual::ResourceStatus::FAILED);
   }
 }
 
@@ -783,16 +906,11 @@ void ImageVisual::DoSetOffScene(Actor& actor)
 
   // Image release is dependent on the ReleasePolicy, renderer is removed.
   actor.RemoveRenderer(mImpl->mRenderer);
+  mRendererAdded = false;
+
   if(mReleasePolicy == Toolkit::ImageVisual::ReleasePolicy::DETACHED)
   {
-    RemoveTexture(); // If INVALID_TEXTURE_ID then removal will be attempted on atlas
-    mImpl->mResourceStatus = Toolkit::Visual::ResourceStatus::PREPARING;
-
-    TextureSet textureSet = TextureSet::New();
-    mImpl->mRenderer.SetTextures(textureSet);
-    ComputeTextureSize();
-
-    mLoadState = TextureManager::LoadState::NOT_STARTED;
+    ResetRenderer();
   }
 
   mPlacementActor.Reset();
@@ -815,7 +933,17 @@ void ImageVisual::DoCreatePropertyMap(Property::Map& map) const
   map.Insert(Toolkit::ImageVisual::Property::FITTING_MODE, mFittingMode);
   map.Insert(Toolkit::ImageVisual::Property::SAMPLING_MODE, mSamplingMode);
 
-  map.Insert(Toolkit::ImageVisual::Property::PIXEL_AREA, mPixelArea);
+  if(mImpl->mRenderer && mPixelAreaIndex != Property::INVALID_INDEX)
+  {
+    // Update values from Renderer
+    Vector4 pixelArea = mImpl->mRenderer.GetProperty<Vector4>(mPixelAreaIndex);
+    map.Insert(Toolkit::ImageVisual::Property::PIXEL_AREA, pixelArea);
+  }
+  else
+  {
+    map.Insert(Toolkit::ImageVisual::Property::PIXEL_AREA, mPixelArea);
+  }
+
   map.Insert(Toolkit::ImageVisual::Property::WRAP_MODE_U, mWrapModeU);
   map.Insert(Toolkit::ImageVisual::Property::WRAP_MODE_V, mWrapModeV);
 
@@ -832,6 +960,8 @@ void ImageVisual::DoCreatePropertyMap(Property::Map& map) const
   map.Insert(Toolkit::ImageVisual::Property::LOAD_POLICY, mLoadPolicy);
   map.Insert(Toolkit::ImageVisual::Property::RELEASE_POLICY, mReleasePolicy);
   map.Insert(Toolkit::ImageVisual::Property::ORIENTATION_CORRECTION, mOrientationCorrection);
+
+  map.Insert(Toolkit::DevelImageVisual::Property::FAST_TRACK_UPLOADING, mUseFastTrackUploading);
 }
 
 void ImageVisual::DoCreateInstancePropertyMap(Property::Map& map) const
@@ -887,6 +1017,7 @@ void ImageVisual::UploadCompleted()
   {
     mImpl->mRenderer.RegisterProperty(ATLAS_RECT_UNIFORM_NAME, mAtlasRect);
     actor.AddRenderer(mImpl->mRenderer);
+    mRendererAdded = true;
     // reset the weak handle so that the renderer only get added to actor once
     mPlacementActor.Reset();
   }
@@ -896,6 +1027,64 @@ void ImageVisual::UploadCompleted()
   mLoadState = TextureManager::LoadState::LOAD_FINISHED;
 }
 
+// From FastTrackLoadingTask
+void ImageVisual::FastLoadComplete(FastTrackLoadingTaskPtr task)
+{
+  Toolkit::Visual::ResourceStatus resourceStatus;
+
+  DALI_ASSERT_ALWAYS(mFastTrackLoadingTask == task && "Task was not canceled successfully!");
+  DALI_ASSERT_ALWAYS(mRendererAdded && "Some FastTrack logic missed!");
+
+  Actor actor = mPlacementActor.GetHandle();
+
+  if(mFastTrackLoadingTask && mFastTrackLoadingTask->mLoadSuccess)
+  {
+    resourceStatus = Toolkit::Visual::ResourceStatus::READY;
+    mLoadState     = TextureManager::LoadState::LOAD_FINISHED;
+
+    // Change premultiplied alpha flag after change renderer.
+    EnablePreMultipliedAlpha(mFastTrackLoadingTask->mPremultiplied);
+
+    if(mFastTrackLoadingTask->mLoadPlanesAvaliable)
+    {
+      if(mFastTrackLoadingTask->mPlanesLoaded)
+      {
+        // Let we use regular yuv cases.
+        mNeedYuvToRgb = true;
+      }
+      else
+      {
+        // Let we use regular image cases.
+        mNeedYuvToRgb = false;
+
+        auto textureSet = mImpl->mRenderer.GetTextures();
+        DALI_ASSERT_ALWAYS(textureSet && textureSet.GetTextureCount() > 0u && "Previous texture set must exist!");
+
+        Dali::TextureSet newTextureSet = TextureSet::New();
+        newTextureSet.SetTexture(0u, textureSet.GetTexture(0u));
+        mImpl->mRenderer.SetTextures(newTextureSet);
+      }
+
+      // We can specify what kind of shader we need to use now. Update shader.
+      mNeedUnifiedYuvAndRgb = false;
+      UpdateShader();
+    }
+  }
+  else
+  {
+    resourceStatus = Toolkit::Visual::ResourceStatus::FAILED;
+    mLoadState     = TextureManager::LoadState::LOAD_FAILED;
+
+    // Change renderer as broken.
+    ShowBrokenImage();
+  }
+
+  mFastTrackLoadingTask.Reset();
+
+  // Signal to observers ( control ) that resources are ready. Must be all resources.
+  ResourceReady(resourceStatus);
+}
+
 // From Texture Manager
 void ImageVisual::LoadComplete(bool loadingSuccess, TextureInformation textureInformation)
 {
@@ -912,18 +1101,7 @@ void ImageVisual::LoadComplete(bool loadingSuccess, TextureInformation textureIn
     Actor actor = mPlacementActor.GetHandle();
     if(!loadingSuccess)
     {
-      Vector2 imageSize = Vector2::ZERO;
-      if(actor)
-      {
-        imageSize           = actor.GetProperty(Actor::Property::SIZE).Get<Vector2>();
-        mPlacementActorSize = imageSize;
-      }
-      else
-      {
-        imageSize = mPlacementActorSize;
-      }
-
-      mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize);
+      ShowBrokenImage();
       textureInformation.textureSet = mImpl->mRenderer.GetTextures();
     }
     else
@@ -947,13 +1125,14 @@ void ImageVisual::LoadComplete(bool loadingSuccess, TextureInformation textureIn
           UpdateShader();
         }
       }
-    }
 
-    if(actor)
-    {
-      actor.AddRenderer(mImpl->mRenderer);
-      // reset the weak handle so that the renderer only get added to actor once
-      mPlacementActor.Reset();
+      if(actor)
+      {
+        actor.AddRenderer(mImpl->mRenderer);
+        mRendererAdded = true;
+        // reset the weak handle so that the renderer only get added to actor once
+        mPlacementActor.Reset();
+      }
     }
   }
 
@@ -1018,6 +1197,8 @@ void ImageVisual::RemoveTexture()
   }
   else
   {
+    ResetFastTrackLoadingTask();
+
     Vector4         atlasRect(0.f, 0.f, 1.f, 1.f);
     Property::Index index = mImpl->mRenderer.GetPropertyIndex(ATLAS_RECT_UNIFORM_NAME);
     if(index != Property::INVALID_INDEX)
@@ -1093,7 +1274,6 @@ Shader ImageVisual::GenerateShader() const
 {
   Shader shader;
 
-  bool       usesWholeTexture  = true;
   const bool useStandardShader = !mImpl->mCustomShader;
   const bool useNativeImage    = (mTextures && DevelTexture::IsNative(mTextures.GetTexture(0)));
 
@@ -1103,17 +1283,18 @@ Shader ImageVisual::GenerateShader() const
     // Create and cache the standard shader
     shader = mImageVisualShaderFactory.GetShader(
       mFactoryCache,
-      ImageVisualShaderFeature::FeatureBuilder()
+      ImageVisualShaderFeatureBuilder()
         .EnableTextureAtlas(mImpl->mFlags & Visual::Base::Impl::IS_ATLASING_APPLIED && !useNativeImage)
         .ApplyDefaultTextureWrapMode(mWrapModeU <= WrapMode::CLAMP_TO_EDGE && mWrapModeV <= WrapMode::CLAMP_TO_EDGE)
         .EnableRoundedCorner(IsRoundedCornerRequired())
         .EnableBorderline(IsBorderlineRequired())
         .SetTextureForFragmentShaderCheck(useNativeImage ? mTextures.GetTexture(0) : Dali::Texture())
         .EnableAlphaMaskingOnRendering(requiredAlphaMaskingOnRendering)
-        .EnableYuvToRgb(mNeedYuvToRgb));
+        .EnableYuvToRgb(mNeedYuvToRgb, mNeedUnifiedYuvAndRgb));
   }
   else
   {
+    bool             usesWholeTexture = true;
     std::string_view vertexShaderView;
     std::string_view fragmentShaderView;
 
@@ -1157,14 +1338,32 @@ Shader ImageVisual::GenerateShader() const
     {
       shader = Shader::New(vertexShaderView, fragmentShaderView, mImpl->mCustomShader->mHints);
     }
+
+    if(usesWholeTexture)
+    {
+      shader.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT);
+    }
   }
 
-  if(usesWholeTexture)
+  return shader;
+}
+
+Dali::Property ImageVisual::OnGetPropertyObject(Dali::Property::Key key)
+{
+  if((key.type == Property::Key::INDEX && key.indexKey == Toolkit::ImageVisual::Property::PIXEL_AREA) || (key.type == Property::Key::STRING && key.stringKey == PIXEL_AREA_UNIFORM_NAME))
   {
-    shader.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT);
+    if(DALI_LIKELY(mImpl->mRenderer))
+    {
+      if(mPixelAreaIndex == Property::INVALID_INDEX)
+      {
+        mPixelAreaIndex = mImpl->mRenderer.RegisterProperty(mPixelAreaIndex, PIXEL_AREA_UNIFORM_NAME, mPixelArea);
+      }
+      return Dali::Property(mImpl->mRenderer, mPixelAreaIndex);
+    }
   }
 
-  return shader;
+  Handle handle;
+  return Dali::Property(handle, Property::INVALID_INDEX);
 }
 
 void ImageVisual::CheckMaskTexture()
@@ -1190,6 +1389,69 @@ void ImageVisual::CheckMaskTexture()
   }
 }
 
+void ImageVisual::ResetRenderer()
+{
+  RemoveTexture(); // If INVALID_TEXTURE_ID then removal will be attempted on atlas
+  mImpl->mResourceStatus = Toolkit::Visual::ResourceStatus::PREPARING;
+
+  TextureSet textureSet = TextureSet::New();
+  mImpl->mRenderer.SetTextures(textureSet);
+  ComputeTextureSize();
+
+  mLoadState = TextureManager::LoadState::NOT_STARTED;
+}
+
+void ImageVisual::ShowBrokenImage()
+{
+  if(mEnableBrokenImage)
+  {
+    Actor actor = mPlacementActor.GetHandle();
+
+    Vector2 imageSize = Vector2::ZERO;
+    if(actor)
+    {
+      imageSize           = actor.GetProperty(Actor::Property::SIZE).Get<Vector2>();
+      mPlacementActorSize = imageSize;
+
+      if(mRendererAdded)
+      {
+        actor.RemoveRenderer(mImpl->mRenderer);
+        mRendererAdded = false;
+      }
+    }
+
+    mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize);
+    if(actor)
+    {
+      actor.AddRenderer(mImpl->mRenderer);
+      mRendererAdded = true;
+      mPlacementActor.Reset();
+    }
+  }
+  else
+  {
+    if(mRendererAdded)
+    {
+      Actor actor = mPlacementActor.GetHandle();
+      if(actor)
+      {
+        actor.RemoveRenderer(mImpl->mRenderer);
+        mRendererAdded = false;
+      }
+    }
+    ResetRenderer();
+  }
+}
+
+void ImageVisual::ResetFastTrackLoadingTask()
+{
+  if(mFastTrackLoadingTask)
+  {
+    Dali::AsyncTaskManager::Get().RemoveTask(mFastTrackLoadingTask);
+    mFastTrackLoadingTask.Reset();
+  }
+}
+
 } // namespace Internal
 
 } // namespace Toolkit