#define __DALI_INTEGRATION_RESOURCE_TYPES_H__
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
// EXTERNAL INCLUDES
#include <stdint.h>
-#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-operations.h>
#include <dali/public-api/math/uint-16-pair.h>
-#include <dali/public-api/math/vector2.h>
-#include <dali/integration-api/resource-declarations.h>
namespace Dali
{
namespace Integration
{
-// Resource Types
-
/**
- * Extendable set of resource types
+ * BitmapResourceType describes a bitmap resource.
*/
-enum ResourceTypeId
-{
- ResourceBitmap,
- ResourceNativeImage,
- ResourceTargetImage,
- ResourceShader
-};
-
-/**
- * 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
+struct BitmapResourceType
{
/**
* Constructor.
FittingMode::Type scalingMode = FittingMode::DEFAULT,
SamplingMode::Type samplingMode = SamplingMode::DEFAULT,
bool orientationCorrection = true )
- : ResourceType(ResourceBitmap),
- size(size), scalingMode(scalingMode), samplingMode(samplingMode), orientationCorrection(orientationCorrection) {}
+ : size( size ),
+ scalingMode( scalingMode ),
+ samplingMode( samplingMode ),
+ orientationCorrection( orientationCorrection )
+ {}
/**
* Destructor.
*/
- virtual ~BitmapResourceType() {}
-
- /**
- * @copydoc ResourceType::Clone
- */
- virtual ResourceType* Clone() const
- {
- return new BitmapResourceType( size, scalingMode, samplingMode, orientationCorrection );
- }
+ ~BitmapResourceType()
+ {}
/**
* Attributes are copied from the request.
// 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.
- */
-struct NativeImageResourceType : public ResourceType
-{
- /**
- * Constructor.
- */
- NativeImageResourceType()
- : ResourceType(ResourceNativeImage) {}
-
- /**
- * Constructor.
- * @param[in] dimensions Width and Height to allocate for image.
- */
- NativeImageResourceType( ImageDimensions dimensions )
- : ResourceType(ResourceNativeImage),
- imageDimensions(dimensions) {}
-
- /**
- * Destructor.
- */
- virtual ~NativeImageResourceType() {}
-
- /**
- * @copydoc ResourceType::Clone
- */
- virtual ResourceType* Clone() const
- {
- return new NativeImageResourceType(imageDimensions);
- }
-
- /**
- * Attributes are copied from the request (if supplied).
- */
- ImageDimensions imageDimensions;
-
-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] dims Width and Height to allocate for image.
- */
- RenderTargetResourceType( ImageDimensions dims )
- : ResourceType(ResourceTargetImage),
- imageDimensions(dims) {}
-
- /**
- * Destructor.
- */
- virtual ~RenderTargetResourceType() {}
-
- /**
- * @copydoc ResourceType::Clone
- */
- virtual ResourceType* Clone() const
- {
- return new RenderTargetResourceType(imageDimensions);
- }
-
- /**
- * Image size is copied from the request.
- */
- ImageDimensions imageDimensions;
-
-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
-
-private:
-
- // Undefined copy constructor.
- ShaderResourceType(const ShaderResourceType& typePath);
-
- // Undefined assignment operator.
- ShaderResourceType& operator=(const ShaderResourceType& rhs);
};
} // namespace Integration