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=1ce668b18c8e6cb169bf083431586be34012bfb1;hpb=c3f9162ab11786380e2ec9c55f217c2daf7722e8;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 1ce668b..f5b4392 100644 --- a/dali-toolkit/internal/visuals/image/batch-image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/batch-image-visual.cpp @@ -24,14 +24,15 @@ #include #include #include +#include #include #include #include -#include #include // INTERNAL HEADER #include +#include #include #include #include @@ -86,11 +87,21 @@ const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER( }\n ); -} //unnamed namespace +} // unnamed namespace + +BatchImageVisualPtr BatchImageVisual::New( VisualFactoryCache& factoryCache, const std::string& url, const Property::Map& properties ) +{ + BatchImageVisualPtr visual = new BatchImageVisual( factoryCache ); + visual->mImageUrl = url; + visual->SetProperties( properties ); + + return visual; +} BatchImageVisual::BatchImageVisual( VisualFactoryCache& factoryCache ) - : Visual::Base( factoryCache ), - mDesiredSize() +: Visual::Base( factoryCache ), + mImageUrl(""), + mDesiredSize() { } @@ -98,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 ); - - if( imageURLValue ) - { - 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 ); - } + // url already passed in constructor - // Remove old renderer if exit. - if( mImpl->mRenderer ) + int desiredWidth = 0; + Property::Value* desiredWidthValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::DESIRED_WIDTH, DESIRED_WIDTH ); + if( desiredWidthValue ) { - if( actor ) // Remove old renderer from actor. - { - actor.RemoveRenderer( mImpl->mRenderer ); - } - if( !oldImageUrl.empty() ) // Clean old renderer from cache. - { - CleanCache( oldImageUrl ); - } + desiredWidthValue->Get( desiredWidth ); } - // If actor is on stage, create new renderer and apply to actor. - if( actor && actor.OnStage() ) + int desiredHeight = 0; + Property::Value* desiredHeightValue = propertyMap.Find( Dali::Toolkit::ImageVisual::Property::DESIRED_HEIGHT, DESIRED_HEIGHT ); + if( desiredHeightValue ) { - SetOnStage( actor ); + desiredHeightValue->Get( desiredHeight ); } -} -void BatchImageVisual::SetSize( const Vector2& size ) -{ - Visual::Base::SetSize( size ); + mDesiredSize = ImageDimensions( desiredWidth, desiredHeight ); } -void BatchImageVisual::GetNaturalSize( Vector2& naturalSize ) const +void BatchImageVisual::GetNaturalSize( Vector2& naturalSize ) { if( mDesiredSize.GetWidth() > 0 && mDesiredSize.GetHeight() > 0 ) { @@ -213,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; } @@ -226,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 ); } @@ -249,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() ) { @@ -281,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