X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-scene3d%2Finternal%2Fcontrols%2Fscene-view%2Fscene-view-impl.h;h=3d8c63961b53baab0504ad2ef2f6ec7d8c7483a6;hb=HEAD;hp=fc17fa7076e319af73cd5ee7a2f2a88ae5358aa1;hpb=026a32be68bfde3ccce97b366b1098df731354e4;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-scene3d/internal/controls/scene-view/scene-view-impl.h b/dali-scene3d/internal/controls/scene-view/scene-view-impl.h index fc17fa7..47ff5e7 100644 --- a/dali-scene3d/internal/controls/scene-view/scene-view-impl.h +++ b/dali-scene3d/internal/controls/scene-view/scene-view-impl.h @@ -2,7 +2,7 @@ #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. @@ -21,20 +21,25 @@ // EXTERNAL INCLUDES #include #include -#include +#include +#include +#include #include #include +#include #include #include +#include #include #include #include #include // INTERNAL INCLUDES -#include #include -#include +#include +#include +#include namespace Dali { @@ -105,14 +110,14 @@ public: * * @param[in] item scene observer to be registered. */ - void RegisterSceneItem(Scene3D::Internal::ImageBasedLightObserver* item); + void RegisterSceneItem(Scene3D::Internal::LightObserver* item); /** * @brief Unregister an item * * @param[in] item scene observer to be unregistered. */ - void UnregisterSceneItem(Scene3D::Internal::ImageBasedLightObserver* item); + void UnregisterSceneItem(Scene3D::Internal::LightObserver* item); /** * @copydoc SceneView::SetImageBasedLightSource() @@ -130,6 +135,46 @@ public: float GetImageBasedLightScaleFactor() const; /** + * @brief Adds a Light object to this SceneView. + * Multiple light object can be added on this SceneView + * But the number of lights those actually turned on has limitation. + * Scene3D::Light::GetMaximumEnabledLightCount() method can be used to know the maximum namber. + * + * @param[in] light Light object to be added. + */ + void AddLight(Scene3D::Light light); + + /** + * @brief Removes a Light object to this SceneView. + * If the light is currently turned on, and SceneView has lights more than maximum number of enabled light. + * One of light in queue is turned on after this light is removed. + * + * @param[in] light Light object to be removed. + */ + void RemoveLight(Scene3D::Light light); + + /** + * @brief Set a shadow to this scene by input light. + * Currently, SceneView supports only one shadow. + * + * @param[in] light Light object to make shadow. + * @note The shadow will be drawn if the input light is turn on in current scene. + */ + void SetShadow(Scene3D::Light light); + + /** + * @brief Removes Shadow from this SceneView. + * + * @param[in] light Light object to be removed. + */ + void RemoveShadow(Scene3D::Light light); + + /** + * @copydoc SceneView::GetActivatedLightCount() + */ + uint32_t GetActivatedLightCount() const; + + /** * @copydoc SceneView::UseFramebuffer() */ void UseFramebuffer(bool useFramebuffer); @@ -140,9 +185,44 @@ public: 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::GetFramebufferMultiSamplingLevel() + */ + uint8_t GetFramebufferMultiSamplingLevel() const; + + /** * @copydoc SceneView::SetSkybox() */ - void SetSkybox(const std::string& skyboxUrl, Scene3D::SceneView::SkyboxType skyboxType); + void SetSkybox(const std::string& skyboxUrl); + + /** + * @copydoc SceneView::SetSkyboxEnvironmentMapType() + */ + void SetSkyboxEnvironmentMapType(Scene3D::EnvironmentMapType skyboxEnvironmentMapType); /** * @copydoc SceneView::SetSkyboxIntensity() @@ -164,6 +244,87 @@ public: */ 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 Updates shader uniforms about shadow. + * @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. @@ -244,9 +405,12 @@ private: void RotateCamera(); /** - * @brief Asynchronously skybox (Equirectangular) loading finished. + * @brief UpdateSkybox with skybox url and skybox environment map type. + * + * @param[in] skyboxUrl image url for skybox. + * @param[in] skyboxEnvironmentMapType The environment type of skybox. */ - void OnSkyboxEquirectangularLoadComplete(uint32_t loadedTaskId, PixelData pixelData); + void UpdateSkybox(const std::string& skyboxUrl, Scene3D::EnvironmentMapType skyboxEnvironmentMapType); /** * @brief Asynchronously skybox loading finished. @@ -273,49 +437,111 @@ private: */ void NotifyImageBasedLightTextureChange(); + /** + * @brief Update shadowMap framebuffer when the size should be changed. + * @param[in] shadowMapSize The size of shadowMap texture. The texture's width and hight is equal. + */ + 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: + /** + * 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 - Dali::WeakHandle mWindow; - CameraActor mDefaultCamera; - CameraActor mSelectedCamera; - std::vector mCameras; - std::vector mItems; - Dali::FrameBuffer mFrameBuffer; - Dali::Texture mTexture; - Dali::RenderTask mRenderTask; - Layer mRootLayer; - int32_t mWindowOrientation; - Dali::Actor mSkybox; - Quaternion mSkyboxOrientation; - float mSkyboxIntensity{1.0f}; + Dali::WeakHandle mWindow; + Integration::SceneHolder mSceneHolder; + CameraActor mDefaultCamera; + CameraActor mSelectedCamera; + std::vector 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>> 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 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; + + // Light + std::vector> mLights; // Pair of Light object and flag that denotes the light is currently activated or not. + Dali::FrameBuffer mShadowFrameBuffer; + Dali::RenderTask mShadowMapRenderTask; + Scene3D::Light mShadowLight; + Dali::Texture mShadowTexture; // Asynchronous Loading. - EnvironmentMapLoadTaskPtr mSkyboxLoadTask; - EnvironmentMapLoadTaskPtr mIblDiffuseLoadTask; - EnvironmentMapLoadTaskPtr mIblSpecularLoadTask; - std::string mSkyboxUrl; - std::string mDiffuseIblUrl; - std::string mSpecularIblUrl; - Dali::Toolkit::AsyncImageLoader mSkyboxImageLoader; - uint32_t mSkyboxImageId{0u}; - - Scene3D::SceneView::SkyboxType mSkyboxEnvironmentMapType{Scene3D::SceneView::SkyboxType::CUBEMAP}; - Dali::Texture mSkyboxTexture; - Dali::Texture mDiffuseTexture; - Dali::Texture mSpecularTexture; - float mIblScaleFactor{1.0f}; - bool mUseFrameBuffer{false}; - bool mSkyboxResourceReady{true}; - bool mIblDiffuseResourceReady{true}; - bool mIblSpecularResourceReady{true}; - bool mSkyboxDirty{false}; - bool mIblDiffuseDirty{false}; - bool mIblSpecularDirty{false}; - - // TODO : Light Source + EnvironmentMapLoadTaskPtr mSkyboxLoadTask; + EnvironmentMapLoadTaskPtr mIblDiffuseLoadTask; + EnvironmentMapLoadTaskPtr mIblSpecularLoadTask; + std::string mSkyboxUrl; + std::string mDiffuseIblUrl; + std::string mSpecularIblUrl; + + Scene3D::EnvironmentMapType mSkyboxEnvironmentMapType{Scene3D::EnvironmentMapType::AUTO}; + Dali::Texture mSkyboxTexture; + Dali::Texture mDiffuseTexture; + Dali::Texture mSpecularTexture; + float mIblScaleFactor{1.0f}; + uint32_t mSpecularMipmapLevels{1u}; + bool mUseFrameBuffer{false}; + bool mSkyboxResourceReady{true}; + bool mIblDiffuseResourceReady{true}; + bool mIblSpecularResourceReady{true}; + bool mSkyboxDirty{false}; + bool mIblDiffuseDirty{false}; + bool mIblSpecularDirty{false}; }; } // namespace Internal