Refactoring TextureUploadObserver. 02/268202/4
authorseungho <sbsh.baek@samsung.com>
Fri, 17 Dec 2021 04:03:52 +0000 (13:03 +0900)
committerseungho <sbsh.baek@samsung.com>
Fri, 17 Dec 2021 05:27:25 +0000 (14:27 +0900)
 - Use unified method for any request.

Change-Id: Ief4b744cd42b9184f83ba0ac0ba3436befd2aa61
Signed-off-by: seungho <sbsh.baek@samsung.com>
18 files changed:
automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp
automated-tests/src/dali-toolkit/utc-Dali-ImageView.cpp
dali-toolkit/internal/visuals/animated-image/fixed-image-cache.cpp
dali-toolkit/internal/visuals/animated-image/fixed-image-cache.h
dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.cpp
dali-toolkit/internal/visuals/animated-image/rolling-animated-image-cache.h
dali-toolkit/internal/visuals/animated-image/rolling-image-cache.cpp
dali-toolkit/internal/visuals/animated-image/rolling-image-cache.h
dali-toolkit/internal/visuals/image/image-visual.cpp
dali-toolkit/internal/visuals/image/image-visual.h
dali-toolkit/internal/visuals/npatch-data.cpp
dali-toolkit/internal/visuals/npatch-data.h
dali-toolkit/internal/visuals/npatch/npatch-visual.cpp
dali-toolkit/internal/visuals/npatch/npatch-visual.h
dali-toolkit/internal/visuals/texture-manager-impl.cpp
dali-toolkit/internal/visuals/texture-manager-impl.h
dali-toolkit/internal/visuals/texture-upload-observer.cpp
dali-toolkit/internal/visuals/texture-upload-observer.h

index 1553f97b03f2895e8f1c805fd6b76283fa43b23e..d27948240e368a06924b50cf5ab8c8f42b3caf92 100644 (file)
@@ -76,20 +76,19 @@ public:
   {
   }
 
-  virtual void UploadComplete( bool loadSuccess, int32_t textureId, TextureSet textureSet,
-                               bool useAtlasing, const Vector4& atlasRect, bool preMultiplied ) override
+  virtual void LoadComplete( bool loadSuccess, TextureInformation textureInformation ) override
   {
-    mCompleteType = CompleteType::UPLOAD_COMPLETE;
-    mLoaded = loadSuccess;
-    mObserverCalled = true;
-    mTextureSet = textureSet;
-  }
-
-  virtual void LoadComplete( bool loadSuccess, Devel::PixelBuffer pixelBuffer, const VisualUrl& url, bool preMultiplied ) override
-  {
-    mCompleteType = CompleteType::LOAD_COMPLETE;
+    if(textureInformation.returnType == TextureUploadObserver::ReturnType::TEXTURE)
+    {
+      mCompleteType = CompleteType::UPLOAD_COMPLETE;
+    }
+    else
+    {
+      mCompleteType = CompleteType::LOAD_COMPLETE;
+    }
     mLoaded = loadSuccess;
     mObserverCalled = true;
+    mTextureSet = textureInformation.textureSet;
   }
 
   CompleteType mCompleteType;
index e8dd77e1f141042e880cc3c9842621445c7e8fc1..96f4536d789e68c4ea9cba584a93fd2661040052 100644 (file)
@@ -3048,7 +3048,7 @@ void OnResourceReadySignal03( Control control )
   if(gResourceReadySignalCounter == 0)
   {
     // Queue loading
-    // 1. Use cached image, then UploadComplete will be called right after OnResourceReadySignal03.
+    // 1. Use cached image, then LoadComplete will be called right after OnResourceReadySignal03.
     gImageView2[ImageView::Property::IMAGE] = gImage_34_RGBA;
 
     // 2. Load a new image
index 4593bc7b777a02866f6163435a5365dc38a644ce..dcb66213e87de6df05a5cfd80212f5bc64c16b2e 100644 (file)
@@ -131,9 +131,9 @@ void FixedImageCache::LoadBatch()
 
     mReadyFlags.push_back(false);
 
-    // Note, if the image is already loaded, then UploadComplete will get called
+    // Note, if the image is already loaded, then LoadComplete will get called
     // from within this method. This means it won't yet have a texture id, so we
-    // need to account for this inside the UploadComplete method using mRequestingLoad.
+    // need to account for this inside the LoadComplete method using mRequestingLoad.
     mRequestingLoad = true;
 
     bool                               synchronousLoading = false;
@@ -186,42 +186,25 @@ void FixedImageCache::CheckFrontFrame(bool wasReady)
   }
 }
 
