X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fupdate%2Fmanager%2Ftransform-manager.cpp;h=651d23036b90962827dda91130dd90dfb33cd8b4;hb=b43741a90b40ca9dfbd33d6a9d390d3c09230e89;hp=b289bf4be2d55d6ae9499bcbf67d837eee23800a;hpb=d0641c99b5f097f199f6526881da79632c5ccaab;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/update/manager/transform-manager.cpp b/dali/internal/update/manager/transform-manager.cpp old mode 100644 new mode 100755 index b289bf4..651d230 --- a/dali/internal/update/manager/transform-manager.cpp +++ b/dali/internal/update/manager/transform-manager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -21,10 +21,10 @@ //EXTERNAL INCLUDES #include #include +#include //INTERNAL INCLUDES #include -#include #include namespace Dali @@ -42,12 +42,41 @@ namespace static const float gDefaultTransformComponentAnimatableData[] = { 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f }; //Default values for anchor point (CENTER) and parent origin (TOP_LEFT) -static const float gDefaultTransformComponentStaticData[] = { 0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 0.5f }; - -DALI_COMPILE_TIME_ASSERT( sizeof(gDefaultTransformComponentAnimatableData) == sizeof(TransformComponentAnimatable) ); -DALI_COMPILE_TIME_ASSERT( sizeof(gDefaultTransformComponentStaticData) == sizeof(TransformComponentStatic) ); +static const float gDefaultTransformComponentStaticData[] = { 0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 0.5f, true }; + +static_assert( sizeof(gDefaultTransformComponentAnimatableData) == sizeof(TransformComponentAnimatable), "gDefaultTransformComponentAnimatableData should have the same number of floats as specified in TransformComponentAnimatable" ); +static_assert( sizeof(gDefaultTransformComponentStaticData) == sizeof(TransformComponentStatic), "gDefaultTransformComponentStaticData should have the same number of floats as specified in TransformComponentStatic" ); + +/** + * @brief Calculates the center position for the transform component + * @param[out] centerPosition The calculated center-position of the transform component + * @param[in] transformComponentStatic A const reference to the static component transform struct + * @param[in] transformComponentAnimatable A const reference to the animatable component transform struct + * @param[in] size The size of the current transform component + * @param[in] half Halfway point of the transform + * @param[in] topLeft The top-left coords of the transform + */ +inline void CalculateCenterPosition( + Vector3& centerPosition, + const TransformComponentStatic& transformComponentStatic, + const TransformComponentAnimatable& transformComponentAnimatable, + const Vector3& size, + const Vector3& half, + const Vector3& topLeft ) +{ + // Calculate the center-point by applying the scale and rotation on the anchor point. + centerPosition = ( half - transformComponentStatic.mAnchorPoint ) * size * transformComponentAnimatable.mScale; + centerPosition *= transformComponentAnimatable.mOrientation; + + // If the position is ignoring the anchor-point, then remove the anchor-point shift from the position. + if( ! transformComponentStatic.mPositionUsesAnchorPoint ) + { + centerPosition -= ( topLeft - transformComponentStatic.mAnchorPoint ) * size; + } } +} // unnamed namespace + TransformManager::TransformManager() :mComponentCount(0), mReorder(false) @@ -77,6 +106,10 @@ TransformId TransformManager::CreateTransform() mSizeBase.PushBack(Vector3(0.0f,0.0f,0.0f)); mComponentDirty.PushBack(false); mLocalMatrixDirty.PushBack(false); + mComponentChanged.PushBack(false); + mPrevWorld.PushBack(Matrix::IDENTITY); + mUpdateSizeHint.PushBack(Vector3(0.0f,0.0f,0.0f)); + mUpdateSizeHintBase.PushBack(Vector3(0.0f,0.0f,0.0f)); } else { @@ -94,6 +127,10 @@ TransformId TransformManager::CreateTransform() mSizeBase[mComponentCount] = Vector3(0.0f,0.0f,0.0f); mComponentDirty[mComponentCount] = false; mLocalMatrixDirty[mComponentCount] = false; + mComponentChanged[mComponentCount] = false; + mPrevWorld[mComponentCount].SetIdentity(); + mUpdateSizeHint[mComponentCount] = Vector3(0.0f,0.0f,0.0f); + mUpdateSizeHintBase[mComponentCount] = Vector3(0.0f,0.0f,0.0f); } mComponentCount++; @@ -104,7 +141,7 @@ void TransformManager::RemoveTransform(TransformId id) { //Move the last element to the gap mComponentCount--; - unsigned int index = mIds[id]; + TransformId index = mIds[id]; mTxComponentAnimatable[index] = mTxComponentAnimatable[mComponentCount]; mTxComponentStatic[index] = mTxComponentStatic[mComponentCount]; mInheritanceMode[index] = mInheritanceMode[mComponentCount]; @@ -117,6 +154,10 @@ void TransformManager::RemoveTransform(TransformId id) mComponentDirty[index] = mComponentDirty[mComponentCount]; mLocalMatrixDirty[index] = mLocalMatrixDirty[mComponentCount]; mBoundingSpheres[index] = mBoundingSpheres[mComponentCount]; + mComponentChanged[index] = mComponentChanged[mComponentCount]; + mPrevWorld[index] = mPrevWorld[mComponentCount]; + mUpdateSizeHint[index] = mUpdateSizeHint[mComponentCount]; + mUpdateSizeHintBase[index] = mUpdateSizeHintBase[mComponentCount]; TransformId lastItemId = mComponentId[mComponentCount]; mIds[ lastItemId ] = index; @@ -129,7 +170,7 @@ void TransformManager::RemoveTransform(TransformId id) void TransformManager::SetParent( TransformId id, TransformId parentId ) { DALI_ASSERT_ALWAYS( id != parentId ); - unsigned int index = mIds[id]; + TransformId index = mIds[id]; mParent[ index ] = parentId; mComponentDirty[ index ] = true; mReorder = true; @@ -147,7 +188,7 @@ Matrix& TransformManager::GetWorldMatrix( TransformId id ) void TransformManager::SetInheritPosition( TransformId id, bool inherit ) { - unsigned int index = mIds[id]; + TransformId index = mIds[id]; if( inherit ) { mInheritanceMode[ index ] |= INHERIT_POSITION; @@ -162,7 +203,7 @@ void TransformManager::SetInheritPosition( TransformId id, bool inherit ) void TransformManager::SetInheritScale( TransformId id, bool inherit ) { - unsigned int index = mIds[id]; + TransformId index = mIds[id]; if( inherit ) { mInheritanceMode[ index ] |= INHERIT_SCALE; @@ -177,7 +218,7 @@ void TransformManager::SetInheritScale( TransformId id, bool inherit ) void TransformManager::SetInheritOrientation( TransformId id, bool inherit ) { - unsigned int index = mIds[id]; + TransformId index = mIds[id]; if( inherit ) { mInheritanceMode[ index ] |= INHERIT_ORIENTATION; @@ -186,7 +227,6 @@ void TransformManager::SetInheritOrientation( TransformId id, bool inherit ) { mInheritanceMode[ index ] &= ~INHERIT_ORIENTATION; } - mComponentDirty[index] = true; } @@ -197,6 +237,7 @@ void TransformManager::ResetToBaseValue() memcpy( &mTxComponentAnimatable[0], &mTxComponentAnimatableBaseValue[0], sizeof(TransformComponentAnimatable)*mComponentCount ); memcpy( &mSize[0], &mSizeBase[0], sizeof(Vector3)*mComponentCount ); memset( &mLocalMatrixDirty[0], false, sizeof(bool)*mComponentCount ); + memcpy( &mUpdateSizeHint[0], &mUpdateSizeHintBase[0], sizeof(Vector3)*mComponentCount ); } } @@ -211,25 +252,26 @@ void TransformManager::Update() } //Iterate through all components to compute its world matrix - Vector3 anchorPosition; + Vector3 centerPosition; Vector3 localPosition; - Vector3 half( 0.5f,0.5f,0.5f ); + const Vector3 half( 0.5f,0.5f,0.5f ); + const Vector3 topLeft( 0.0f, 0.0f, 0.5f ); for( unsigned int i(0); i