+ mRendererUpdateNeeded = false;
+
+ // Removes the texture set.
+ RemoveTextureSet();
+
+ // Remove any renderer previously set.
+ if( mImpl->mRenderer )
+ {
+ control.RemoveRenderer( mImpl->mRenderer );
+ }
+
+ if( ( relayoutSize.width > Math::MACHINE_EPSILON_1000 ) &&
+ ( relayoutSize.height > Math::MACHINE_EPSILON_1000 ) )
+ {
+ Vector4 atlasRect = FULL_TEXTURE_RECT;
+
+ // Create a texture for the text without any styles
+ PixelData data = mTypesetter->Render( relayoutSize, Text::Typesetter::RENDER_NO_STYLES );
+
+ // It may happen the image atlas can't handle a pixel data it exceeds the maximum size.
+ // In that case, create a texture. TODO: should tile the text.
+
+ Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D,
+ data.GetPixelFormat(),
+ data.GetWidth(),
+ data.GetHeight() );
+
+ texture.Upload( data );
+
+ TextureSet textureSet = TextureSet::New();
+ textureSet.SetTexture( 0u, texture );
+
+ // Create a texture for all the text styles (without the text itself)
+ PixelData styleData = mTypesetter->Render( relayoutSize, Text::Typesetter::RENDER_NO_TEXT );
+
+ Texture styleTexture = Texture::New( Dali::TextureType::TEXTURE_2D,
+ styleData.GetPixelFormat(),
+ styleData.GetWidth(),
+ styleData.GetHeight() );
+
+ styleTexture.Upload( styleData );
+
+ textureSet.SetTexture( 1u, styleTexture );
+
+ // Create a texture as a mask to avoid color glyphs (e.g. emojis) to be affected by text color animation
+ PixelData maskData = mTypesetter->Render( relayoutSize, Text::Typesetter::RENDER_MASK );
+
+ Texture maskTexture = Texture::New( Dali::TextureType::TEXTURE_2D,
+ styleData.GetPixelFormat(),
+ styleData.GetWidth(),
+ styleData.GetHeight() );
+
+ maskTexture.Upload( maskData );
+
+ textureSet.SetTexture( 2u, maskTexture );
+
+ // Filter mode needs to be set to linear to produce better quality while scaling.
+ Sampler sampler = Sampler::New();
+ sampler.SetFilterMode( FilterMode::LINEAR, FilterMode::LINEAR );
+ textureSet.SetSampler( 0u, sampler );
+ textureSet.SetSampler( 1u, sampler );
+ textureSet.SetSampler( 2u, sampler );
+
+ mImpl->mRenderer.SetTextures( textureSet );
+
+ mImpl->mFlags &= ~Impl::IS_ATLASING_APPLIED;
+
+ mImpl->mRenderer.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, atlasRect );
+
+ // Check whether it is a markup text with multiple text colors
+ const Vector4* const colorsBuffer = mController->GetTextModel()->GetColors();
+ bool hasMultipleTextColors = ( NULL != colorsBuffer );
+ mImpl->mRenderer.RegisterProperty( "uHasMultipleTextColors", static_cast<float>( hasMultipleTextColors ) );
+
+ //Register transform properties
+ mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT );
+
+ control.AddRenderer( mImpl->mRenderer );
+
+ // Text rendered and ready to display
+ ResourceReady();
+ }