-void FixedImageCache::UploadComplete(
-  bool           loadSuccess,
-  int32_t        textureId,
-  TextureSet     textureSet,
-  bool           useAtlasing,
-  const Vector4& atlasRect,
-  bool           preMultiplied)
+void FixedImageCache::LoadComplete(bool loadSuccess, TextureInformation textureInformation)
 {
   bool frontFrameReady = IsFrontReady();
 
   if(!mRequestingLoad)
   {
-    SetImageFrameReady(textureId);
+    SetImageFrameReady(textureInformation.textureId);
 
     CheckFrontFrame(frontFrameReady);
   }
   else
   {
-    // UploadComplete has been called from within RequestLoad. TextureManager must
+    // LoadComplete has been called from within RequestLoad. TextureManager must
     // therefore already have the texture cached, so make the texture ready.
     // (Use the last texture, as the texture id hasn't been assigned yet)
     mReadyFlags.back() = true;
   }
 }
 
-void FixedImageCache::LoadComplete(
-  bool               loadSuccess,
-  Devel::PixelBuffer pixelBuffer,
-  const VisualUrl&   url,
-  bool               preMultiplied)
-{
-  // LoadComplete is called if this TextureUploadObserver requested to load
-  // an image that will be returned as a type of PixelBuffer by using a method
-  // TextureManager::LoadPixelBuffer.
-}
-
 } //namespace Internal
 } //namespace Toolkit
 } //namespace Dali
\ No newline at end of file
index 63212df060aeb92e1e16b030cf85fe6e9eefef2d..dc19937ed5eff33651b7bbac3e56c53ab0d5dba8 100644 (file)
@@ -110,19 +110,7 @@ private:
   void CheckFrontFrame(bool wasReady);
 
 protected:
-  void UploadComplete(
-    bool           loadSuccess,
-    int32_t        textureId,
-    TextureSet     textureSet,
-    bool           useAtlasing,
-    const Vector4& atlasRect,
-    bool           premultiplied) override;
-
-  void LoadComplete(
-    bool               loadSuccess,
-    Devel::PixelBuffer pixelBuffer,
-    const VisualUrl&   url,
-    bool               preMultiplied) override;
+  void LoadComplete(bool loadSuccess, TextureInformation textureInformation) override;
 
 private:
   std::vector<UrlStore>& mImageUrls;
index eba93412a8b17e04c4e47fe9fab832b38ab85f96..490c3bebda0548d0648d60b7519be13d7b88e9c9 100644 (file)
@@ -274,28 +274,22 @@ void RollingAnimatedImageCache::CheckFrontFrame(bool wasReady)
   }
 }
 
-void RollingAnimatedImageCache::UploadComplete(
-  bool           loadSuccess,
-  int32_t        textureId,
-  TextureSet     textureSet,
-  bool           useAtlasing,
-  const Vector4& atlasRect,
-  bool           preMultiplied)
+void RollingAnimatedImageCache::LoadComplete(bool loadSuccess, TextureInformation textureInformation)
 {
-  DALI_LOG_INFO(gAnimImgLogFilter, Debug::Concise, "AnimatedImageVisual::UploadComplete(textureId:%d) start\n", textureId);
+  DALI_LOG_INFO(gAnimImgLogFilter, Debug::Concise, "AnimatedImageVisual::LoadComplete(textureId:%d) start\n", textureInformation.textureId);
   LOG_CACHE;
 
   bool frontFrameReady = IsFrontReady();
 
   if(!mRequestingLoad)
   {
-    SetImageFrameReady(textureId);
+    SetImageFrameReady(textureInformation.textureId);
 
     CheckFrontFrame(frontFrameReady);
   }
   else
   {
-    // UploadComplete has been called from within RequestLoad. TextureManager must
+    // LoadComplete has been called from within RequestLoad. TextureManager must
     // therefore already have the texture cached, so make the texture ready.
     // (Use the last texture, as the texture id hasn't been assigned yet)
     mQueue.Back().mReady = true;
@@ -316,17 +310,6 @@ void RollingAnimatedImageCache::UploadComplete(
   LOG_CACHE;
 }
 
-void RollingAnimatedImageCache::LoadComplete(
-  bool               loadSuccess,
-  Devel::PixelBuffer pixelBuffer,
-  const VisualUrl&   url,
-  bool               preMultiplied)
-{
-  // LoadComplete is called if this TextureUploadObserver requested to load
-  // an image that will be returned as a type of PixelBuffer by using a method
-  // TextureManager::LoadPixelBuffer.
-}
-
 } //namespace Internal
 } //namespace Toolkit
 } //namespace Dali
