X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fimage%2Fimage-visual.cpp;h=b8abd9b2e1c9fff4ab14b09c50b96b681133e880;hb=81b6946e6eae9989ba04ba164adf9347e85efdfe;hp=7e196fa52b325ca3d2aa2a768e3588e346516ad7;hpb=6261b85db16d8e9f842c9dc152046747eec67eaa;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 7e196fa..b8abd9b 100644 --- a/dali-toolkit/internal/visuals/image/image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/image-visual.cpp @@ -21,8 +21,7 @@ // EXTERNAL HEADERS #include // for strlen() #include -#include -#include +#include #include #include #include @@ -41,6 +40,7 @@ #include #include #include +#include namespace Dali { @@ -516,7 +516,15 @@ void ImageVisual::CreateRenderer( TextureSet& textureSet ) if( !mImpl->mCustomShader ) { - geometry = CreateGeometry( mFactoryCache, ImageDimensions( 1, 1 ) ); + TextureManager& textureManager = mFactoryCache.GetTextureManager(); + + uint32_t firstElementCount {0u}; + uint32_t secondElementCount {0u}; + geometry = textureManager.GetRenderGeometry(mTextureId, firstElementCount, secondElementCount); + if(!firstElementCount && !secondElementCount) + { + geometry = CreateGeometry( mFactoryCache, ImageDimensions( 1, 1 ) ); + } shader = mImageVisualShaderFactory.GetShader( mFactoryCache, mImpl->mFlags & Impl::IS_ATLASING_APPLIED, @@ -610,13 +618,27 @@ bool ImageVisual::AttemptAtlasing() void ImageVisual::InitializeRenderer() { auto attemptAtlasing = AttemptAtlasing(); - // texture set has to be created first as we need to know if atlasing succeeded or not - // when selecting the shader - if( mTextureId == TextureManager::INVALID_TEXTURE_ID && ! mTextures ) // Only load the texture once + // Load Texture if mTextures is empty. + // mTextures is already set, the mTexture can be used to create Renderer. + // There are two cases mTextures is empty. + // 1. mTextureId == TextureManager::INVALID_TEXTURE_ID + // - Visual is on stage with LoadPolicy::ATTACHED + // 2. mTextureId != TextureManager::INVALID_TEXTURE_ID + // - If ReleasePolicy is DESTROYED, InitializeRenderer called every on stage called. + // - Then every resources those contained in Visual are Reset but mTextureId is remained when the Off stage time, + // - So, mTextures needed to be get from texture manager to created resources like mImpl->mRenderer. + if( ! mTextures ) { - LoadTexture( attemptAtlasing, mAtlasRect, mTextures, mOrientationCorrection, - TextureManager::ReloadPolicy::CACHED ); + if( mTextureId == TextureManager::INVALID_TEXTURE_ID ) + { + LoadTexture( attemptAtlasing, mAtlasRect, mTextures, mOrientationCorrection, + TextureManager::ReloadPolicy::CACHED ); + } + else + { + mTextures = mFactoryCache.GetTextureManager().GetTextureSet( mTextureId ); + } } CreateRenderer( mTextures ); @@ -637,7 +659,7 @@ void ImageVisual::InitializeRenderer() } } -void ImageVisual::DoSetOnStage( Actor& actor ) +void ImageVisual::DoSetOnScene( Actor& actor ) { if( mImageUrl.IsValid() ) { @@ -673,9 +695,9 @@ void ImageVisual::DoSetOnStage( Actor& actor ) } } -void ImageVisual::DoSetOffStage( Actor& actor ) +void ImageVisual::DoSetOffScene( Actor& actor ) { - // Visual::Base::SetOffStage only calls DoSetOffStage if mRenderer exists (is on onstage) + // Visual::Base::SetOffScene only calls DoSetOffScene if mRenderer exists (is on onstage) // Image release is dependent on the ReleasePolicy, renderer is destroyed. actor.RemoveRenderer( mImpl->mRenderer); @@ -837,6 +859,37 @@ void ImageVisual::UploadComplete( bool loadingSuccess, int32_t textureId, Textur { resourceStatus = Toolkit::Visual::ResourceStatus::FAILED; } + + // use geometry if needed + if( loadingSuccess ) + { + uint32_t firstElementCount{0u}; + uint32_t secondElementCount{0u}; + auto geometry = mFactoryCache.GetTextureManager().GetRenderGeometry(mTextureId, firstElementCount, secondElementCount); + if (mImpl->mRenderer && geometry) + { + mImpl->mRenderer.SetGeometry(geometry); + Dali::DevelRenderer::DrawCommand drawCommand{}; + drawCommand.drawType = DevelRenderer::DrawType::INDEXED; + + if (firstElementCount) + { + drawCommand.firstIndex = 0; + drawCommand.elementCount = firstElementCount; + drawCommand.queue = DevelRenderer::RENDER_QUEUE_OPAQUE; + DevelRenderer::AddDrawCommand(mImpl->mRenderer, drawCommand); + } + + if (secondElementCount) + { + drawCommand.firstIndex = firstElementCount; + drawCommand.elementCount = secondElementCount; + drawCommand.queue = DevelRenderer::RENDER_QUEUE_TRANSPARENT; + DevelRenderer::AddDrawCommand(mImpl->mRenderer, drawCommand); + } + } + } + // Signal to observers ( control ) that resources are ready. Must be all resources. ResourceReady( resourceStatus ); mLoading = false;