Support embedded texture data for glTF + alpha
[platform/core/uifw/dali-toolkit.git] / dali-scene3d / public-api / loader / buffer-definition.h
1 #ifndef DALI_SCENE3D_LOADER_BUFFER_DEFINITION_H
2 #define DALI_SCENE3D_LOADER_BUFFER_DEFINITION_H
3 /*
4  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 // INTERNAL INCLUDES
21 #include <dali-scene3d/public-api/api.h>
22
23 // EXTERNAL INCLUDES
24 #include <fstream>
25 #include <memory>
26 #include <vector>
27
28 namespace Dali
29 {
30 namespace Scene3D
31 {
32 namespace Loader
33 {
34 /**
35  * @brief Defines a buffer that is loaded from input uri.
36  * The buffer can contain 3D resource data such as mesh, animation, and texture.
37  */
38 struct DALI_SCENE3D_API BufferDefinition
39 {
40   using Vector = std::vector<BufferDefinition>;
41
42   BufferDefinition();
43   ~BufferDefinition();
44
45   BufferDefinition(const BufferDefinition& other)            = default;
46   BufferDefinition& operator=(const BufferDefinition& other) = default;
47
48   BufferDefinition(BufferDefinition&& other);
49   BufferDefinition& operator=(BufferDefinition&&) = default;
50
51   /**
52    * @brief Retrieves data stream of this buffer.
53    * @return iostream of this buffer
54    */
55   std::iostream& GetBufferStream();
56
57   /**
58    * @brief Retrieves uri of this buffer
59    * @return uri of the buffer
60    */
61   std::string GetUri();
62
63   /**
64    * @brief Checks whether the buffer is available or not.
65    * It is available, if the buffer is successfully loaded from file or base64 stream.
66    * @return True if it is available.
67    */
68   bool IsAvailable();
69
70 private:
71   /**
72    * @brief Loads buffer from file or encoded stream.
73    */
74   void LoadBuffer();
75
76 public: // DATA
77   std::string mResourcePath;
78   std::string mUri;
79   uint32_t    mByteLength{0};
80   std::string mName;
81
82 private:
83   struct Impl;
84   std::unique_ptr<Impl> mImpl;
85
86   bool mIsEmbedded{false};
87 };
88
89 } // namespace Loader
90 } // namespace Scene3D
91 } // namespace Dali
92
93 #endif // DALI_SCENE3D_LOADER_BUFFER_DEFINITION_H