index b1b4afcdbcb22217efce5e043217de65dc3d023b..e1d201b72ce6a3376460df8607e6b0f42c6643bd 100644 (file)
@@ -138,19 +138,7 @@ private:
   void CheckFrontFrame(bool wasReady);
 
 protected:
-  void UploadComplete(
-    bool           loadSuccess,
-    int32_t        textureId,
-    TextureSet     textureSet,
-    bool           useAtlasing,
-    const Vector4& atlasRect,
-    bool           preMultiplied) override;
-
-  void LoadComplete(
-    bool               loadSuccess,
-    Devel::PixelBuffer pixelBuffer,
-    const VisualUrl&   url,
-    bool               preMultiplied) override;
+  void LoadComplete(bool loadSuccess, TextureInformation textureInformation) override;
 
 private:
   /**
index 9bcf8e446f182e700a5b2940dc816f37f92ecbcd..caecf397f98140304f20ad8631075855ce6a996d 100644 (file)
@@ -190,9 +190,9 @@ void RollingImageCache::LoadBatch()
 
     mQueue.PushBack(imageFrame);
 
-    // Note, if the image is already loaded, then UploadComplete will get called
+    // Note, if the image is already loaded, then LoadComplete will get called
     // from within this method. This means it won't yet have a texture id, so we
-    // need to account for this inside the UploadComplete method using mRequestingLoad.
+    // need to account for this inside the LoadComplete method using mRequestingLoad.
     mRequestingLoad = true;
 
     bool                               synchronousLoading = false;
@@ -246,28 +246,22 @@ void RollingImageCache::CheckFrontFrame(bool wasReady)
   }
 }
 
-void RollingImageCache::UploadComplete(
-  bool           loadSuccess,
-  int32_t        textureId,
-  TextureSet     textureSet,
-  bool           useAtlasing,
-  const Vector4& atlasRect,
-  bool           preMultiplied)
+void RollingImageCache::LoadComplete(bool loadSuccess, TextureInformation textureInformation)
 {
-  DALI_LOG_INFO(gAnimImgLogFilter, Debug::Concise, "AnimatedImageVisual::UploadComplete(textureId:%d) start\n", textureId);
+  DALI_LOG_INFO(gAnimImgLogFilter, Debug::Concise, "AnimatedImageVisual::LoadComplete(textureId:%d) start\n", textureInformation.textureId);
   LOG_CACHE;
 
   bool frontFrameReady = IsFrontReady();
 
   if(!mRequestingLoad)
   {
-    SetImageFrameReady(textureId);
+    SetImageFrameReady(textureInformation.textureId);
 
     CheckFrontFrame(frontFrameReady);
   }
   else
   {
-    // UploadComplete has been called from within RequestLoad. TextureManager must
+    // LoadComplete has been called from within RequestLoad. TextureManager must
     // therefore already have the texture cached, so make the texture ready.
     // (Use the last texture, as the texture id hasn't been assigned yet)
     mQueue.Back().mReady = true;
@@ -276,17 +270,6 @@ void RollingImageCache::UploadComplete(
   LOG_CACHE;
 }
 
-void RollingImageCache::LoadComplete(
-  bool               loadSuccess,
-  Devel::PixelBuffer pixelBuffer,
-  const VisualUrl&   url,
-  bool               preMultiplied)
-{
-  // LoadComplete is called if this TextureUploadObserver requested to load
-  // an image that will be returned as a type of PixelBuffer by using a method
-  // TextureManager::LoadPixelBuffer.
-}
-
 } //namespace Internal
 } //namespace Toolkit
 } //namespace Dali
index 1fcbe88ccc0c0bd7be549275e639c723d7aef4b3..1490c4189b6d556c0c16489a80820e7baee96a87 100644 (file)
@@ -126,19 +126,7 @@ private:
   void CheckFrontFrame(bool wasReady);
 
 protected:
-  void UploadComplete(
-    bool           loadSuccess,
-    int32_t        textureId,
-    TextureSet     textureSet,
-    bool           useAtlasing,
-    const Vector4& atlasRect,
-    bool           preMultiplied) override;
-
-  void LoadComplete(
-    bool               loadSuccess,
-    Devel::PixelBuffer pixelBuffer,
-    const VisualUrl&   url,
-    bool               preMultiplied) override;
+  void LoadComplete(bool loadSuccess, TextureInformation textureInformation) override;
 
 private:
   /**
index 7676bf8eab41f729ee95b297265ea46add326751..39b18ee886f3812c67f969bbbc0651ad5feac130 100644 (file)
@@ -853,17 +853,17 @@ void ImageVisual::UploadCompleted()
 }
 
 // From Texture Manager
-void ImageVisual::UploadComplete(bool loadingSuccess, int32_t textureId, TextureSet textureSet, bool usingAtlas, const Vector4& atlasRectangle, bool preMultiplied)
+void ImageVisual::LoadComplete(bool loadingSuccess, TextureInformation textureInformation)
 {
   Toolkit::Visual::ResourceStatus resourceStatus;
   if(mImpl->mRenderer)
   {
-    if(usingAtlas)
+    if(textureInformation.useAtlasing)
     {
       mImpl->mRenderer.RegisterProperty(ATLAS_RECT_UNIFORM_NAME, mAtlasRect);
     }
 
-    EnablePreMultipliedAlpha(preMultiplied);
+    EnablePreMultipliedAlpha(textureInformation.preMultiplied);
 
     Actor actor = mPlacementActor.GetHandle();
     if(!loadingSuccess)
@@ -874,14 +874,14 @@ void ImageVisual::UploadComplete(bool loadingSuccess, int32_t textureId, Texture
         imageSize = actor.GetProperty(Actor::Property::SIZE).Get<Vector2>();
       }
       mFactoryCache.UpdateBrokenImageRenderer(mImpl->mRenderer, imageSize);
-      textureSet = mImpl->mRenderer.GetTextures();
+      textureInformation.textureSet = mImpl->mRenderer.GetTextures();
     }
     else
     {
       Sampler sampler = Sampler::New();
       sampler.SetWrapMode(mWrapModeU, mWrapModeV);
-      textureSet.SetSampler(0u, sampler);
-      mImpl->mRenderer.SetTextures(textureSet);
+      textureInformation.textureSet.SetSampler(0u, sampler);
+      mImpl->mRenderer.SetTextures(textureInformation.textureSet);
     }
 
     if(actor)
@@ -895,7 +895,7 @@ void ImageVisual::UploadComplete(bool loadingSuccess, int32_t textureId, Texture
   // Storing TextureSet needed when renderer staged.
   if(!mImpl->mRenderer)
   {
-    mTextures = textureSet;
+    mTextures = textureInformation.textureSet;
   }
 
   // Image loaded, set status regardless of staged status.
index 55fb59b265a2096bdb5a56c9badb2f4f7d7ba6d3..bc94ffb63b71a6d2a209c28c776248b6869215c0 100644 (file)
@@ -248,24 +248,14 @@ public:
   void UploadCompleted() override;
 
   /**
-   * @copydoc TextureUploadObserver::UploadCompleted
+   * @copydoc TextureUploadObserver::LoadCompleted
    *
    * To avoid rendering garbage pixels, renderer should be added to actor after the resources are ready.
    * This callback is the place to add the renderer as it would be called once the loading is finished.
    */
