Revert "[Tizen] Add Asynchronous loading for Model and SceneView"
authortscholb <scholb.kim@samsung.com>
Wed, 2 Nov 2022 07:51:56 +0000 (16:51 +0900)
committertscholb <scholb.kim@samsung.com>
Wed, 2 Nov 2022 07:51:56 +0000 (16:51 +0900)
This reverts commit 70f10889bc6e8c08b061a3c8e092932504b427c5.

dali-scene3d/internal/controls/model/model-impl.cpp
dali-scene3d/internal/controls/model/model-impl.h
dali-scene3d/internal/controls/scene-view/scene-view-impl.cpp
dali-scene3d/internal/controls/scene-view/scene-view-impl.h
dali-scene3d/public-api/controls/model/model.cpp
dali-scene3d/public-api/controls/model/model.h

index 3a6b11d..24e7af5 100644 (file)
@@ -23,7 +23,6 @@
 #include <dali-toolkit/internal/controls/control/control-data-impl.h>
 #include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 #include <dali/devel-api/actors/actor-devel.h>
-#include <dali/integration-api/adaptor-framework/adaptor.h>
 #include <dali/integration-api/debug.h>
 #include <dali/public-api/object/type-registry-helper.h>
 #include <dali/public-api/object/type-registry.h>
@@ -180,8 +179,6 @@ Model::Model(const std::string& modelUrl, const std::string& resourceDirectoryUr
   mModelUrl(modelUrl),
   mResourceDirectoryUrl(resourceDirectoryUrl),
   mModelRoot(),
-  mModelLoadedCallback(nullptr),
-  mIblLoadedCallback(nullptr),
   mNaturalSize(Vector3::ZERO),
   mModelPivot(AnchorPoint::CENTER),
   mIblScaleFactor(1.0f),
@@ -193,17 +190,6 @@ Model::Model(const std::string& modelUrl, const std::string& resourceDirectoryUr
 
 Model::~Model()
 {
-  if(mModelLoadedCallback && Adaptor::IsAvailable())
-  {
-    // Removes the callback from the callback manager in case the control is destroyed before the callback is executed.
-    Adaptor::Get().RemoveIdle(mModelLoadedCallback);
-  }
-
-  if(mIblLoadedCallback && Adaptor::IsAvailable())
-  {
-    // Removes the callback from the callback manager in case the control is destroyed before the callback is executed.
-    Adaptor::Get().RemoveIdle(mIblLoadedCallback);
-  }
 }
 
 Dali::Scene3D::Model Model::New(const std::string& modelUrl, const std::string& resourceDirectoryUrl)
@@ -243,16 +229,17 @@ bool Model::GetChildrenSensitive() const
 
 void Model::SetImageBasedLightSource(const std::string& diffuseUrl, const std::string& specularUrl, float scaleFactor)
 {
-  // Request asynchronous model loading
-  if(!mIblLoadedCallback)
+  mIBLResourceReady       = false;
+  Texture diffuseTexture  = Dali::Scene3D::Loader::LoadCubeMap(diffuseUrl);
+  Texture specularTexture = Dali::Scene3D::Loader::LoadCubeMap(specularUrl);
+  SetImageBasedLightTexture(diffuseTexture, specularTexture, scaleFactor);
+  mIBLResourceReady = true;
+
+  // If Model resource is already ready, then set resource ready.
+  // If Model resource is still not ready, wait for model resource ready.
+  if(IsResourceReady())
   {
-    mIBLResourceReady = false;
-    mDiffuseIblUrl    = diffuseUrl;
-    mSpecularIblUrl   = specularUrl;
-    mIblScaleFactor   = scaleFactor;
-    // The callback manager takes the ownership of the callback object.
-    mIblLoadedCallback = MakeCallback(this, &Model::OnLoadComplete);
-    Adaptor::Get().AddIdle(mIblLoadedCallback, false);
+    SetResourceReady(false);
   }
 }
 
@@ -329,14 +316,7 @@ void Model::OnSceneConnection(int depth)
 {
   if(!mModelRoot)
   {
-    // Request asynchronous model loading
-    if(!mModelLoadedCallback)
-    {
-      mModelResourceReady = false;
-      // The callback manager takes the ownership of the callback object.
-      mModelLoadedCallback = MakeCallback(this, &Model::OnLoadComplete);
-      Adaptor::Get().AddIdle(mModelLoadedCallback, false);
-    }
+    LoadModel();
   }
 
   Actor parent = Self().GetParent();
@@ -370,8 +350,7 @@ Vector3 Model::GetNaturalSize()
 {
   if(!mModelRoot)
   {
-    DALI_LOG_ERROR("Model is still not loaded.\n");
-    return Vector3::ZERO;
+    LoadModel();
   }
 
   return mNaturalSize;
@@ -530,13 +509,10 @@ void Model::LoadModel()
 
   Self().SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
   Self().SetProperty(Dali::Actor::Property::ANCHOR_POINT, Vector3(mModelPivot.x, 1.0f - mModelPivot.y, mModelPivot.z));
-}
 
-void Model::LoadImageBasedLight()
-{
-  Texture diffuseTexture  = Dali::Scene3D::Loader::LoadCubeMap(mDiffuseIblUrl);
-  Texture specularTexture = Dali::Scene3D::Loader::LoadCubeMap(mSpecularIblUrl);
-  SetImageBasedLightTexture(diffuseTexture, specularTexture, mIblScaleFactor);
+  mModelResourceReady = true;
+
+  Control::SetResourceReady(false);
 }
 
 void Model::ScaleModel()
@@ -633,37 +609,6 @@ void Model::UpdateImageBasedLightScaleFactor()
   }
 }
 
-void Model::OnLoadComplete()
-{
-  // TODO: In this implementation, we cannot know which request occurs this OnLoadComplete Callback.
-  // Currently it is no problem because the all loading is processed in this method.
-
-  // Prevent to emit unnecessary resource ready signal.
-  if(IsResourceReady())
-  {
-    return;
-  }
-
-  if(!mIBLResourceReady)
-  {
-    LoadImageBasedLight();
-    mIBLResourceReady  = true;
-    mIblLoadedCallback = nullptr;
-  }
-
-  if(!mModelResourceReady)
-  {
-    LoadModel();
-    mModelResourceReady  = true;
-    mModelLoadedCallback = nullptr;
-  }
-
-  if(IsResourceReady())
-  {
-    Control::SetResourceReady(false);
-  }
-}
-
 } // namespace Internal
 } // namespace Scene3D
 } // namespace Dali
