X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fintegration-api%2Fresource-types.h;h=fd0decff7cc55e99ae570b33155b29b995121ace;hb=d12ff6718dd01d8fa663550ff178e228062c40d4;hp=3319aaed2e4decf8dba3161d329bb7283151bdc3;hpb=73c37a734c864d1098c86a44a064c9f35a2ed15d;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/integration-api/resource-types.h b/dali/integration-api/resource-types.h index 3319aae..fd0decf 100644 --- a/dali/integration-api/resource-types.h +++ b/dali/integration-api/resource-types.h @@ -1,8 +1,8 @@ -#ifndef __DALI_INTEGRATION_RESOURCE_TYPES_H__ -#define __DALI_INTEGRATION_RESOURCE_TYPES_H__ +#ifndef DALI_INTEGRATION_RESOURCE_TYPES_H +#define DALI_INTEGRATION_RESOURCE_TYPES_H /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -20,286 +20,66 @@ // EXTERNAL INCLUDES #include -#include // INTERNAL INCLUDES -#include -#include -#include -#include +#include +#include namespace Dali { +using ImageDimensions = Uint16Pair; namespace Integration { - -// Resource Types - -/** - * Extendable set of resource types - */ -enum ResourceTypeId -{ - ResourceBitmap, - ResourceNativeImage, - ResourceTargetImage, - ResourceShader, - ResourceMesh -}; - -/** - * The abstract base class for resource types. - */ -struct ResourceType -{ - /** - * Constructor. - * @param[in] typeId resource type id - */ - ResourceType(ResourceTypeId typeId) - : id(typeId) {} - - /** - * Destructor. - */ - virtual ~ResourceType() {} - - /** - * Create a copy of the resource type with the same attributes. - * @return pointer to the new ResourceType. - */ - virtual ResourceType* Clone() const = 0; - - const ResourceTypeId id; - -private: - - // Undefined copy constructor. - ResourceType(const ResourceType& typePath); - - // Undefined assignment operator. - ResourceType& operator=(const ResourceType& rhs); -}; - -/** - * BitmapResourceType describes a bitmap resource, which can be requested - * from ResourceLoader::LoadResource() or AllocateBitmapImage. - */ -struct BitmapResourceType : public ResourceType -{ - /** - * Constructor. - * @param[in] attribs parameters for image loading request - */ - BitmapResourceType(const ImageAttributes& attribs) - : ResourceType(ResourceBitmap), - imageAttributes(attribs) {} - - /** - * Destructor. - */ - virtual ~BitmapResourceType() {} - - /** - * @copydoc ResourceType::Clone - */ - virtual ResourceType* Clone() const - { - 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); -}; - /** - * NativeImageResourceType describes a native image resource, which can be injected - * through ResourceManager::AddNativeImage() or requested through ResourceLoader::LoadResource(). - * If the adaptor does not support NativeImages, it can fall back to Bitmap type. + * BitmapResourceType describes a bitmap resource. */ -struct NativeImageResourceType : public ResourceType +struct BitmapResourceType { /** * Constructor. - */ - NativeImageResourceType() - : ResourceType(ResourceNativeImage) {} - - /** - * Constructor. - * @param[in] attribs parameters for image loading request - */ - NativeImageResourceType(const ImageAttributes& attribs) - : ResourceType(ResourceNativeImage), - imageAttributes(attribs) {} - - /** - * Destructor. - */ - virtual ~NativeImageResourceType() {} - - /** - * @copydoc ResourceType::Clone - */ - virtual ResourceType* Clone() const + * @param[in] size The requested size for the bitmap. + * @param[in] scalingMode The method to use to map the source bitmap to the desired + * dimensions. + * @param[in] samplingMode The filter to use if the bitmap needs to be downsampled + * to the requested size. + * @param[in] orientationCorrection Whether to use bitmap metadata to rotate or + * flip the bitmap, e.g., from portrait to landscape. + */ + BitmapResourceType(ImageDimensions size = ImageDimensions(0, 0), + FittingMode::Type scalingMode = FittingMode::DEFAULT, + SamplingMode::Type samplingMode = SamplingMode::DEFAULT, + bool orientationCorrection = true) + : size(size), + scalingMode(scalingMode), + samplingMode(samplingMode), + orientationCorrection(orientationCorrection) { - return new NativeImageResourceType(imageAttributes); } /** - * 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 RenderTargetResourceType : public ResourceType -{ - /** - * Constructor. - */ - RenderTargetResourceType() - : ResourceType(ResourceTargetImage) {} - - /** - * Constructor. - * @param[in] attribs parameters for image loading request - */ - RenderTargetResourceType(const ImageAttributes& attribs) - : ResourceType(ResourceTargetImage), - imageAttributes(attribs) {} - - /** * Destructor. */ - virtual ~RenderTargetResourceType() {} - - /** - * @copydoc ResourceType::Clone - */ - virtual ResourceType* Clone() const - { - return new RenderTargetResourceType(imageAttributes); - } + ~BitmapResourceType() = default; /** * 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 ShaderResourceType : public ResourceType -{ - /** - * Constructor. - */ - ShaderResourceType(size_t shaderHash, const std::string& vertexSource, const std::string& fragmentSource) - : ResourceType(ResourceShader), - hash(shaderHash), - vertexShader(vertexSource), - fragmentShader(fragmentSource) - { - } - - /** - * Destructor. - */ - virtual ~ShaderResourceType() - { - } - - /** - * @copydoc ResourceType::Clone - */ - virtual ResourceType* Clone() const - { - return new ShaderResourceType(hash, vertexShader, fragmentShader); - } - -public: // Attributes - 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 + ImageDimensions size; + FittingMode::Type scalingMode; + SamplingMode::Type samplingMode; + bool orientationCorrection; private: - // Undefined copy constructor. - ShaderResourceType(const ShaderResourceType& typePath); - - // Undefined assignment operator. - ShaderResourceType& operator=(const ShaderResourceType& rhs); -}; - -/** - * MeshResourceType describes a mesh program resource, which can be created - * using ResourceManager::AllocateMesh. - */ -struct MeshResourceType : public ResourceType -{ - /** - * 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); + BitmapResourceType(const BitmapResourceType& typePath); // Undefined assignment operator. - MeshResourceType& operator=(const MeshResourceType& rhs); + BitmapResourceType& operator=(const BitmapResourceType& rhs); }; } // namespace Integration } // namespace Dali -#endif // __DALI_INTEGRATION_RESOURCE_TYPES_H__ +#endif // DALI_INTEGRATION_RESOURCE_TYPES_H