[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / internal / common / environment-map-load-task.h
1 #ifndef DALI_SCENE3D_ENVIRONMENT_MAP_LOAD_TASK_H
2 #define DALI_SCENE3D_ENVIRONMENT_MAP_LOAD_TASK_H
3
4 /*
5  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 // EXTERNAL INCLUDES
21 #include <dali/public-api/adaptor-framework/async-task-manager.h>
22 #include <dali/public-api/common/intrusive-ptr.h>
23 #include <dali/public-api/images/pixel-data.h>
24 #include <memory>
25
26 // INTERNAL INCLUDES
27 #include <dali-scene3d/public-api/common/environment-map.h>
28 #include <dali-scene3d/public-api/loader/environment-map-data.h>
29 #include <dali-scene3d/public-api/loader/load-result.h>
30 #include <dali-scene3d/public-api/loader/scene-definition.h>
31
32 namespace Dali
33 {
34 namespace Scene3D
35 {
36 namespace Internal
37 {
38 class EnvironmentMapLoadTask;
39 typedef IntrusivePtr<EnvironmentMapLoadTask> EnvironmentMapLoadTaskPtr;
40
41 class EnvironmentMapLoadTask : public AsyncTask
42 {
43 public:
44   /**
45    * Constructor
46    * @param[in] environmentMapUrl The url of the environment map image file.
47    * @param[in] callback The callback that is called when the operation is completed.
48    */
49   EnvironmentMapLoadTask(const std::string& environmentMapUrl, Dali::Scene3D::EnvironmentMapType environmentMapType, CallbackBase* callback);
50
51   /**
52    * Destructor.
53    */
54   ~EnvironmentMapLoadTask();
55
56   /**
57    * Whether the task has succeeded.
58    * @return True if the task has succeeded.
59    */
60   bool HasSucceeded() const;
61
62   /**
63    * Retrieves loaded Ibl Texture
64    * @return Texture that is loaded from url.
65    * @note Do not call this method in worker thread.
66    */
67   Dali::Texture GetLoadedTexture();
68
69   /**
70    * Retrieves Mipmap levels of loaded Ibl texture
71    * @return mipmap levels of loaded Ibl texture
72    */
73   uint32_t GetMipmapLevels();
74
75   /**
76    * Retrieves EnvironmentMap type of the loaded texture
77    * @return EnvironmentMap type of the loaded texture
78    */
79   Dali::Scene3D::EnvironmentMapType GetEnvironmentMapType();
80
81 public: // Implementation of AsyncTask
82   /**
83    * @copydoc Dali::AsyncTask::Process()
84    */
85   void Process();
86
87   /**
88    * @copydoc Dali::AsyncTask::IsReady()
89    */
90   bool IsReady();
91
92   /**
93    * @copydoc Dali::AsyncTask::GetTaskName()
94    */
95   std::string_view GetTaskName() const override
96   {
97     return "EnvironmentMapLoadTask";
98   }
99
100 private:
101   // Undefined
102   EnvironmentMapLoadTask(const EnvironmentMapLoadTask& task) = delete;
103
104   // Undefined
105   EnvironmentMapLoadTask& operator=(const EnvironmentMapLoadTask& task) = delete;
106
107 private:
108   std::string                               mEnvironmentMapUrl;
109   Dali::Scene3D::Loader::EnvironmentMapData mEnvironmentMapData;
110
111   bool mIsReady;
112   bool mHasSucceeded;
113 };
114
115 } // namespace Internal
116
117 } // namespace Scene3D
118
119 } // namespace Dali
120
121 #endif // DALI_SCENE3D_ENVIRONMENT_MAP_LOAD_TASK_H