- case Toolkit::TextVisual::Property::RENDERING_BACKEND:
- {
- value = mRenderingBackend;
- break;
- }
- case Toolkit::TextVisual::Property::TEXT:
- {
- std::string text;
- mController->GetText( text );
- value = text;
- break;
- }
- case Toolkit::TextVisual::Property::FONT_FAMILY:
- {
- value = mController->GetDefaultFontFamily();
- break;
- }
- case Toolkit::TextVisual::Property::FONT_STYLE:
- {
- GetFontStyleProperty( mController, value, Text::FontStyle::DEFAULT );
- break;
- }
- case Toolkit::TextVisual::Property::POINT_SIZE:
- {
- value = mController->GetDefaultPointSize();
- break;
- }
- case Toolkit::TextVisual::Property::MULTI_LINE:
- {
- value = mController->IsMultiLineEnabled();
- break;
- }
- case Toolkit::TextVisual::Property::HORIZONTAL_ALIGNMENT:
- {
- const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::HorizontalAlignment >( mController->GetHorizontalAlignment(),
- HORIZONTAL_ALIGNMENT_STRING_TABLE,
- HORIZONTAL_ALIGNMENT_STRING_TABLE_COUNT );
- if( name )
- {
- value = std::string( name );
- }
- break;
- }
- case Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT:
- {
- const char* name = Scripting::GetEnumerationName< Toolkit::Text::LayoutEngine::VerticalAlignment >( mController->GetVerticalAlignment(),
- VERTICAL_ALIGNMENT_STRING_TABLE,
- VERTICAL_ALIGNMENT_STRING_TABLE_COUNT );
- if( name )
- {
- value = std::string( name );
- }
- break;
- }
- case Toolkit::TextVisual::Property::TEXT_COLOR:
- {
- value = mController->GetTextColor();
- break;
- }
- case Toolkit::TextVisual::Property::ENABLE_MARKUP:
- {
- value = mController->IsMarkupProcessorEnabled();
- break;
- }
- case Toolkit::TextVisual::Property::ENABLE_AUTO_SCROLL:
- {
- value = mController->IsAutoScrollEnabled();
- break;
- }
- case Toolkit::TextVisual::Property::AUTO_SCROLL_SPEED:
- {
- value = mController->GetAutoScrollSpeed();
- break;
- }
- case Toolkit::TextVisual::Property::AUTO_SCROLL_LOOP_COUNT:
- {
- value = mController->GetAutoScrollLoopCount();
- break;
- }
- case Toolkit::TextVisual::Property::AUTO_SCROLL_GAP:
- {
- value = mController->GetAutoScrollWrapGap();
- break;
- }
- case Toolkit::TextVisual::Property::LINE_SPACING:
- {
- value = mController->GetDefaultLineSpacing();
- break;
- }
- case Toolkit::TextVisual::Property::UNDERLINE:
- {
- GetUnderlineProperties( mController, value, Text::EffectStyle::DEFAULT );
- break;
- }
- case Toolkit::TextVisual::Property::SHADOW:
+ PixelData data = ConvertToPixelData(info.textBuffer, info.width, info.height, info.offsetPosition, info.textPixelFormat);
+ AddTexture(textureSet, data, sampler, textureSetIndex);
+ ++textureSetIndex;
+ }
+
+ if(styleEnabled && info.styleBuffer)
+ {
+ PixelData styleData = ConvertToPixelData(info.styleBuffer, info.width, info.height, info.offsetPosition, Pixel::RGBA8888);
+ AddTexture(textureSet, styleData, sampler, textureSetIndex);
+ ++textureSetIndex;
+ }
+
+ if(containsColorGlyph && !hasMultipleTextColors && info.maskBuffer)
+ {
+ PixelData maskData = ConvertToPixelData(info.maskBuffer, info.width, info.height, info.offsetPosition, Pixel::L8);
+ AddTexture(textureSet, maskData, sampler, textureSetIndex);
+ }
+
+ renderer.SetTextures(textureSet);
+
+ //Register transform properties
+ mImpl->mTransform.RegisterUniforms(renderer, Direction::LEFT_TO_RIGHT);
+
+ // Enable the pre-multiplied alpha to improve the text quality
+ renderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, true);
+ renderer.RegisterProperty(PREMULTIPLIED_ALPHA, 1.0f);
+
+ // Set size and offset for the tiling.
+ renderer.RegisterProperty(SIZE, Vector2(info.width, info.height));
+ renderer.RegisterProperty(OFFSET, Vector2(info.offSet.x, info.offSet.y));
+ renderer.RegisterProperty("uHasMultipleTextColors", static_cast<float>(hasMultipleTextColors));
+ renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
+
+ mRendererList.push_back(renderer);
+}
+
+void TextVisual::AddRenderer(Actor& actor, const Vector2& size, bool hasMultipleTextColors, bool containsColorGlyph, bool styleEnabled)
+{
+ Shader shader = GetTextShader(mFactoryCache, hasMultipleTextColors, containsColorGlyph, styleEnabled);
+ mImpl->mRenderer.SetShader(shader);
+
+ // Get the maximum size.
+ const int maxTextureSize = Dali::GetMaxTextureSize();
+
+ // No tiling required. Use the default renderer.
+ if(size.height < maxTextureSize)
+ {
+ TextureSet textureSet = GetTextTexture(size, hasMultipleTextColors, containsColorGlyph, styleEnabled);
+
+ mImpl->mRenderer.SetTextures(textureSet);
+ //Register transform properties
+ mImpl->mTransform.RegisterUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
+ mImpl->mRenderer.RegisterProperty("uHasMultipleTextColors", static_cast<float>(hasMultipleTextColors));
+ mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
+
+ mRendererList.push_back(mImpl->mRenderer);
+ }
+ // If the pixel data exceeds the maximum size, tiling is required.
+ else
+ {
+ // Filter mode needs to be set to linear to produce better quality while scaling.
+ Sampler sampler = Sampler::New();
+ sampler.SetFilterMode(FilterMode::LINEAR, FilterMode::LINEAR);
+
+ // 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);
+
+ int verifiedWidth = data.GetWidth();
+ int verifiedHeight = data.GetHeight();
+
+ // Set information for creating textures.
+ TilingInfo info(verifiedWidth, maxTextureSize, textPixelFormat);
+
+ // Get the buffer of text.
+ Dali::DevelPixelData::PixelDataBuffer textPixelData = Dali::DevelPixelData::ReleasePixelDataBuffer(data);
+ info.textBuffer = textPixelData.buffer;
+
+ if(styleEnabled)