From 8295300529456e6693e04d8bc7998db85263c7c5 Mon Sep 17 00:00:00 2001 From: Kimmo Hoikka Date: Mon, 10 Nov 2014 17:53:42 +0000 Subject: [PATCH] Remove a few exports by getting rid of two std::vectors and two std::sets [Problem] [Cause] [Solution] Change-Id: I84df0e7804fd732002cd09db72879b4f82c9f211 --- .../event/animation/active-constraint-base.cpp | 32 ++++++++------- .../event/animation/active-constraint-base.h | 5 +-- .../event/animation/active-constraint-impl.h | 48 ++++++++++++++-------- dali/internal/render/gl-resources/context.cpp | 9 +--- dali/internal/render/gl-resources/context.h | 15 +++---- .../animation/scene-graph-constraint-base.cpp | 2 +- .../update/animation/scene-graph-constraint-base.h | 21 ++++++---- .../update/animation/scene-graph-constraint.h | 8 ++-- dali/internal/update/common/property-owner.h | 4 -- dali/internal/update/nodes/node.h | 1 + 10 files changed, 79 insertions(+), 66 deletions(-) diff --git a/dali/internal/event/animation/active-constraint-base.cpp b/dali/internal/event/animation/active-constraint-base.cpp index 9accd09..55ec3e5 100644 --- a/dali/internal/event/animation/active-constraint-base.cpp +++ b/dali/internal/event/animation/active-constraint-base.cpp @@ -509,9 +509,9 @@ void ActiveConstraintBase::SceneObjectRemoved( ProxyObject& proxy ) void ActiveConstraintBase::ProxyDestroyed( ProxyObject& proxy ) { // Remove proxy pointer from observation set - ProxyObjectIter iter = mObservedProxies.find( &proxy ); - DALI_ASSERT_DEBUG( mObservedProxies.end() != iter ); - mObservedProxies.erase( iter ); + ProxyObjectIter iter = std::find( mObservedProxies.Begin(), mObservedProxies.End(), &proxy ); + DALI_ASSERT_DEBUG( mObservedProxies.End() != iter ); + mObservedProxies.Erase( iter ); // Stop observing the remaining proxies StopObservation(); @@ -524,41 +524,43 @@ void ActiveConstraintBase::ProxyDestroyed( ProxyObject& proxy ) void ActiveConstraintBase::ObserveProxy( ProxyObject& proxy ) { - if ( mObservedProxies.end() == mObservedProxies.find(&proxy) ) + ProxyObjectIter iter = std::find( mObservedProxies.Begin(), mObservedProxies.End(), &proxy ); + if ( mObservedProxies.End() == iter ) { proxy.AddObserver( *this ); - mObservedProxies.insert( &proxy ); + mObservedProxies.PushBack( &proxy ); } } void ActiveConstraintBase::StopObservation() { - for( ProxyObjectIter iter = mObservedProxies.begin(); mObservedProxies.end() != iter; ++iter ) + const ProxyObjectIter end = mObservedProxies.End(); + for( ProxyObjectIter iter = mObservedProxies.Begin(); iter != end; ++iter ) { (*iter)->RemoveObserver( *this ); } - mObservedProxies.clear(); + mObservedProxies.Clear(); } void ActiveConstraintBase::FirstApplyFinished( Object* object ) { - ActiveConstraintBase& self = dynamic_cast( *object ); + // trust the object is correct as its set in FirstApply (in this same file) + ActiveConstraintBase* self = static_cast( object ); // This is necessary when the constraint was not added to scene-graph during the animation - self.SetWeight( Dali::ActiveConstraint::FINAL_WEIGHT ); + self->SetWeight( Dali::ActiveConstraint::FINAL_WEIGHT ); // The animation is no longer needed - GetImplementation(self.mApplyAnimation).SetFinishedCallback( NULL, NULL ); - self.mApplyAnimation.Reset(); + GetImplementation(self->mApplyAnimation).SetFinishedCallback( NULL, NULL ); + self->mApplyAnimation.Reset(); // Chain "Finish" to "Applied" signal - if ( !self.mAppliedSignal.Empty() ) + if ( !self->mAppliedSignal.Empty() ) { - Dali::ActiveConstraint handle( &self ); - - self.mAppliedSignal.Emit( handle ); + Dali::ActiveConstraint handle( self ); + self->mAppliedSignal.Emit( handle ); } // WARNING - this constraint may now have been deleted; don't do anything else here diff --git a/dali/internal/event/animation/active-constraint-base.h b/dali/internal/event/animation/active-constraint-base.h index d17912e..f7670b1 100644 --- a/dali/internal/event/animation/active-constraint-base.h +++ b/dali/internal/event/animation/active-constraint-base.h @@ -27,7 +27,6 @@ #include #include #include -#include #include namespace Dali @@ -37,8 +36,8 @@ namespace Internal { class EventToUpdate; -typedef std::set ProxyObjectContainer; -typedef ProxyObjectContainer::iterator ProxyObjectIter; +typedef Dali::Vector ProxyObjectContainer; +typedef ProxyObjectContainer::Iterator ProxyObjectIter; namespace SceneGraph { diff --git a/dali/internal/event/animation/active-constraint-impl.h b/dali/internal/event/animation/active-constraint-impl.h index a0d9253..3a20508 100644 --- a/dali/internal/event/animation/active-constraint-impl.h +++ b/dali/internal/event/animation/active-constraint-impl.h @@ -22,7 +22,6 @@ #include // INTERNAL INCLUDES -#include #include #include #include @@ -45,6 +44,21 @@ namespace Internal { /** + * Helper to add only unique entries to the propertyOwner container + * @param propertyOwners to add the entries to + * @param object to add + */ +inline void AddUnique( SceneGraph::PropertyOwnerContainer& propertyOwners, SceneGraph::PropertyOwner* object ) +{ + const SceneGraph::PropertyOwnerIter iter = std::find( propertyOwners.Begin(), propertyOwners.End(), object ); + if( iter == propertyOwners.End() ) + { + // each owner should only be added once + propertyOwners.PushBack( object ); + } +} + +/** * Connects a constraint which takes another property as an input. */ template < typename PropertyType > @@ -149,9 +163,9 @@ private: return; } - // Build a set of property-owners, providing the scene-graph properties - SceneGraph::PropertyOwnerSet propertyOwners; - propertyOwners.insert( targetObject ); + // Build a container of property-owners, providing the scene-graph properties + SceneGraph::PropertyOwnerContainer propertyOwners; + propertyOwners.PushBack( targetObject ); // Build the constraint function; this requires a scene-graph property from each source ConstraintFunctionPtr func( ConnectConstraintFunction( propertyOwners ) ); @@ -188,11 +202,11 @@ private: /** * Helper for ConnectConstraint. Creates a connected constraint-function. - * Also populates the property-owner set, for each input connected to the constraint-function. - * @param[out] propertyOwners The set of property-owners providing the scene-graph properties. + * Also populates the property-owner container, for each input connected to the constraint-function. + * @param[out] propertyOwners The container of property-owners providing the scene-graph properties. * @return A connected constraint-function, or NULL if the scene-graph properties are not available. */ - PropertyConstraintBase* ConnectConstraintFunction( SceneGraph::PropertyOwnerSet& propertyOwners ) + PropertyConstraintBase* ConnectConstraintFunction( SceneGraph::PropertyOwnerContainer& propertyOwners ) { PropertyConstraintBase* func = mUserFunction->Clone(); bool usingComponentFunc( false ); @@ -213,7 +227,7 @@ private: // The property owner will not exist, if the target proxy-object is off-stage if( NULL != owner ) { - propertyOwners.insert( owner ); + AddUnique( propertyOwners, owner ); inputProperty = const_cast< PropertyInputImpl* >( source.object->GetSceneObjectInputProperty( source.propertyIndex ) ); componentIndex = source.object->GetPropertyComponentIndex( source.propertyIndex ); @@ -247,7 +261,7 @@ private: // The property owner will not exist, if the parent proxy-object is off-stage if ( NULL != owner ) { - propertyOwners.insert( owner ); + AddUnique( propertyOwners, owner ); inputProperty = const_cast< PropertyInputImpl* >( proxyParent->GetSceneObjectInputProperty( source.propertyIndex ) ); componentIndex = proxyParent->GetPropertyComponentIndex( source.propertyIndex ); @@ -396,9 +410,9 @@ private: return; } - // Build a set of property-owners, providing the scene-graph properties - SceneGraph::PropertyOwnerSet propertyOwners; - propertyOwners.insert( targetObject ); + // Build a container of property-owners, providing the scene-graph properties + SceneGraph::PropertyOwnerContainer propertyOwners; + propertyOwners.PushBack( targetObject ); // Build the constraint function; this requires a scene-graph property from each source ConstraintFunctionPtr func( ConnectConstraintFunction( propertyOwners ) ); @@ -497,11 +511,11 @@ private: /** * Helper for ConnectConstraint. Creates a connected constraint-function. - * Also populates the property-owner set, for each input connected to the constraint-function. - * @param[out] propertyOwners The set of property-owners providing the scene-graph properties. + * Also populates the property-owner container, for each input connected to the constraint-function. + * @param[out] propertyOwners The container of property-owners providing the scene-graph properties. * @return A connected constraint-function, or NULL if the scene-graph properties are not available. */ - PropertyConstraintBase* ConnectConstraintFunction( SceneGraph::PropertyOwnerSet& propertyOwners ) + PropertyConstraintBase* ConnectConstraintFunction( SceneGraph::PropertyOwnerContainer& propertyOwners ) { PropertyConstraintBase* func = mUserFunction->Clone(); bool usingComponentFunc( false ); @@ -522,7 +536,7 @@ private: // The property owner will not exist, if the target proxy-object is off-stage if( NULL != owner ) { - propertyOwners.insert( owner ); + AddUnique( propertyOwners, owner ); inputProperty = const_cast< PropertyInputImpl* >( source.object->GetSceneObjectInputProperty( source.propertyIndex ) ); componentIndex = source.object->GetPropertyComponentIndex( source.propertyIndex ); @@ -556,7 +570,7 @@ private: // The property owner will not exist, if the parent proxy-object is off-stage if ( NULL != owner ) { - propertyOwners.insert( owner ); + AddUnique( propertyOwners, owner ); inputProperty = const_cast< PropertyInputImpl* >( proxyParent->GetSceneObjectInputProperty( source.propertyIndex ) ); componentIndex = proxyParent->GetPropertyComponentIndex( source.propertyIndex ); diff --git a/dali/internal/render/gl-resources/context.cpp b/dali/internal/render/gl-resources/context.cpp index eff48a5..d943940 100644 --- a/dali/internal/render/gl-resources/context.cpp +++ b/dali/internal/render/gl-resources/context.cpp @@ -100,7 +100,6 @@ Context::Context(Integration::GlAbstraction& glAbstraction) mBlendEquationSeparateModeRGB( GL_FUNC_ADD ), mBlendEquationSeparateModeAlpha( GL_FUNC_ADD ), mMaxTextureSize(0), - mMaxTextureUnits(0), mClearColor(Color::WHITE), // initial color, never used until it's been set by the user mCullFaceMode(CullNone), mViewPort( 0, 0, 0, 0 ), @@ -333,12 +332,8 @@ void Context::ResetGlState() mGlAbstraction.FrontFace(GL_CCW); mGlAbstraction.CullFace(GL_BACK); - // get max texture units - mGlAbstraction.GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &mMaxTextureUnits); - DALI_ASSERT_DEBUG(mMaxTextureUnits > 7); // according to GLES 2.0 specification - mBound2dTextureId.reserve(mMaxTextureUnits); // rebind texture units - for( int i=0; i < mMaxTextureUnits; ++i ) + for( unsigned int i=0; i < MAX_TEXTURE_UNITS; ++i ) { mBound2dTextureId[ i ] = 0; // set active texture @@ -354,7 +349,7 @@ void Context::ResetGlState() mGlAbstraction.GetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS_OES, &numProgramBinaryFormats); if( GL_NO_ERROR == mGlAbstraction.GetError() && 0 != numProgramBinaryFormats ) { - mProgramBinaryFormats.resize(numProgramBinaryFormats); + mProgramBinaryFormats.Resize(numProgramBinaryFormats); mGlAbstraction.GetIntegerv(GL_PROGRAM_BINARY_FORMATS_OES, &mProgramBinaryFormats[0]); } diff --git a/dali/internal/render/gl-resources/context.h b/dali/internal/render/gl-resources/context.h index 073a2a0..e285ae6 100644 --- a/dali/internal/render/gl-resources/context.h +++ b/dali/internal/render/gl-resources/context.h @@ -21,7 +21,7 @@ // INTERNAL INCLUDES #include #include -#include +#include #include #include #include @@ -64,6 +64,8 @@ public: */ static const unsigned int MAX_ATTRIBUTE_CACHE_SIZE = 8; + static const unsigned int MAX_TEXTURE_UNITS = 8; // for GLES 2.0 its 8, which is more than DALi uses anyways + /** * Creates the Dali Context object. * This method does not create an OpenGL context i.e. that is done from outside dali-core. @@ -636,7 +638,7 @@ public: // reset the cached texture id's incase the driver re-uses them // when creating new textures - for( int i=0; i < mMaxTextureUnits; ++i ) + for( unsigned int i=0; i < MAX_TEXTURE_UNITS; ++i ) { mBound2dTextureId[ i ] = 0; } @@ -1615,7 +1617,7 @@ public: */ GLint CachedNumberOfProgramBinaryFormats() const { - return mProgramBinaryFormats.size(); + return mProgramBinaryFormats.Count(); } /** @@ -1625,7 +1627,7 @@ public: */ GLint CachedProgramBinaryFormat( const unsigned int formatIndex = 0 ) const { - DALI_ASSERT_ALWAYS( formatIndex < mProgramBinaryFormats.size() && "formatIndex out of bounds"); + DALI_ASSERT_ALWAYS( formatIndex < mProgramBinaryFormats.Count() && "formatIndex out of bounds"); return mProgramBinaryFormats[ formatIndex ]; } @@ -1797,7 +1799,7 @@ private: // Data // glBindTexture() state unsigned int mActiveTextureUnit; - std::vector mBound2dTextureId; ///< The ID passed to glBindTexture(GL_TEXTURE_2D) + GLuint mBound2dTextureId[ MAX_TEXTURE_UNITS ]; ///< The ID passed to glBindTexture(GL_TEXTURE_2D) // glBlendColor() state bool mUsingDefaultBlendColor; @@ -1813,10 +1815,9 @@ private: // Data GLenum mBlendEquationSeparateModeAlpha; ///< Controls Alpha blend mode GLint mMaxTextureSize; ///< return value from GetIntegerv(GL_MAX_TEXTURE_SIZE) - GLint mMaxTextureUnits; ///< return value from GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS) Vector4 mClearColor; ///< clear color - std::vector mProgramBinaryFormats; ///< array of supported program binary formats + Dali::Vector mProgramBinaryFormats; ///< array of supported program binary formats // Face culling mode CullFaceMode mCullFaceMode; diff --git a/dali/internal/update/animation/scene-graph-constraint-base.cpp b/dali/internal/update/animation/scene-graph-constraint-base.cpp index 19b0373..56cd82c 100644 --- a/dali/internal/update/animation/scene-graph-constraint-base.cpp +++ b/dali/internal/update/animation/scene-graph-constraint-base.cpp @@ -35,7 +35,7 @@ namespace SceneGraph unsigned int ConstraintBase::mTotalInstanceCount = 0; #endif -ConstraintBase::ConstraintBase( PropertyOwnerSet& ownerSet ) +ConstraintBase::ConstraintBase( PropertyOwnerContainer& ownerSet ) : mWeight( Dali::ActiveConstraint::DEFAULT_WEIGHT ), mRemoveAction( Dali::Constraint::DEFAULT_REMOVE_ACTION ), mFirstApply( true ), diff --git a/dali/internal/update/animation/scene-graph-constraint-base.h b/dali/internal/update/animation/scene-graph-constraint-base.h index 06dce2f..05bbda5 100644 --- a/dali/internal/update/animation/scene-graph-constraint-base.h +++ b/dali/internal/update/animation/scene-graph-constraint-base.h @@ -41,6 +41,9 @@ template <> struct ParameterType< Dali::Constraint::RemoveAction > namespace SceneGraph { +typedef Dali::Vector PropertyOwnerContainer; +typedef PropertyOwnerContainer::Iterator PropertyOwnerIter; + /** * An abstract base class for Constraints. * This can be used to constrain a property of a scene-object, after animations have been applied. @@ -54,7 +57,7 @@ public: /** * Constructor */ - ConstraintBase( PropertyOwnerSet& ownerSet ); + ConstraintBase( PropertyOwnerContainer& ownerContainer ); /** * Virtual destructor. @@ -143,7 +146,8 @@ private: */ void StartObservation() { - for( PropertyOwnerIter iter = mObservedOwners.begin(); mObservedOwners.end() != iter; ++iter ) + const PropertyOwnerIter end = mObservedOwners.End(); + for( PropertyOwnerIter iter = mObservedOwners.Begin(); end != iter; ++iter ) { (*iter)->AddObserver( *this ); } @@ -154,12 +158,13 @@ private: */ void StopObservation() { - for( PropertyOwnerIter iter = mObservedOwners.begin(); mObservedOwners.end() != iter; ++iter ) + const PropertyOwnerIter end = mObservedOwners.End(); + for( PropertyOwnerIter iter = mObservedOwners.Begin(); end != iter; ++iter ) { (*iter)->RemoveObserver( *this ); } - mObservedOwners.clear(); + mObservedOwners.Clear(); } /** @@ -178,10 +183,10 @@ private: if ( !mDisconnected ) { // Discard pointer to disconnected property owner - PropertyOwnerIter iter = mObservedOwners.find( &owner ); - if( mObservedOwners.end() != iter ) + PropertyOwnerIter iter = std::find( mObservedOwners.Begin(), mObservedOwners.End(), &owner ); + if( mObservedOwners.End() != iter ) { - mObservedOwners.erase( iter ); + mObservedOwners.Erase( iter ); // Stop observing the remaining property owners StopObservation(); @@ -217,7 +222,7 @@ protected: private: - PropertyOwnerSet mObservedOwners; ///< A set of pointers to each observed object. Not owned. + PropertyOwnerContainer mObservedOwners; ///< A set of pointers to each observed object. Not owned. #ifdef DEBUG_ENABLED static unsigned int mCurrentInstanceCount; ///< The current number of Constraint instances in existence. diff --git a/dali/internal/update/animation/scene-graph-constraint.h b/dali/internal/update/animation/scene-graph-constraint.h index de9b4b5..4866d6a 100644 --- a/dali/internal/update/animation/scene-graph-constraint.h +++ b/dali/internal/update/animation/scene-graph-constraint.h @@ -62,7 +62,7 @@ public: * @return A smart-pointer to a newly allocated constraint. */ static ConstraintBase* New( const PropertyBase& targetProperty, - PropertyOwnerSet& ownerSet, + PropertyOwnerContainer& ownerContainer, ConstraintFunctionPtr func, InterpolatorFunc interpolator, const AnimatableProperty* customWeight ) @@ -71,7 +71,7 @@ public: PropertyBase& property = const_cast< PropertyBase& >( targetProperty ); return new Constraint< PropertyType, PropertyAccessorType >( property, - ownerSet, + ownerContainer, func, interpolator, customWeight ); @@ -159,11 +159,11 @@ private: * @copydoc Dali::Internal::SceneGraph::Constraint::New() */ Constraint( PropertyBase& targetProperty, - PropertyOwnerSet& ownerSet, + PropertyOwnerContainer& ownerContainer, ConstraintFunctionPtr func, InterpolatorFunc interpolator, const AnimatableProperty* customWeight ) - : ConstraintBase( ownerSet ), + : ConstraintBase( ownerContainer ), mTargetProperty( &targetProperty ), mFunc( func ), mInterpolator( interpolator ), diff --git a/dali/internal/update/common/property-owner.h b/dali/internal/update/common/property-owner.h index f9e0369..ffce83f 100644 --- a/dali/internal/update/common/property-owner.h +++ b/dali/internal/update/common/property-owner.h @@ -22,7 +22,6 @@ // INTERNAL INCLUDES #include -#include #include #include #include @@ -40,9 +39,6 @@ namespace SceneGraph class PropertyOwner; -typedef std::set PropertyOwnerSet; -typedef PropertyOwnerSet::iterator PropertyOwnerIter; - typedef OwnerContainer< PropertyBase* > OwnedPropertyContainer; typedef OwnedPropertyContainer::Iterator OwnedPropertyIter; diff --git a/dali/internal/update/nodes/node.h b/dali/internal/update/nodes/node.h index ce2125a..b5cc583 100644 --- a/dali/internal/update/nodes/node.h +++ b/dali/internal/update/nodes/node.h @@ -21,6 +21,7 @@ // INTERNAL INCLUDES #include #include +#include #include #include #include -- 2.7.4