index a037c93..3db9c57 100644 (file)
@@ -155,11 +155,6 @@ private:
   void LoadModel();
 
   /**
-   * @brief Loads image based light from file.
-   */
-  void LoadImageBasedLight();
-
-  /**
    * @brief Scales the model to fit the control or to return to original size.
    */
   void ScaleModel();
@@ -184,11 +179,6 @@ private:
    */
   void UpdateImageBasedLightScaleFactor();
 
-  /**
-   * @brief Asynchronously loading finished.
-   */
-  void OnLoadComplete();
-
 private:
   std::string                    mModelUrl;
   std::string                    mResourceDirectoryUrl;
@@ -197,11 +187,6 @@ private:
   std::vector<WeakHandle<Actor>> mRenderableActors;
   WeakHandle<Scene3D::SceneView> mParentSceneView;
 
-  CallbackBase* mModelLoadedCallback;
-  CallbackBase* mIblLoadedCallback;
-  std::string   mDiffuseIblUrl;
-  std::string   mSpecularIblUrl;
-
   Dali::Texture mSpecularTexture;
   Dali::Texture mDiffuseTexture;
   Vector3       mNaturalSize;
index 61962b5..08afa17 100644 (file)
@@ -26,7 +26,6 @@
 #include <dali-toolkit/public-api/image-loader/image-url.h>
 #include <dali-toolkit/public-api/image-loader/image.h>
 #include <dali/devel-api/common/stage.h>
