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.
18 * @file FUiEffects_RuntimeUnitLight.cpp
19 * @brief This file contains an implementation of UnitLight class methods
23 #include <FBaseSysLog.h>
24 #include <FUiEffects_EffectErrorMessages.h>
25 #include <FUiEffects_RuntimeUnitLight.h>
27 using namespace Tizen::Ui::Effects::_Utils;
30 namespace Tizen { namespace Ui { namespace Effects { namespace _Runtime
33 UnitLight::ObjectsPool UnitLight::__objectsPool = UnitLight::ObjectsPool();
35 UnitLight::UnitLight(const string& name) :
36 isEnabledChanged(false)
37 , isColourChanged(false)
38 , isIntensityChanged(false)
39 , isSomethingChanged(false)
42 , __colour(1.f, 0.f, 0.f)
48 UnitLight::UnitLight(bool enabled,
52 isEnabledChanged(false)
53 , isColourChanged(false)
54 , isIntensityChanged(false)
55 , isSomethingChanged(false)
59 , __intensity(intensity)
64 UnitLight::~UnitLight(void)
70 UnitLight::GetEnabled(void) const
76 UnitLight::GetColour(void) const
82 UnitLight::GetIntensity(void) const
88 UnitLight::GetName(void) const
94 UnitLight::SetEnabled(bool enabled)
96 if (__enabled != enabled)
99 if (!isEnabledChanged)
101 isEnabledChanged = true;
102 isSomethingChanged = true;
106 isEnabledChanged = false;
113 UnitLight::SetColour(const Vec3f& colour)
115 SetColour(colour.x, colour.y, colour.z);
120 UnitLight::SetColour(float red, float green, float blue)
122 if (fabs(__colour.x - red) > EFFECT_EPSILONF
123 || fabs(__colour.y - green) > EFFECT_EPSILONF
124 || fabs(__colour.z - blue) > EFFECT_EPSILONF)
129 isColourChanged = true;
130 isSomethingChanged = true;
136 UnitLight::SetIntensity(float intensity)
138 if (fabs(__intensity - intensity) > EFFECT_EPSILONF)
140 __intensity = intensity;
141 isIntensityChanged = true;
142 isSomethingChanged = true;
147 UnitLight::ResetSigns(void)
149 isEnabledChanged = false;
150 isColourChanged = false;
151 isIntensityChanged = false;
152 isSomethingChanged = false;
156 UnitLight::AddUnitLightToPool(UnitLight* unitLigth)
158 if (unitLigth == null)
163 SysAssertf(IsUnitLightInPool(*unitLigth).first == false, _UiEffectError::INTERNAL_ERROR);
164 __objectsPool.push_back(unitLigth);
170 UnitLight::ReleaseObjectsPool(void)
172 ObjectsPool::iterator it = __objectsPool.begin();
173 for (; it != __objectsPool.end(); ++it)
175 SysAssertf(*it != null, _UiEffectError::INTERNAL_ERROR);
178 __objectsPool.clear();
181 UnitLight::DoesExistsInPool
182 UnitLight::IsUnitLightInPool(UnitLight& unitLight)
184 ObjectsPool::iterator it = __objectsPool.begin();
185 for (; it != __objectsPool.end(); ++it)
187 if (&unitLight == *it)
189 return make_pair(true, it);
192 return make_pair(false, __objectsPool.end());
196 UnitLight::RemoveUnitLightFromPool(ObjectsPool::iterator it)
198 __objectsPool.erase(it);
201 } } } } // Tizen::Ui::Effects::_Runtime