Dali 3D User Interface Engine
image-attributes.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 // CLASS HEADER
20 
21 // EXTERNAL INCLUDES
22 #include <cmath>
23 
24 namespace Dali
25 {
26 namespace Internal
27 {
28 
29 const ImageAttributes ImageAttributes::DEFAULT_ATTRIBUTES;
30 
32 {
34  : width(0),
35  height(0),
36  scaling(Dali::FittingMode::SHRINK_TO_FIT),
37  filtering(SamplingMode::BOX),
39  {
40  }
41 
43  {
44  }
45 
47  : width( rhs.width ),
48  height( rhs.height ),
49  scaling( rhs.scaling ),
50  filtering( rhs.filtering ),
52  {
53  }
54 
56  {
57  if (this != &rhs)
58  {
59  width = rhs.width;
60  height = rhs.height;
61  scaling = rhs.scaling;
62  filtering = rhs.filtering;
63 
65  }
66 
67  return *this;
68  }
69 
70  unsigned int width : 16;
71  unsigned int height : 16;
75 };
76 
77 
79 : impl( new ImageAttributesImpl() )
80 {
81 }
82 
84 : impl( new ImageAttributesImpl(*rhs.impl) )
85 {
86 }
87 
89 {
90  *impl = *rhs.impl;
91 
92  return *this;
93 }
94 
96 {
97  delete impl;
98 }
99 
100 void ImageAttributes::SetSize(unsigned int width, unsigned int height)
101 {
102  impl->width = width;
103  impl->height = height;
104 }
105 
106 void ImageAttributes::SetSize( const Size& size )
107 {
108  impl->width = size.width;
109  impl->height = size.height;
110 }
111 
113 {
114  impl->scaling = scale;
115 }
116 
118 {
119  impl->filtering = filtering;
120 }
121 
123 {
124  impl->mOrientationCorrection = enabled;
125 }
126 
127 void ImageAttributes::Reset( ImageDimensions dimensions, ScalingMode scaling, FilterMode sampling, bool orientationCorrection )
128 {
129  impl->width = dimensions.GetWidth();
130  impl->height = dimensions.GetHeight();
131  impl->scaling = scaling;
132  impl->filtering = sampling;
133  impl->mOrientationCorrection = orientationCorrection;
134 }
135 
136 unsigned int ImageAttributes::GetWidth() const
137 {
138  return impl->width;
139 }
140 
141 unsigned int ImageAttributes::GetHeight() const
142 {
143  return impl->height;
144 }
145 
147 {
148  return Size(impl->width, impl->height);
149 }
150 
152 {
153  return impl->scaling;
154 }
155 
157 {
158  return impl->filtering;
159 }
160 
162 {
163  return impl->mOrientationCorrection;
164 }
165 
167 {
168  return ImageAttributes();
169 }
170 
171 ImageAttributes ImageAttributes::New(unsigned int imageWidth, unsigned int imageHeight)
172 {
173  ImageAttributes attributes;
174  attributes.impl->width = imageWidth;
175  attributes.impl->height = imageHeight;
176  return attributes;
177 }
178 
185 {
186  if (a.impl->width != b.impl->width)
187  {
188  return a.impl->width < b.impl->width;
189  }
190 
191  if (a.impl->height != b.impl->height)
192  {
193  return a.impl->height < b.impl->height;
194  }
195 
196  if (a.impl->mOrientationCorrection != b.impl->mOrientationCorrection)
197  {
198  return a.impl->mOrientationCorrection < b.impl->mOrientationCorrection;
199  }
200 
201  if (a.impl->scaling != b.impl->scaling)
202  {
203  return a.impl->scaling < b.impl->scaling;
204  }
205 
206  if (a.impl->filtering != b.impl->filtering)
207  {
208  return a.impl->filtering < b.impl->filtering;
209  }
210 
211  // they are equal
212  return false;
213 }
214 
221 {
222  return a.impl->width == b.impl->width &&
223  a.impl->height == b.impl->height &&
224  a.impl->mOrientationCorrection == b.impl->mOrientationCorrection &&
225  a.impl->scaling == b.impl->scaling &&
226  a.impl->filtering == b.impl->filtering;
227 }
228 
235 {
236  return !(a == b);
237 }
238 
239 } // namespace Internal
240 } // namespace Dali
Dali Docs Home
Read more about Dali