-  void UploadComplete(bool success, int32_t textureId, TextureSet textureSet, bool usingAtlas, const Vector4& atlasRectangle, bool preMultiplied) override;
+  void LoadComplete(bool success, TextureInformation textureInformation) override;
 
 private:
-  /**
-   * @copydoc TextureUploadObserver::LoadComplete
-   *
-   * To avoid rendering garbage pixels, renderer should be added to actor after the resources are ready.
-   * This callback is the place to add the renderer as it would be called once the PixelBuffer loading is finished.
-   */
-  void LoadComplete(bool loadSuccess, Devel::PixelBuffer pixelBuffer, const VisualUrl& url, bool preMultiplied) override
-  {
-  }
-
   /**
    * Allocate the mask data when a masking property is defined in the property map
    */
index cb144b83c95ab5d3a1444cb4b9d56c9d590a50b6..e8a60424b64aa5bb6f7fd2994ca96ba7f761c4bd 100644 (file)
@@ -224,11 +224,11 @@ void NPatchData::SetLoadedNPatchData(Devel::PixelBuffer& pixelBuffer, bool preMu
   mLoadingState = LoadingState::LOAD_COMPLETE;
 }
 
-void NPatchData::LoadComplete(bool loadSuccess, Devel::PixelBuffer pixelBuffer, const VisualUrl& url, bool preMultiplied)
+void NPatchData::LoadComplete(bool loadSuccess, TextureInformation textureInformation)
 {
   if(loadSuccess)
   {
-    SetLoadedNPatchData(pixelBuffer, preMultiplied);
+    SetLoadedNPatchData(textureInformation.pixelBuffer, textureInformation.preMultiplied);
   }
   else
   {
@@ -238,7 +238,7 @@ void NPatchData::LoadComplete(bool loadSuccess, Devel::PixelBuffer pixelBuffer,
   for(uint32_t index = 0; index < mObserverList.Count(); ++index)
   {
     TextureUploadObserver* observer = mObserverList[index];
-    observer->UploadComplete(loadSuccess, TextureManager::INVALID_TEXTURE_ID, mTextureSet, false, Vector4(), preMultiplied);
+    observer->LoadComplete(loadSuccess, TextureUploadObserver::TextureInformation(TextureUploadObserver::ReturnType::TEXTURE, TextureManager::INVALID_TEXTURE_ID, mTextureSet, false, Vector4(), textureInformation.preMultiplied));
   }
 }
 
index 7a052c4f47d3073898e7c7d0af72d940e62fac09..94d7f2b7d965f26d99e63504cd68f3141a63e4f5 100644 (file)
@@ -252,23 +252,13 @@ public:
   void SetLoadedNPatchData(Devel::PixelBuffer& pixelBuffer, bool preMultiplied);
 
 private:
-  /**
-   * @copydoc TextureUploadObserver::UploadCompleted
-   *
-   * To avoid rendering garbage pixels, renderer should be added to actor after the resources are ready.
-   * This callback is the place to add the renderer as it would be called once the loading is finished.
-   */
-  void UploadComplete(bool loadSuccess, int32_t textureId, TextureSet textureSet, bool useAtlasing, const Vector4& atlasRect, bool preMultiplied) override
-  {
-  }
-
   /**
    * @copydoc TextureUploadObserver::LoadComplete
    *
    * To avoid rendering garbage pixels, renderer should be added to actor after the resources are ready.
    * This callback is the place to add the renderer as it would be called once the loading is finished.
    */
-  void LoadComplete(bool loadSuccess, Devel::PixelBuffer pixelBuffer, const VisualUrl& url, bool preMultiplied) override;
+  void LoadComplete(bool loadSuccess, TextureInformation textureInformation) override;
 
 private:
   using ObserverListType = Dali::Vector<TextureUploadObserver*>;
index 1f48eca0937f9a9c9ddd87815c9705b79ba7c33a..b9e046a02e0793547a576806917df0e2dbc5ae9c 100644 (file)
@@ -777,32 +777,34 @@ void NPatchVisual::SetResource()
   }
 }
 
