Revert "[Tizen] Add ResourceReady for Control"
authorTaehyub Kim <taehyub.kim@samsung.com>
Wed, 14 Sep 2022 02:38:33 +0000 (11:38 +0900)
committerTaehyub Kim <taehyub.kim@samsung.com>
Wed, 14 Sep 2022 02:38:33 +0000 (11:38 +0900)
This reverts commit 2b234125bbf3b4b993a4b4872cff363359ea966a.

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

index 464b447..61a5303 100644 (file)
@@ -20,6 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <dali-toolkit/dali-toolkit.h>
+#include <dali-toolkit/devel-api/controls/control-devel.h>
 #include <dali-toolkit/internal/controls/control/control-data-impl.h>
 #include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
 #include <dali/integration-api/debug.h>
@@ -28,8 +29,8 @@
 #include <filesystem>
 
 // INTERNAL INCLUDES
-#include <dali-scene3d/internal/controls/scene-view/scene-view-impl.h>
 #include <dali-scene3d/public-api/controls/model-view/model-view.h>
+#include <dali-scene3d/internal/controls/scene-view/scene-view-impl.h>
 #include <dali-scene3d/public-api/loader/animation-definition.h>
 #include <dali-scene3d/public-api/loader/camera-parameters.h>
 #include <dali-scene3d/public-api/loader/cube-map-loader.h>
@@ -180,9 +181,7 @@ ModelView::ModelView(const std::string& modelPath, const std::string& resourcePa
   mModelPivot(AnchorPoint::CENTER),
   mIblScaleFactor(1.0f),
   mFitSize(true),
-  mFitCenter(true),
-  mModelResourceReady(false),
-  mIBLResourceReady(false)
+  mFitCenter(true)
 {
 }
 
@@ -222,18 +221,9 @@ void ModelView::FitCenter(bool fit)
 
 void ModelView::SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor)
 {
-  mIBLResourceReady = false;
   Texture diffuseTexture  = Dali::Scene3D::Loader::LoadCubeMap(diffuse);
   Texture specularTexture = Dali::Scene3D::Loader::LoadCubeMap(specular);
   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())
-  {
-    SetResourceReady();
-  }
 }
 
 void ModelView::SetImageBasedLightTexture(Dali::Texture diffuse, Dali::Texture specular, float scaleFactor)
@@ -349,11 +339,6 @@ void ModelView::OnRelayout(const Vector2& size, RelayoutContainer& container)
   ScaleModel();
 }
 
-bool ModelView::IsResourceReady() const
-{
-  return mModelResourceReady && mIBLResourceReady;
-}
-
 void ModelView::LoadModel()
 {
   std::filesystem::path modelPath(mModelPath);
@@ -479,11 +464,6 @@ void ModelView::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));
-
-  mModelResourceReady = true;
-  mIBLResourceReady   = true;
-
-  Control::SetResourceReady();
 }
 
 void ModelView::ScaleModel()
index 2ec360f..10d04f2 100644 (file)
@@ -135,11 +135,6 @@ private:
   void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
 
   /**
-   * @copydoc Toolkit::Control::IsResourceReady()
-   */
-  bool IsResourceReady() const override;
-
-  /**
    * @brief Loads a model from file
    */
   void LoadModel();
@@ -179,8 +174,6 @@ private:
   float         mIblScaleFactor;
   bool          mFitSize;
   bool          mFitCenter;
-  bool          mModelResourceReady;
-  bool          mIBLResourceReady;
 };
 
 } // namespace Internal
