X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fupdate%2Fmanager%2Fupdate-proxy-impl.cpp;h=22b45a342eae190227abfeb7446c7958e2e32158;hb=481e9d8aefa1276909f0598d18c8533b93a2e31c;hp=85404a915e9987e70ba7273e918edd992c656d41;hpb=8c3caa8bda5ec3573039af783dd81789fb1cc871;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/update/manager/update-proxy-impl.cpp b/dali/internal/update/manager/update-proxy-impl.cpp index 85404a9..22b45a3 100644 --- a/dali/internal/update/manager/update-proxy-impl.cpp +++ b/dali/internal/update/manager/update-proxy-impl.cpp @@ -18,6 +18,9 @@ // CLASS HEADER #include +// INTERNAL INCLUDES +#include + namespace Dali { @@ -27,7 +30,7 @@ namespace Internal namespace { -SceneGraph::Node* FindNodeInSceneGraph( unsigned int id, SceneGraph::Node& node ) +SceneGraph::Node* FindNodeInSceneGraph( uint32_t id, SceneGraph::Node& node ) { SceneGraph::Node* matchingNode = NULL; @@ -52,12 +55,14 @@ SceneGraph::Node* FindNodeInSceneGraph( unsigned int id, SceneGraph::Node& node } // unnamed namespace -UpdateProxy::UpdateProxy( SceneGraph::TransformManager& transformManager, SceneGraph::Node& rootNode ) +UpdateProxy::UpdateProxy( SceneGraph::UpdateManager& updateManager, SceneGraph::TransformManager& transformManager, SceneGraph::Node& rootNode ) : mNodeContainer(), mLastCachedIdNodePair( { 0u, NULL } ), mCurrentBufferIndex( 0u ), + mUpdateManager( updateManager ), mTransformManager( transformManager ), - mRootNode( rootNode ) + mRootNode( rootNode ), + mPropertyModifier( nullptr ) { } @@ -65,101 +70,175 @@ UpdateProxy::~UpdateProxy() { } -Vector3 UpdateProxy::GetPosition( unsigned int id ) const +bool UpdateProxy::GetPosition( uint32_t id, Vector3& position ) const { - const Dali::Matrix& matrix = GetWorldMatrix( id ); - return matrix.GetTranslation3(); + bool success = false; + const SceneGraph::Node* node = GetNodeWithId( id ); + if( node ) + { + position = mTransformManager.GetVector3PropertyValue( node->mTransformId, SceneGraph::TRANSFORM_PROPERTY_POSITION ); + success = true; + } + return success; } -void UpdateProxy::SetPosition( unsigned int id, const Vector3& position ) +bool UpdateProxy::SetPosition( uint32_t id, const Vector3& position ) { - const SceneGraph::Node* node = GetNodeWithId( id ); + bool success = false; + SceneGraph::Node* node = GetNodeWithId( id ); if( node ) { - Matrix& matrix = mTransformManager.GetWorldMatrix( node->mTransformId ); - matrix.SetTranslation( position ); + mTransformManager.SetVector3PropertyValue( node->mTransformId, SceneGraph::TRANSFORM_PROPERTY_POSITION, position ); + success = true; } + return success; } -const Vector3& UpdateProxy::GetSize( unsigned int id ) const +bool UpdateProxy::BakePosition( uint32_t id, const Vector3& position ) { - const SceneGraph::Node* node = GetNodeWithId( id ); + bool success = false; + SceneGraph::Node* node = GetNodeWithId( id ); if( node ) { - return mTransformManager.GetVector3PropertyValue( node->mTransformId, SceneGraph::TRANSFORM_PROPERTY_SIZE ); + mTransformManager.BakeVector3PropertyValue( node->mTransformId, SceneGraph::TRANSFORM_PROPERTY_POSITION, position ); + success = true; } + return success; +} - return Vector3::ZERO; +bool UpdateProxy::GetSize( uint32_t id, Vector3& size ) const +{ + bool success = false; + const SceneGraph::Node* node = GetNodeWithId( id ); + if( node ) + { + size = mTransformManager.GetVector3PropertyValue( node->mTransformId, SceneGraph::TRANSFORM_PROPERTY_SIZE ); + success = true; + } + return success; } -void UpdateProxy::SetSize( unsigned int id, const Vector3& size ) +bool UpdateProxy::SetSize( uint32_t id, const Vector3& size ) { + bool success = false; SceneGraph::Node* node = GetNodeWithId( id ); if( node ) { mTransformManager.SetVector3PropertyValue( node->mTransformId, SceneGraph::TRANSFORM_PROPERTY_SIZE, size ); + success = true; } + return success; } -void UpdateProxy::GetPositionAndSize( unsigned int id, Vector3& position, Vector3& size ) const +bool UpdateProxy::BakeSize( uint32_t id, const Vector3& size ) { - Matrix worldMatrix( false ); - GetWorldMatrixAndSize( id, worldMatrix, size ); - position = worldMatrix.GetTranslation3(); + bool success = false; + SceneGraph::Node* node = GetNodeWithId( id ); + if( node ) + { + mTransformManager.BakeVector3PropertyValue( node->mTransformId, SceneGraph::TRANSFORM_PROPERTY_SIZE, size ); + success = true; + } + return success; } -Vector4 UpdateProxy::GetWorldColor( unsigned int id ) const +bool UpdateProxy::GetPositionAndSize( uint32_t id, Vector3& position, Vector3& size ) const { - SceneGraph::Node* node = GetNodeWithId( id ); + bool success = false; + const SceneGraph::Node* node = GetNodeWithId( id ); if( node ) { - return node->mWorldColor.Get( mCurrentBufferIndex ); + position = mTransformManager.GetVector3PropertyValue( node->mTransformId, SceneGraph::TRANSFORM_PROPERTY_POSITION ); + size = mTransformManager.GetVector3PropertyValue( node->mTransformId, SceneGraph::TRANSFORM_PROPERTY_SIZE ); + success = true; } + return success; +} - return Vector4::ZERO; +bool UpdateProxy::GetScale( uint32_t id, Vector3& scale ) const +{ + bool success = false; + const SceneGraph::Node* node = GetNodeWithId( id ); + if( node ) + { + scale = mTransformManager.GetVector3PropertyValue( node->mTransformId, SceneGraph::TRANSFORM_PROPERTY_SCALE ); + success = true; + } + + return success; } -void UpdateProxy::SetWorldColor( unsigned int id, const Vector4& color ) const +bool UpdateProxy::SetScale( uint32_t id, const Vector3& scale ) { + bool success = false; SceneGraph::Node* node = GetNodeWithId( id ); if( node ) { - Vector4& currentColor = node->mWorldColor.Get( mCurrentBufferIndex ); - currentColor = color; + mTransformManager.SetVector3PropertyValue( node->mTransformId, SceneGraph::TRANSFORM_PROPERTY_SCALE, scale ); + success = true; } + return success; } -void UpdateProxy::GetWorldMatrixAndSize( unsigned int id, Matrix& worldMatrix, Vector3& size ) const +bool UpdateProxy::BakeScale( uint32_t id, const Vector3& scale ) { - const SceneGraph::Node* node = GetNodeWithId( id ); + bool success = false; + SceneGraph::Node* node = GetNodeWithId( id ); if( node ) { - mTransformManager.GetWorldMatrixAndSize( node->mTransformId, worldMatrix, size ); + mTransformManager.BakeVector3PropertyValue( node->mTransformId, SceneGraph::TRANSFORM_PROPERTY_SCALE, scale ); + success = true; } + return success; } -const Matrix& UpdateProxy::GetWorldMatrix( unsigned int id ) const +bool UpdateProxy::GetColor( uint32_t id, Vector4& color ) const { - const SceneGraph::Node* node = GetNodeWithId( id ); + bool success = false; + SceneGraph::Node* node = GetNodeWithId( id ); if( node ) { - return mTransformManager.GetWorldMatrix( node->mTransformId ); + color = node->mColor.Get( mCurrentBufferIndex ); + success = true; } - return Matrix::IDENTITY; + return success; } -void UpdateProxy::SetWorldMatrix( unsigned int id, const Matrix& worldMatrix ) +bool UpdateProxy::SetColor( uint32_t id, const Vector4& color ) { + bool success = false; SceneGraph::Node* node = GetNodeWithId( id ); if( node ) { - Matrix& currentMatrix = mTransformManager.GetWorldMatrix( node->mTransformId ); - currentMatrix = worldMatrix; + node->mColor.Set( mCurrentBufferIndex, color ); + node->SetDirtyFlag( SceneGraph::NodePropertyFlags::COLOR ); + AddResetter( *node, node->mColor ); + success = true; } + return success; } -SceneGraph::Node* UpdateProxy::GetNodeWithId( unsigned int id ) const +bool UpdateProxy::BakeColor( uint32_t id, const Vector4& color ) +{ + bool success = false; + SceneGraph::Node* node = GetNodeWithId( id ); + if( node ) + { + node->mColor.Bake( mCurrentBufferIndex, color ); + success = true; + } + return success; +} + +void UpdateProxy::NodeHierarchyChanged() +{ + mLastCachedIdNodePair = { 0u, NULL }; + mNodeContainer.clear(); + mPropertyModifier.reset(); +} + +SceneGraph::Node* UpdateProxy::GetNodeWithId( uint32_t id ) const { SceneGraph::Node* node = NULL; @@ -196,6 +275,15 @@ SceneGraph::Node* UpdateProxy::GetNodeWithId( unsigned int id ) const return node; } +void UpdateProxy::AddResetter( SceneGraph::Node& node, SceneGraph::PropertyBase& propertyBase ) +{ + if( ! mPropertyModifier ) + { + mPropertyModifier = PropertyModifierPtr( new PropertyModifier( mUpdateManager ) ); + } + mPropertyModifier->AddResetter( node, propertyBase ); +} + } // namespace Internal } // namespace Dali