[dali_2.3.28] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / internal / controls / scene-view / scene-view-impl.h
index 647df5e..47ff5e7 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_SCENE3D_INTERNAL_SCENE_VIEW_H
 
 /*
 #define DALI_SCENE3D_INTERNAL_SCENE_VIEW_H
 
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 // EXTERNAL INCLUDES
 #include <dali-toolkit/internal/visuals/image/image-visual.h>
 #include <dali-toolkit/public-api/controls/control-impl.h>
 // EXTERNAL INCLUDES
 #include <dali-toolkit/internal/visuals/image/image-visual.h>
 #include <dali-toolkit/public-api/controls/control-impl.h>
+#include <dali-toolkit/public-api/controls/image-view/image-view.h>
 #include <dali/integration-api/adaptor-framework/scene-holder.h>
 #include <dali/integration-api/adaptor-framework/scene-holder.h>
+#include <dali/integration-api/ordered-set.h>
 #include <dali/public-api/actors/camera-actor.h>
 #include <dali/public-api/actors/layer.h>
 #include <dali/public-api/actors/camera-actor.h>
 #include <dali/public-api/actors/layer.h>
+#include <dali/public-api/adaptor-framework/timer.h>
 #include <dali/public-api/adaptor-framework/window.h>
 #include <dali/public-api/animation/animation.h>
 #include <dali/public-api/adaptor-framework/window.h>
 #include <dali/public-api/animation/animation.h>
+#include <dali/public-api/capture/capture.h>
 #include <dali/public-api/object/weak-handle.h>
 #include <dali/public-api/render-tasks/render-task.h>
 #include <dali/public-api/rendering/frame-buffer.h>
 #include <dali/public-api/object/weak-handle.h>
 #include <dali/public-api/render-tasks/render-task.h>
 #include <dali/public-api/rendering/frame-buffer.h>
@@ -181,6 +185,26 @@ public:
   bool IsUsingFramebuffer() const;
 
   /**
   bool IsUsingFramebuffer() const;
 
   /**
+   * @copydoc SceneView::SetResolution()
+   */
+  void SetResolution(uint32_t width, uint32_t height);
+
+  /**
+   * @copydoc SceneView::GetResolutionWidth()
+   */
+  uint32_t GetResolutionWidth();
+
+  /**
+   * @copydoc SceneView::GetResolutionHeight()
+   */
+  uint32_t GetResolutionHeight();
+
+  /**
+   * @copydoc SceneView::ResetResolution()
+   */
+  void ResetResolution();
+
+  /**
    * @copydoc SceneView::SetFramebufferMultiSamplingLevel()
    */
   void SetFramebufferMultiSamplingLevel(uint8_t multiSamplingLevel);
    * @copydoc SceneView::SetFramebufferMultiSamplingLevel()
    */
   void SetFramebufferMultiSamplingLevel(uint8_t multiSamplingLevel);
@@ -221,17 +245,86 @@ public:
   Quaternion GetSkyboxOrientation() const;
 
   /**
   Quaternion GetSkyboxOrientation() const;
 
   /**
+   * @copydoc SceneView::Capture()
+   */
+  int32_t Capture(Dali::CameraActor camera, const Vector2& size);
+
+  /**
+   * @copydoc SceneView::FinishedSignal
+   */
+  Dali::Scene3D::SceneView::CaptureFinishedSignalType& CaptureFinishedSignal();
+
+  /**
    * @brief Retrieves ShaderManager of this SceneView.
    * @return ShaderManager of this SceneView.
    */
   Dali::Scene3D::Loader::ShaderManagerPtr GetShaderManager() const;
 
   /**
    * @brief Retrieves ShaderManager of this SceneView.
    * @return ShaderManager of this SceneView.
    */
   Dali::Scene3D::Loader::ShaderManagerPtr GetShaderManager() const;
 
   /**
-   * @brief Update shader uniforms about shadow.
+   * @brief Updates shader uniforms about shadow.
    * @param[in] light Light that makes shadow.
    */
   void UpdateShadowUniform(Scene3D::Light light);
 
    * @param[in] light Light that makes shadow.
    */
   void UpdateShadowUniform(Scene3D::Light light);
 
