X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fimage%2Fimage-visual.cpp;h=b61c23b9b76328594d8c98c026af48ccb50525f4;hb=d13e8792c0e8dd0a3f5fb167ca9ee7c0155b7afc;hp=ab6d1b616f6b026372a62956208be6d14e11b565;hpb=a68dbe03813fd3db34c81f4e6960572e8882930b;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/image/image-visual.cpp b/dali-toolkit/internal/visuals/image/image-visual.cpp index ab6d1b6..b61c23b 100644 --- a/dali-toolkit/internal/visuals/image/image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/image-visual.cpp @@ -31,7 +31,7 @@ // INTERNAL HEADER #include -#include +#include #include #include #include @@ -185,11 +185,6 @@ Geometry CreateGeometry( VisualFactoryCache& factoryCache, ImageDimensions gridS if( gridSize == ImageDimensions( 1, 1 ) ) { geometry = factoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY ); - if( !geometry ) - { - geometry = VisualFactoryCache::CreateQuadGeometry(); - factoryCache.SaveGeometry( VisualFactoryCache::QUAD_GEOMETRY, geometry ); - } } else { @@ -203,6 +198,18 @@ Geometry CreateGeometry( VisualFactoryCache& factoryCache, ImageDimensions gridS ImageVisualPtr ImageVisual::New( VisualFactoryCache& factoryCache, const std::string& imageUrl, + const Property::Map& properties, + ImageDimensions size, + FittingMode::Type fittingMode, + Dali::SamplingMode::Type samplingMode ) +{ + ImageVisualPtr imageVisualPtr( new ImageVisual( factoryCache, imageUrl, size, fittingMode, samplingMode ) ); + imageVisualPtr->SetProperties( properties ); + return imageVisualPtr; +} + +ImageVisualPtr ImageVisual::New( VisualFactoryCache& factoryCache, + const std::string& imageUrl, ImageDimensions size, FittingMode::Type fittingMode, Dali::SamplingMode::Type samplingMode ) @@ -272,11 +279,14 @@ void ImageVisual::DoSetProperties( const Property::Map& propertyMap ) mSamplingMode = Dali::SamplingMode::Type( value ); } + // Use a variable to detect if the width or height have been modified by the property map. + bool desiredSizeSpecified = false; int desiredWidth = 0; Property::Value* desiredWidthValue = propertyMap.Find( Toolkit::ImageVisual::Property::DESIRED_WIDTH, IMAGE_DESIRED_WIDTH ); if( desiredWidthValue ) { desiredWidthValue->Get( desiredWidth ); + desiredSizeSpecified = true; } int desiredHeight = 0; @@ -284,9 +294,14 @@ void ImageVisual::DoSetProperties( const Property::Map& propertyMap ) if( desiredHeightValue ) { desiredHeightValue->Get( desiredHeight ); + desiredSizeSpecified = true; } - mDesiredSize = ImageDimensions( desiredWidth, desiredHeight ); + // Only update the desired size if specified in the property map. + if( desiredSizeSpecified ) + { + mDesiredSize = ImageDimensions( desiredWidth, desiredHeight ); + } Property::Value* pixelAreaValue = propertyMap.Find( Toolkit::ImageVisual::Property::PIXEL_AREA, PIXEL_AREA_UNIFORM_NAME ); if( pixelAreaValue ) @@ -522,13 +537,11 @@ TextureSet ImageVisual::CreateTextureSet( Vector4& textureRect, const std::strin void ImageVisual::InitializeRenderer( const std::string& imageUrl ) { - DALI_ASSERT_DEBUG( !mImpl->mRenderer && "Renderer should have been removed from stage and already reset before initialization" ); - mImageUrl = imageUrl; mImpl->mFlags &= ~Impl::IS_ATLASING_APPLIED; if( !mImpl->mCustomShader && - ( strncasecmp( imageUrl.c_str(), HTTP_URL, sizeof(HTTP_URL) -1 ) != 0 ) && // ignore remote images + ( strncasecmp( imageUrl.c_str(), HTTP_URL, sizeof(HTTP_URL) -1 ) != 0 ) && // dont atlas remote images ( strncasecmp( imageUrl.c_str(), HTTPS_URL, sizeof(HTTPS_URL) -1 ) != 0 ) ) { bool defaultWrapMode = mWrapModeU <= WrapMode::CLAMP_TO_EDGE && mWrapModeV <= WrapMode::CLAMP_TO_EDGE; @@ -586,7 +599,6 @@ void ImageVisual::InitializeRenderer( const std::string& imageUrl ) void ImageVisual::InitializeRenderer( const Image& image ) { - DALI_ASSERT_DEBUG( !mImpl->mRenderer && "Renderer should have been removed from stage and already reset before initialization" ); mImpl->mFlags &= ~Impl::IS_FROM_CACHE; @@ -669,7 +681,7 @@ void ImageVisual::DoSetOffStage( Actor& actor ) void ImageVisual::DoCreatePropertyMap( Property::Map& map ) const { map.Clear(); - map.Insert( Toolkit::VisualProperty::TYPE, Toolkit::Visual::IMAGE ); + map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::IMAGE ); bool sync = IsSynchronousResourceLoading(); map.Insert( SYNCHRONOUS_LOADING, sync ); @@ -699,17 +711,6 @@ void ImageVisual::DoCreatePropertyMap( Property::Map& map ) const map.Insert( Toolkit::ImageVisual::Property::WRAP_MODE_V, mWrapModeV ); } -void ImageVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue ) -{ - // TODO -} - -Dali::Property::Value ImageVisual::DoGetProperty( Dali::Property::Index index ) -{ - // TODO - return Dali::Property::Value(); -} - void ImageVisual::OnSetTransform() { if( mImpl->mRenderer )