-#include <dali/integration-api/adaptor-framework/adaptor.h>
 #include <dali/integration-api/debug.h>
 #include <dali/public-api/object/type-registry-helper.h>
 #include <dali/public-api/object/type-registry.h>
@@ -61,19 +60,11 @@ Property::Index RENDERING_BUFFER = Dali::Toolkit::Control::CONTROL_PROPERTY_END_
 } // anonymous namespace
 
 SceneView::SceneView()
-: Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT)),
-  mIblLoadedCallback(nullptr)
+: Control(ControlBehaviour(CONTROL_BEHAVIOUR_DEFAULT))
 {
 }
 
-SceneView::~SceneView()
-{
-  if(mIblLoadedCallback && Adaptor::IsAvailable())
-  {
-    // Removes the callback from the callback manager in case the control is destroyed before the callback is executed.
-    Adaptor::Get().RemoveIdle(mIblLoadedCallback);
-  }
-}
+SceneView::~SceneView() = default;
 
 Dali::Scene3D::SceneView SceneView::New()
 {
@@ -197,17 +188,28 @@ void SceneView::UnregisterModel(Scene3D::Model model)
 
 void SceneView::SetImageBasedLightSource(const std::string& diffuseUrl, const std::string& specularUrl, float scaleFactor)
 {
-  // Request asynchronous model loading
-  if(!mIblLoadedCallback)
+  mIBLResourceReady = false;
+  Texture diffuseTexture = Dali::Scene3D::Loader::LoadCubeMap(diffuseUrl);
+  if(diffuseTexture)
   {
-    mIBLResourceReady = false;
-    mDiffuseIblUrl    = diffuseUrl;
-    mSpecularIblUrl   = specularUrl;
-    mIblScaleFactor   = scaleFactor;
-    // The callback manager takes the ownership of the callback object.
-    mIblLoadedCallback = MakeCallback(this, &SceneView::OnLoadComplete);
-    Adaptor::Get().AddIdle(mIblLoadedCallback, false);
+    Texture specularTexture = Dali::Scene3D::Loader::LoadCubeMap(specularUrl);
+    if(specularTexture)
+    {
+      mDiffuseTexture  = diffuseTexture;
+      mSpecularTexture = specularTexture;
+      mIblScaleFactor  = scaleFactor;
+
+      for(auto&& model : mModels)
+      {
+        if(model)
+        {
+          model.SetImageBasedLightTexture(mDiffuseTexture, mSpecularTexture, mIblScaleFactor);
+        }
+      }
+    }
   }
+  mIBLResourceReady = true;
+  Control::SetResourceReady(false);
 }
 
 void SceneView::SetImageBasedLightScaleFactor(float scaleFactor)
@@ -352,14 +354,14 @@ void SceneView::UpdateRenderTask()
       mRenderTask.SetCameraActor(mSelectedCamera);
     }
 
-    Vector3     size        = Self().GetProperty<Vector3>(Dali::Actor::Property::SIZE);
+    Vector3 size = Self().GetProperty<Vector3>(Dali::Actor::Property::SIZE);
     const float aspectRatio = size.width / size.height;
     mSelectedCamera.SetAspectRatio(aspectRatio);
-    const float halfHeight                                              = mSelectedCamera[Dali::CameraActor::Property::TOP_PLANE_DISTANCE];
-    const float halfWidth                                               = aspectRatio * halfHeight;
+    const float halfHeight = mSelectedCamera[Dali::CameraActor::Property::TOP_PLANE_DISTANCE];
+    const float halfWidth = aspectRatio * halfHeight;
     mSelectedCamera[Dali::CameraActor::Property::LEFT_PLANE_DISTANCE]   = -halfWidth;
     mSelectedCamera[Dali::CameraActor::Property::RIGHT_PLANE_DISTANCE]  = halfWidth;