-void NPatchVisual::UploadComplete(bool loadSuccess, int32_t textureId, TextureSet textureSet, bool useAtlasing, const Vector4& atlasRect, bool preMultiplied)
+void NPatchVisual::LoadComplete(bool loadSuccess, TextureInformation textureInformation)
 {
-  EnablePreMultipliedAlpha(preMultiplied);
-  if(!loadSuccess)
+  if(textureInformation.returnType == TextureUploadObserver::ReturnType::TEXTURE)
   {
-    // Image loaded and ready to display
-    ResourceReady(Toolkit::Visual::ResourceStatus::FAILED);
-  }
-
-  if(mAuxiliaryPixelBuffer || !mAuxiliaryUrl.IsValid())
-  {
-    SetResource();
-  }
-}
+    EnablePreMultipliedAlpha(textureInformation.preMultiplied);
+    if(!loadSuccess)
+    {
+      // Image loaded and ready to display
+      ResourceReady(Toolkit::Visual::ResourceStatus::FAILED);
+    }
 
-void NPatchVisual::LoadComplete(bool loadSuccess, Devel::PixelBuffer pixelBuffer, const VisualUrl& url, bool preMultiplied)
-{
-  if(loadSuccess && url.GetUrl() == mAuxiliaryUrl.GetUrl())
-  {
-    mAuxiliaryPixelBuffer = pixelBuffer;
-    SetResource();
+    if(mAuxiliaryPixelBuffer || !mAuxiliaryUrl.IsValid())
+    {
+      SetResource();
+    }
   }
-  else
+  else  // for the ReturnType::PIXEL_BUFFER
   {
-    // Image loaded and ready to display
-    ResourceReady(Toolkit::Visual::ResourceStatus::FAILED);
+    if(loadSuccess && textureInformation.url == mAuxiliaryUrl.GetUrl())
+    {
+      mAuxiliaryPixelBuffer = textureInformation.pixelBuffer;
+      SetResource();
+    }
+    else
+    {
+      // Image loaded and ready to display
+      ResourceReady(Toolkit::Visual::ResourceStatus::FAILED);
+    }
   }
 }
 
