Initial removal of Text features
[platform/core/uifw/dali-core.git] / dali / integration-api / resource-types.h
1 #ifndef __DALI_INTEGRATION_RESOURCE_TYPES_H__
2 #define __DALI_INTEGRATION_RESOURCE_TYPES_H__
3
4 /*
5  * Copyright (c) 2014 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
21 // EXTERNAL INCLUDES
22 #include <stdint.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/common/dali-common.h>
26 #include <dali/public-api/common/vector-wrapper.h>
27 #include <dali/public-api/images/image-attributes.h>
28 #include <dali/integration-api/resource-declarations.h>
29
30 namespace Dali
31 {
32
33 namespace Integration
34 {
35
36 // Resource Types
37
38 /**
39  * Extendable set of resource types
40  */
41 enum ResourceTypeId
42 {
43   ResourceBitmap,
44   ResourceNativeImage,
45   ResourceTargetImage,
46   ResourceShader,
47   ResourceModel,
48   ResourceMesh
49 };
50
51 /**
52  * The abstract base class for resource types.
53  */
54 struct ResourceType
55 {
56   /**
57    * Constructor.
58    * @param[in] typeId resource type id
59    */
60   ResourceType(ResourceTypeId typeId)
61   : id(typeId) {}
62
63   /**
64    * Destructor.
65    */
66   virtual ~ResourceType() {}
67
68   /**
69    * Create a copy of the resource type with the same attributes.
70    * @return pointer to the new ResourceType.
71    */
72   virtual ResourceType* Clone() const = 0;
73
74   const ResourceTypeId id;
75
76 private:
77
78   // Undefined copy constructor.
79   ResourceType(const ResourceType& typePath);
80
81   // Undefined assignment operator.
82   ResourceType& operator=(const ResourceType& rhs);
83 };
84
85 /**
86  * BitmapResourceType describes a bitmap resource, which can be requested
87  * from ResourceLoader::LoadResource() or AllocateBitmapImage.
88  */
89 struct BitmapResourceType : public ResourceType
90 {
91   /**
92    * Constructor.
93    * @param[in] attribs parameters for image loading request
94    */
95   BitmapResourceType(const ImageAttributes& attribs)
96   : ResourceType(ResourceBitmap),
97     imageAttributes(attribs) {}
98
99   /**
100    * Destructor.
101    */
102   virtual ~BitmapResourceType() {}
103
104   /**
105    * @copydoc ResourceType::Clone
106    */
107   virtual ResourceType* Clone() const
108   {
109     return new BitmapResourceType(imageAttributes);
110   }
111
112   /**
113    * Attributes are copied from the request.
114    */
115   ImageAttributes imageAttributes;
116
117 private:
118
119   // Undefined copy constructor.
120   BitmapResourceType(const BitmapResourceType& typePath);
121
122   // Undefined assignment operator.
123   BitmapResourceType& operator=(const BitmapResourceType& rhs);
124 };
125
126 /**
127  * NativeImageResourceType describes a native image resource, which can be injected
128  * through ResourceManager::AddNativeImage() or requested through ResourceLoader::LoadResource().
129  * If the adaptor does not support NativeImages, it can fall back to Bitmap type.
130  */
131 struct NativeImageResourceType : public ResourceType
132 {
133   /**
134    * Constructor.
135    */
136   NativeImageResourceType()
137   : ResourceType(ResourceNativeImage) {}
138
139   /**
140    * Constructor.
141    * @param[in] attribs parameters for image loading request
142    */
143   NativeImageResourceType(const ImageAttributes& attribs)
144   : ResourceType(ResourceNativeImage),
145     imageAttributes(attribs) {}
146
147   /**
148    * Destructor.
149    */
150   virtual ~NativeImageResourceType() {}
151
152  /**
153   * @copydoc ResourceType::Clone
154   */
155   virtual ResourceType* Clone() const
156   {
157     return new NativeImageResourceType(imageAttributes);
158   }
159
160   /**
161    * Attributes are copied from the request (if supplied).
162    */
163   ImageAttributes imageAttributes;
164
165 private:
166
167   // Undefined copy constructor.
168   NativeImageResourceType(const NativeImageResourceType& typePath);
169
170   // Undefined assignment operator.
171   NativeImageResourceType& operator=(const NativeImageResourceType& rhs);
172 };
173
174 /**
175  * RenderTargetResourceType describes a bitmap resource, which can injected
176  * through ResourceManager::AddTargetImage()
177  */
178 struct RenderTargetResourceType : public ResourceType
179 {
180   /**
181    * Constructor.
182    */
183   RenderTargetResourceType()
184   : ResourceType(ResourceTargetImage) {}
185
186   /**
187    * Constructor.
188    * @param[in] attribs parameters for image loading request
189    */
190   RenderTargetResourceType(const ImageAttributes& attribs)
191   : ResourceType(ResourceTargetImage),
192     imageAttributes(attribs) {}
193
194   /**
195    * Destructor.
196    */
197   virtual ~RenderTargetResourceType() {}
198
199   /**
200    * @copydoc ResourceType::Clone
201    */
202   virtual ResourceType* Clone() const
203   {
204     return new RenderTargetResourceType(imageAttributes);
205   }
206
207   /**
208    * Attributes are copied from the request.
209    */
210   ImageAttributes imageAttributes;
211
212 private:
213
214   // Undefined copy constructor.
215   RenderTargetResourceType(const RenderTargetResourceType& typePath);
216
217   // Undefined assignment operator.
218   RenderTargetResourceType& operator=(const RenderTargetResourceType& rhs);
219 };
220
221 /**
222  * ShaderResourceType describes a shader program resource, which can be requested
223  * from PlatformAbstraction::LoadResource()
224  */
225 struct ShaderResourceType : public ResourceType
226 {
227   /**
228    * Constructor.
229    */
230   ShaderResourceType(size_t shaderHash, const std::string& vertexSource, const std::string& fragmentSource)
231   : ResourceType(ResourceShader),
232     hash(shaderHash),
233     vertexShader(vertexSource),
234     fragmentShader(fragmentSource)
235   {
236   }
237
238   /**
239    * Destructor.
240    */
241   virtual ~ShaderResourceType()
242   {
243   }
244
245   /**
246    * @copydoc ResourceType::Clone
247    */
248   virtual ResourceType* Clone() const
249   {
250     return new ShaderResourceType(hash, vertexShader, fragmentShader);
251   }
252
253 public: // Attributes
254   size_t            hash;              ///< Hash of the vertex/fragment sources
255   const std::string vertexShader;      ///< source code for vertex program
256   const std::string fragmentShader;    ///< source code for fragment program
257
258 private:
259
260   // Undefined copy constructor.
261   ShaderResourceType(const ShaderResourceType& typePath);
262
263   // Undefined assignment operator.
264   ShaderResourceType& operator=(const ShaderResourceType& rhs);
265 };
266
267 /**
268  * ModelResourceType describes a model resource, which can be requested
269  * from PlatformAbstraction::LoadResource()
270  */
271 struct ModelResourceType : public ResourceType
272 {
273   /**
274    * Constructor.
275    */
276   ModelResourceType()
277     : ResourceType(ResourceModel)
278   {
279   }
280
281   /**
282    * Destructor.
283    */
284   virtual ~ModelResourceType()
285   {
286   }
287
288   /**
289    * @copydoc ResourceType::Clone
290    */
291   virtual ResourceType* Clone() const
292   {
293     return new ModelResourceType();
294   }
295
296 private:
297
298   // Undefined copy constructor.
299   ModelResourceType(const ModelResourceType& typePath);
300
301   // Undefined assignment operator.
302   ModelResourceType& operator=(const ModelResourceType& rhs);
303 };
304
305
306 /**
307  * MeshResourceType describes a mesh program resource, which can be created
308  * using ResourceManager::AllocateMesh.
309  */
310 struct MeshResourceType : public ResourceType
311 {
312   /**
313    * Constructor.
314    */
315   MeshResourceType()
316   : ResourceType(ResourceMesh) {}
317
318   /**
319    * Destructor.
320    */
321   virtual ~MeshResourceType() {}
322
323   /**
324    * @copydoc ResourceType::Clone
325    */
326   virtual ResourceType* Clone() const
327   {
328     return new MeshResourceType();
329   }
330
331 private:
332
333   // Undefined copy constructor.
334   MeshResourceType(const MeshResourceType& typePath);
335
336   // Undefined assignment operator.
337   MeshResourceType& operator=(const MeshResourceType& rhs);
338 };
339
340 } // namespace Integration
341
342 } // namespace Dali
343
344 #endif // __DALI_INTEGRATION_RESOURCE_TYPES_H__