X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fimage%2Fimage-visual.cpp;h=0251a1dad2199d68b11b357e73b0ddb4c5f66660;hb=8d0ccc12714da58e6e2c971188b221ed2158d658;hp=03e0657963fa9dff9fe5905e39063a84f430285e;hpb=2ca1c3856ce848a94f54444f1014a820e91ee207;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 03e0657..0251a1d 100644 --- a/dali-toolkit/internal/visuals/image/image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/image-visual.cpp @@ -187,6 +187,23 @@ ImageVisual::~ImageVisual() } } + if(mImageUrl.IsValid()) + { + // Decrease reference count of External Resources : + // EncodedImageBuffer or ExternalTextures. + // Ensure the stage is still valid before accessing texture manager. + if(mImageUrl.GetProtocolType() == VisualUrl::TEXTURE) + { + TextureManager& textureManager = mFactoryCache.GetTextureManager(); + textureManager.RemoveExternalTexture(mImageUrl.GetUrl()); + } + else if(mImageUrl.IsBufferResource()) + { + TextureManager& textureManager = mFactoryCache.GetTextureManager(); + textureManager.RemoveExternalEncodedImageBuffer(mImageUrl.GetUrl()); + } + } + // ImageVisual destroyed so remove texture unless ReleasePolicy is set to never release if((mTextureId != TextureManager::INVALID_TEXTURE_ID) && (mReleasePolicy != Toolkit::ImageVisual::ReleasePolicy::NEVER)) { @@ -530,7 +547,16 @@ void ImageVisual::OnInitialize() } } - Shader shader = GetShader(); + // Increase reference count of External Resources : + // EncodedImageBuffer or ExternalTextures. + // Reference count will be decreased at destructor of the visual. + if(mImageUrl.IsValid() && (mImageUrl.IsBufferResource() || mImageUrl.GetProtocolType() == VisualUrl::TEXTURE)) + { + TextureManager& textureManager = mFactoryCache.GetTextureManager(); + textureManager.UseExternalResource(mImageUrl.GetUrl()); + } + + Shader shader = GenerateShader(); // Create the renderer mImpl->mRenderer = Renderer::New(geometry, shader); @@ -595,7 +621,7 @@ void ImageVisual::LoadTexture(bool& atlasing, Vector4& atlasRect, TextureSet& te bool ImageVisual::AttemptAtlasing() { - return (!mImpl->mCustomShader && mImageUrl.GetProtocolType() == VisualUrl::LOCAL && mAttemptAtlasing); + return (!mImpl->mCustomShader && (mImageUrl.IsLocalResource() || mImageUrl.IsBufferResource()) && mAttemptAtlasing); } void ImageVisual::InitializeRenderer() @@ -626,6 +652,10 @@ void ImageVisual::InitializeRenderer() if(mTextures) { mImpl->mRenderer.SetTextures(mTextures); + if(DevelTexture::IsNative(mTextures.GetTexture(0))) + { + UpdateShader(); + } mTextures.Reset(); // Visual should not keep a handle to the texture after this point. } @@ -792,7 +822,7 @@ void ImageVisual::UpdateShader() { if(mImpl->mRenderer) { - Shader shader = GetShader(); + Shader shader = GenerateShader(); mImpl->mRenderer.SetShader(shader); } } @@ -930,7 +960,7 @@ void ImageVisual::RemoveTexture() } } -Shader ImageVisual::GetShader() +Shader ImageVisual::GenerateShader() const { Shader shader; @@ -974,9 +1004,11 @@ Shader ImageVisual::GetShader() // Create and cache the standard shader shader = mImageVisualShaderFactory.GetShader( mFactoryCache, - mImpl->mFlags & Impl::IS_ATLASING_APPLIED, - mWrapModeU <= WrapMode::CLAMP_TO_EDGE && mWrapModeV <= WrapMode::CLAMP_TO_EDGE, - IsRoundedCornerRequired()); + mImpl->mFlags & Impl::IS_ATLASING_APPLIED ? TextureAtlas::ENABLED : TextureAtlas::DISABLED, + mWrapModeU <= WrapMode::CLAMP_TO_EDGE && mWrapModeV <= WrapMode::CLAMP_TO_EDGE ? DefaultTextureWrapMode::APPLY : DefaultTextureWrapMode::DO_NOT_APPLY, + IsRoundedCornerRequired() ? RoundedCorner::ENABLED : RoundedCorner::DISABLED, + IsBorderlineRequired() ? Borderline::ENABLED : Borderline::DISABLED + ); } else if(mImpl->mCustomShader) {