2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FGrpFloatDimension.cpp
20 * @brief This is the implementation file for FloatDimension class.
22 * This file contains implementation of Point class.
26 #include <FGrpFloatDimension.h>
32 // epsilon is assumed to be 0.00001f, not 1.192092896e-07f
33 const float _EPSILON = 0.00001f;
36 _IsEqual(float f1, float f2)
38 return (((f1 > f2) ? f1 - f2 : f2 - f1) < _EPSILON);
43 namespace Tizen { namespace Graphics
46 FloatDimension::FloatDimension(void)
53 FloatDimension::FloatDimension(const FloatDimension& rhs)
60 FloatDimension::FloatDimension(float width_, float height_)
67 FloatDimension::~FloatDimension(void)
72 FloatDimension::operator=(const FloatDimension& rhs)
79 this->width = rhs.width;
80 this->height = rhs.height;
87 FloatDimension::operator ==(const FloatDimension& rhs) const
89 return ((_IsEqual(this->width, rhs.width) && _IsEqual(this->height, rhs.height)) ? true : false);
93 FloatDimension::operator !=(const FloatDimension& rhs) const
95 return (!operator ==(rhs));
99 FloatDimension::Equals(const Tizen::Base::Object& rhs) const
106 const FloatDimension* pDim = dynamic_cast <const FloatDimension*>(&rhs);
113 return (*this == *pDim);
117 FloatDimension::GetHashCode(void) const
119 const float inverseEpsilon = 1.0f / _EPSILON;
121 int reinterpretedX = int(this->width * inverseEpsilon);
122 int reinterpretedY = int(this->height * inverseEpsilon);
124 return reinterpretedX ^ (reinterpretedY * 31);
128 FloatDimension::SetSize(float width, float height)
131 this->height = height;
134 }} // Tizen::Graphics