[dali_1.2.39] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / integration-api / resource-types.h
1 #ifndef __DALI_INTEGRATION_RESOURCE_TYPES_H__
2 #define __DALI_INTEGRATION_RESOURCE_TYPES_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <stdint.h>
23 #include <string>
24
25 // INTERNAL INCLUDES
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>
32
33 namespace Dali
34 {
35
36 typedef Uint16Pair ImageDimensions;
37
38 namespace Integration
39 {
40
41 // Resource Types
42
43 /**
44  * Extendable set of resource types
45  */
46 enum ResourceTypeId
47 {
48   ResourceBitmap
49 };
50
51 /**
52  * The abstract base class for resource types.
53  */
54 struct ResourceType
55 {
56   /**
57    * Constructor.
58    * @param[in] typeId resource type id
59    */
60   ResourceType(ResourceTypeId typeId)
61   : id(typeId) {}
62
63   /**
64    * Destructor.
65    */
66   virtual ~ResourceType() {}
67
68   /**
69    * Create a copy of the resource type with the same attributes.
70    * @return pointer to the new ResourceType.
71    */
72   virtual ResourceType* Clone() const = 0;
73
74   const ResourceTypeId id;
75
76 private:
77
78   // Undefined copy constructor.
79   ResourceType(const ResourceType& typePath);
80
81   // Undefined assignment operator.
82   ResourceType& operator=(const ResourceType& rhs);
83 };
84
85 /**
86  * BitmapResourceType describes a bitmap resource, which can be requested
87  * from ResourceLoader::LoadResource() or AllocateBitmapImage.
88  */
89 struct BitmapResourceType : public ResourceType
90 {
91   /**
92    * Constructor.
93    * @param[in] size The requested size for the bitmap.
94    * @param[in] scalingMode The method to use to map the source bitmap to the desired
95    * dimensions.
96    * @param[in] samplingMode The filter to use if the bitmap needs to be downsampled
97    * to the requested size.
98    * @param[in] orientationCorrection Whether to use bitmap metadata to rotate or
99    * flip the bitmap, e.g., from portrait to landscape.
100    */
101   BitmapResourceType( ImageDimensions size = ImageDimensions( 0, 0 ),
102                       FittingMode::Type scalingMode = FittingMode::DEFAULT,
103                       SamplingMode::Type samplingMode = SamplingMode::DEFAULT,
104                       bool orientationCorrection = true )
105   : ResourceType(ResourceBitmap),
106     size(size), scalingMode(scalingMode), samplingMode(samplingMode), orientationCorrection(orientationCorrection) {}
107
108   /**
109    * Destructor.
110    */
111   virtual ~BitmapResourceType() {}
112
113   /**
114    * @copydoc ResourceType::Clone
115    */
116   virtual ResourceType* Clone() const
117   {
118     return new BitmapResourceType( size, scalingMode, samplingMode, orientationCorrection );
119   }
120
121   /**
122    * Attributes are copied from the request.
123    */
124   ImageDimensions size;
125   FittingMode::Type scalingMode;
126   SamplingMode::Type samplingMode;
127   bool orientationCorrection;
128
129 private:
130
131   // Undefined copy constructor.
132   BitmapResourceType(const BitmapResourceType& typePath);
133
134   // Undefined assignment operator.
135   BitmapResourceType& operator=(const BitmapResourceType& rhs);
136 };
137
138 } // namespace Integration
139
140 } // namespace Dali
141
142 #endif // __DALI_INTEGRATION_RESOURCE_TYPES_H__