[dali_2.3.24] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / public-api / loader / environment-definition.h
index a6f1946..39aa53a 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef DALI_SCENE3D_LOADER_ENVIRONMENT_DEFINITION_H
 #define DALI_SCENE3D_LOADER_ENVIRONMENT_DEFINITION_H
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
  *
  */
 
-// INTERNAL INCLUDES
-#include "dali-scene3d/public-api/api.h"
-#include "dali-scene3d/public-api/loader/cube-data.h"
-
 // EXTERNAL INCLUDES
-#include "dali/public-api/math/quaternion.h"
-#include "dali/public-api/rendering/texture.h"
+#include <dali/public-api/math/quaternion.h>
+#include <dali/public-api/rendering/texture.h>
 #include <memory>
 
-namespace Dali
-{
-namespace Scene3D
-{
-namespace Loader
+// INTERNAL INCLUDES
+#include <dali-scene3d/public-api/api.h>
+#include <dali-scene3d/public-api/loader/environment-map-data.h>
+
+namespace Dali::Scene3D::Loader
 {
 /**
- * @brief Defines an environment map with either or both of radiance
- *  and irradiance maps.
+ * @brief Defines an environment map with either or both of radiance and irradiance maps.
+ * @SINCE_2_0.7
  */
 struct DALI_SCENE3D_API EnvironmentDefinition
 {
   struct Textures
   {
-    Texture mDiffuse;  // irradiance
-    Texture mSpecular; // radiance
-    Texture mBrdf;     // pre-computed brdf
+    Texture  mDiffuse;  // irradiance
+    Texture  mSpecular; // radiance
+    Texture  mBrdf;     // pre-computed brdf
+    uint32_t mSpecularMipmapLevels{1u};
 
     bool IsLoaded() const
     {
@@ -52,9 +49,9 @@ struct DALI_SCENE3D_API EnvironmentDefinition
 
   struct RawData
   {
-    CubeData  mDiffuse;
-    CubeData  mSpecular;
-    PixelData mBrdf;
+    EnvironmentMapData mDiffuse;
+    EnvironmentMapData mSpecular;
+    PixelData          mBrdf;
   };
 
   using EnvironmentData = std::pair<EnvironmentDefinition, Textures>;
@@ -68,25 +65,36 @@ struct DALI_SCENE3D_API EnvironmentDefinition
   EnvironmentDefinition(EnvironmentDefinition&&) = default;
   EnvironmentDefinition& operator=(EnvironmentDefinition&&) = default;
 
+  static Dali::Texture GetBrdfTexture();
+
   /**
    * @brief Loads raw pixel data for the given diffuse and specular maps.
+   * @SINCE_2_0.7
+   * @return The raw data for the given diffuse and specular maps
    * @note This can be done on any thread.
    */
-  RawData LoadRaw(const std::string& environmentsPath) const;
+  RawData LoadRaw(const std::string& environmentsPath);
 
   /**
-   * @brief Creates DALi cubemap Textures from the pixel data in @a raw, then
-   *  returns them in a Textures object.
+   * @brief Creates DALi cubemap Textures from the pixel data in @a raw, then returns them in a Textures object.
+   * @SINCE_2_0.7
+   * @return DALi cubemap Textures
    * @note This must only be called from the event thread.
    */
-  Textures Load(RawData&& raw) const;
+  Textures Load(RawData&& raw);
 
   /**
    * @brief Get default intensity value.
+   * @SINCE_2_2.1
    * @return Default intensity. (1.0f)
    */
   static float GetDefaultIntensity();
 
+private:
+  /// @cond internal
+  static void LoadBrdfTexture();
+  /// @endcond internal
+
 public: // DATA
   std::string              mDiffuseMapPath;
   std::string              mSpecularMapPath;
@@ -95,10 +103,13 @@ public: // DATA
   Vector3                  mYDirection      = Vector3::ONE;
   float                    mIblIntensity    = 1.0f;
   bool                     mUseBrdfTexture  = false;
+
+private:
+  static PixelData mBrdfPixelData;
+  static Texture   mBrdfTexture;
+  static bool      mIsBrdfLoaded;
 };
 
-} // namespace Loader
-} // namespace Scene3D
-} // namespace Dali
+} // namespace Dali::Scene3D::Loader
 
-#endif //DALI_SCENE3D_LOADER_ENVIRONMENT_DEFINITION_H
+#endif // DALI_SCENE3D_LOADER_ENVIRONMENT_DEFINITION_H