Asynchronous loading of Scene3D 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) 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/common/vector-wrapper.h>
23 #include <dali/public-api/images/pixel-data.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 #include <dali/public-api/adaptor-framework/async-task-manager.h>
30
31 namespace Dali
32 {
33 namespace Scene3D
34 {
35 namespace Internal
36 {
37 class ModelLoadTask;
38 typedef IntrusivePtr<ModelLoadTask> ModelLoadTaskPtr;
39
40 class ModelLoadTask : public AsyncTask
41 {
42 public:
43   /**
44    * Constructor
45    * @param[in] modelUrl model file path.(e.g., glTF, and DLI).
46    * @param[in] resourceDirectoryUrl resource file path that includes binary, image etc.
47    * @param[in] callback The callback that is called when the operation is completed.
48    */
49   ModelLoadTask(const std::string& modelUrl, const std::string& resourceDirectoryUrl, CallbackBase* callback);
50
51   /**
52    * Destructor.
53    */
54   ~ModelLoadTask();
55
56   /**
57    * Process the task
58    */
59   void Process() override;
60
61   /**
62    * Whether the task is ready to process.
63    * @return True if the task is ready to process.
64    */
65   bool IsReady() override;
66
67   /**
68    * Whether the task has succeeded.
69    * @return True if the task has succeeded.
70    */
71   bool HasSucceeded() const;
72
73 private:
74   // Undefined
75   ModelLoadTask(const ModelLoadTask& task) = delete;
76
77   // Undefined
78   ModelLoadTask& operator=(const ModelLoadTask& task) = delete;
79
80 public:
81   std::string mModelUrl;
82   std::string mResourceDirectoryUrl;
83
84   Dali::Scene3D::Loader::ResourceBundle                        mResources;
85   Dali::Scene3D::Loader::SceneDefinition                       mScene;
86   Dali::Scene3D::Loader::SceneMetadata                         mMetaData;
87   std::vector<Dali::Scene3D::Loader::AnimationGroupDefinition> mAnimGroups;
88   std::vector<Dali::Scene3D::Loader::CameraParameters>         mCameraParameters;
89   std::vector<Dali::Scene3D::Loader::LightParameters>          mLights;
90   std::vector<Dali::Scene3D::Loader::AnimationDefinition>      mAnimations;
91
92   Dali::Scene3D::Loader::Customization::Choices         mResourceChoices;
93   std::vector<Dali::Scene3D::Loader::ResourceRefCounts> mResourceRefCounts;
94   bool                                                  mHasSucceeded;
95 };
96
97 } // namespace Internal
98
99 } // namespace Scene3D
100
101 } // namespace Dali
102
103 #endif // DALI_SCENE3D_MODEL_LOAD_TASK_H