// EXTERNAL HEADERS
#include <cstring> // for strlen()
#include <dali/public-api/actors/layer.h>
-#include <dali/public-api/common/stage.h>
+#include <dali/devel-api/common/stage.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>
#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
#include <dali-toolkit/internal/visuals/visual-url.h>
#include <dali-toolkit/internal/visuals/image-visual-shader-factory.h>
+#include <dali/devel-api/rendering/renderer-devel.h>
namespace Dali
{
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,
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 );
}
}
-void ImageVisual::DoSetOnStage( Actor& actor )
+void ImageVisual::DoSetOnScene( Actor& actor )
{
if( mImageUrl.IsValid() )
{
}
}
-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);
{
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;