From: Kimmo Hoikka Date: Mon, 1 Dec 2014 16:52:46 +0000 (+0000) Subject: Cleanup property system, remove 12 redundant std::maps and 114 std::strings being... X-Git-Tag: accepted/tizen/common/20141211.150202~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2ac8028e3ed170002c2f5ee84d2809cf4224c036;p=platform%2Fcore%2Fuifw%2Fdali-core.git Cleanup property system, remove 12 redundant std::maps and 114 std::strings being created in startup Change-Id: Id7105d126eacaadc9c9efdb5c75a660697203177 --- diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index b1b2bda..1ba9bd1 100644 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -217,8 +217,6 @@ TypeAction a2(mType, Dali::Actor::ACTION_HIDE, &Actor::DoAction); } -Actor::DefaultPropertyLookup* Actor::mDefaultPropertyLookup = NULL; - ActorPtr Actor::New() { ActorPtr actor( new Actor( BASIC ) ); @@ -2066,16 +2064,6 @@ void Actor::Initialize() AddNodeMessage( mStage->GetUpdateManager(), *node ); // Pass ownership to scene-graph mNode = node; // Keep raw-pointer to Node - if(!mDefaultPropertyLookup) - { - mDefaultPropertyLookup = new DefaultPropertyLookup(); - - for (int i=0; ifind( name ); - if ( mDefaultPropertyLookup->end() != result ) + for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) { - index = result->second; + const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[ i ]; + if( 0 == strcmp( name.c_str(), property->name ) ) // dont want to convert rhs to string + { + index = i; + break; + } } return index; diff --git a/dali/internal/event/actors/actor-impl.h b/dali/internal/event/actors/actor-impl.h index 6f6a375..bb92041 100644 --- a/dali/internal/event/actors/actor-impl.h +++ b/dali/internal/event/actors/actor-impl.h @@ -22,7 +22,6 @@ #include // INTERNAL INCLUDES -#include #include #include #include @@ -1161,7 +1160,7 @@ public: // Default property extensions from ProxyObject /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName() */ - virtual const std::string& GetDefaultPropertyName(Property::Index index) const; + virtual const char* GetDefaultPropertyName(Property::Index index) const; /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex() @@ -1400,29 +1399,11 @@ protected: PositionInheritanceMode mPositionInheritanceMode : 2; ///< Cached: Determines how position is inherited ColorMode mColorMode : 2; ///< Cached: Determines whether mWorldColor is inherited - // Default properties - typedef std::map DefaultPropertyLookup; - private: static ActorContainer mNullChildren; ///< Empty container (shared by all actors, returned by GetChildren() const) static unsigned int mActorCounter; ///< A counter to track the actor instance creation - // Default properties - static DefaultPropertyLookup* mDefaultPropertyLookup; - -}; - -/** - * @brief Structure for setting up default properties and their details. - */ -struct PropertyDetails -{ - std::string name; ///< The name of the property. - Property::Type type; ///< The property type. - bool writable:1; ///< Whether the property is writable - bool animatable:1; ///< Whether the property is animatable. - bool constraintInput:1; ///< Whether the property can be used as an input to a constraint. }; } // namespace Internal diff --git a/dali/internal/event/actors/camera-actor-impl.cpp b/dali/internal/event/actors/camera-actor-impl.cpp index f952f47..e2a99dc 100644 --- a/dali/internal/event/actors/camera-actor-impl.cpp +++ b/dali/internal/event/actors/camera-actor-impl.cpp @@ -52,8 +52,6 @@ const Property::Index CameraActor::INVERT_Y_AXIS = Internal::DEFAULT_A namespace Internal { -bool CameraActor::mFirstInstance = true; -Actor::DefaultPropertyLookup* CameraActor::mDefaultCameraActorPropertyLookup = NULL; namespace { @@ -73,7 +71,7 @@ BaseHandle Create() TypeRegistration mType( typeid(Dali::CameraActor), typeid(Dali::Actor), Create ); -const std::string DEFAULT_CAMERA_ACTOR_PROPERTY_NAMES[] = +const char* DEFAULT_CAMERA_ACTOR_PROPERTY_NAMES[] = { "type", "projection-mode", @@ -90,7 +88,7 @@ const std::string DEFAULT_CAMERA_ACTOR_PROPERTY_NAMES[] = "view-matrix", "invert-y-axis" }; -const int DEFAULT_CAMERA_ACTOR_PROPERTY_COUNT = sizeof( DEFAULT_CAMERA_ACTOR_PROPERTY_NAMES ) / sizeof( std::string ); +const int DEFAULT_CAMERA_ACTOR_PROPERTY_COUNT = sizeof( DEFAULT_CAMERA_ACTOR_PROPERTY_NAMES ) / sizeof( DEFAULT_CAMERA_ACTOR_PROPERTY_NAMES[0] ); const Property::Type DEFAULT_CAMERA_ACTOR_PROPERTY_TYPES[DEFAULT_CAMERA_ACTOR_PROPERTY_COUNT] = { @@ -191,16 +189,6 @@ CameraActorPtr CameraActor::New( const Size& size ) void CameraActor::OnInitialize() { - if(CameraActor::mFirstInstance) - { - mDefaultCameraActorPropertyLookup = new DefaultPropertyLookup(); - const int start = DEFAULT_ACTOR_PROPERTY_MAX_COUNT; - for ( int i = 0; i < DEFAULT_CAMERA_ACTOR_PROPERTY_COUNT; ++i ) - { - (*mDefaultCameraActorPropertyLookup)[DEFAULT_CAMERA_ACTOR_PROPERTY_NAMES[i]] = i + start; - } - CameraActor::mFirstInstance = false; - } } CameraActor::CameraActor() @@ -513,7 +501,7 @@ Property::Type CameraActor::GetDefaultPropertyType( Property::Index index ) cons } } -const std::string& CameraActor::GetDefaultPropertyName( Property::Index index ) const +const char* CameraActor::GetDefaultPropertyName( Property::Index index ) const { if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT) { @@ -527,12 +515,7 @@ const std::string& CameraActor::GetDefaultPropertyName( Property::Index index ) { return DEFAULT_CAMERA_ACTOR_PROPERTY_NAMES[index]; } - else - { - // index out-of-bounds - static const std::string INVALID_PROPERTY_NAME; - return INVALID_PROPERTY_NAME; - } + return NULL; } } @@ -540,17 +523,19 @@ Property::Index CameraActor::GetDefaultPropertyIndex(const std::string& name) co { Property::Index index = Property::INVALID_INDEX; - DALI_ASSERT_DEBUG( NULL != mDefaultCameraActorPropertyLookup ); - // Look for name in current class' default properties - DefaultPropertyLookup::const_iterator result = mDefaultCameraActorPropertyLookup->find( name ); - if ( mDefaultCameraActorPropertyLookup->end() != result ) + for( int i = 0; i < DEFAULT_CAMERA_ACTOR_PROPERTY_COUNT; ++i ) { - index = result->second; + if( 0 == strcmp( name.c_str(), DEFAULT_CAMERA_ACTOR_PROPERTY_NAMES[ i ] ) ) // dont want to convert rhs to string + { + index = i + DEFAULT_ACTOR_PROPERTY_MAX_COUNT; + break; + } } - else + + // If not found, check in base class + if( Property::INVALID_INDEX == index ) { - // If not found, check in base class index = Actor::GetDefaultPropertyIndex( name ); } diff --git a/dali/internal/event/actors/camera-actor-impl.h b/dali/internal/event/actors/camera-actor-impl.h index 780fab7..9794b45 100644 --- a/dali/internal/event/actors/camera-actor-impl.h +++ b/dali/internal/event/actors/camera-actor-impl.h @@ -211,7 +211,7 @@ public: // properties /** * copydoc Dali::Internal::ProxyObject */ - virtual const std::string& GetDefaultPropertyName( Property::Index index ) const; + virtual const char* GetDefaultPropertyName( Property::Index index ) const; /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex() @@ -256,9 +256,9 @@ protected: virtual ~CameraActor(); private: + CameraAttachmentPtr mCameraAttachment; - static bool mFirstInstance ; - static DefaultPropertyLookup* mDefaultCameraActorPropertyLookup; ///< Default properties + }; } // namespace Internal diff --git a/dali/internal/event/actors/image-actor-impl.cpp b/dali/internal/event/actors/image-actor-impl.cpp index ebdce3e..c9d4ff7 100644 --- a/dali/internal/event/actors/image-actor-impl.cpp +++ b/dali/internal/event/actors/image-actor-impl.cpp @@ -35,8 +35,6 @@ const Property::Index ImageActor::IMAGE = Internal::DEFAULT_RENDE namespace Internal { -bool ImageActor::mFirstInstance = true; -Actor::DefaultPropertyLookup* ImageActor::mDefaultImageActorPropertyLookup = NULL; namespace { @@ -48,22 +46,15 @@ BaseHandle Create() TypeRegistration mType( typeid(Dali::ImageActor), typeid(Dali::RenderableActor), Create ); -const std::string DEFAULT_IMAGE_ACTOR_PROPERTY_NAMES[] = +const Internal::PropertyDetails DEFAULT_IMAGE_ACTOR_PROPERTY_DETAILS[] = { - "pixel-area", - "style", - "border", - "image" -}; -const int DEFAULT_IMAGE_ACTOR_PROPERTY_COUNT = sizeof( DEFAULT_IMAGE_ACTOR_PROPERTY_NAMES ) / sizeof( std::string ); - -const Property::Type DEFAULT_IMAGE_ACTOR_PROPERTY_TYPES[DEFAULT_IMAGE_ACTOR_PROPERTY_COUNT] = -{ - Property::RECTANGLE, // "pixel-area", - Property::STRING, // "style", - Property::VECTOR4, // "border", - Property::MAP, // "image", + // Name Type writable animatable constraint-input + { "pixel-area", Property::RECTANGLE, true, false, true }, // PIXEL_AREA + { "style", Property::STRING, true, false, true }, // STYLE + { "border", Property::VECTOR4, true, false, true }, // BORDER + { "image", Property::MAP, true, false, false }, // IMAGE }; +const int DEFAULT_IMAGE_ACTOR_PROPERTY_COUNT = sizeof( DEFAULT_IMAGE_ACTOR_PROPERTY_DETAILS ) / sizeof( DEFAULT_IMAGE_ACTOR_PROPERTY_DETAILS[0] ); ImageActor::Style StyleEnum(const std::string &s) { @@ -114,16 +105,6 @@ ImageActorPtr ImageActor::New() void ImageActor::OnInitialize() { - if(ImageActor::mFirstInstance) - { - mDefaultImageActorPropertyLookup = new DefaultPropertyLookup(); - const int start = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT; - for ( int i = 0; i < DEFAULT_IMAGE_ACTOR_PROPERTY_COUNT; ++i ) - { - (*mDefaultImageActorPropertyLookup)[DEFAULT_IMAGE_ACTOR_PROPERTY_NAMES[i]] = i + start; - } - ImageActor::mFirstInstance = false; - } } void ImageActor::SetImage( ImagePtr& image ) @@ -321,14 +302,19 @@ void ImageActor::GetDefaultPropertyIndices( Property::IndexContainer& indices ) bool ImageActor::IsDefaultPropertyWritable( Property::Index index ) const { - if(index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT) + if( index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT ) { return RenderableActor::IsDefaultPropertyWritable(index); } else { - return true; + index -= DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT; + if ( ( index >= 0 ) && ( index < DEFAULT_IMAGE_ACTOR_PROPERTY_COUNT ) ) + { + return DEFAULT_IMAGE_ACTOR_PROPERTY_DETAILS[ index ].writable; + } } + return false; } bool ImageActor::IsDefaultPropertyAnimatable( Property::Index index ) const @@ -339,8 +325,13 @@ bool ImageActor::IsDefaultPropertyAnimatable( Property::Index index ) const } else { - return false; + index -= DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT; + if ( ( index >= 0 ) && ( index < DEFAULT_IMAGE_ACTOR_PROPERTY_COUNT ) ) + { + return DEFAULT_IMAGE_ACTOR_PROPERTY_DETAILS[ index ].animatable; + } } + return false; } bool ImageActor::IsDefaultPropertyAConstraintInput( Property::Index index ) const @@ -349,7 +340,15 @@ bool ImageActor::IsDefaultPropertyAConstraintInput( Property::Index index ) cons { return RenderableActor::IsDefaultPropertyAConstraintInput(index); } - return true; // Our properties can be used as input to constraints. + else + { + index -= DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT; + if ( ( index >= 0 ) && ( index < DEFAULT_IMAGE_ACTOR_PROPERTY_COUNT ) ) + { + return DEFAULT_IMAGE_ACTOR_PROPERTY_DETAILS[ index ].constraintInput; + } + } + return false; } Property::Type ImageActor::GetDefaultPropertyType( Property::Index index ) const @@ -364,7 +363,7 @@ Property::Type ImageActor::GetDefaultPropertyType( Property::Index index ) const if ( ( index >= 0 ) && ( index < DEFAULT_IMAGE_ACTOR_PROPERTY_COUNT ) ) { - return DEFAULT_IMAGE_ACTOR_PROPERTY_TYPES[index]; + return DEFAULT_IMAGE_ACTOR_PROPERTY_DETAILS[index].type; } else { @@ -374,7 +373,7 @@ Property::Type ImageActor::GetDefaultPropertyType( Property::Index index ) const } } -const std::string& ImageActor::GetDefaultPropertyName( Property::Index index ) const +const char* ImageActor::GetDefaultPropertyName( Property::Index index ) const { if(index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT) { @@ -386,13 +385,12 @@ const std::string& ImageActor::GetDefaultPropertyName( Property::Index index ) c if ( ( index >= 0 ) && ( index < DEFAULT_IMAGE_ACTOR_PROPERTY_COUNT ) ) { - return DEFAULT_IMAGE_ACTOR_PROPERTY_NAMES[index]; + return DEFAULT_IMAGE_ACTOR_PROPERTY_DETAILS[index].name; } else { // index out-of-bounds - static const std::string INVALID_PROPERTY_NAME; - return INVALID_PROPERTY_NAME; + return NULL; } } } @@ -401,20 +399,22 @@ Property::Index ImageActor::GetDefaultPropertyIndex(const std::string& name) con { Property::Index index = Property::INVALID_INDEX; - DALI_ASSERT_DEBUG( NULL != mDefaultImageActorPropertyLookup ); - - // Look for name in current class' default properties - DefaultPropertyLookup::const_iterator result = mDefaultImageActorPropertyLookup->find( name ); - if ( mDefaultImageActorPropertyLookup->end() != result ) + // Look for name in default properties + for( int i = 0; i < DEFAULT_IMAGE_ACTOR_PROPERTY_COUNT; ++i ) { - index = result->second; + const Internal::PropertyDetails* property = &DEFAULT_IMAGE_ACTOR_PROPERTY_DETAILS[ i ]; + if( 0 == strcmp( name.c_str(), property->name ) ) // dont want to convert rhs to string + { + index = i + DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT; + break; + } } - else + + // If not found, check in base class + if( Property::INVALID_INDEX == index ) { - // If not found, check in base class index = RenderableActor::GetDefaultPropertyIndex( name ); } - return index; } diff --git a/dali/internal/event/actors/image-actor-impl.h b/dali/internal/event/actors/image-actor-impl.h index d89970c..60477a3 100644 --- a/dali/internal/event/actors/image-actor-impl.h +++ b/dali/internal/event/actors/image-actor-impl.h @@ -144,7 +144,7 @@ public: // Default property extensions from ProxyObject /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName() */ - virtual const std::string& GetDefaultPropertyName(Property::Index index) const; + virtual const char* GetDefaultPropertyName(Property::Index index) const; /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex() @@ -250,9 +250,6 @@ private: bool mUsingNaturalSize:1; ///< True only when the actor is using bool mInternalSetSize:1; ///< True whilst setting size internally, false at all other times - static bool mFirstInstance ; - static DefaultPropertyLookup* mDefaultImageActorPropertyLookup; ///< Default properties - }; } // namespace Internal diff --git a/dali/internal/event/actors/layer-impl.cpp b/dali/internal/event/actors/layer-impl.cpp index ad5080c..3550e74 100644 --- a/dali/internal/event/actors/layer-impl.cpp +++ b/dali/internal/event/actors/layer-impl.cpp @@ -35,8 +35,6 @@ const Property::Index Layer::CLIPPING_BOX = Internal::DEFAULT_ACTOR_PROPERTY_ namespace Internal { -bool Layer::mFirstInstance = true; -Actor::DefaultPropertyLookup* Layer::mDefaultLayerPropertyLookup = NULL; namespace { @@ -53,18 +51,13 @@ TypeAction a2(mType, Dali::Layer::ACTION_LOWER, &Layer::DoAction); TypeAction a3(mType, Dali::Layer::ACTION_RAISE_TO_TOP, &Layer::DoAction); TypeAction a4(mType, Dali::Layer::ACTION_LOWER_TO_BOTTOM, &Layer::DoAction); -const std::string DEFAULT_LAYER_PROPERTY_NAMES[] = +const PropertyDetails DEFAULT_PROPERTY_DETAILS[] = { - "clipping-enable", - "clipping-box" -}; -const int DEFAULT_LAYER_PROPERTY_COUNT = sizeof( DEFAULT_LAYER_PROPERTY_NAMES ) / sizeof( std::string ); - -const Property::Type DEFAULT_LAYER_PROPERTY_TYPES[DEFAULT_LAYER_PROPERTY_COUNT] = -{ - Property::BOOLEAN, // "clipping-enable", - Property::RECTANGLE, // "clipping-box", + // Name Type writable animatable constraint-input + { "clipping-enable", Property::BOOLEAN, true, false, true }, // CLIPPING_ENABLE + { "clipping-box", Property::RECTANGLE, true, false, true }, // CLIPPING_BOX }; +const int DEFAULT_LAYER_PROPERTY_COUNT = sizeof( DEFAULT_PROPERTY_DETAILS ) / sizeof( DEFAULT_PROPERTY_DETAILS[0] ); } // unnamed namespace @@ -119,16 +112,6 @@ Layer::Layer( Actor::DerivedType type ) void Layer::OnInitialize() { - if(Layer::mFirstInstance) - { - mDefaultLayerPropertyLookup = new DefaultPropertyLookup(); - const int start = DEFAULT_ACTOR_PROPERTY_MAX_COUNT; - for ( int i = 0; i < DEFAULT_LAYER_PROPERTY_COUNT; ++i ) - { - (*mDefaultLayerPropertyLookup)[DEFAULT_LAYER_PROPERTY_NAMES[i]] = i + start; - } - Layer::mFirstInstance = false; - } } Layer::~Layer() @@ -362,7 +345,7 @@ bool Layer::IsDefaultPropertyWritable( Property::Index index ) const } else { - return true; + return true; // all properties writable, no need to lookup the table } } @@ -374,7 +357,7 @@ bool Layer::IsDefaultPropertyAnimatable( Property::Index index ) const } else { - return false; + return false; // all properties non animateable, no need to lookup the table } } @@ -384,7 +367,7 @@ bool Layer::IsDefaultPropertyAConstraintInput( Property::Index index ) const { return Actor::IsDefaultPropertyAConstraintInput(index); } - return true; // our properties can be used as an input to a constraint + return true; // our properties can be used as an input to a constraint, no need to lookup the table } Property::Type Layer::GetDefaultPropertyType( Property::Index index ) const @@ -399,7 +382,7 @@ Property::Type Layer::GetDefaultPropertyType( Property::Index index ) const if ( ( index >= 0 ) && ( index < DEFAULT_LAYER_PROPERTY_COUNT ) ) { - return DEFAULT_LAYER_PROPERTY_TYPES[index]; + return DEFAULT_PROPERTY_DETAILS[index].type; } else { @@ -409,8 +392,7 @@ Property::Type Layer::GetDefaultPropertyType( Property::Index index ) const } } - -const std::string& Layer::GetDefaultPropertyName( Property::Index index ) const +const char* Layer::GetDefaultPropertyName( Property::Index index ) const { if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT) { @@ -422,13 +404,11 @@ const std::string& Layer::GetDefaultPropertyName( Property::Index index ) const if ( ( index >= 0 ) && ( index < DEFAULT_LAYER_PROPERTY_COUNT ) ) { - return DEFAULT_LAYER_PROPERTY_NAMES[index]; + return DEFAULT_PROPERTY_DETAILS[index].name; } else { - // index out-of-bounds - static const std::string INVALID_PROPERTY_NAME; - return INVALID_PROPERTY_NAME; + return NULL; } } } @@ -437,15 +417,17 @@ Property::Index Layer::GetDefaultPropertyIndex(const std::string& name) const { Property::Index index = Property::INVALID_INDEX; - DALI_ASSERT_DEBUG( NULL != mDefaultLayerPropertyLookup ); - // Look for name in current class' default properties - DefaultPropertyLookup::const_iterator result = mDefaultLayerPropertyLookup->find( name ); - if ( mDefaultLayerPropertyLookup->end() != result ) + for( int i = 0; i < DEFAULT_LAYER_PROPERTY_COUNT; ++i ) { - index = result->second; + const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[ i ]; + if( 0 == strcmp( name.c_str(), property->name ) ) // dont want to convert rhs to string + { + index = i + DEFAULT_ACTOR_PROPERTY_MAX_COUNT; + break; + } } - else + if( Property::INVALID_INDEX == index ) { // If not found, check in base class index = Actor::GetDefaultPropertyIndex( name ); diff --git a/dali/internal/event/actors/layer-impl.h b/dali/internal/event/actors/layer-impl.h index ccea127..1ac9482 100644 --- a/dali/internal/event/actors/layer-impl.h +++ b/dali/internal/event/actors/layer-impl.h @@ -205,7 +205,7 @@ public: // Default property extensions from ProxyObject /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName() */ - virtual const std::string& GetDefaultPropertyName(Property::Index index) const; + virtual const char* GetDefaultPropertyName(Property::Index index) const; /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex() @@ -286,8 +286,6 @@ private: bool mTouchConsumed:1; ///< Whether we should consume touch (including gesture). bool mHoverConsumed:1; ///< Whether we should consume hover. - static bool mFirstInstance; - static DefaultPropertyLookup* mDefaultLayerPropertyLookup; ///< Default properties }; } // namespace Internal diff --git a/dali/internal/event/actors/light-actor-impl.cpp b/dali/internal/event/actors/light-actor-impl.cpp index 2c5f562..8a61e42 100644 --- a/dali/internal/event/actors/light-actor-impl.cpp +++ b/dali/internal/event/actors/light-actor-impl.cpp @@ -37,8 +37,6 @@ const Property::Index LightActor::DIRECTION = Internal::DEFAULT_AC namespace Internal { -bool LightActor::mFirstInstance = true ; -Actor::DefaultPropertyLookup* LightActor::mDefaultLightActorPropertyLookup = NULL; namespace { @@ -146,16 +144,6 @@ LightActorPtr LightActor::New() void LightActor::OnInitialize() { - if(LightActor::mFirstInstance) - { - mDefaultLightActorPropertyLookup = new DefaultPropertyLookup(); - const int start = DEFAULT_ACTOR_PROPERTY_MAX_COUNT; - for ( int i = 0; i < DEFAULT_LIGHT_ACTOR_PROPERTY_COUNT; ++i ) - { - (*mDefaultLightActorPropertyLookup)[DEFAULT_LIGHT_ACTOR_PROPERTY_DETAILS[i].name] = i + start; - } - LightActor::mFirstInstance = false ; - } } LightActor::LightActor() @@ -218,7 +206,7 @@ bool LightActor::IsDefaultPropertyWritable( Property::Index index ) const } else { - return true ; + return true; // all properties are writable } } @@ -230,7 +218,7 @@ bool LightActor::IsDefaultPropertyAnimatable( Property::Index index ) const } else { - return false ; + return false; // all properties are non animateable } } @@ -265,7 +253,7 @@ Property::Type LightActor::GetDefaultPropertyType( Property::Index index ) const } } -const std::string& LightActor::GetDefaultPropertyName( Property::Index index ) const +const char* LightActor::GetDefaultPropertyName( Property::Index index ) const { if(index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT) { @@ -281,9 +269,7 @@ const std::string& LightActor::GetDefaultPropertyName( Property::Index index ) c } else { - // index out-of-bounds - static const std::string INVALID_PROPERTY_NAME; - return INVALID_PROPERTY_NAME; + return NULL; } } } @@ -292,17 +278,20 @@ Property::Index LightActor::GetDefaultPropertyIndex(const std::string& name) con { Property::Index index = Property::INVALID_INDEX; - DALI_ASSERT_DEBUG( NULL != mDefaultLightActorPropertyLookup ); - // Look for name in current class' default properties - DefaultPropertyLookup::const_iterator result = mDefaultLightActorPropertyLookup->find( name ); - if ( mDefaultLightActorPropertyLookup->end() != result ) + for( int i = 0; i < DEFAULT_LIGHT_ACTOR_PROPERTY_COUNT; ++i ) { - index = result->second; + const Internal::PropertyDetails* property = &DEFAULT_LIGHT_ACTOR_PROPERTY_DETAILS[ i ]; + if( 0 == strcmp( name.c_str(), property->name ) ) // dont want to convert rhs to string + { + index = i + DEFAULT_ACTOR_PROPERTY_MAX_COUNT; + break; + } } - else + + // If not found, check in base class + if( Property::INVALID_INDEX == index ) { - // If not found, check in base class index = Actor::GetDefaultPropertyIndex( name ); } diff --git a/dali/internal/event/actors/light-actor-impl.h b/dali/internal/event/actors/light-actor-impl.h index fd36299..a661868 100644 --- a/dali/internal/event/actors/light-actor-impl.h +++ b/dali/internal/event/actors/light-actor-impl.h @@ -82,7 +82,7 @@ public: // Default property extensions from ProxyObject /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName() */ - virtual const std::string& GetDefaultPropertyName(Property::Index index) const; + virtual const char* GetDefaultPropertyName(Property::Index index) const; /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex() @@ -135,8 +135,7 @@ private: LightAttachmentPtr mLightAttachment; bool mIsActive; - static bool mFirstInstance ; - static DefaultPropertyLookup* mDefaultLightActorPropertyLookup; ///< Default properties + }; } // namespace Internal diff --git a/dali/internal/event/actors/text-actor-impl.cpp b/dali/internal/event/actors/text-actor-impl.cpp index 8d60a79..e631516 100644 --- a/dali/internal/event/actors/text-actor-impl.cpp +++ b/dali/internal/event/actors/text-actor-impl.cpp @@ -59,7 +59,7 @@ const Property::Index TextActor::TEXT_COLOR = Internal::DEFAULT_ namespace { -const std::string DEFAULT_TEXT_ACTOR_PROPERTY_NAMES[] = +const char* DEFAULT_TEXT_ACTOR_PROPERTY_NAMES[] = { "text", "font", @@ -84,7 +84,7 @@ const std::string DEFAULT_TEXT_ACTOR_PROPERTY_NAMES[] = "shadow-size", "text-color" }; -const int DEFAULT_TEXT_ACTOR_PROPERTY_COUNT = sizeof( DEFAULT_TEXT_ACTOR_PROPERTY_NAMES ) / sizeof( std::string ); +const int DEFAULT_TEXT_ACTOR_PROPERTY_COUNT = sizeof( DEFAULT_TEXT_ACTOR_PROPERTY_NAMES ) / sizeof( DEFAULT_TEXT_ACTOR_PROPERTY_NAMES[0] ); const Property::Type DEFAULT_TEXT_ACTOR_PROPERTY_TYPES[DEFAULT_TEXT_ACTOR_PROPERTY_COUNT] = { @@ -116,8 +116,6 @@ const Property::Type DEFAULT_TEXT_ACTOR_PROPERTY_TYPES[DEFAULT_TEXT_ACTOR_PROPER namespace Internal { -bool TextActor::mFirstInstance = true; -Actor::DefaultPropertyLookup* TextActor::mDefaultTextActorPropertyLookup = NULL; namespace { @@ -171,16 +169,6 @@ TextActor::TextActor(bool fontDetection) void TextActor::OnInitialize() { - if(TextActor::mFirstInstance) - { - mDefaultTextActorPropertyLookup = new DefaultPropertyLookup(); - const int start = DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT; - for ( int i = 0; i < DEFAULT_TEXT_ACTOR_PROPERTY_COUNT; ++i ) - { - (*mDefaultTextActorPropertyLookup)[DEFAULT_TEXT_ACTOR_PROPERTY_NAMES[i]] = i + start; - } - TextActor::mFirstInstance = false ; - } } TextActor::~TextActor() @@ -659,7 +647,7 @@ void TextActor::GetDefaultPropertyIndices( Property::IndexContainer& indices ) c } } -const std::string& TextActor::GetDefaultPropertyName( Property::Index index ) const +const char* TextActor::GetDefaultPropertyName( Property::Index index ) const { if(index < DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT) { @@ -675,9 +663,7 @@ const std::string& TextActor::GetDefaultPropertyName( Property::Index index ) co } else { - // index out-of-bounds - static const std::string INVALID_PROPERTY_NAME; - return INVALID_PROPERTY_NAME; + return NULL; } } } @@ -686,17 +672,19 @@ Property::Index TextActor::GetDefaultPropertyIndex(const std::string& name) cons { Property::Index index = Property::INVALID_INDEX; - DALI_ASSERT_DEBUG( NULL != mDefaultTextActorPropertyLookup ); - - // Look for name in current class' default properties - DefaultPropertyLookup::const_iterator result = mDefaultTextActorPropertyLookup->find( name ); - if ( mDefaultTextActorPropertyLookup->end() != result ) + // Look for name in default properties + for( int i = 0; i < DEFAULT_TEXT_ACTOR_PROPERTY_COUNT; ++i ) { - index = result->second; + if( 0 == strcmp( name.c_str(), DEFAULT_TEXT_ACTOR_PROPERTY_NAMES[ i ] ) ) // dont want to convert rhs to string + { + index = i + DEFAULT_RENDERABLE_ACTOR_PROPERTY_MAX_COUNT; + break; + } } - else + + // If not found, check in base class + if( Property::INVALID_INDEX == index ) { - // If not found, check in base class index = RenderableActor::GetDefaultPropertyIndex( name ); } @@ -711,7 +699,7 @@ bool TextActor::IsDefaultPropertyWritable( Property::Index index ) const } else { - return true ; + return true; } } @@ -723,7 +711,7 @@ bool TextActor::IsDefaultPropertyAnimatable( Property::Index index ) const } else { - return false ; + return false; } } diff --git a/dali/internal/event/actors/text-actor-impl.h b/dali/internal/event/actors/text-actor-impl.h index 7d7192b..a226e13 100644 --- a/dali/internal/event/actors/text-actor-impl.h +++ b/dali/internal/event/actors/text-actor-impl.h @@ -337,7 +337,7 @@ private: // ProxyObject default non-animatable properties /** * copydoc Dali::Internal::ProxyObject */ - virtual const std::string& GetDefaultPropertyName( Property::Index index ) const ; + virtual const char* GetDefaultPropertyName( Property::Index index ) const ; /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex() @@ -387,8 +387,6 @@ private: bool mInternalSetSize:1; ///< to determine when we are internally setting size bool mFontDetection:1; ///< tells whether TextActor should query platform abstraction after SetText bool mObserving:1; ///< Whether the text actor is waiting for text to load - static bool mFirstInstance; - static DefaultPropertyLookup* mDefaultTextActorPropertyLookup; ///< Default properties }; } // namespace Internal diff --git a/dali/internal/event/animation/active-constraint-base.cpp b/dali/internal/event/animation/active-constraint-base.cpp index 55ec3e5..6deb37f 100644 --- a/dali/internal/event/animation/active-constraint-base.cpp +++ b/dali/internal/event/animation/active-constraint-base.cpp @@ -61,7 +61,7 @@ namespace // unnamed namespace * We want to discourage the use of property strings (minimize string comparisons), * particularly for the default properties. */ -const std::string DEFAULT_PROPERTY_NAMES[] = +const char* DEFAULT_PROPERTY_NAMES[] = { "weight" }; @@ -335,7 +335,7 @@ void ActiveConstraintBase::GetDefaultPropertyIndices( Property::IndexContainer& } } -const std::string& ActiveConstraintBase::GetDefaultPropertyName( Property::Index index ) const +const char* ActiveConstraintBase::GetDefaultPropertyName( Property::Index index ) const { if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) ) { @@ -343,9 +343,7 @@ const std::string& ActiveConstraintBase::GetDefaultPropertyName( Property::Index } else { - // index out of range..return empty string - static const std::string INVALID_PROPERTY_NAME; - return INVALID_PROPERTY_NAME; + return NULL; } } @@ -354,7 +352,7 @@ Property::Index ActiveConstraintBase::GetDefaultPropertyIndex( const std::string Property::Index index = Property::INVALID_INDEX; // Only one name to compare with... - if ( name == DEFAULT_PROPERTY_NAMES[0] ) + if( 0 == strcmp( name.c_str(), DEFAULT_PROPERTY_NAMES[0] ) ) // dont want to convert rhs to string { index = 0; } diff --git a/dali/internal/event/animation/active-constraint-base.h b/dali/internal/event/animation/active-constraint-base.h index f7670b1..1d34066 100644 --- a/dali/internal/event/animation/active-constraint-base.h +++ b/dali/internal/event/animation/active-constraint-base.h @@ -209,7 +209,7 @@ public: // Default property extensions from ProxyObject /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName() */ - virtual const std::string& GetDefaultPropertyName( Property::Index index ) const; + virtual const char* GetDefaultPropertyName( Property::Index index ) const; /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex() diff --git a/dali/internal/event/animation/path-impl.cpp b/dali/internal/event/animation/path-impl.cpp index 94477f2..b273245 100644 --- a/dali/internal/event/animation/path-impl.cpp +++ b/dali/internal/event/animation/path-impl.cpp @@ -39,20 +39,13 @@ const float BezierBasisCoeff[] = { -1.0f, 3.0f, -3.0f, 1.0f, const Dali::Matrix BezierBasis = Dali::Matrix( BezierBasisCoeff ); -struct PropertyDetails +const Dali::Internal::PropertyDetails DEFAULT_PROPERTY_DETAILS[] = { - std::string name; ///< The name of the property. - Dali::Property::Type type; ///< The property type. - bool writable:1; ///< Whether the property is writable - bool animatable:1; ///< Whether the property is animatable. - bool constraintInput:1; ///< Whether the property can be used as an input to a constraint. + { "points", Dali::Property::ARRAY, true, false, false }, + { "control-points", Dali::Property::ARRAY, true, false, false }, }; -const PropertyDetails DEFAULT_PROPERTY_DETAILS[] = {{"points", Dali::Property::ARRAY, true, false, false }, - {"control-points", Dali::Property::ARRAY, true, false, false }, - }; - -const int DEFAULT_PROPERTY_COUNT = sizeof( DEFAULT_PROPERTY_DETAILS ) / sizeof( PropertyDetails ); +const int DEFAULT_PROPERTY_COUNT = sizeof( DEFAULT_PROPERTY_DETAILS ) / sizeof( DEFAULT_PROPERTY_DETAILS[0] ); }//Unnamed namespace @@ -102,7 +95,7 @@ void Path::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const } } -const std::string& Path::GetDefaultPropertyName(Property::Index index) const +const char* Path::GetDefaultPropertyName(Property::Index index) const { if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) ) { @@ -111,8 +104,7 @@ const std::string& Path::GetDefaultPropertyName(Property::Index index) const else { // index out of range - static const std::string INVALID_PROPERTY_NAME; - return INVALID_PROPERTY_NAME; + return NULL; } } @@ -120,9 +112,11 @@ Property::Index Path::GetDefaultPropertyIndex(const std::string& name) const { Property::Index index = Property::INVALID_INDEX; - for( int i(0); iname ) ) // dont want to convert rhs to string { index = i; break; diff --git a/dali/internal/event/animation/path-impl.h b/dali/internal/event/animation/path-impl.h index 5233747..bc57570 100644 --- a/dali/internal/event/animation/path-impl.h +++ b/dali/internal/event/animation/path-impl.h @@ -90,7 +90,7 @@ private: /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName() */ - virtual const std::string& GetDefaultPropertyName(Property::Index index) const; + virtual const char* GetDefaultPropertyName(Property::Index index) const; /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex() diff --git a/dali/internal/event/common/object-impl.h b/dali/internal/event/common/object-impl.h index 296ee7b..7e585c5 100644 --- a/dali/internal/event/common/object-impl.h +++ b/dali/internal/event/common/object-impl.h @@ -58,7 +58,7 @@ public: /** * @copydoc Dali::Handle::GetPropertyName() */ - virtual const std::string& GetPropertyName(Property::Index index) const = 0; + virtual std::string GetPropertyName(Property::Index index) const = 0; /** * @copydoc Dali::Handle::GetPropertyIndex() diff --git a/dali/internal/event/common/proxy-object.cpp b/dali/internal/event/common/proxy-object.cpp index f667b18..583fd95 100644 --- a/dali/internal/event/common/proxy-object.cpp +++ b/dali/internal/event/common/proxy-object.cpp @@ -172,7 +172,7 @@ unsigned int ProxyObject::GetPropertyCount() const return count; } -const std::string& ProxyObject::GetPropertyName( Property::Index index ) const +std::string ProxyObject::GetPropertyName( Property::Index index ) const { DALI_ASSERT_ALWAYS( index > Property::INVALID_INDEX && "Property index out of bounds" ); diff --git a/dali/internal/event/common/proxy-object.h b/dali/internal/event/common/proxy-object.h index 28de752..8cfef1b 100644 --- a/dali/internal/event/common/proxy-object.h +++ b/dali/internal/event/common/proxy-object.h @@ -41,6 +41,18 @@ namespace Dali namespace Internal { +/** + * @brief Structure for setting up default properties and their details. + */ +struct PropertyDetails +{ + const char* name; ///< The name of the property. + Property::Type type; ///< The property type. + bool writable:1; ///< Whether the property is writable + bool animatable:1; ///< Whether the property is animatable. + bool constraintInput:1; ///< Whether the property can be used as an input to a constraint. +}; + class Stage; class PropertyInputImpl; class ProxyObject; @@ -171,7 +183,7 @@ public: // Property system interface from Internal::Object /** * @copydoc Dali::Internal::Object::GetPropertyName() */ - virtual const std::string& GetPropertyName( Property::Index index ) const; + virtual std::string GetPropertyName( Property::Index index ) const; /** * @copydoc Dali::Internal::Object::GetPropertyIndex() @@ -356,7 +368,7 @@ private: // Default property extensions for derived classes * Query how many default properties the derived class supports. * @return The number of default properties. */ - virtual const std::string& GetDefaultPropertyName( Property::Index index ) const = 0; + virtual const char* GetDefaultPropertyName( Property::Index index ) const = 0; /** * Query the index of a default property. diff --git a/dali/internal/event/effects/shader-effect-impl.cpp b/dali/internal/event/effects/shader-effect-impl.cpp index c162229..ab85eb8 100644 --- a/dali/internal/event/effects/shader-effect-impl.cpp +++ b/dali/internal/event/effects/shader-effect-impl.cpp @@ -58,10 +58,27 @@ const Property::Index ShaderEffect::GEOMETRY_HINTS = 3; namespace Internal { -ShaderEffect::DefaultPropertyLookup* ShaderEffect::mDefaultPropertyLookup = NULL; - namespace { +const PropertyDetails DEFAULT_PROPERTY_DETAILS[] = +{ + // Name Type writable animatable constraint-input + { "grid-density", Property::FLOAT, true, false, false }, // GRID_DENSITY + { "image", Property::MAP, true, false, false }, // IMAGE + { "program", Property::MAP, true, false, false }, // PROGRAM + { "geometry-hints", Property::INTEGER, true, false, false }, // GEOMETRY_HINTS +}; + +const int DEFAULT_PROPERTY_COUNT = sizeof( DEFAULT_PROPERTY_DETAILS ) / sizeof( DEFAULT_PROPERTY_DETAILS[0] ); + +BaseHandle Create() +{ + Internal::ShaderEffectPtr internal = Internal::ShaderEffect::New(); + + return Dali::ShaderEffect(internal.Get()); +} + +TypeRegistration mType( typeid(Dali::ShaderEffect), typeid(Dali::Handle), Create ); struct WrapperStrings { @@ -102,7 +119,7 @@ WrapperStrings customShaderWrappers [] = * @param[in] fragmentBody from application * @param[in] modifiesGeometry based on flags and vertex shader */ -void WrapAndSetProgram( ShaderEffect& effect, +void WrapAndSetProgram( Internal::ShaderEffect& effect, GeometryType actualGeometryType, GeometryType expectedGeometryType, const std::string& vertexPrefix, const std::string& fragmentPrefix, const std::string& vertexBody, const std::string& fragmentBody, @@ -175,32 +192,6 @@ void WrapAndSetProgram( ShaderEffect& effect, } } -BaseHandle Create() -{ - Internal::ShaderEffectPtr internal = Internal::ShaderEffect::New(); - - return Dali::ShaderEffect(internal.Get()); -} - -TypeRegistration mType( typeid(Dali::ShaderEffect), typeid(Dali::Handle), Create ); - -const std::string DEFAULT_PROPERTY_NAMES[] = -{ - "grid-density", - "image", - "program", - "geometry-hints", -}; -const int DEFAULT_PROPERTY_COUNT = sizeof( DEFAULT_PROPERTY_NAMES ) / sizeof( std::string ); - -const Property::Type DEFAULT_PROPERTY_TYPES[DEFAULT_PROPERTY_COUNT] = -{ - Property::FLOAT, // "grid-density", - Property::MAP, // "image", - Property::MAP, // "program", - Property::INTEGER, // "geometry-hints", -}; - std::string GetShader(const std::string& field, const Property::Value& property) { std::string value; @@ -422,17 +413,15 @@ void ShaderEffect::GetDefaultPropertyIndices( Property::IndexContainer& indices } } -const std::string& ShaderEffect::GetDefaultPropertyName(Property::Index index) const +const char* ShaderEffect::GetDefaultPropertyName(Property::Index index) const { if( index < DEFAULT_PROPERTY_COUNT ) { - return DEFAULT_PROPERTY_NAMES[index]; + return DEFAULT_PROPERTY_DETAILS[index].name; } else { - // index out of range..return empty string - static const std::string INVALID_PROPERTY_NAME; - return INVALID_PROPERTY_NAME; + return NULL; } } @@ -440,48 +429,41 @@ Property::Index ShaderEffect::GetDefaultPropertyIndex(const std::string& name) c { Property::Index index = Property::INVALID_INDEX; - // Lazy initialization of static mDefaultPropertyLookup - if (!mDefaultPropertyLookup) + // Look for name in default properties + for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) { - mDefaultPropertyLookup = new DefaultPropertyLookup(); - - for (int i=0; iname ) ) // dont want to convert rhs to string { - (*mDefaultPropertyLookup)[DEFAULT_PROPERTY_NAMES[i]] = i; + index = i; + break; } } - DALI_ASSERT_DEBUG( NULL != mDefaultPropertyLookup ); - - // Look for name in default properties - DefaultPropertyLookup::const_iterator result = mDefaultPropertyLookup->find( name ); - if ( mDefaultPropertyLookup->end() != result ) - { - index = result->second; - } return index; + } bool ShaderEffect::IsDefaultPropertyWritable(Property::Index index) const { - return true; + return true; // all properties are writable } bool ShaderEffect::IsDefaultPropertyAnimatable(Property::Index index) const { - return false; + return false; // all properties are non animatable } bool ShaderEffect::IsDefaultPropertyAConstraintInput( Property::Index index ) const { - return false; + return false; // all properties cannot be used as constraint input } Property::Type ShaderEffect::GetDefaultPropertyType(Property::Index index) const { if( index < DEFAULT_PROPERTY_COUNT ) { - return DEFAULT_PROPERTY_TYPES[index]; + return DEFAULT_PROPERTY_DETAILS[index].type; } else { diff --git a/dali/internal/event/effects/shader-effect-impl.h b/dali/internal/event/effects/shader-effect-impl.h index 7c5ff31..690d779 100644 --- a/dali/internal/event/effects/shader-effect-impl.h +++ b/dali/internal/event/effects/shader-effect-impl.h @@ -152,7 +152,7 @@ public: // Default property extensions from ProxyObject /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName() */ - virtual const std::string& GetDefaultPropertyName( Property::Index index ) const; + virtual const char* GetDefaultPropertyName( Property::Index index ) const; /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex() @@ -238,9 +238,6 @@ private: // Data Dali::ShaderEffect::GeometryHints mGeometryHints; ///< shader geometry hints for building the geometry Dali::Vector< UniformCoordinateType > mCoordinateTypes; ///< cached to avoid sending tons of unnecessary messages - // Default properties - typedef std::map DefaultPropertyLookup; - static DefaultPropertyLookup* mDefaultPropertyLookup; }; } // namespace Internal diff --git a/dali/internal/event/events/gesture-detector-impl.cpp b/dali/internal/event/events/gesture-detector-impl.cpp index 3032227..ea366e0 100644 --- a/dali/internal/event/events/gesture-detector-impl.cpp +++ b/dali/internal/event/events/gesture-detector-impl.cpp @@ -196,9 +196,9 @@ void GestureDetector::GetDefaultPropertyIndices( Property::IndexContainer& ) con { } -const std::string& GestureDetector::GetDefaultPropertyName( Property::Index index ) const +const char* GestureDetector::GetDefaultPropertyName( Property::Index index ) const { - return String::EMPTY; + return NULL; } Property::Index GestureDetector::GetDefaultPropertyIndex(const std::string& name) const diff --git a/dali/internal/event/events/gesture-detector-impl.h b/dali/internal/event/events/gesture-detector-impl.h index 6f56ddb..3d85fcc 100644 --- a/dali/internal/event/events/gesture-detector-impl.h +++ b/dali/internal/event/events/gesture-detector-impl.h @@ -180,7 +180,7 @@ private: // Default property extensions from ProxyObject /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName() */ - virtual const std::string& GetDefaultPropertyName(Property::Index index) const; + virtual const char* GetDefaultPropertyName(Property::Index index) const; /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex() diff --git a/dali/internal/event/events/pan-gesture-detector-impl.cpp b/dali/internal/event/events/pan-gesture-detector-impl.cpp index 9ea8920..ada772d 100644 --- a/dali/internal/event/events/pan-gesture-detector-impl.cpp +++ b/dali/internal/event/events/pan-gesture-detector-impl.cpp @@ -103,8 +103,6 @@ float GetOppositeAngle( float angle ) } // unnamed namespace -PanGestureDetector::DefaultPropertyLookup* PanGestureDetector::mDefaultPropertyLookup = NULL; - PanGestureDetectorPtr PanGestureDetector::New() { return new PanGestureDetector; @@ -116,15 +114,6 @@ PanGestureDetector::PanGestureDetector() mMaximumTouches(1), mSceneObject(NULL) { - if( !mDefaultPropertyLookup ) - { - mDefaultPropertyLookup = new DefaultPropertyLookup(); - const int start = DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT; - for ( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) - { - ( *mDefaultPropertyLookup )[ DEFAULT_PROPERTIES[i].name ] = i + start; - } - } } PanGestureDetector::~PanGestureDetector() @@ -356,7 +345,7 @@ void PanGestureDetector::GetDefaultPropertyIndices( Property::IndexContainer& in } } -const std::string& PanGestureDetector::GetDefaultPropertyName( Property::Index index ) const +const char* PanGestureDetector::GetDefaultPropertyName( Property::Index index ) const { index -= DEFAULT_GESTURE_DETECTOR_PROPERTY_MAX_COUNT; if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) ) @@ -365,9 +354,7 @@ const std::string& PanGestureDetector::GetDefaultPropertyName( Property::Index i } else { - // Index out-of-range... return empty string. - static const std::string INVALID_PROPERTY_NAME; - return INVALID_PROPERTY_NAME; + return NULL; } } @@ -375,15 +362,16 @@ Property::Index PanGestureDetector::GetDefaultPropertyIndex(const std::string& n { Property::Index index = Property::INVALID_INDEX; - DALI_ASSERT_DEBUG( NULL != mDefaultPropertyLookup ); - // Look for name in default properties - DefaultPropertyLookup::const_iterator result = mDefaultPropertyLookup->find( name ); - if ( mDefaultPropertyLookup->end() != result ) + for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) { - index = result->second; + const Internal::PropertyDetails* property = &DEFAULT_PROPERTIES[ i ]; + if( 0 == strcmp( name.c_str(), property->name ) ) // dont want to convert rhs to string + { + index = i; + break; + } } - return index; } diff --git a/dali/internal/event/events/pan-gesture-detector-impl.h b/dali/internal/event/events/pan-gesture-detector-impl.h index d8ac20d..ae0e069 100644 --- a/dali/internal/event/events/pan-gesture-detector-impl.h +++ b/dali/internal/event/events/pan-gesture-detector-impl.h @@ -19,7 +19,6 @@ */ // INTERNAL INCLUDES -#include #include #include #include @@ -227,7 +226,7 @@ private: /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName() */ - virtual const std::string& GetDefaultPropertyName(Property::Index index) const; + virtual const char* GetDefaultPropertyName(Property::Index index) const; /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex() @@ -300,10 +299,6 @@ private: const SceneGraph::PanGesture* mSceneObject; ///< Not owned - // Default properties - - typedef std::map DefaultPropertyLookup; - static DefaultPropertyLookup* mDefaultPropertyLookup; }; } // namespace Internal diff --git a/dali/internal/event/modeling/animatable-mesh-impl.cpp b/dali/internal/event/modeling/animatable-mesh-impl.cpp index 54cc750..9ba7606 100644 --- a/dali/internal/event/modeling/animatable-mesh-impl.cpp +++ b/dali/internal/event/modeling/animatable-mesh-impl.cpp @@ -37,26 +37,18 @@ namespace Internal namespace { -const std::string DEFAULT_PROPERTY_NAMES[] = +const PropertyDetails DEFAULT_PROPERTY_DETAILS[] = { - "position", - "vertex-color", - "texture-coords" + // Name Type writable animatable constraint-input + { "position", Property::VECTOR3, true, true, true }, // POSITION + { "vertex-color", Property::VECTOR4, true, true, true }, // COLOR + { "texture-coords", Property::VECTOR2, true, true, true }, // TEXTURE_COORDS }; -const int VERTEX_PROPERTY_COUNT = sizeof( DEFAULT_PROPERTY_NAMES ) / sizeof( std::string ); -const Property::Type DEFAULT_PROPERTY_TYPES[ VERTEX_PROPERTY_COUNT ] = -{ - Property::VECTOR3, // position - Property::VECTOR4, // Color - Property::VECTOR2, // Texture Coords -}; +const int VERTEX_PROPERTY_COUNT = sizeof( DEFAULT_PROPERTY_DETAILS ) / sizeof( DEFAULT_PROPERTY_DETAILS[0] ); } // namespace -AnimatableMesh::DefaultPropertyLookup* AnimatableMesh::mDefaultPropertyLookup = NULL; - - AnimatableMesh::AnimatableMesh( SceneGraph::UpdateManager& updateManager, SceneGraph::AnimatableMesh* sceneObject, @@ -234,17 +226,15 @@ void AnimatableMesh::GetDefaultPropertyIndices( Property::IndexContainer& indice } } -const std::string& AnimatableMesh::GetDefaultPropertyName( Property::Index index ) const +const char* AnimatableMesh::GetDefaultPropertyName( Property::Index index ) const { if ( ( index >= 0 ) && ( index < mPropertyCount ) ) { - return DEFAULT_PROPERTY_NAMES[index % VERTEX_PROPERTY_COUNT]; + return DEFAULT_PROPERTY_DETAILS[index % VERTEX_PROPERTY_COUNT].name; } else { - // Index out-of-range... return empty string. - static const std::string INVALID_PROPERTY_NAME; - return INVALID_PROPERTY_NAME; + return NULL; } } @@ -252,31 +242,39 @@ Property::Index AnimatableMesh::GetDefaultPropertyIndex(const std::string& name) { Property::Index index = Property::INVALID_INDEX; - // TODO: Property names should be modified to append the vertex index - + // Look for name in default properties + for( int i = 0; i < VERTEX_PROPERTY_COUNT; ++i ) + { + const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[ i ]; + if( 0 == strcmp( name.c_str(), property->name ) ) // dont want to convert rhs to string + { + index = i; + break; + } + } return index; } bool AnimatableMesh::IsDefaultPropertyWritable(Property::Index index) const { - return true; + return DEFAULT_PROPERTY_DETAILS[ index % VERTEX_PROPERTY_COUNT ].writable; } bool AnimatableMesh::IsDefaultPropertyAnimatable(Property::Index index) const { - return true; + return DEFAULT_PROPERTY_DETAILS[ index % VERTEX_PROPERTY_COUNT ].animatable; } bool AnimatableMesh::IsDefaultPropertyAConstraintInput( Property::Index index ) const { - return true; + return DEFAULT_PROPERTY_DETAILS[ index % VERTEX_PROPERTY_COUNT ].constraintInput; } Property::Type AnimatableMesh::GetDefaultPropertyType(Property::Index index) const { if ( ( index >= 0 ) && ( index < mPropertyCount ) ) { - return DEFAULT_PROPERTY_TYPES[index % VERTEX_PROPERTY_COUNT ]; + return DEFAULT_PROPERTY_DETAILS[ index % VERTEX_PROPERTY_COUNT ].type; } else { diff --git a/dali/internal/event/modeling/animatable-mesh-impl.h b/dali/internal/event/modeling/animatable-mesh-impl.h index 69c5806..ecc6289 100644 --- a/dali/internal/event/modeling/animatable-mesh-impl.h +++ b/dali/internal/event/modeling/animatable-mesh-impl.h @@ -172,7 +172,7 @@ public: // Implementation of ProxyObject /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName() */ - virtual const std::string& GetDefaultPropertyName(Property::Index index) const; + virtual const char* GetDefaultPropertyName(Property::Index index) const; /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex() @@ -246,9 +246,6 @@ private: unsigned int mNumberOfVertices; int mPropertyCount; - // Default properties - typedef std::map DefaultPropertyLookup; - static DefaultPropertyLookup* mDefaultPropertyLookup; }; }//Internal diff --git a/dali/internal/event/object/custom-object-internal.cpp b/dali/internal/event/object/custom-object-internal.cpp index 372ef1f..b16d254 100644 --- a/dali/internal/event/object/custom-object-internal.cpp +++ b/dali/internal/event/object/custom-object-internal.cpp @@ -31,11 +31,6 @@ using Dali::Internal::SceneGraph::PropertyBase; using Dali::Internal::SceneGraph::UpdateManager; using Dali::Internal::SceneGraph::AnimatableProperty; -namespace -{ -const std::string INVALID_PROPERTY_NAME; -} - namespace Dali { @@ -84,9 +79,9 @@ void CustomObject::GetDefaultPropertyIndices( Property::IndexContainer& indices { } -const std::string& CustomObject::GetDefaultPropertyName( Property::Index index ) const +const char* CustomObject::GetDefaultPropertyName( Property::Index index ) const { - return INVALID_PROPERTY_NAME; + return NULL; } Property::Index CustomObject::GetDefaultPropertyIndex(const std::string& name) const diff --git a/dali/internal/event/object/custom-object-internal.h b/dali/internal/event/object/custom-object-internal.h index f1e8cf7..c47eb56 100644 --- a/dali/internal/event/object/custom-object-internal.h +++ b/dali/internal/event/object/custom-object-internal.h @@ -75,7 +75,7 @@ public: /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName() */ - virtual const std::string& GetDefaultPropertyName(Property::Index index) const; + virtual const char* GetDefaultPropertyName(Property::Index index) const; /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex() diff --git a/dali/internal/event/render-tasks/render-task-impl.cpp b/dali/internal/event/render-tasks/render-task-impl.cpp index 85b6e49..5b955e0 100644 --- a/dali/internal/event/render-tasks/render-task-impl.cpp +++ b/dali/internal/event/render-tasks/render-task-impl.cpp @@ -49,13 +49,13 @@ namespace Internal namespace // For internal properties { -const std::string DEFAULT_PROPERTY_NAMES[] = +const char* DEFAULT_PROPERTY_NAMES[] = { "viewport-position", "viewport-size", "clear-color" }; -const int DEFAULT_PROPERTY_COUNT = sizeof( DEFAULT_PROPERTY_NAMES ) / sizeof( std::string ); +const int DEFAULT_PROPERTY_COUNT = sizeof( DEFAULT_PROPERTY_NAMES ) / sizeof( DEFAULT_PROPERTY_NAMES[0]); const Property::Type DEFAULT_PROPERTY_TYPES[DEFAULT_PROPERTY_COUNT] = { @@ -66,8 +66,6 @@ const Property::Type DEFAULT_PROPERTY_TYPES[DEFAULT_PROPERTY_COUNT] = }// unnamed namespace -RenderTask::DefaultPropertyLookup* RenderTask::sDefaultPropertyLookup = NULL; - RenderTask* RenderTask::New( bool isSystemLevel ) { RenderTask* task( new RenderTask( ThreadLocalStorage::Get().GetEventToUpdate(), isSystemLevel ) ); @@ -474,7 +472,7 @@ void RenderTask::GetDefaultPropertyIndices( Property::IndexContainer& indices ) } } -const std::string& RenderTask::GetDefaultPropertyName( Property::Index index ) const +const char* RenderTask::GetDefaultPropertyName( Property::Index index ) const { if( index < DEFAULT_PROPERTY_COUNT ) { @@ -482,9 +480,7 @@ const std::string& RenderTask::GetDefaultPropertyName( Property::Index index ) c } else { - // index out of range..return empty string - static const std::string INVALID_PROPERTY_NAME; - return INVALID_PROPERTY_NAME; + return NULL; } } @@ -492,41 +488,32 @@ Property::Index RenderTask::GetDefaultPropertyIndex(const std::string& name) con { Property::Index index = Property::INVALID_INDEX; - // Lazy initialization of static sDefaultPropertyLookup - if (!sDefaultPropertyLookup) + // Look for name in default properties + for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i ) { - sDefaultPropertyLookup = new DefaultPropertyLookup(); - - for (int i=0; ifind( name ); - if ( sDefaultPropertyLookup->end() != result ) - { - index = result->second; - } return index; } bool RenderTask::IsDefaultPropertyWritable(Property::Index index) const { - return true; + return true; // all properties writable } bool RenderTask::IsDefaultPropertyAnimatable(Property::Index index) const { - return true; + return true; // all properties animatable } bool RenderTask::IsDefaultPropertyAConstraintInput( Property::Index index ) const { - return true; + return true; // all properties can be used as constraint input } Property::Type RenderTask::GetDefaultPropertyType(Property::Index index) const diff --git a/dali/internal/event/render-tasks/render-task-impl.h b/dali/internal/event/render-tasks/render-task-impl.h index d14746e..5895375 100644 --- a/dali/internal/event/render-tasks/render-task-impl.h +++ b/dali/internal/event/render-tasks/render-task-impl.h @@ -251,7 +251,7 @@ public: // Implementation of ProxyObject /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName() */ - virtual const std::string& GetDefaultPropertyName(Property::Index index) const; + virtual const char* GetDefaultPropertyName(Property::Index index) const; /** * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex() @@ -454,10 +454,6 @@ private: bool mCullMode : 1; ///< True if the render-task's actors should be culled bool mIsSystemLevel : 1; ///< True if the render-task is on the system level task list. - // Default properties - typedef std::map DefaultPropertyLookup; - static DefaultPropertyLookup* sDefaultPropertyLookup; - //Signals Dali::RenderTask::RenderTaskSignalV2 mSignalFinishedV2; ///< Signal emmited when the render task has been processed. }; diff --git a/dali/internal/update/common/inherited-property.h b/dali/internal/update/common/inherited-property.h index b6d8348..6a9fa9a 100644 --- a/dali/internal/update/common/inherited-property.h +++ b/dali/internal/update/common/inherited-property.h @@ -527,7 +527,6 @@ public: /** * Create an inherited property. - * @param [in] initialValue The initial value of the property. */ InheritedMatrix() : mValue(), diff --git a/dali/public-api/actors/renderable-actor.h b/dali/public-api/actors/renderable-actor.h index 31236ac..9294453 100644 --- a/dali/public-api/actors/renderable-actor.h +++ b/dali/public-api/actors/renderable-actor.h @@ -32,8 +32,6 @@ namespace Internal DALI_INTERNAL class RenderableActor; } -class ShaderEffect; - /** * @brief Face culling modes. */ diff --git a/dali/public-api/object/handle.cpp b/dali/public-api/object/handle.cpp index d81b062..4c1b482 100644 --- a/dali/public-api/object/handle.cpp +++ b/dali/public-api/object/handle.cpp @@ -71,7 +71,7 @@ unsigned int Handle::GetPropertyCount() const return GetImplementation(*this).GetPropertyCount(); } -const std::string& Handle::GetPropertyName(Property::Index index) const +std::string Handle::GetPropertyName(Property::Index index) const { return GetImplementation(*this).GetPropertyName( index ); } diff --git a/dali/public-api/object/handle.h b/dali/public-api/object/handle.h index 090f7c5..8ad0111 100644 --- a/dali/public-api/object/handle.h +++ b/dali/public-api/object/handle.h @@ -139,7 +139,7 @@ public: * @param [in] index The index of the property. * @return The name of the property. */ - const std::string& GetPropertyName(Property::Index index) const; + std::string GetPropertyName(Property::Index index) const; /** * @brief Query the index of a property. diff --git a/dali/public-api/object/type-info.h b/dali/public-api/object/type-info.h index 06bf230..e613c62 100644 --- a/dali/public-api/object/type-info.h +++ b/dali/public-api/object/type-info.h @@ -21,6 +21,7 @@ // INTERNAL INCLUDES #include +#include namespace Dali {