index ce4ae17..659dd5a 100644 (file)
@@ -83,13 +83,6 @@ void SceneView::AddCamera(CameraActor camera)
 {
   if(camera)
   {
-    {
-      // To do not change camera properties during OnScene in CameraActor
-      // TODO: this will be removed after CameraActor is fixed.
-      Vector3     size        = Self().GetProperty<Vector3>(Dali::Actor::Property::SIZE);
-      const float aspectRatio = (size.height > 0.1f) ? size.width / size.height : 1.0f;
-      camera.SetAspectRatio(aspectRatio);
-    }
     if(mCameras.empty())
     {
       UpdateCamera(camera);
@@ -195,7 +188,6 @@ void SceneView::UnregisterModelView(Scene3D::ModelView modelView)
 
 void SceneView::SetImageBasedLightSource(const std::string& diffuse, const std::string& specular, float scaleFactor)
 {
-  mIBLResourceReady = false;
   Texture diffuseTexture = Dali::Scene3D::Loader::LoadCubeMap(diffuse);
   if(diffuseTexture)
   {
@@ -215,8 +207,6 @@ void SceneView::SetImageBasedLightSource(const std::string& diffuse, const std::
       }
     }
   }
-  mIBLResourceReady = true;
-  Control::SetResourceReady();
 }
 
 void SceneView::UseFramebuffer(bool useFramebuffer)
@@ -274,11 +264,6 @@ void SceneView::OnInitialize()
   mDefaultCamera.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
   mDefaultCamera.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
   mDefaultCamera.SetNearClippingPlane(1.0f);
-  {
-    // To do not change camera properties during OnScene in CameraActor
-    // TODO: this will be removed after CameraActor is fixed.
-    mDefaultCamera.SetAspectRatio(1.0f);
-  }
   AddCamera(mDefaultCamera);
   UpdateCamera(mDefaultCamera);
 }
@@ -319,11 +304,6 @@ void SceneView::OnRelayout(const Vector2& size, RelayoutContainer& container)
   UpdateRenderTask();
 }
 
-bool SceneView::IsResourceReady() const
-{
-  return mIBLResourceReady;
-}
-
 void SceneView::UpdateCamera(CameraActor camera)
 {
   if(camera)
@@ -349,16 +329,25 @@ void SceneView::UpdateRenderTask()
     }
 
     Vector3 size = Self().GetProperty<Vector3>(Dali::Actor::Property::SIZE);
