Asynchronous loading of Scene3D resources
[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) 2022 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/common/intrusive-ptr.h>
22 #include <dali/public-api/images/pixel-data.h>
23 #include <dali/public-api/adaptor-framework/async-task-manager.h>
24 #include <memory>
25
26 // INTERNAL INCLUDES
27 #include <dali-scene3d/public-api/loader/load-result.h>
28 #include <dali-scene3d/public-api/loader/scene-definition.h>
29
30 namespace Dali
31 {
32 namespace Scene3D
33 {
34 namespace Internal
35 {
36 class EnvironmentMapLoadTask;
37 typedef IntrusivePtr<EnvironmentMapLoadTask> EnvironmentMapLoadTaskPtr;
38
39 class EnvironmentMapLoadTask : public AsyncTask
40 {
41 public:
42   /**
43    * Constructor
44    * @param[in] environmentMapUrl The url of the environment map image file.
45    * @param[in] callback The callback that is called when the operation is completed.
46    */
47   EnvironmentMapLoadTask(const std::string& environmentMapUrl, CallbackBase* callback);
48
49   /**
50    * Destructor.
51    */
52   ~EnvironmentMapLoadTask();
53
54   /**
55    * Process the task
56    */
57   void Process() override;
58
59   /**
60    * Whether the task is ready to process.
61    * @return True if the task is ready to process.
62    */
63   bool IsReady() override;
64
65   /**
66    * Whether the task has succeeded.
67    * @return True if the task has succeeded.
68    */
69   bool HasSucceeded() const;
70
71   /**
72    * Retrieves loaded Environment Map
73    * @return CubeData loaded from url.
74    *
75    * TODO: Supports Equirectangular environment map
76    */
77   Dali::Scene3D::Loader::CubeData GetEnvironmentMap() const;
78
79 private:
80   // Undefined
81   EnvironmentMapLoadTask(const EnvironmentMapLoadTask& task) = delete;
82
83   // Undefined
84   EnvironmentMapLoadTask& operator=(const EnvironmentMapLoadTask& task) = delete;
85
86 private:
87   std::string                     mEnvironmentMapUrl;
88   Dali::Scene3D::Loader::CubeData mEnvironmentMapPixelData;
89
90   bool mIsReady;
91   bool mHasSucceeded;
92 };
93
94 } // namespace Internal
95
96 } // namespace Scene3D
97
98 } // namespace Dali
99
100 #endif // DALI_SCENE3D_ENVIRONMENT_MAP_LOAD_TASK_H