X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fpublic-api%2Fmath%2Fvector3.cpp;h=2b410d0e3d3188373f1f70a597931d09b63c7faf;hb=d54d1e47a70d7fee30d9e045272e5a81c3348128;hp=9afb55b110a1fd3152c59938a0b81780e260e8e9;hpb=055de0438aa78da994e63bc03c486f05cee430da;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/public-api/math/vector3.cpp b/dali/public-api/math/vector3.cpp index 9afb55b..2b410d0 100644 --- a/dali/public-api/math/vector3.cpp +++ b/dali/public-api/math/vector3.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2015 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,10 @@ #include #include +// EXTERNAL INCLUDES +#include +#include + // INTERNAL INCLUDES #include #include @@ -26,10 +30,6 @@ #include #include -// EXTERNAL INCLUDES -#include -#include - namespace Dali { using Internal::PerformanceMonitor; @@ -179,149 +179,4 @@ Vector3 Clamp( const Vector3& v, const float& min, const float& max ) return result; } -Vector3 FitKeepAspectRatio( const Vector3& target, const Vector3& source ) -{ - float scale = 0.0f; - - if ( fabsf(source.x) > 0.0f ) - { - scale = target.x / source.x; - } - - if ( fabsf(source.y) > 0.0f ) - { - if ( scale > Math::MACHINE_EPSILON_1 ) - { - scale = std::min( scale, target.y / source.y ); - } - else - { - scale = target.y / source.y; - } - } - - if ( fabsf(source.z) > 0.0f ) - { - if ( scale > Math::MACHINE_EPSILON_1 ) - { - scale = std::min( scale, target.z / source.z ); - } - else - { - scale = target.z / source.z; - } - } - - if ( scale < Math::MACHINE_EPSILON_1 ) - { - scale = 1.0f; - } - - return Vector3( scale, scale, scale ); -} - -Vector3 FillKeepAspectRatio( const Vector3& target, const Vector3& source ) -{ - float scale = 0.0f; - - if ( fabsf(source.x) > 0.0f ) - { - scale = target.x / source.x; - } - - if ( fabsf(source.y) > 0.0f ) - { - if ( scale > Math::MACHINE_EPSILON_1 ) - { - scale = std::max( scale, target.y / source.y ); - } - else - { - scale = target.y / source.y; - } - } - - if ( fabsf(source.z) > 0.0f ) - { - if ( scale > Math::MACHINE_EPSILON_1 ) - { - scale = std::max( scale, target.z / source.z ); - } - else - { - scale = target.z / source.z; - } - } - - if ( scale < Math::MACHINE_EPSILON_1 ) - { - scale = 1.0f; - } - - return Vector3( scale, scale, scale ); -} - -Vector3 FillXYKeepAspectRatio( const Vector3& target, const Vector3& source ) -{ - float scale = 0.0f; - - if ( fabsf(source.x) > 0.0f ) - { - scale = target.x / source.x; - } - - if ( fabsf(source.y) > 0.0f ) - { - if ( scale > Math::MACHINE_EPSILON_1 ) - { - scale = std::max( scale, target.y / source.y ); - } - else - { - scale = target.y / source.y; - } - } - - if ( scale < Math::MACHINE_EPSILON_1 ) - { - scale = 1.0f; - } - - return Vector3( scale, scale, scale ); -} - -Vector3 ShrinkInsideKeepAspectRatio( const Vector3& target, const Vector3& source ) -{ - // calculate source size vs target size to see if we need to shrink - float widthScale = 1.0f; - if( target.width < source.width ) - { - // not enough width, width needs to shrink - widthScale = target.width / source.width; - } - float heightScale = 1.0f; - if( target.height < source.height ) - { - // not enough height, height needs to shrink - heightScale = target.height / source.height; - } - float depthScale = 1.0f; - if( target.depth < source.depth ) - { - // not enough depth, depth needs to shrink - depthScale = target.depth / source.depth; - } - // use smaller of the scales - float scale = std::min( std::min( widthScale, heightScale ), depthScale ); - - // check if we need to scale - if( scale < 1.0f ) - { - // scale natural size to fit inside - return Vector3( scale, scale, scale ); - } - // there is enough space so use source size - return Vector3::ONE; -} - } // namespace Dali