index 02db5a4d69784f4ffc4acec01ec5429274f3c282..a266edc01693f45c7bdb5bda087f5e5dde4f6ba4 100644 (file)
@@ -207,20 +207,12 @@ private:
 
 private:
   /**
-   * @copydoc TextureUploadObserver::UploadCompleted
+   * @copydoc TextureUploadObserver::LoadCompleted
    *
    * To avoid rendering garbage pixels, renderer should be added to actor after the resources are ready.
    * This callback is the place to add the renderer as it would be called once the loading is finished.
    */
-  void UploadComplete(bool loadSuccess, int32_t textureId, TextureSet textureSet, bool useAtlasing, const Vector4& atlasRect, bool preMultiplied) override;
-
-  /**
-   * @copydoc TextureUploadObserver::LoadComplete
-   *
-   * To avoid rendering garbage pixels, renderer should be added to actor after the resources are ready.
-   * This callback is the place to add the renderer as it would be called once the loading is finished.
-   */
-  void LoadComplete(bool loadSuccess, Devel::PixelBuffer pixelBuffer, const VisualUrl& url, bool preMultiplied) override;
+  void LoadComplete(bool loadSuccess, TextureInformation textureInformation) override;
 
 private:
   WeakHandle<Actor>                         mPlacementActor; ///< Weakhandle to contain Actor during texture loading
index 49867c4f40f67fd39e260f36517c3c8ec78d7a85..3578ede2973b89b344eff9aaf88fd87fcb521091 100644 (file)
@@ -179,7 +179,7 @@ TextureSet TextureManager::LoadAnimatedImageTexture(
     TextureManager::LoadState loadState = GetTextureStateInternal(textureId);
     if(loadState == TextureManager::LoadState::UPLOADED)
     {
-      // UploadComplete has already been called - keep the same texture set
+      // LoadComplete has already been called - keep the same texture set
       textureSet = GetTextureSet(textureId);
     }
   }
