+ if ( containsColorGlyph && !hasMultipleTextColors )
+ {
+ // Create a L8 texture as a mask to avoid color glyphs (e.g. emojis) to be affected by text color animation
+ PixelData maskData = mTypesetter->Render( size, textDirection, Text::Typesetter::RENDER_MASK, false, Pixel::L8 );
+ Dali::DevelPixelData::PixelDataBuffer maskPixelData = Dali::DevelPixelData::ReleasePixelDataBuffer( maskData );
+ info.maskBuffer = maskPixelData.buffer;
+ }
+
+ // Get the current offset for recalculate the offset when tiling.
+ Property::Map retMap;
+ mImpl->mTransform.GetPropertyMap( retMap );
+ Property::Value* offsetValue = retMap.Find( Dali::Toolkit::Visual::Transform::Property::OFFSET );
+ if( offsetValue )
+ {
+ offsetValue->Get( info.offSet );
+ }
+
+ // Create a textureset in the default renderer.
+ CreateTextureSet( info, mImpl->mRenderer, sampler, hasMultipleTextColors, containsColorGlyph, styleEnabled );
+
+ verifiedHeight -= maxTextureSize;
+
+ Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
+
+ int offsetPosition = verifiedWidth * maxTextureSize;
+ // Create a renderer by cutting maxTextureSize.
+ while( verifiedHeight > 0 )
+ {
+ Renderer tilingRenderer = Renderer::New( geometry, shader );
+ tilingRenderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, Toolkit::DepthIndex::CONTENT );
+ // New offset position of buffer for tiling.
+ info.offsetPosition += offsetPosition;
+ // New height for tiling.
+ info.height = ( verifiedHeight - maxTextureSize ) > 0 ? maxTextureSize : verifiedHeight;
+ // New offset for tiling.
+ info.offSet.y += maxTextureSize;
+ // Create a textureset int the new tiling renderer.
+ CreateTextureSet( info, tilingRenderer, sampler, hasMultipleTextColors, containsColorGlyph, styleEnabled );
+
+ verifiedHeight -= maxTextureSize;
+ }
+ }
+
+ mImpl->mFlags &= ~Impl::IS_ATLASING_APPLIED;
+
+ for( RendererContainer::iterator iter = mRendererList.begin(); iter != mRendererList.end(); ++iter)
+ {
+ Renderer renderer = (*iter);
+ if( renderer )
+ {
+ actor.AddRenderer( renderer );
+ }
+ }
+}
+
+
+TextureSet TextVisual::GetTextTexture( const Vector2& size, bool hasMultipleTextColors, bool containsColorGlyph, bool styleEnabled )
+{
+ // 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 textureSet = TextureSet::New();
+
+ // Create RGBA texture if the text contains emojis or multiple text colors, otherwise L8 texture
+ Pixel::Format textPixelFormat = ( containsColorGlyph || hasMultipleTextColors ) ? Pixel::RGBA8888 : Pixel::L8;
+
+ // Check the text direction
+ Toolkit::DevelText::TextDirection::Type textDirection = mController->GetTextDirection();
+
+ // Create a texture for the text without any styles
+ PixelData data = mTypesetter->Render( size, textDirection, Text::Typesetter::RENDER_NO_STYLES, false, textPixelFormat );
+
+ // 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.
+ unsigned int textureSetIndex = 0u;
+
+ AddTexture( textureSet, data, sampler, textureSetIndex );
+ ++textureSetIndex;
+
+ if ( styleEnabled )
+ {
+ // Create RGBA texture for all the text styles (without the text itself)
+ PixelData styleData = mTypesetter->Render( size, textDirection, Text::Typesetter::RENDER_NO_TEXT, false, Pixel::RGBA8888 );
+
+ AddTexture( textureSet, styleData, sampler, textureSetIndex );
+ ++textureSetIndex;
+ }
+
+ if ( containsColorGlyph && !hasMultipleTextColors )
+ {
+ // Create a L8 texture as a mask to avoid color glyphs (e.g. emojis) to be affected by text color animation
+ PixelData maskData = mTypesetter->Render( size, textDirection, Text::Typesetter::RENDER_MASK, false, Pixel::L8 );
+
+ AddTexture( textureSet, maskData, sampler, textureSetIndex );
+ }
+
+ return textureSet;
+}
+
+Shader TextVisual::GetTextShader( VisualFactoryCache& factoryCache, bool hasMultipleTextColors, bool containsColorGlyph, bool styleEnabled )
+{
+ Shader shader;
+
+ if( hasMultipleTextColors && !styleEnabled )
+ {
+ // We don't animate text color if the text contains multiple colors
+ shader = factoryCache.GetShader( VisualFactoryCache::TEXT_SHADER_MULTI_COLOR_TEXT );
+ if( !shader )
+ {
+ shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_MULTI_COLOR_TEXT );
+ shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
+ factoryCache.SaveShader( VisualFactoryCache::TEXT_SHADER_MULTI_COLOR_TEXT, shader );