1 #ifndef __DALI_INTEGRATION_RESOURCE_TYPES_H__
2 #define __DALI_INTEGRATION_RESOURCE_TYPES_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
39 * Extendable set of resource types
52 * The abstract base class for resource types.
58 * @param[in] typeId resource type id
60 ResourceType(ResourceTypeId typeId)
66 virtual ~ResourceType() {}
69 * Create a copy of the resource type with the same attributes.
70 * @return pointer to the new ResourceType.
72 virtual ResourceType* Clone() const = 0;
74 const ResourceTypeId id;
78 // Undefined copy constructor.
79 ResourceType(const ResourceType& typePath);
81 // Undefined assignment operator.
82 ResourceType& operator=(const ResourceType& rhs);
86 * BitmapResourceType describes a bitmap resource, which can be requested
87 * from ResourceLoader::LoadResource() or AllocateBitmapImage.
89 struct BitmapResourceType : public ResourceType
93 * @param[in] attribs parameters for image loading request
95 BitmapResourceType(const ImageAttributes& attribs)
96 : ResourceType(ResourceBitmap),
97 imageAttributes(attribs) {}
102 virtual ~BitmapResourceType() {}
105 * @copydoc ResourceType::Clone
107 virtual ResourceType* Clone() const
109 return new BitmapResourceType(imageAttributes);
113 * Attributes are copied from the request.
115 ImageAttributes imageAttributes;
119 // Undefined copy constructor.
120 BitmapResourceType(const BitmapResourceType& typePath);
122 // Undefined assignment operator.
123 BitmapResourceType& operator=(const BitmapResourceType& rhs);
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.
131 struct NativeImageResourceType : public ResourceType
136 NativeImageResourceType()
137 : ResourceType(ResourceNativeImage) {}
141 * @param[in] attribs parameters for image loading request
143 NativeImageResourceType(const ImageAttributes& attribs)
144 : ResourceType(ResourceNativeImage),
145 imageAttributes(attribs) {}
150 virtual ~NativeImageResourceType() {}
153 * @copydoc ResourceType::Clone
155 virtual ResourceType* Clone() const
157 return new NativeImageResourceType(imageAttributes);
161 * Attributes are copied from the request (if supplied).
163 ImageAttributes imageAttributes;
167 // Undefined copy constructor.
168 NativeImageResourceType(const NativeImageResourceType& typePath);
170 // Undefined assignment operator.
171 NativeImageResourceType& operator=(const NativeImageResourceType& rhs);
175 * RenderTargetResourceType describes a bitmap resource, which can injected
176 * through ResourceManager::AddTargetImage()
178 struct RenderTargetResourceType : public ResourceType
183 RenderTargetResourceType()
184 : ResourceType(ResourceTargetImage) {}
188 * @param[in] attribs parameters for image loading request
190 RenderTargetResourceType(const ImageAttributes& attribs)
191 : ResourceType(ResourceTargetImage),
192 imageAttributes(attribs) {}
197 virtual ~RenderTargetResourceType() {}
200 * @copydoc ResourceType::Clone
202 virtual ResourceType* Clone() const
204 return new RenderTargetResourceType(imageAttributes);
208 * Attributes are copied from the request.
210 ImageAttributes imageAttributes;
214 // Undefined copy constructor.
215 RenderTargetResourceType(const RenderTargetResourceType& typePath);
217 // Undefined assignment operator.
218 RenderTargetResourceType& operator=(const RenderTargetResourceType& rhs);
222 * ShaderResourceType describes a shader program resource, which can be requested
223 * from PlatformAbstraction::LoadResource()
225 struct ShaderResourceType : public ResourceType
230 ShaderResourceType(size_t shaderHash, const std::string& vertexSource, const std::string& fragmentSource)
231 : ResourceType(ResourceShader),
233 vertexShader(vertexSource),
234 fragmentShader(fragmentSource)
241 virtual ~ShaderResourceType()
246 * @copydoc ResourceType::Clone
248 virtual ResourceType* Clone() const
250 return new ShaderResourceType(hash, vertexShader, fragmentShader);
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
260 // Undefined copy constructor.
261 ShaderResourceType(const ShaderResourceType& typePath);
263 // Undefined assignment operator.
264 ShaderResourceType& operator=(const ShaderResourceType& rhs);
268 * ModelResourceType describes a model resource, which can be requested
269 * from PlatformAbstraction::LoadResource()
271 struct ModelResourceType : public ResourceType
277 : ResourceType(ResourceModel)
284 virtual ~ModelResourceType()
289 * @copydoc ResourceType::Clone
291 virtual ResourceType* Clone() const
293 return new ModelResourceType();
298 // Undefined copy constructor.
299 ModelResourceType(const ModelResourceType& typePath);
301 // Undefined assignment operator.
302 ModelResourceType& operator=(const ModelResourceType& rhs);
307 * MeshResourceType describes a mesh program resource, which can be created
308 * using ResourceManager::AllocateMesh.
310 struct MeshResourceType : public ResourceType
316 : ResourceType(ResourceMesh) {}
321 virtual ~MeshResourceType() {}
324 * @copydoc ResourceType::Clone
326 virtual ResourceType* Clone() const
328 return new MeshResourceType();
333 // Undefined copy constructor.
334 MeshResourceType(const MeshResourceType& typePath);
336 // Undefined assignment operator.
337 MeshResourceType& operator=(const MeshResourceType& rhs);
340 } // namespace Integration
344 #endif // __DALI_INTEGRATION_RESOURCE_TYPES_H__