+  /**
+   * @brief Sets alpha mask url
+   * @param[in] alphaMaskUrl Url for alpha mask.
+   */
+  void SetAlphaMaskUrl(std::string& alphaMaskUrl);
+
+  /**
+   * @brief Retrieves alpha mask url
+   * @return Alpha mask url.
+   */
+  std::string GetAlphaMaskUrl();
+
+  /**
+   * @brief Sets mask content scale factor
+   * @param[in] maskContentScaleFactor Scale factor for mask content.
+   */
+  void SetMaskContentScaleFactor(float maskContentScaleFactor);
+
+  /**
+   * @brief Retrieves mask content scale factor
+   * @return Scale factor for mask content.
+   */
+  float GetMaskContentScaleFactor();
+
+  /**
+   * @brief Sets whether the rendered result will be crop to mask or not.
+   * @param[in] enableCropToMask True for crop rendered result to mask.
+   */
+  void EnableCropToMask(bool enableCropToMask);
+
+  /**
+   * @brief Retrieves whether the crop to mask is enabled or not.
+   * @return True when rendered result is cropped to mask.
+   */
+  bool IsEnabledCropToMask();
+
+  /**
+   * @brief Gets current RenderTask
+   */
+  Dali::RenderTask GetRenderTask();
+
+  // Properties
+
+  /**
+   * Called when a property of an object of this type is set.
+   * @param[in] object The object whose property is set.
+   * @param[in] index The property index.
+   * @param[in] value The new property value.
+   */
+  static void SetProperty(BaseObject* object, Property::Index index, const Property::Value& value);
+
+  /**
+   * Called to retrieve a property of an object of this type.
+   * @param[in] object The object whose property is to be retrieved.
+   * @param[in] index The property index.
+   * @return The current value of the property.
+   */
+  static Property::Value GetProperty(BaseObject* object, Property::Index index);
+
 protected:
   /**
    * @brief Constructs a new SceneView.
 protected:
   /**
    * @brief Constructs a new SceneView.
@@ -350,26 +443,73 @@ private:
    */
   void UpdateShadowMapBuffer(uint32_t shadowMapSize);
 
    */
   void UpdateShadowMapBuffer(uint32_t shadowMapSize);
 
+  /**
+   * @brief CaptureFinished Callback that is called the capture rendering is finished.
+   * @param[in] task RenderTask that draws requested capture scene.
+   */
+  void OnCaptureFinished(Dali::RenderTask& task);
+
+  /**
+   * @brief Time out Callback to handle the case each capture request is not finished for long time.
+   * @return True if the timer needs to go on.
+   */
+  bool OnTimeOut();
+
 private:
 private:
+  /**
+   * Data to store Capture related objects.
+   */
+  struct CaptureData
+  {
+    int32_t                  mStartTick;
+    int32_t                  mCaptureId;                // Unique Key to distinguish requested Captures.
+    Dali::Toolkit::ImageUrl  mCaptureUrl;               // URL for first captured buffer, but it is Y-inverted.
+    Dali::Toolkit::ImageView mCaptureImageView;         // ImageView to draw first capture buffer to be transfered as input for invert.
+    Dali::RenderTask         mCaptureTask;              // RenderTask that is used to capture first buffer.
+    Dali::Texture            mCaptureTexture;           // First Captured texture, but it is Y-inverted.
+    Dali::FrameBuffer        mCaptureFrameBuffer;       // First Captured FBO, but it is Y-inverted.
+    Dali::CameraActor        mCaptureInvertCamera;      // CameraActor to invert first captured buffer by second pass.
+    Dali::RenderTask         mCaptureInvertTask;        // RenderTask to invert first captured buffer.
+    Dali::Texture            mCaptureInvertTexture;     // Result texture of second pass. This is final Texture result.
+    Dali::FrameBuffer        mCaptureInvertFrameBuffer; // FBO for firnal Texture result
+  };
+
   Toolkit::Visual::Base mVisual;
 
   /////////////////////////////////////////////////////////////
   // FrameBuffer and Rendertask to render child objects as a 3D Scene
   Toolkit::Visual::Base mVisual;
 
   /////////////////////////////////////////////////////////////
   // FrameBuffer and Rendertask to render child objects as a 3D Scene
