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