From: taeyoon0.lee Date: Wed, 11 Oct 2017 09:06:47 +0000 (+0900) Subject: Revert "[4.0] Add support for Texture url in ImageVisual" X-Git-Tag: accepted/tizen/4.0/unified/20171012.230025~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F19%2F154819%2F1;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git Revert "[4.0] Add support for Texture url in ImageVisual" This reverts commit a79d49f2492b7e2ef14720b6bcbcdd02b6aed3b1. Change-Id: I40cbf1f3a943e186c4fa58c81ab8f7b0f05b546e --- diff --git a/dali-toolkit/internal/visuals/image/image-visual.cpp b/dali-toolkit/internal/visuals/image/image-visual.cpp index ab956e8..ee0042a 100644 --- a/dali-toolkit/internal/visuals/image/image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/image-visual.cpp @@ -258,6 +258,7 @@ ImageVisual::ImageVisual( VisualFactoryCache& factoryCache, Dali::SamplingMode::Type samplingMode ) : Visual::Base( factoryCache ), mImage(), + mPixels(), mPixelArea( FULL_TEXTURE_RECT ), mPlacementActor(), mImageUrl( imageUrl ), @@ -276,6 +277,7 @@ ImageVisual::ImageVisual( VisualFactoryCache& factoryCache, ImageVisual::ImageVisual( VisualFactoryCache& factoryCache, const Image& image ) : Visual::Base( factoryCache ), mImage( image ), + mPixels(), mPixelArea( FULL_TEXTURE_RECT ), mPlacementActor(), mImageUrl(), @@ -359,6 +361,14 @@ void ImageVisual::DoSetProperties( const Property::Map& propertyMap ) } } + if( ( mImpl->mFlags & Impl::IS_SYNCHRONOUS_RESOURCE_LOADING ) && mImageUrl.IsValid() ) + { + // if sync loading is required, the loading should start + // immediately when new image url is set or the actor is off stage + // ( for on-stage actor with image url unchanged, resource loading + // is already finished ) + LoadResourceSynchronously(); + } } void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& value ) @@ -675,27 +685,30 @@ bool ImageVisual::IsSynchronousResourceLoading() const return mImpl->mFlags & Impl::IS_SYNCHRONOUS_RESOURCE_LOADING; } +void ImageVisual::LoadResourceSynchronously() +{ + if( mImageUrl.IsValid() ) + { + Devel::PixelBuffer pixelBuffer = LoadImageFromFile( mImageUrl.GetUrl(), mDesiredSize, mFittingMode, mSamplingMode ); + + if( pixelBuffer ) + { + mPixels = Devel::PixelBuffer::Convert(pixelBuffer); // takes ownership of buffer + } + mTextureLoading = false; + } +} + TextureSet ImageVisual::CreateTextureSet( Vector4& textureRect, bool synchronousLoading, bool attemptAtlasing ) { TextureSet textureSet; mTextureLoading = false; - textureRect = FULL_TEXTURE_RECT; + textureRect = FULL_TEXTURE_RECT; if( synchronousLoading ) { - PixelData data; - if( mImageUrl.IsValid() ) - { - // if sync loading is required, the loading should immediately when actor is on stage - Devel::PixelBuffer pixelBuffer = LoadImageFromFile( mImageUrl.GetUrl(), mDesiredSize, mFittingMode, mSamplingMode ); - - if( pixelBuffer ) - { - data = Devel::PixelBuffer::Convert(pixelBuffer); // takes ownership of buffer - } - } - if( !data ) + if( !mPixels ) { // use broken image textureSet = TextureSet::New(); @@ -705,15 +718,15 @@ TextureSet ImageVisual::CreateTextureSet( Vector4& textureRect, bool synchronous { if( attemptAtlasing ) { - textureSet = mFactoryCache.GetAtlasManager()->Add( textureRect, data ); + textureSet = mFactoryCache.GetAtlasManager()->Add(textureRect, mPixels ); mImpl->mFlags |= Impl::IS_ATLASING_APPLIED; } if( !textureSet ) // big image, no atlasing or atlasing failed { mImpl->mFlags &= ~Impl::IS_ATLASING_APPLIED; - Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D, data.GetPixelFormat(), - data.GetWidth(), data.GetHeight() ); - texture.Upload( data ); + Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D, mPixels.GetPixelFormat(), + mPixels.GetWidth(), mPixels.GetHeight() ); + texture.Upload( mPixels ); textureSet = TextureSet::New(); textureSet.SetTexture( 0u, texture ); } @@ -721,11 +734,11 @@ TextureSet ImageVisual::CreateTextureSet( Vector4& textureRect, bool synchronous } else { - mTextureLoading = true; if( attemptAtlasing ) { textureSet = mFactoryCache.GetAtlasManager()->Add( textureRect, mImageUrl.GetUrl(), mDesiredSize, mFittingMode, true, this ); mImpl->mFlags |= Impl::IS_ATLASING_APPLIED; + mTextureLoading = true; } if( !textureSet ) // big image, no atlasing or atlasing failed { @@ -749,6 +762,7 @@ TextureSet ImageVisual::CreateTextureSet( Vector4& textureRect, bool synchronous } TextureManager::LoadState loadState = textureManager.GetTextureState( mTextureId ); + mTextureLoading = ( loadState == TextureManager::LOADING ); if( loadState == TextureManager::UPLOADED ) diff --git a/dali-toolkit/internal/visuals/image/image-visual.h b/dali-toolkit/internal/visuals/image/image-visual.h index 0c2f756..334406f 100644 --- a/dali-toolkit/internal/visuals/image/image-visual.h +++ b/dali-toolkit/internal/visuals/image/image-visual.h @@ -286,6 +286,11 @@ private: bool IsSynchronousResourceLoading() const; /** + * @brief Load the resource synchronously + */ + void LoadResourceSynchronously(); + + /** * Creates the texture set and adds the texture to it * @param[out] textureRect The texture area of the texture in the atlas. * @param[in] url The URL of the image resource to use. @@ -328,6 +333,7 @@ private: }; Image mImage; + PixelData mPixels; Vector4 mPixelArea; WeakHandle mPlacementActor; VisualUrl mImageUrl;