X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fupdate%2Fcommon%2Fproperty-owner.cpp;h=81ca85c66a5b830ddcc847902489dc4c211a8a02;hb=55827866fcb8c7ee47581ac4335a3390472090e8;hp=d2283e014f3bec3feecd76b01c21aa894ada39b0;hpb=8f2c5571c924479b6a07a2c2187dedd9c685baf0;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/update/common/property-owner.cpp b/dali/internal/update/common/property-owner.cpp old mode 100644 new mode 100755 index d2283e0..81ca85c --- a/dali/internal/update/common/property-owner.cpp +++ b/dali/internal/update/common/property-owner.cpp @@ -1,18 +1,19 @@ -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ // CLASS HEADER #include @@ -40,7 +41,7 @@ PropertyOwner* PropertyOwner::New() PropertyOwner::~PropertyOwner() { - DisconnectFromSceneGraph(); + Destroy(); } void PropertyOwner::AddObserver(Observer& observer) @@ -71,7 +72,7 @@ bool PropertyOwner::IsObserved() return mObservers.Count() != 0u; } -void PropertyOwner::DisconnectFromSceneGraph() +void PropertyOwner::Destroy() { // Notification for observers const ConstObserverIter endIter = mObservers.End(); @@ -86,48 +87,48 @@ void PropertyOwner::DisconnectFromSceneGraph() mConstraints.Clear(); } -void PropertyOwner::InstallCustomProperty(PropertyBase* property) +void PropertyOwner::ConnectToSceneGraph() { - DALI_ASSERT_DEBUG( NULL != property ); - - mCustomProperties.PushBack( property ); + // Notification for observers + const ConstObserverIter endIter = mObservers.End(); + for( ConstObserverIter iter = mObservers.Begin(); iter != endIter; ++iter) + { + (*iter)->PropertyOwnerConnected( *this ); + } } -void PropertyOwner::ResetToBaseValues( BufferIndex updateBufferIndex ) +void PropertyOwner::DisconnectFromSceneGraph( BufferIndex updateBufferIndex ) { - // Reset custom properties - const OwnedPropertyIter endIter = mCustomProperties.End(); - for ( OwnedPropertyIter iter = mCustomProperties.Begin(); endIter != iter; ++iter ) + // Notification for observers + const ConstObserverIter endIter = mObservers.End(); + for( ConstObserverIter iter = mObservers.Begin(); iter != endIter; ++iter) { - (*iter)->ResetToBaseValue( updateBufferIndex ); + (*iter)->PropertyOwnerDisconnected( updateBufferIndex, *this ); } - // Reset constraint weights - const ConstraintIter constraintEndIter = mConstraints.End(); - for( ConstraintIter iter = mConstraints.Begin(); constraintEndIter != iter; ++iter ) - { - (*iter)->mWeight.ResetToBaseValue( updateBufferIndex ); - } + // Remove all constraints when disconnected from scene-graph + mConstraints.Clear(); +} - // Notification for derived classes, to reset default properties - ResetDefaultProperties( updateBufferIndex ); +void PropertyOwner::InstallCustomProperty( OwnerPointer& property ) +{ + mCustomProperties.PushBack( property.Release() ); } + ConstraintOwnerContainer& PropertyOwner::GetConstraints() { return mConstraints; } -void PropertyOwner::ApplyConstraint( ConstraintBase* constraint ) +void PropertyOwner::ApplyConstraint( OwnerPointer& constraint ) { - mConstraints.PushBack( constraint ); - constraint->OnConnect(); + mConstraints.PushBack( constraint.Release() ); } void PropertyOwner::RemoveConstraint( ConstraintBase* constraint ) { - // Reset constraint weights const ConstraintIter constraintEndIter = mConstraints.End(); for( ConstraintIter iter = mConstraints.Begin(); constraintEndIter != iter; ++iter ) { @@ -138,14 +139,48 @@ void PropertyOwner::RemoveConstraint( ConstraintBase* constraint ) } } - // Should not come here - DALI_ASSERT_DEBUG( false && "Constraint missing in RemoveConstraint" ); + //it may be that the constraint has already been removed e.g. from disconnection from scene graph, so nothing needs to be done } PropertyOwner::PropertyOwner() { } +void PropertyOwner::AddUniformMapping( OwnerPointer< UniformPropertyMapping >& map ) +{ + mUniformMaps.Add( map.Release() ); +} + +void PropertyOwner::RemoveUniformMapping( const std::string& uniformName ) +{ + mUniformMaps.Remove( uniformName ); +} + +const UniformMap& PropertyOwner::GetUniformMap() const +{ + return mUniformMaps; +} + +void PropertyOwner::AddUniformMapObserver( UniformMap::Observer& observer ) +{ + mUniformMaps.AddObserver( observer ); +} + +void PropertyOwner::RemoveUniformMapObserver( UniformMap::Observer& observer ) +{ + mUniformMaps.RemoveObserver( observer ); +} + +void PropertyOwner::SetPropertyDirty( bool value ) +{ + mPropertyDirty = value; +} + +bool PropertyOwner::IsPropertyDirty() const +{ + return mPropertyDirty; +} + } // namespace SceneGraph } // namespace Internal