- auto attemptAtlasing = false;
- // for custom shader or remote image, atlas is not applied
- Vector4 atlasRect; // ignored in this case
- TextureSet textures =
- textureManager.LoadTexture(mImageUrl, mDesiredSize, mFittingMode, mSamplingMode,
- mMaskingData, IsSynchronousResourceLoading(), mTextureId,
- atlasRect, attemptAtlasing, mLoadingStatus, mWrapModeU, mWrapModeV, this,
- nullptr, nullptr); // no atlasing
- DALI_ASSERT_DEBUG(attemptAtlasing == false);
- CreateRenderer( textures );
+ mImpl->mFlags &= ~Impl::IS_ATLASING_APPLIED;
+ }
+}
+
+bool ImageVisual::AttemptAtlasing()
+{
+ return ( ! mImpl->mCustomShader && mImageUrl.GetProtocolType() == VisualUrl::LOCAL && mAttemptAtlasing );
+}
+
+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
+ {
+ LoadTexture( attemptAtlasing, mAtlasRect, mTextures, mOrientationCorrection,
+ TextureManager::ReloadPolicy::CACHED );
+ }
+
+ CreateRenderer( mTextures );
+ mTextures.Reset(); // Visual should not keep a handle to the texture after this point.
+
+ if( attemptAtlasing ) // the texture is packed inside atlas
+ {
+ mImpl->mRenderer.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, mAtlasRect );
+
+ bool defaultWrapMode = mWrapModeU <= WrapMode::CLAMP_TO_EDGE && mWrapModeV <= WrapMode::CLAMP_TO_EDGE;
+
+ if( !defaultWrapMode ) // custom wrap mode
+ {
+ Vector2 wrapMode(mWrapModeU-WrapMode::CLAMP_TO_EDGE, mWrapModeV-WrapMode::CLAMP_TO_EDGE);
+ wrapMode.Clamp( Vector2::ZERO, Vector2( 2.f, 2.f ) );
+ mImpl->mRenderer.RegisterProperty( WRAP_MODE_UNIFORM_NAME, wrapMode );
+ }