#ifndef __DALI_INTEGRATION_RESOURCE_TYPES_H__
#define __DALI_INTEGRATION_RESOURCE_TYPES_H__
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
// EXTERNAL INCLUDES
#include <stdint.h>
-#include <vector>
+#include <string>
// INTERNAL INCLUDES
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/images/image-attributes.h>
#include <dali/integration-api/resource-declarations.h>
// Resource Types
/**
- * Extendable set of resource type identifiers used by ResourceType subclasses.
+ * Extendable set of resource types
*/
enum ResourceTypeId
{
- ResourceImageData, ///< A buffer of image data with dimension and type metadata.
+ ResourceBitmap,
ResourceNativeImage,
ResourceTargetImage,
ResourceShader,
- ResourceModel,
ResourceMesh,
- ResourceText,
- ResourceTexture, ///< Used to pass through a request for a GLES texture to be allocated on the render thread.
- ResourceAppBitmap ///< Used in Core to tag Bitmaps that belong to BitmapImages.
+ ResourceText
};
/**
- * @brief A ResourceType-derived class is just a data bucket.
- *
- * Each ResourceType derived class carries a bundle of data specific to one or
- * more resource request types that are unambiguously specified by the
- * <code>id</code> member of this base class.
- * Dispatch on that ResourceTypeId to know exactly which kind of resource
- * request is associated with a particular instance.
+ * The abstract base class for resource types.
*/
-struct DALI_IMPORT_API ResourceType
+struct ResourceType
{
/**
* Constructor.
ResourceType(ResourceTypeId typeId)
: id(typeId) {}
+ /**
+ * Destructor.
+ */
virtual ~ResourceType() {}
/**
private:
// Undefined copy constructor.
- ResourceType( const ResourceType& type );
+ ResourceType(const ResourceType& typePath);
// Undefined assignment operator.
- ResourceType& operator=( const ResourceType& rhs );
+ ResourceType& operator=(const ResourceType& rhs);
};
/**
- * ImageResourceType can be used to identify a a request as pertaining
- * to images and carries some image attributes to modify the request.
- * @todo Replace all uses of other image-related ResourceTypes with
- * this one as they are duplicates.
+ * BitmapResourceType describes a bitmap resource, which can be requested
+ * from ResourceLoader::LoadResource() or AllocateBitmapImage.
*/
-struct DALI_IMPORT_API ImageResourceType : public ResourceType
+struct BitmapResourceType : public ResourceType
{
/**
* Constructor.
- * @param[in] typeId One of the image ResourceTypeIds.
* @param[in] attribs parameters for image loading request
*/
- ImageResourceType(const ResourceTypeId typeId, const ImageAttributes& attribs)
- : ResourceType(typeId),
- imageAttributes(attribs)
- {
- DALI_ASSERT_DEBUG( typeId == ResourceTexture || typeId == ResourceImageData || typeId == ResourceNativeImage || typeId == ResourceTargetImage || typeId == ResourceAppBitmap );
- }
+ BitmapResourceType(const ImageAttributes& attribs)
+ : ResourceType(ResourceBitmap),
+ imageAttributes(attribs) {}
+
+ /**
+ * Destructor.
+ */
+ virtual ~BitmapResourceType() {}
/**
* @copydoc ResourceType::Clone
*/
virtual ResourceType* Clone() const
{
- return new ImageResourceType( id, imageAttributes );
+ return new BitmapResourceType(imageAttributes);
}
/**
* Attributes are copied from the request.
*/
ImageAttributes imageAttributes;
+
+private:
+
+ // Undefined copy constructor.
+ BitmapResourceType(const BitmapResourceType& typePath);
+
+ // Undefined assignment operator.
+ BitmapResourceType& operator=(const BitmapResourceType& rhs);
};
/**
* through ResourceManager::AddNativeImage() or requested through ResourceLoader::LoadResource().
* If the adaptor does not support NativeImages, it can fall back to Bitmap type.
*/
-struct DALI_IMPORT_API NativeImageResourceType : public ResourceType
+struct NativeImageResourceType : public ResourceType
{
/**
- * Default constructor initialises the base class with the correct ResourceTypeId.
+ * Constructor.
*/
NativeImageResourceType()
: ResourceType(ResourceNativeImage) {}
: ResourceType(ResourceNativeImage),
imageAttributes(attribs) {}
+ /**
+ * Destructor.
+ */
+ virtual ~NativeImageResourceType() {}
+
/**
* @copydoc ResourceType::Clone
*/
* Attributes are copied from the request (if supplied).
*/
ImageAttributes imageAttributes;
+
+private:
+
+ // Undefined copy constructor.
+ NativeImageResourceType(const NativeImageResourceType& typePath);
+
+ // Undefined assignment operator.
+ NativeImageResourceType& operator=(const NativeImageResourceType& rhs);
};
/**
* RenderTargetResourceType describes a bitmap resource, which can injected
* through ResourceManager::AddTargetImage()
*/
-struct DALI_IMPORT_API RenderTargetResourceType : public ResourceType
+struct RenderTargetResourceType : public ResourceType
{
/**
- * Default constructor initialises the base class with the correct ResourceTypeId.
+ * Constructor.
*/
RenderTargetResourceType()
: ResourceType(ResourceTargetImage) {}
imageAttributes(attribs) {}
/**
+ * Destructor.
+ */
+ virtual ~RenderTargetResourceType() {}
+
+ /**
* @copydoc ResourceType::Clone
*/
virtual ResourceType* Clone() const
* Attributes are copied from the request.
*/
ImageAttributes imageAttributes;
+
+private:
+
+ // Undefined copy constructor.
+ RenderTargetResourceType(const RenderTargetResourceType& typePath);
+
+ // Undefined assignment operator.
+ RenderTargetResourceType& operator=(const RenderTargetResourceType& rhs);
};
/**
* ShaderResourceType describes a shader program resource, which can be requested
* from PlatformAbstraction::LoadResource()
*/
-struct DALI_IMPORT_API ShaderResourceType : public ResourceType
+struct ShaderResourceType : public ResourceType
{
+ /**
+ * Constructor.
+ */
ShaderResourceType(size_t shaderHash, const std::string& vertexSource, const std::string& fragmentSource)
: ResourceType(ResourceShader),
hash(shaderHash),
}
/**
+ * Destructor.
+ */
+ virtual ~ShaderResourceType()
+ {
+ }
+
+ /**
* @copydoc ResourceType::Clone
*/
virtual ResourceType* Clone() const
size_t hash; ///< Hash of the vertex/fragment sources
const std::string vertexShader; ///< source code for vertex program
const std::string fragmentShader; ///< source code for fragment program
+
+private:
+
+ // Undefined copy constructor.
+ ShaderResourceType(const ShaderResourceType& typePath);
+
+ // Undefined assignment operator.
+ ShaderResourceType& operator=(const ShaderResourceType& rhs);
};
/**
* TextResourceType describes a font resource, which can be requested.
* from PlatformAbstraction::LoadResource() No font atlas is created.
*/
-struct DALI_IMPORT_API TextResourceType : public ResourceType
+struct TextResourceType : public ResourceType
{
/**
* Text quality enum
* on the 32 bit words that follow so rather than using the minimum number of
* bits for each, we give "loaded" a whole 8 bits and push it to a byte-aligned
* address to make access possible via a plain byte load instead of a load,
- * mask, shift sequence. The naive bitwidths before this modification are as follows:<code>
+ * mask, shift sequence. The naive bitwidths before this modification are as follows:
* character:21;
* quality:1;
- * loaded:1;</code>
+ * loaded:1;
* @{
*/
uint32_t character:21; ///< character code (UTF-32), max value of 0x10ffff (21 bits)
}
/**
+ * virtual destructor
+ */
+ virtual ~TextResourceType()
+ {
+ }
+
+ /**
* @copydoc ResourceType::Clone
*/
virtual ResourceType* Clone() const
Vector2 mMaxGlyphSize; ///< Max glyph size for font
GlyphCacheMode mCache; ///< Whether text glyphs should be cached.
-};
-/**
- * ModelResourceType describes a model resource, which can be requested
- * from PlatformAbstraction::LoadResource()
- */
-struct DALI_IMPORT_API ModelResourceType : public ResourceType
-{
- /**
- * Default constructor initialises the base class with the correct ResourceTypeId.
- */
- ModelResourceType()
- : ResourceType(ResourceModel)
- {
- }
+private:
- /**
- * @copydoc ResourceType::Clone
- */
- virtual ResourceType* Clone() const
- {
- return new ModelResourceType();
- }
+ // Undefined copy constructor.
+ TextResourceType(const TextResourceType& typePath);
+
+ // Undefined copy constructor.
+ TextResourceType& operator=(const TextResourceType& rhs);
};
* MeshResourceType describes a mesh program resource, which can be created
* using ResourceManager::AllocateMesh.
*/
-struct DALI_IMPORT_API MeshResourceType : public ResourceType
+struct MeshResourceType : public ResourceType
{
/**
- * Default constructor initialises the base class with the correct ResourceTypeId.
+ * Constructor.
*/
MeshResourceType()
: ResourceType(ResourceMesh) {}
/**
+ * Destructor.
+ */
+ virtual ~MeshResourceType() {}
+
+ /**
* @copydoc ResourceType::Clone
*/
virtual ResourceType* Clone() const
{
return new MeshResourceType();
}
+
+private:
+
+ // Undefined copy constructor.
+ MeshResourceType(const MeshResourceType& typePath);
+
+ // Undefined assignment operator.
+ MeshResourceType& operator=(const MeshResourceType& rhs);
};
inline bool operator==(const TextResourceType::GlyphPosition& lhs, const TextResourceType::GlyphPosition& rhs)
} // namespace Dali
#endif // __DALI_INTEGRATION_RESOURCE_TYPES_H__
-