X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fimage%2Fimage-visual.cpp;h=295aeb8606fe54cf16a847c99efe4f6b614ac2de;hp=9522618406c360b384e2e71abd7183a5f6d81e0a;hb=3ea0c6dd8536cc1ebd948f47f569bc8f09547e27;hpb=63c8495b30e5bbf76548256887eee20e00e256e2 diff --git a/dali-toolkit/internal/visuals/image/image-visual.cpp b/dali-toolkit/internal/visuals/image/image-visual.cpp index 9522618..295aeb8 100644 --- a/dali-toolkit/internal/visuals/image/image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/image-visual.cpp @@ -303,7 +303,8 @@ ImageVisual::ImageVisual( VisualFactoryCache& factoryCache, const Image& image ) mLoadPolicy( DevelImageVisual::LoadPolicy::ATTACHED ), mReleasePolicy( DevelImageVisual::ReleasePolicy::DESTROYED ), mAttemptAtlasing( false ), - mLoading( false ) + mLoading( false ), + mOrientationCorrection( true ) { } @@ -399,6 +400,10 @@ void ImageVisual::DoSetProperties( const Property::Map& propertyMap ) { DoSetProperty( Toolkit::DevelImageVisual::Property::RELEASE_POLICY, keyValue.second ); } + else if( keyValue.first == ORIENTATION_CORRECTION_NAME ) + { + DoSetProperty( Toolkit::DevelImageVisual::Property::ORIENTATION_CORRECTION, keyValue.second ); + } } } @@ -406,7 +411,7 @@ void ImageVisual::DoSetProperties( const Property::Map& propertyMap ) if ( mLoadPolicy == DevelImageVisual::LoadPolicy::IMMEDIATE ) { auto attemptAtlasing = mAttemptAtlasing; - LoadTexture( attemptAtlasing, mAtlasRect, mTextures ); + LoadTexture( attemptAtlasing, mAtlasRect, mTextures, mOrientationCorrection ); } } @@ -557,6 +562,16 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v int loadPolicy; Scripting::GetEnumerationProperty( value, LOAD_POLICY_TABLE, LOAD_POLICY_TABLE_COUNT, loadPolicy ); mLoadPolicy = DevelImageVisual::LoadPolicy::Type( loadPolicy ); + break; + } + case Toolkit::DevelImageVisual::Property::ORIENTATION_CORRECTION: + { + bool orientationCorrection( mOrientationCorrection ); + if( value.Get( orientationCorrection ) ) + { + mOrientationCorrection = orientationCorrection; + } + break; } } } @@ -740,7 +755,7 @@ bool ImageVisual::IsSynchronousResourceLoading() const return mImpl->mFlags & Impl::IS_SYNCHRONOUS_RESOURCE_LOADING; } -void ImageVisual::LoadTexture( bool& atlasing, Vector4& atlasRect, TextureSet& textures ) +void ImageVisual::LoadTexture( bool& atlasing, Vector4& atlasRect, TextureSet& textures, bool orientationCorrection ) { TextureManager& textureManager = mFactoryCache.GetTextureManager(); @@ -757,7 +772,7 @@ void ImageVisual::LoadTexture( bool& atlasing, Vector4& atlasRect, TextureSet& t textures = textureManager.LoadTexture( mImageUrl, mDesiredSize, mFittingMode, mSamplingMode, mMaskingData, IsSynchronousResourceLoading(), mTextureId, atlasRect, atlasing, mLoading, mWrapModeU, - mWrapModeV, textureObserver, atlasUploadObserver, atlasManager ); + mWrapModeV, textureObserver, atlasUploadObserver, atlasManager, mOrientationCorrection ); } void ImageVisual::InitializeRenderer() @@ -769,7 +784,7 @@ void ImageVisual::InitializeRenderer() if( mTextureId == TextureManager::INVALID_TEXTURE_ID && ! mTextures ) // Only load the texture once { - LoadTexture( attemptAtlasing, mAtlasRect, mTextures ); + LoadTexture( attemptAtlasing, mAtlasRect, mTextures, mOrientationCorrection ); } if( attemptAtlasing ) // Flag needs to be set before creating renderer @@ -854,7 +869,7 @@ void ImageVisual::DoSetOnStage( Actor& actor ) mPlacementActor.Reset(); // Image loaded and ready to display - ResourceReady(); + ResourceReady( Toolkit::Visual::ResourceStatus::READY ); } } @@ -912,6 +927,7 @@ void ImageVisual::DoCreatePropertyMap( Property::Map& map ) const map.Insert( Toolkit::ImageVisual::Property::WRAP_MODE_V, mWrapModeV ); map.Insert( Toolkit::ImageVisual::Property::ATLASING, mAttemptAtlasing ); + if( mMaskingData != NULL ) { map.Insert( Toolkit::ImageVisual::Property::ALPHA_MASK_URL, mMaskingData->mAlphaMaskUrl.GetUrl() ); @@ -921,7 +937,7 @@ void ImageVisual::DoCreatePropertyMap( Property::Map& map ) const map.Insert( Toolkit::DevelImageVisual::Property::LOAD_POLICY, mLoadPolicy ); map.Insert( Toolkit::DevelImageVisual::Property::RELEASE_POLICY, mReleasePolicy ); - + map.Insert( Toolkit::DevelImageVisual::Property::ORIENTATION_CORRECTION, mOrientationCorrection ); } void ImageVisual::DoCreateInstancePropertyMap( Property::Map& map ) const @@ -948,6 +964,12 @@ void ImageVisual::OnSetTransform() } } +bool ImageVisual::IsResourceReady() const +{ + return ( mImpl->mResourceStatus == Toolkit::Visual::ResourceStatus::READY || + mImpl->mResourceStatus == Toolkit::Visual::ResourceStatus::FAILED ); +} + Shader ImageVisual::GetImageShader( VisualFactoryCache& factoryCache, bool atlasing, bool defaultTextureWrapping ) { Shader shader; @@ -1020,6 +1042,7 @@ void ImageVisual::UploadCompleted() // From Texture Manager void ImageVisual::UploadComplete( bool loadingSuccess, int32_t textureId, TextureSet textureSet, bool usingAtlas, const Vector4& atlasRectangle ) { + Toolkit::Visual::ResourceStatus resourceStatus; Actor actor = mPlacementActor.GetHandle(); if( actor ) { @@ -1039,6 +1062,8 @@ void ImageVisual::UploadComplete( bool loadingSuccess, int32_t textureId, Textur sampler.SetWrapMode( mWrapModeU, mWrapModeV ); textureSet.SetSampler( 0u, sampler ); mImpl->mRenderer.SetTextures(textureSet); + + resourceStatus = Toolkit::Visual::ResourceStatus::READY; } else { @@ -1048,11 +1073,20 @@ void ImageVisual::UploadComplete( bool loadingSuccess, int32_t textureId, Textur mImpl->mRenderer.SetTextures( textureSet ); ApplyImageToSampler( brokenImage ); + + resourceStatus = Toolkit::Visual::ResourceStatus::FAILED; } // Image loaded and ready to display - ResourceReady(); + ResourceReady( resourceStatus ); } } + + // Storing TextureSet needed when renderer staged. + if( ! mImpl->mRenderer ) + { + mTextures = textureSet; + } + mLoading = false; }