X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fimage%2Fbatch-image-visual.cpp;h=f5b43927930522c77b2d5e7b3cd41e9cc108aaf5;hb=caf7677175a0e8b9c690d4f2ab73adc295f22c0e;hp=973355ab04718d48be0c4b3da1bf61d8f2f212b6;hpb=f4c1e7f52d49c3ce033b9ee4c3c7414b06a22d45;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/image/batch-image-visual.cpp b/dali-toolkit/internal/visuals/image/batch-image-visual.cpp index 973355a..f5b4392 100644 --- a/dali-toolkit/internal/visuals/image/batch-image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/batch-image-visual.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,7 @@ // INTERNAL HEADER #include +#include #include #include #include @@ -87,13 +89,18 @@ const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER( } // unnamed namespace -BatchImageVisualPtr BatchImageVisual::New( VisualFactoryCache& factoryCache ) +BatchImageVisualPtr BatchImageVisual::New( VisualFactoryCache& factoryCache, const std::string& url, const Property::Map& properties ) { - return new BatchImageVisual( factoryCache ); + BatchImageVisualPtr visual = new BatchImageVisual( factoryCache ); + visual->mImageUrl = url; + visual->SetProperties( properties ); + + return visual; } BatchImageVisual::BatchImageVisual( VisualFactoryCache& factoryCache ) : Visual::Base( factoryCache ), + mImageUrl(""), mDesiredSize() { } @@ -102,58 +109,28 @@ BatchImageVisual::~BatchImageVisual() { } -void BatchImageVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap ) +void BatchImageVisual::DoSetProperties( const Property::Map& propertyMap ) { - std::string oldImageUrl = mImageUrl; - Property::Value* imageURLValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::URL, Dali::Toolkit::Internal::IMAGE_URL_NAME ); + // url already passed in constructor - if( imageURLValue ) + int desiredWidth = 0; + Property::Value* desiredWidthValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::DESIRED_WIDTH, DESIRED_WIDTH ); + if( desiredWidthValue ) { - imageURLValue->Get( mImageUrl ); - - int desiredWidth = 0; - Property::Value* desiredWidthValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::DESIRED_WIDTH, DESIRED_WIDTH ); - if( desiredWidthValue ) - { - desiredWidthValue->Get( desiredWidth ); - } - - int desiredHeight = 0; - Property::Value* desiredHeightValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::DESIRED_HEIGHT, DESIRED_HEIGHT ); - if( desiredHeightValue ) - { - desiredHeightValue->Get( desiredHeight ); - } - - mDesiredSize = ImageDimensions( desiredWidth, desiredHeight ); + desiredWidthValue->Get( desiredWidth ); } - // Remove old renderer if exit. - if( mImpl->mRenderer ) + int desiredHeight = 0; + Property::Value* desiredHeightValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::DESIRED_HEIGHT, DESIRED_HEIGHT ); + if( desiredHeightValue ) { - if( actor ) // Remove old renderer from actor. - { - actor.RemoveRenderer( mImpl->mRenderer ); - } - if( !oldImageUrl.empty() ) // Clean old renderer from cache. - { - CleanCache( oldImageUrl ); - } + desiredHeightValue->Get( desiredHeight ); } - // If actor is on stage, create new renderer and apply to actor. - if( actor && actor.OnStage() ) - { - SetOnStage( actor ); - } + mDesiredSize = ImageDimensions( desiredWidth, desiredHeight ); } -void BatchImageVisual::SetSize( const Vector2& size ) -{ - Visual::Base::SetSize( size ); -} - -void BatchImageVisual::GetNaturalSize( Vector2& naturalSize ) const +void BatchImageVisual::GetNaturalSize( Vector2& naturalSize ) { if( mDesiredSize.GetWidth() > 0 && mDesiredSize.GetHeight() > 0 ) { @@ -217,7 +194,7 @@ void BatchImageVisual::InitializeRenderer( const std::string& imageUrl ) mImpl->mRenderer.SetTextures( textureSet ); // Turn batching on, to send message it must be on stage. - mImpl->mRenderer.SetProperty( Dali::Renderer::Property::BATCHING_ENABLED, true ); + mImpl->mRenderer.SetProperty( Dali::DevelRenderer::Property::BATCHING_ENABLED, true ); } mImpl->mFlags |= Impl::IS_FROM_CACHE; } @@ -230,7 +207,7 @@ void BatchImageVisual::DoSetOnStage( Actor& actor ) InitializeRenderer( mImageUrl ); } // Turn batching on, to send message it must be on stage - mImpl->mRenderer.SetProperty( Dali::Renderer::Property::BATCHING_ENABLED, true ); + mImpl->mRenderer.SetProperty( Dali::DevelRenderer::Property::BATCHING_ENABLED, true ); actor.AddRenderer( mImpl->mRenderer ); } @@ -253,7 +230,7 @@ void BatchImageVisual::DoSetOffStage( Actor& actor ) void BatchImageVisual::DoCreatePropertyMap( Property::Map& map ) const { map.Clear(); - map.Insert( Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE ); + map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::IMAGE ); if( !mImageUrl.empty() ) { @@ -264,17 +241,6 @@ void BatchImageVisual::DoCreatePropertyMap( Property::Map& map ) const } } -void BatchImageVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue ) -{ - // TODO -} - -Dali::Property::Value BatchImageVisual::DoGetProperty( Dali::Property::Index index ) -{ - // TODO - return Dali::Property::Value(); -} - Shader BatchImageVisual::GetBatchShader( VisualFactoryCache& factoryCache ) { Shader shader = factoryCache.GetShader( VisualFactoryCache::BATCH_IMAGE_SHADER ); @@ -296,6 +262,14 @@ void BatchImageVisual::CleanCache(const std::string& url) } } +void BatchImageVisual::OnSetTransform() +{ + if( mImpl->mRenderer ) + { + //Register transform properties + mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT ); + } +} } // namespace Internal