-    const float aspectRatio = size.width / size.height;
-    mSelectedCamera.SetAspectRatio(aspectRatio);
-    const float fov = mSelectedCamera[Dali::CameraActor::Property::FIELD_OF_VIEW];
-    const float near = mSelectedCamera[Dali::CameraActor::Property::NEAR_PLANE_DISTANCE];
-    const float halfHeight = tanf(fov/2) * near;
-    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::BOTTOM_PLANE_DISTANCE] = -halfHeight; // Bottom is -ve to keep consistency with orthographic values
+    float   fov  = 0.0f;
+    Vector3 cameraPosition(Vector3::ZERO);
+    float   nearPlain = 1.0f;
+    float   farPlain  = 1.0f;
+
+    // Several properties such as fov, nearPlane, farPlane, and position should not be changed after SetPerspectiveProjection is called.
+    // In the 3D scene, the properties are not changed by the changes of canvas size.
+    fov            = mSelectedCamera[Dali::CameraActor::Property::FIELD_OF_VIEW];
+    nearPlain      = mSelectedCamera[Dali::CameraActor::Property::NEAR_PLANE_DISTANCE];
+    farPlain       = mSelectedCamera[Dali::CameraActor::Property::FAR_PLANE_DISTANCE];
+    cameraPosition = Vector3(mSelectedCamera[Dali::Actor::Property::POSITION]);
+
+    mSelectedCamera.SetPerspectiveProjection(Dali::Size(size));
+
+    mSelectedCamera[Dali::CameraActor::Property::FIELD_OF_VIEW]       = fov;
+    mSelectedCamera[Dali::CameraActor::Property::NEAR_PLANE_DISTANCE] = nearPlain;
+    mSelectedCamera[Dali::CameraActor::Property::FAR_PLANE_DISTANCE]  = farPlain;
+    mSelectedCamera[Dali::Actor::Property::POSITION]                  = cameraPosition;
+
     if(mUseFrameBuffer)
     {
       Dali::FrameBuffer currentFrameBuffer = mRenderTask.GetFrameBuffer();
index e3de91e..724bc7d 100644 (file)
@@ -178,11 +178,6 @@ private:
   void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
 
   /**
-   * @copydoc Toolkit::Control::IsResourceReady()
-   */
-  bool IsResourceReady() const override;
-
-  /**
    * @brief Changes main camera as a input camera
    *
    * @param camera CameraActor that will be a main camera of the SceneView
@@ -213,7 +208,6 @@ private:
   Dali::Texture mDiffuseTexture;
   float         mIblScaleFactor{1.0f};
   bool          mUseFrameBuffer{false};
-  bool          mIBLResourceReady{true};
 
   // TODO : Light Source
 };
index 37a51df..4c74704 100644 (file)
@@ -910,25 +910,6 @@ void Control::Impl::StartObservingVisual(Toolkit::Visual::Base& visual)
 }
 
 // Called by a Visual when it's resource is ready
-void Control::Impl::ResourceReady()
-{
-  Actor self = mControlImpl.Self();
-  // A visual is ready so control may need relayouting if staged
-  if(self.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE))
-  {
-    mControlImpl.RelayoutRequest();
-  }
-
-  // Emit signal if all enabled visuals registered by the control are ready.
-  if(IsResourceReady())
-  {
-    // Reset the flag
-    mNeedToEmitResourceReady = false;
-    EmitResourceReadySignal();
-  }
-}
-
-// Called by a Visual when it's resource is ready
 void Control::Impl::ResourceReady(Visual::Base& object)
 {
   DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Control::Impl::ResourceReady() replacements pending[%d]\n", mRemoveVisuals.Count());
@@ -957,7 +938,20 @@ void Control::Impl::ResourceReady(Visual::Base& object)
     }
   }
 
-  ResourceReady();
+  // A visual is ready so control may need relayouting if staged
+  if(self.GetProperty<bool>(Actor::Property::CONNECTED_TO_SCENE))
+  {
+    mControlImpl.RelayoutRequest();
+  }
+
+  // Emit signal if all enabled visuals registered by the control are ready.
+  if(IsResourceReady())
+  {
+    // Reset the flag
+    mNeedToEmitResourceReady = false;
+
+    EmitResourceReadySignal();
+  }
 }
 
 void Control::Impl::NotifyVisualEvent(Visual::Base& object, Property::Index signalId)
index d242053..46cc97b 100644 (file)
@@ -126,11 +126,6 @@ public:
   void LongPressDetected(Actor actor, const LongPressGesture& longPress);
 
   /**
-   * @brief Called when resources of control are ready.
-   */
-  void ResourceReady();
-
-  /**
    * @brief Called when a resource is ready.
    * @param[in] object The visual whose resources are ready
    * @note Overriding method in Visual::EventObserver.
index 6638121..60efa05 100644 (file)
@@ -167,12 +167,6 @@ void Control::ClearBackground()
   RelayoutRequest();
 }
 
-void Control::SetResourceReady()
-{
-  Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(*this);
-  controlDataImpl.ResourceReady();
-}
-
 Toolkit::DevelControl::ControlAccessible* Control::GetAccessibleObject()
 {
   return mImpl->GetAccessibleObject();
@@ -456,12 +450,6 @@ void Control::OnInitialize()
 {
 }
 
-bool Control::IsResourceReady() const
-{
-  const Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(*this);
-  return controlDataImpl.IsResourceReady();
-}
-
 void Control::OnStyleChange(Toolkit::StyleManager styleManager, StyleChange::Type change)
 {
   // By default the control is only interested in theme (not font) changes
index 568d5e3..9ccb533 100644 (file)
@@ -115,11 +115,6 @@ public:
    */
   void ClearBackground();
 
-  /**
-   * @brief Called when resources of control are ready.
-   */
-  void SetResourceReady();
-
   // Accessibility
 
   /**
@@ -461,11 +456,6 @@ public: // API for derived classes to override
    */
   virtual void OnInitialize();
 
-  /**
-   * @copydoc Dali::Toolkit::Control::IsResourceReady
-   */
-  virtual bool IsResourceReady() const;
-
   // Styling
 
   /**
index f411d4d..245bdd5 100644 (file)
@@ -117,7 +117,10 @@ void Control::ClearBackground()
 
 bool Control::IsResourceReady() const
 {
-  return Internal::GetImplementation(*this).IsResourceReady();
+  const Internal::Control&       internalControl = Toolkit::Internal::GetImplementation(*this);
+  const Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get(internalControl);
+
+  return controlDataImpl.IsResourceReady();
 }
 
 Toolkit::Visual::ResourceStatus Control::GetVisualResourceStatus(Dali::Property::Index index)