From: David Steele Date: Wed, 2 Aug 2017 13:11:52 +0000 (+0100) Subject: Updated ImageVisual::GetNaturalSize to work with loaded images X-Git-Tag: dali_1.2.51~1 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=a046c21262ef124f23ecd70dd99348294872cc23;ds=sidebyside Updated ImageVisual::GetNaturalSize to work with loaded images Change-Id: I33d5a66aec57460e318fced5b41deb16fe9beba5 --- diff --git a/dali-toolkit/internal/visuals/image/image-visual.cpp b/dali-toolkit/internal/visuals/image/image-visual.cpp index b558cfd..dcb222d 100644 --- a/dali-toolkit/internal/visuals/image/image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/image-visual.cpp @@ -528,8 +528,20 @@ void ImageVisual::GetNaturalSize( Vector2& naturalSize ) naturalSize.y = mDesiredSize.GetHeight(); return; } + else if( mImpl->mRenderer ) // Check if we have a loaded image + { + auto textureSet = mImpl->mRenderer.GetTextures(); + + if( textureSet ) + { + auto texture = textureSet.GetTexture(0); + naturalSize.x = texture.GetWidth(); + naturalSize.y = texture.GetHeight(); + return; + } + } - else if( mMaskingData != NULL && mMaskingData->mAlphaMaskUrl.IsValid() && + if( mMaskingData != NULL && mMaskingData->mAlphaMaskUrl.IsValid() && mMaskingData->mCropToMask ) { ImageDimensions dimensions = Dali::GetClosestImageSize( mMaskingData->mAlphaMaskUrl.GetUrl() ); @@ -540,23 +552,26 @@ void ImageVisual::GetNaturalSize( Vector2& naturalSize ) } return; } - else if( mImageUrl.IsValid() && mImageUrl.GetLocation() == VisualUrl::LOCAL ) + else if( mImageUrl.IsValid() ) { - ImageDimensions dimensions = Dali::GetClosestImageSize( mImageUrl.GetUrl() ); - - if( dimensions != ImageDimensions( 0, 0 ) ) - { - naturalSize.x = dimensions.GetWidth(); - naturalSize.y = dimensions.GetHeight(); - } - else + if( mImageUrl.GetLocation() == VisualUrl::LOCAL ) { - Image brokenImage = VisualFactoryCache::GetBrokenVisualImage(); + ImageDimensions dimensions = Dali::GetClosestImageSize( mImageUrl.GetUrl() ); + + if( dimensions != ImageDimensions( 0, 0 ) ) + { + naturalSize.x = dimensions.GetWidth(); + naturalSize.y = dimensions.GetHeight(); + } + else + { + Image brokenImage = VisualFactoryCache::GetBrokenVisualImage(); - naturalSize.x = brokenImage.GetWidth(); - naturalSize.y = brokenImage.GetWidth(); + naturalSize.x = brokenImage.GetWidth(); + naturalSize.y = brokenImage.GetWidth(); + } + return; } - return; } naturalSize = Vector2::ZERO;