@@ -330,7 +330,7 @@ TextureSet TextureManager::LoadTexture(
         TextureManager::LoadState loadState = GetTextureStateInternal(textureId);
         if(loadState == TextureManager::LoadState::UPLOADED)
         {
-          // UploadComplete has already been called - keep the same texture set
+          // LoadComplete has already been called - keep the same texture set
           textureSet = GetTextureSet(textureId);
         }
 
@@ -978,7 +978,7 @@ void TextureManager::LoadOrQueueTexture(TextureInfo& textureInfo, TextureUploadO
       {
         // The Texture has already loaded. The other observers have already been notified.
         // We need to send a "late" loaded notification for this observer.
-        observer->UploadComplete(true, textureInfo.textureId, textureInfo.textureSet, textureInfo.useAtlas, textureInfo.atlasRect, textureInfo.preMultiplied);
+        observer->LoadComplete(true, TextureUploadObserver::TextureInformation(TextureUploadObserver::ReturnType::TEXTURE, textureInfo.textureId, textureInfo.textureSet, textureInfo.useAtlas, textureInfo.atlasRect, textureInfo.preMultiplied));
       }
       break;
     }
@@ -1040,11 +1040,11 @@ void TextureManager::ProcessQueuedTextures()
       TextureInfo& textureInfo(mTextureInfoContainer[cacheIndex]);
       if(textureInfo.loadState == LoadState::UPLOADED)
       {
-        element.mObserver->UploadComplete(true, textureInfo.textureId, textureInfo.textureSet, textureInfo.useAtlas, textureInfo.atlasRect, textureInfo.preMultiplied);
+        element.mObserver->LoadComplete(true, TextureUploadObserver::TextureInformation(TextureUploadObserver::ReturnType::TEXTURE, textureInfo.textureId, textureInfo.textureSet, textureInfo.useAtlas, textureInfo.atlasRect, textureInfo.preMultiplied));
       }
       else if(textureInfo.loadState == LoadState::LOAD_FINISHED && textureInfo.storageType == StorageType::RETURN_PIXEL_BUFFER)
       {
-        element.mObserver->LoadComplete(true, textureInfo.pixelBuffer, textureInfo.url, textureInfo.preMultiplied);
+        element.mObserver->LoadComplete(true, TextureUploadObserver::TextureInformation(TextureUploadObserver::ReturnType::PIXEL_BUFFER, textureInfo.pixelBuffer, textureInfo.url.GetUrl(), textureInfo.preMultiplied));
       }
       else
       {
@@ -1266,7 +1266,7 @@ void TextureManager::NotifyObservers(TextureInfo& textureInfo, bool success)
   {
     TextureUploadObserver* observer = info->observerList[0];
 
-    // During UploadComplete() a Control ResourceReady() signal is emitted.
+    // During LoadComplete() a Control ResourceReady() signal is emitted.
     // During that signal the app may add remove /add Textures (e.g. via
     // ImageViews).
     // It is possible for observers to be removed from the observer list,
@@ -1284,11 +1284,11 @@ void TextureManager::NotifyObservers(TextureInfo& textureInfo, bool success)
 
     if(info->storageType == StorageType::RETURN_PIXEL_BUFFER)
     {
-      observer->LoadComplete(success, info->pixelBuffer, info->url, info->preMultiplied);
+      observer->LoadComplete(success, TextureUploadObserver::TextureInformation(TextureUploadObserver::ReturnType::PIXEL_BUFFER, info->pixelBuffer, info->url.GetUrl(), info->preMultiplied));
     }
     else
     {
-      observer->UploadComplete(success, info->textureId, info->textureSet, info->useAtlas, info->atlasRect, info->preMultiplied);
+      observer->LoadComplete(success, TextureUploadObserver::TextureInformation(TextureUploadObserver::ReturnType::TEXTURE, info->textureId, info->textureSet, info->useAtlas, info->atlasRect, info->preMultiplied));
     }
 
     // Get the textureInfo from the container again as it may have been invalidated.
index 7730d283ff7eab6e5dd3e76cfcd1d60de13d9541..7ca7a05f493e94e1ddf0dc8f1de595a1f73f23b5 100644 (file)
@@ -219,7 +219,7 @@ public:
    * @brief Requests an image load of the given URL.
    *
    * The parameters are used to specify how the image is loaded.
-   * The observer has the UploadComplete method called when the load is ready.
+   * The observer has the LoadComplete method called when the load is ready.
    *
    * When the client has finished with the Texture, Remove() should be called.
    *
@@ -276,7 +276,7 @@ public:
    * @brief Requests an image load of the given URL.
    *
    * The parameters are used to specify how the image is loaded.
-   * The observer has the UploadComplete method called when the load is ready.
+   * The observer has the LoadComplete method called when the load is ready.
    *
    * When the client has finished with the Texture, Remove() should be called.
    *
@@ -311,7 +311,7 @@ public:
    * the blended texture.
    *
    * The parameters are used to specify how the image is loaded.
-   * The observer has the UploadComplete method called when the load is ready.
+   * The observer has the LoadComplete method called when the load is ready.
    *
    * When the client has finished with the Texture, Remove() should be called.
    *
@@ -469,7 +469,7 @@ private:
    * CPU blend with the mask, and upload the blend texture.
    *
    * The parameters are used to specify how the image is loaded.
-   * The observer has the UploadComplete method called when the load is ready.
+   * The observer has the LoadComplete method called when the load is ready.
    *
    * When the client has finished with the Texture, Remove() should be called.
    *
@@ -751,12 +751,6 @@ private:
    */
   bool CreateTiledGeometry(const Devel::PixelBuffer& pixelBuffer, TextureInfo& textureInfo);
 
-  /**
-   * Mark the texture as complete, and inform observers
-   * @param[in] textureInfo The struct associated with this Texture
-   */
-  void UploadComplete(TextureInfo& textureInfo);
-
   /**
    * Notify the current observers that the texture upload is complete,
    * then remove the observers from the list.
index 5c46ff2133219e29e6ed75234da3d079a389f987..6e18175e1e766fc498b5c00ddf9ecc2edc91f678 100644 (file)
 // CLASS HEADER
 #include "texture-upload-observer.h"
 
+// INTERNAL INCLUDES
+#include <dali-toolkit/internal/visuals/texture-manager-impl.h>
+
 namespace Dali
 {
 namespace Toolkit
 {
+TextureUploadObserver::TextureInformation::TextureInformation(ReturnType returnType, int32_t textureId, TextureSet textureSet, bool useAtlasing, const Vector4& atlasRect, bool preMultiplied)
+: returnType(returnType),
+  textureId(textureId),
+  textureSet(textureSet),
+  useAtlasing(useAtlasing),
+  atlasRect(atlasRect),
+  preMultiplied(preMultiplied),
+  pixelBuffer(),
+  url()
+{
+}
+
+TextureUploadObserver::TextureInformation::TextureInformation(ReturnType returnType, Devel::PixelBuffer pixelBuffer, const std::string& url, bool preMultiplied)
+: returnType(returnType),
+  textureId(Internal::TextureManager::INVALID_TEXTURE_ID),
+  textureSet(),
+  useAtlasing(false),
+  atlasRect(Vector4::ZERO),
+  preMultiplied(preMultiplied),
+  pixelBuffer(pixelBuffer),
+  url(url)
+{
+}
+
 TextureUploadObserver::TextureUploadObserver()
 {
 }
index d6657a27c0c802c23de77395b273bfaf0b508bd8..4bb21e8423778de8f3ed90c8d470023e4ed9cb91 100644 (file)
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
 #include <dali/public-api/signals/dali-signal.h>
+#include <dali/public-api/rendering/texture-set.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/visuals/visual-url.h>
 
 namespace Dali
 {
-class TextureSet;
 
 namespace Toolkit
 {
 /**
  * @brief Base class used to observe the upload status of a texture.
  *
- * Derived class must implement the UploadComplete method which is
+ * Derived class must implement the LoadComplete method which is
  * executed once the texture is ready to draw.
  */
 class TextureUploadObserver
@@ -43,6 +43,30 @@ class TextureUploadObserver
 public:
   typedef Signal<void(TextureUploadObserver*)> DestructionSignalType; ///< Signal prototype for the Destruction Signal.
 
+  enum class ReturnType
+  {
+    TEXTURE = 0,
+    PIXEL_BUFFER
+  };
+
+  struct TextureInformation
+  {
+    TextureInformation(ReturnType returnType, int32_t textureId, TextureSet textureSet, bool useAtlasing, const Vector4& atlasRect, bool preMultiplied);
+    TextureInformation(ReturnType returnType, Devel::PixelBuffer pixelBuffer, const std::string& url, bool preMultiplied);
+
+    TextureInformation();
+
+    ReturnType                 returnType;    ///< Returned Texture type.
+    int32_t                    textureId;     ///< The textureId of the loaded texture in the TextureManager
+    TextureSet                 textureSet;    ///< The TextureSet containing the Texture
+    bool                       useAtlasing;   ///< True if atlasing was used (note: this may be different to what was requested)
+    const Vector4&             atlasRect;     ///< If using atlasing, this is the rectangle within the atlas to use.
+    bool                       preMultiplied; ///< True if the image had pre-multiplied alpha applied
+    Devel::PixelBuffer         pixelBuffer;   ///< The PixelBuffer of the loaded image.
+    std::string_view           url;           ///< The url address of the loaded image.
+  };
+
+public:
   /**
    * @brief Constructor.
    */
@@ -53,29 +77,15 @@ public:
    */
   virtual ~TextureUploadObserver();
 
-  /**
-   * The action to be taken once the async load has finished and the upload to GPU is completed.
-   * This should be overridden by the deriving class.
-   *
-   * @param[in] loadSuccess True if the texture load was successful (i.e. the resource is available). If false, then the resource failed to load. In future, this will automatically upload a "broken" image.
-   * @param[in] textureId   The textureId of the loaded texture in the TextureManager
-   * @param[in] textureSet  The TextureSet containing the Texture
-   * @param[in] useAtlasing True if atlasing was used (note: this may be different to what was requested)
-   * @param[in] atlasRect   If using atlasing, this is the rectangle within the atlas to use.
-   * @param[in] preMultiplied True if the image had pre-multiplied alpha applied
-   */
-  virtual void UploadComplete(bool loadSuccess, int32_t textureId, TextureSet textureSet, bool useAtlasing, const Vector4& atlasRect, bool preMultiplied) = 0;
-
   /**
    * The action to be taken once the async load has finished.
+   * And in case of texture loading, this method is called after uploading.
    * This should be overridden by the deriving class.
    *
-   * @param[in] loadSuccess   True if the image load was successful (i.e. the resource is available). If false, then the resource failed to load.
-   * @param[in] pixelBuffer   The PixelBuffer of the loaded image.
-   * @param[in] url           The url address of the loaded image.
-   * @param[in] preMultiplied True if the image had pre-multiplied alpha applied
+   * @param[in] loadSuccess True if the texture load was successful (i.e. the resource is available). If false, then the resource failed to load. In future, this will automatically upload a "broken" image.
+   * @param[in] textureInformation Structure that contains loaded texture information.
    */
-  virtual void LoadComplete(bool loadSuccess, Devel::PixelBuffer pixelBuffer, const Internal::VisualUrl& url, bool preMultiplied) = 0;
+  virtual void LoadComplete(bool loadSuccess, TextureInformation textureInformation) = 0;
 
   /**
    * @brief Returns the destruction signal.