#include <cstring> // for strlen()
#include <dali/public-api/actors/layer.h>
#include <dali/public-api/common/stage.h>
-#include <dali/devel-api/images/texture-set-image.h>
#include <dali/devel-api/adaptor-framework/image-loading.h>
#include <dali/devel-api/scripting/enum-helper.h>
#include <dali/devel-api/scripting/scripting.h>
}
else
{
- Image brokenImage = mFactoryCache.GetBrokenVisualImage();
+ Texture brokenImage = mFactoryCache.GetBrokenVisualImage();
naturalSize.x = brokenImage.GetWidth();
naturalSize.y = brokenImage.GetWidth();
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 );
mPlacementActor.Reset();
}
- if( loadingSuccess )
- {
- Sampler sampler = Sampler::New();
- sampler.SetWrapMode( mWrapModeU, mWrapModeV );
- textureSet.SetSampler( 0u, sampler );
- mImpl->mRenderer.SetTextures(textureSet);
- }
- else
+ if( !loadingSuccess )
{
- Image brokenImage = mFactoryCache.GetBrokenVisualImage();
+ Texture brokenImage = mFactoryCache.GetBrokenVisualImage();
textureSet = TextureSet::New();
+ textureSet.SetTexture(0u, brokenImage);
mImpl->mRenderer.SetTextures( textureSet );
- TextureSetImage( textureSet, 0u, brokenImage );
- Sampler sampler = Sampler::New();
- sampler.SetWrapMode( mWrapModeU, mWrapModeV );
- textureSet.SetSampler( 0u, sampler );
}
+
+ Sampler sampler = Sampler::New();
+ sampler.SetWrapMode( mWrapModeU, mWrapModeV );
+ textureSet.SetSampler( 0u, sampler );
+ mImpl->mRenderer.SetTextures(textureSet);
+
}
// Storing TextureSet needed when renderer staged.