-  Dali::WeakHandle<Dali::Window>                 mWindow;
-  Integration::SceneHolder                       mSceneHolder;
-  CameraActor                                    mDefaultCamera;
-  CameraActor                                    mSelectedCamera;
-  std::vector<CameraActor>                       mCameras;
-  std::vector<Scene3D::Internal::LightObserver*> mItems;
-  Dali::FrameBuffer                              mFrameBuffer;
-  Dali::Texture                                  mTexture;
-  Dali::RenderTask                               mRenderTask;
-  Layer                                          mRootLayer;
-  int32_t                                        mWindowOrientation;
-  Dali::Actor                                    mSkybox;
-  Quaternion                                     mSkyboxOrientation;
-  float                                          mSkyboxIntensity{1.0f};
-  uint8_t                                        mFrameBufferMultiSamplingLevel{0u};
+  Dali::WeakHandle<Dali::Window>                      mWindow;
+  Integration::SceneHolder                            mSceneHolder;
+  CameraActor                                         mDefaultCamera;
+  CameraActor                                         mSelectedCamera;
+  std::vector<CameraActor>                            mCameras;
+  Dali::FrameBuffer                                   mFrameBuffer;
+  Dali::Texture                                       mTexture;
+  Dali::RenderTask                                    mRenderTask;
+  Layer                                               mRootLayer;
+  int32_t                                             mWindowOrientation;
+  Dali::Actor                                         mSkybox;
+  Quaternion                                          mSkyboxOrientation;
+  float                                               mSkyboxIntensity{1.0f};
+  uint8_t                                             mFrameBufferMultiSamplingLevel{0u};
+  Dali::Scene3D::SceneView::CaptureFinishedSignalType mCaptureFinishedSignal;
+
+  int32_t                                                                mCaptureId{0};     // Capture ID for requested capture, this is incrementally increasing.
+  std::vector<std::pair<Dali::RenderTask, std::shared_ptr<CaptureData>>> mCaptureContainer; // Container that stores CaptureData until the Capture is finished.
+  Dali::Timer                                                            mCaptureTimer;     // Timer to check the capture is time out or not.
+  int32_t                                                                mTimerTickCount{0};
+
+  Dali::Integration::OrderedSet<Scene3D::Internal::LightObserver, false> mLightObservers; ///< The set of items to be notified when light properties change. (not owned)
+
+  bool     mWindowSizeChanged{false};
+  uint32_t mWindowWidth{0};
+  uint32_t mWindowHeight{0};
+
+  // Masking
+  std::string mAlphaMaskUrl;
+  float       mMaskContentScaleFactor{1.0f};
+  bool        mCropToMask{true};
+  bool        mMaskingPropertyChanged{false};
 
   // Shader Factory
   Dali::Scene3D::Loader::ShaderManagerPtr mShaderManager;
 
   // Shader Factory
   Dali::Scene3D::Loader::ShaderManagerPtr mShaderManager;
@@ -379,6 +519,7 @@ private:
   Dali::FrameBuffer                            mShadowFrameBuffer;
   Dali::RenderTask                             mShadowMapRenderTask;
   Scene3D::Light                               mShadowLight;
   Dali::FrameBuffer                            mShadowFrameBuffer;
   Dali::RenderTask                             mShadowMapRenderTask;
   Scene3D::Light                               mShadowLight;
+  Dali::Texture                                mShadowTexture;
 
   // Asynchronous Loading.
   EnvironmentMapLoadTaskPtr mSkyboxLoadTask;
 
   // Asynchronous Loading.
   EnvironmentMapLoadTaskPtr mSkyboxLoadTask;