X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=dali-toolkit%2Finternal%2Fvisuals%2Fcolor%2Fcolor-visual.cpp;h=6313211433f7e53ba82a308673e06f812470b4cc;hb=fb0339fee98523cbf3e527ddd8125660aa441c6c;hp=781fdf771e9a25abb637c689168c21033d09ef86;hpb=ce4bae9bcaabc3b38d016e7ef36cc55357087bc0;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/color/color-visual.cpp b/dali-toolkit/internal/visuals/color/color-visual.cpp index 781fdf7..6313211 100644 --- a/dali-toolkit/internal/visuals/color/color-visual.cpp +++ b/dali-toolkit/internal/visuals/color/color-visual.cpp @@ -41,7 +41,6 @@ namespace Internal namespace { -const char * const COLOR_NAME("mixColor"); const char* VERTEX_SHADER = DALI_COMPOSE_SHADER( attribute mediump vec2 aPosition;\n @@ -80,14 +79,15 @@ const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER( ); } -ColorVisualPtr ColorVisual::New( VisualFactoryCache& factoryCache ) +ColorVisualPtr ColorVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties ) { - return new ColorVisual( factoryCache ); + ColorVisualPtr colorVisualPtr( new ColorVisual( factoryCache ) ); + colorVisualPtr->SetProperties( properties ); + return colorVisualPtr; } ColorVisual::ColorVisual( VisualFactoryCache& factoryCache ) -: Visual::Base( factoryCache ), - mMixColorIndex( Property::INVALID_INDEX ) +: Visual::Base( factoryCache ) { } @@ -97,10 +97,20 @@ ColorVisual::~ColorVisual() void ColorVisual::DoSetProperties( const Property::Map& propertyMap ) { - Property::Value* color = propertyMap.Find( Toolkit::ColorVisual::Property::MIX_COLOR, COLOR_NAME ); - if( !( color && color->Get(mMixColor) ) ) + // By virtue of DoSetProperties being called last, this will override + // anything set by DevelVisual::Property::MIX_COLOR + Property::Value* colorValue = propertyMap.Find( Toolkit::ColorVisual::Property::MIX_COLOR, MIX_COLOR ); + if( colorValue ) { - DALI_LOG_ERROR( "Fail to provide a color to the ColorVisual object\n" ); + Vector4 color; + if( colorValue->Get( color ) ) + { + SetMixColor( color ); + } + else + { + DALI_LOG_ERROR("ColorVisual: mixColor property has incorrect type\n"); + } } } @@ -115,7 +125,7 @@ void ColorVisual::DoCreatePropertyMap( Property::Map& map ) const { map.Clear(); map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::COLOR ); - map.Insert( Toolkit::ColorVisual::Property::MIX_COLOR, mMixColor ); + map.Insert( Toolkit::ColorVisual::Property::MIX_COLOR, mImpl->mMixColor ); } void ColorVisual::OnSetTransform() @@ -129,11 +139,6 @@ void ColorVisual::OnSetTransform() void ColorVisual::InitializeRenderer() { Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY ); - if( !geometry ) - { - geometry = VisualFactoryCache::CreateQuadGeometry(); - mFactoryCache.SaveGeometry( VisualFactoryCache::QUAD_GEOMETRY, geometry ); - } Shader shader = mFactoryCache.GetShader( VisualFactoryCache::COLOR_SHADER ); if( !shader ) @@ -144,30 +149,19 @@ void ColorVisual::InitializeRenderer() mImpl->mRenderer = Renderer::New( geometry, shader ); - mMixColorIndex = DevelHandle::RegisterProperty( mImpl->mRenderer, Toolkit::ColorVisual::Property::MIX_COLOR, COLOR_NAME, mMixColor ); - if( mMixColor.a < 1.f ) + // ColorVisual has it's own index key for mix color - use this instead + // of using the new base index to avoid changing existing applications + // String keys will get to this property. + mImpl->mMixColorIndex = DevelHandle::RegisterProperty( mImpl->mRenderer, Toolkit::ColorVisual::Property::MIX_COLOR, MIX_COLOR, mImpl->mMixColor ); + if( mImpl->mMixColor.a < 1.f ) { mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON ); } - //Register transform properties + // Register transform properties mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT ); } -void ColorVisual::SetColor(const Vector4& color) -{ - mMixColor = color; - - if( mImpl->mRenderer ) - { - (mImpl->mRenderer).SetProperty( mMixColorIndex, color ); - if( color.a < 1.f ) - { - mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON ); - } - } -} - } // namespace Internal } // namespace Toolkit