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.
26 #include <dali/public-api/common/dali-common.h>
27 #include <dali/public-api/common/vector-wrapper.h>
28 #include <dali/public-api/images/image-operations.h>
29 #include <dali/public-api/math/uint-16-pair.h>
30 #include <dali/public-api/math/vector2.h>
31 #include <dali/integration-api/resource-declarations.h>
36 typedef Uint16Pair ImageDimensions;
44 * Extendable set of resource types
54 * The abstract base class for resource types.
60 * @param[in] typeId resource type id
62 ResourceType(ResourceTypeId typeId)
68 virtual ~ResourceType() {}
71 * Create a copy of the resource type with the same attributes.
72 * @return pointer to the new ResourceType.
74 virtual ResourceType* Clone() const = 0;
76 const ResourceTypeId id;
80 // Undefined copy constructor.
81 ResourceType(const ResourceType& typePath);
83 // Undefined assignment operator.
84 ResourceType& operator=(const ResourceType& rhs);
88 * BitmapResourceType describes a bitmap resource, which can be requested
89 * from ResourceLoader::LoadResource() or AllocateBitmapImage.
91 struct BitmapResourceType : public ResourceType
95 * @param[in] size The requested size for the bitmap.
96 * @param[in] scalingMode The method to use to map the source bitmap to the desired
98 * @param[in] samplingMode The filter to use if the bitmap needs to be downsampled
99 * to the requested size.
100 * @param[in] orientationCorrection Whether to use bitmap metadata to rotate or
101 * flip the bitmap, e.g., from portrait to landscape.
103 BitmapResourceType( ImageDimensions size = ImageDimensions( 0, 0 ),
104 FittingMode::Type scalingMode = FittingMode::DEFAULT,
105 SamplingMode::Type samplingMode = SamplingMode::DEFAULT,
106 bool orientationCorrection = true )
107 : ResourceType(ResourceBitmap),
108 size(size), scalingMode(scalingMode), samplingMode(samplingMode), orientationCorrection(orientationCorrection) {}
113 virtual ~BitmapResourceType() {}
116 * @copydoc ResourceType::Clone
118 virtual ResourceType* Clone() const
120 return new BitmapResourceType( size, scalingMode, samplingMode, orientationCorrection );
124 * Attributes are copied from the request.
126 ImageDimensions size;
127 FittingMode::Type scalingMode;
128 SamplingMode::Type samplingMode;
129 bool orientationCorrection;
133 // Undefined copy constructor.
134 BitmapResourceType(const BitmapResourceType& typePath);
136 // Undefined assignment operator.
137 BitmapResourceType& operator=(const BitmapResourceType& rhs);
141 * NativeImageResourceType describes a native image resource, which can be injected
142 * through ResourceManager::AddNativeImage() or requested through ResourceLoader::LoadResource().
143 * If the adaptor does not support NativeImages, it can fall back to Bitmap type.
145 struct NativeImageResourceType : public ResourceType
150 NativeImageResourceType()
151 : ResourceType(ResourceNativeImage) {}
155 * @param[in] dimensions Width and Height to allocate for image.
157 NativeImageResourceType( ImageDimensions dimensions )
158 : ResourceType(ResourceNativeImage),
159 imageDimensions(dimensions) {}
164 virtual ~NativeImageResourceType() {}
167 * @copydoc ResourceType::Clone
169 virtual ResourceType* Clone() const
171 return new NativeImageResourceType(imageDimensions);
175 * Attributes are copied from the request (if supplied).
177 ImageDimensions imageDimensions;
181 // Undefined copy constructor.
182 NativeImageResourceType(const NativeImageResourceType& typePath);
184 // Undefined assignment operator.
185 NativeImageResourceType& operator=(const NativeImageResourceType& rhs);
189 * RenderTargetResourceType describes a bitmap resource, which can injected
190 * through ResourceManager::AddTargetImage()
192 struct RenderTargetResourceType : public ResourceType
197 RenderTargetResourceType()
198 : ResourceType(ResourceTargetImage) {}
202 * @param[in] dims Width and Height to allocate for image.
204 RenderTargetResourceType( ImageDimensions dims )
205 : ResourceType(ResourceTargetImage),
206 imageDimensions(dims) {}
211 virtual ~RenderTargetResourceType() {}
214 * @copydoc ResourceType::Clone
216 virtual ResourceType* Clone() const
218 return new RenderTargetResourceType(imageDimensions);
222 * Image size is copied from the request.
224 ImageDimensions imageDimensions;
228 // Undefined copy constructor.
229 RenderTargetResourceType(const RenderTargetResourceType& typePath);
231 // Undefined assignment operator.
232 RenderTargetResourceType& operator=(const RenderTargetResourceType& rhs);
235 } // namespace Integration
239 #endif // __DALI_INTEGRATION_RESOURCE_TYPES_H__