X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fvisual-base-impl.cpp;h=5815c4ad0d11828c885a4fe7c3dfcb6bf0d61e16;hb=6c664b09beef66ee4e223cf30fb17ecdd6889bf7;hp=12b6b35c53572f17295d912f164c3b87bd5a84ee;hpb=baeb5ad3a0b2b1535c48dfb25f3d7ace66cde857;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/visual-base-impl.cpp b/dali-toolkit/internal/visuals/visual-base-impl.cpp index 12b6b35..5815c4a 100644 --- a/dali-toolkit/internal/visuals/visual-base-impl.cpp +++ b/dali-toolkit/internal/visuals/visual-base-impl.cpp @@ -23,10 +23,17 @@ #include //INTERNAL HEARDER -#include +#include #include #include +namespace +{ +#if defined(DEBUG_ENABLED) +Debug::Filter* gVisualBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_VISUAL_BASE" ); +#endif +} + namespace Dali { @@ -61,23 +68,42 @@ void Visual::Base::SetCustomShader( const Property::Map& shaderMap ) void Visual::Base::SetProperties( const Property::Map& propertyMap ) { - Property::Value* customShaderValue = propertyMap.Find( VisualProperty::SHADER, CUSTOM_SHADER ); - if( customShaderValue ) + for( size_t i = 0; i < propertyMap.Count(); ++i ) { - Property::Map shaderMap; - if( customShaderValue->Get( shaderMap ) ) + const KeyValuePair& pair = propertyMap.GetKeyValue( i ); + const Property::Key& key = pair.first; + const Property::Value& value = pair.second; + switch( key.indexKey ) { - SetCustomShader( shaderMap ); - } - } + case DevelVisual::Property::SHADER: + { + Property::Map shaderMap; + if( value.Get( shaderMap ) ) + { + SetCustomShader( shaderMap ); + } + break; + } - Property::Value* transform = propertyMap.Find( Toolkit::Visual::DevelProperty::TRANSFORM, TRANSFORM ); - if( transform ) - { - Property::Map map; - if( transform->Get( map ) ) - { - mImpl->mTransform.SetPropertyMap( map ); + case DevelVisual::Property::TRANSFORM: + { + Property::Map map; + if( value.Get( map ) ) + { + mImpl->mTransform.SetPropertyMap( map ); + } + break; + } + + case DevelVisual::Property::PREMULTIPLIED_ALPHA: + { + bool premultipliedAlpha = false; + if( value.Get( premultipliedAlpha ) ) + { + EnablePreMultipliedAlpha( premultipliedAlpha ); + } + break; + } } } @@ -88,6 +114,14 @@ void Visual::Base::SetTransformAndSize( const Property::Map& transform, Size con { mImpl->mControlSize = controlSize; mImpl->mTransform.SetPropertyMap( transform ); + +#if defined(DEBUG_ENABLED) + std::ostringstream oss; + oss << transform; + DALI_LOG_INFO( gVisualBaseLogFilter, Debug::General, "Visual::Base::SetTransformAndSize(%s) - [\e[1;32mtransform: %s controlSize: (%3.1f, %3.1f)]\e[0m\n", + GetName().c_str(), oss.str().c_str(), controlSize.x, controlSize.y ); +#endif + OnSetTransform(); } @@ -101,9 +135,28 @@ const std::string& Visual::Base::GetName() return mImpl->mName; } -float Visual::Base::GetHeightForWidth( float width ) const +float Visual::Base::GetHeightForWidth( float width ) +{ + float aspectCorrectedHeight = 0.f; + Vector2 naturalSize; + GetNaturalSize( naturalSize ); + if( naturalSize.width ) + { + aspectCorrectedHeight = naturalSize.height * width / naturalSize.width; + } + return aspectCorrectedHeight; +} + +float Visual::Base::GetWidthForHeight( float height ) { - return 0.f; + float aspectCorrectedWidth = 0.f; + Vector2 naturalSize; + GetNaturalSize( naturalSize ); + if( naturalSize.height > 0.0f ) + { + aspectCorrectedWidth = naturalSize.width * height / naturalSize.height; + } + return aspectCorrectedWidth; } void Visual::Base::GetNaturalSize( Vector2& naturalSize ) @@ -163,12 +216,15 @@ void Visual::Base::CreatePropertyMap( Property::Map& map ) const Property::Map transform; mImpl->mTransform.GetPropertyMap( transform ); - map.Insert( Toolkit::Visual::DevelProperty::TRANSFORM, transform ); + map.Insert( DevelVisual::Property::TRANSFORM, transform ); + + bool premultipliedAlpha( IsPreMultipliedAlphaEnabled() ); + map.Insert( DevelVisual::Property::PREMULTIPLIED_ALPHA, premultipliedAlpha ); } void Visual::Base::EnablePreMultipliedAlpha( bool preMultipled ) { - if(preMultipled) + if( preMultipled ) { mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA; } @@ -204,55 +260,9 @@ bool Visual::Base::IsFromCache() const return mImpl->mFlags & Impl::IS_FROM_CACHE; } -void Visual::Base::SetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue ) +Renderer Visual::Base::GetRenderer() { - DALI_ASSERT_ALWAYS( ( index > Property::INVALID_INDEX ) && - ( index > VISUAL_PROPERTY_BASE_START_INDEX ) && // Change the type of visual is not allowed. - "Property index is out of bounds" ); - - if( index < VISUAL_PROPERTY_START_INDEX ) - { - if( index == Dali::Toolkit::Visual::DevelProperty::TRANSFORM ) - { - Property::Map* transformMap = propertyValue.GetMap(); - if( transformMap ) - { - SetTransformAndSize( *transformMap, mImpl->mControlSize ); - } - } - - // TODO set the properties of the visual base. - } - else - { - DoSetProperty( index, propertyValue ); - } -} - -Dali::Property::Value Visual::Base::GetProperty( Dali::Property::Index index ) -{ - DALI_ASSERT_ALWAYS( ( index > Property::INVALID_INDEX ) && - ( index >= VISUAL_PROPERTY_BASE_START_INDEX ) && - "Property index is out of bounds" ); - - Dali::Property::Value value; - - if( index < VISUAL_PROPERTY_START_INDEX ) - { - if( index == Dali::Toolkit::Visual::DevelProperty::TRANSFORM ) - { - Property::Map map; - mImpl->mTransform.GetPropertyMap( map ); - return map; - } - // TODO retrieve the properties of the visual base. - } - else - { - value = DoGetProperty( index ); - } - - return value; + return mImpl->mRenderer; } } // namespace Internal