-    mSelectedCamera[Dali::CameraActor::Property::TOP_PLANE_DISTANCE]    = halfHeight;  // Top is +ve to keep consistency with orthographic values
+    mSelectedCamera[Dali::CameraActor::Property::TOP_PLANE_DISTANCE]    = halfHeight; // Top is +ve to keep consistency with orthographic values
     mSelectedCamera[Dali::CameraActor::Property::BOTTOM_PLANE_DISTANCE] = -halfHeight; // Bottom is -ve to keep consistency with orthographic values
     if(mUseFrameBuffer)
     {
@@ -410,53 +412,6 @@ void SceneView::UpdateRenderTask()
   }
 }
 
-void SceneView::LoadImageBasedLight()
-{
-  Texture diffuseTexture  = Dali::Scene3D::Loader::LoadCubeMap(mDiffuseIblUrl);
-  Texture specularTexture = Dali::Scene3D::Loader::LoadCubeMap(mSpecularIblUrl);
-
-  if(diffuseTexture)
-  {
-    if(specularTexture)
-    {
-      mDiffuseTexture  = diffuseTexture;
-      mSpecularTexture = specularTexture;
-
-      for(auto&& model : mModels)
-      {
-        if(model)
-        {
-          model.SetImageBasedLightTexture(mDiffuseTexture, mSpecularTexture, mIblScaleFactor);
-        }
-      }
-    }
-  }
-}
-
-void SceneView::OnLoadComplete()
-{
-  // TODO: In this implementation, we cannot know which request occurs this OnLoadComplete Callback.
-  // Currently it is no problem because the all loading is processed in this method.
-
-  // Prevent to emit unnecessary resource ready signal.
-  if(IsResourceReady())
-  {
-    return;
-  }
-
-  if(!mIBLResourceReady)
-  {
-    LoadImageBasedLight();
-    mIBLResourceReady  = true;
-    mIblLoadedCallback = nullptr;
-  }
-
-  if(IsResourceReady())
-  {
-    Control::SetResourceReady(false);
-  }
-}
-
 } // namespace Internal
 } // namespace Scene3D
 } // namespace Dali
index 07ceda4..ddd7319 100644 (file)
@@ -30,8 +30,8 @@
 #include <dali/public-api/rendering/texture.h>
 
 // INTERNAL INCLUDES
-#include <dali-scene3d/public-api/controls/model/model.h>
 #include <dali-scene3d/public-api/controls/scene-view/scene-view.h>
+#include <dali-scene3d/public-api/controls/model/model.h>
 
 namespace Dali
 {
@@ -204,16 +204,6 @@ private:
    */
   void UpdateRenderTask();
 
-  /**
-   * @brief Loads image based light from file.
-   */
-  void LoadImageBasedLight();
-
-  /**
-   * @brief Asynchronously loading finished.
-   */
-  void OnLoadComplete();
-
 private:
   Toolkit::Visual::Base mVisual;
 
@@ -227,11 +217,8 @@ private:
   Dali::Texture               mTexture;
   Dali::RenderTask            mRenderTask;
 
-  CallbackBase* mIblLoadedCallback;
-  std::string   mDiffuseIblUrl;
-  std::string   mSpecularIblUrl;
+  Layer mRootLayer;
 
-  Layer         mRootLayer;
   Dali::Texture mSpecularTexture;
   Dali::Texture mDiffuseTexture;
   float         mIblScaleFactor{1.0f};
index 41ecb92..69029d9 100644 (file)
@@ -25,7 +25,9 @@ namespace Dali
 {
 namespace Scene3D
 {
-Model::Model() = default;
+Model::Model()
+{
+}
 
 Model::Model(const Model& model) = default;
 
@@ -35,7 +37,9 @@ Model& Model::operator=(const Model& model) = default;
 
 Model& Model::operator=(Model&& rhs) = default;
 
-Model::~Model() = default;
+Model::~Model()
+{
+}
 
 Model Model::New(const std::string& modelUrl, const std::string& resourceDirectoryUrl)
 {
index acdc447..104e054 100644 (file)
@@ -188,7 +188,6 @@ public:
 
   /**
    * @brief Sets Image Based Light Texture.
-   * @note This method doesn't load texture from file, so this work is performed synchronously.
    *
    * @SINCE_2_1.41
    * @param[in] diffuseTexture cube map texture that can be used as a diffuse IBL source.