Make multiple roots model share the resources.
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / internal / common / model-load-task.h
1 #ifndef DALI_SCENE3D_MODEL_LOAD_TASK_H
2 #define DALI_SCENE3D_MODEL_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/common/intrusive-ptr.h>
22 #include <dali/public-api/common/vector-wrapper.h>
23 #include <dali/public-api/images/pixel-data.h>
24 #include <memory>
25
26 // INTERNAL INCLUDES
27 #include <dali-scene3d/internal/common/model-cache-manager.h>
28 #include <dali-scene3d/public-api/loader/load-result.h>
29 #include <dali-scene3d/public-api/loader/scene-definition.h>
30 #include <dali/devel-api/threading/conditional-wait.h>
31 #include <dali/public-api/adaptor-framework/async-task-manager.h>
32
33 namespace Dali
34 {
35 namespace Scene3D
36 {
37 namespace Internal
38 {
39 class ModelLoadTask;
40 typedef IntrusivePtr<ModelLoadTask> ModelLoadTaskPtr;
41
42 class ModelLoadTask : public AsyncTask
43 {
44 public:
45   /**
46    * Constructor
47    * @param[in] modelUrl Model file path.(e.g., glTF, and DLI).
48    * @param[in] resourceDirectoryUrl Resource file path that includes binary, image etc.
49    * @param[in] callback The callback that is called when the operation is completed.
50    */
51   ModelLoadTask(const std::string& modelUrl, const std::string& resourceDirectoryUrl, CallbackBase* callback);
52
53   /**
54    * Destructor.
55    */
56   ~ModelLoadTask();
57
58   /**
59    * Process the task
60    */
61   void Process() override;
62
63   /**
64    * Whether the task is ready to process.
65    * @return True if the task is ready to process.
66    */
67   bool IsReady() override;
68
69   /**
70    * Whether the task has succeeded.
71    * @return True if the task has succeeded.
72    */
73   bool HasSucceeded() const;
74
75 private:
76   // Undefined
77   ModelLoadTask(const ModelLoadTask& task) = delete;
78
79   // Undefined
80   ModelLoadTask& operator=(const ModelLoadTask& task) = delete;
81
82 public:
83   std::string mModelUrl;
84   std::string mResourceDirectoryUrl;
85
86   Dali::Scene3D::Loader::Customization::Choices mResourceChoices;
87   Dali::Scene3D::Loader::ResourceRefCounts      mResourceRefCount;
88   bool                                          mHasSucceeded;
89
90   ModelCacheManager                 mModelCacheManager;
91   Dali::Scene3D::Loader::LoadResult mLoadResult;
92 };
93
94 } // namespace Internal
95
96 } // namespace Scene3D
97
98 } // namespace Dali
99
100 #endif // DALI_SCENE3D_MODEL_LOAD_TASK_H