/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
namespace
{
+const int CUSTOM_PROPERTY_COUNT(5); // anim,premul,size,offset,multicol
+
const Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
/**
Geometry geometry = mFactoryCache.GetGeometry(VisualFactoryCache::QUAD_GEOMETRY);
Shader shader = GetTextShader(mFactoryCache, TextType::SINGLE_COLOR_TEXT, TextType::NO_EMOJI, TextType::NO_STYLES);
- mImpl->mRenderer = Renderer::New(geometry, shader);
+ mImpl->mRenderer = VisualRenderer::New(geometry, shader);
+ mImpl->mRenderer.ReserveCustomProperties(CUSTOM_PROPERTY_COUNT);
}
void TextVisual::DoSetProperties(const Property::Map& propertyMap)
const Vector4& defaultColor = mController->GetTextModel()->GetDefaultColor();
if(mTextColorAnimatableIndex == Property::INVALID_INDEX)
{
- mTextColorAnimatableIndex = mImpl->mRenderer.RegisterProperty("uTextColorAnimatable", defaultColor);
+ mTextColorAnimatableIndex = mImpl->mRenderer.RegisterUniqueProperty("uTextColorAnimatable", defaultColor);
}
else
{
// Make zero if the alpha value of text color is zero to skip rendering text
if(!mOpacityConstraint)
{
+ // VisualRenderer::Property::OPACITY uses same animatable property internally.
mOpacityConstraint = Constraint::New<float>(mImpl->mRenderer, Dali::DevelRenderer::Property::OPACITY, OpacityConstraint);
mOpacityConstraint.AddSource(Source(actor, mAnimatableTextColorPropertyIndex));
}
const bool markupProcessorEnabled = mController->IsMarkupProcessorEnabled();
const bool strikethroughEnabled = mController->GetTextModel()->IsStrikethroughEnabled();
- const bool styleEnabled = (shadowEnabled || underlineEnabled || outlineEnabled || backgroundEnabled || markupProcessorEnabled || strikethroughEnabled);
+ const bool styleEnabled = (shadowEnabled || underlineEnabled || outlineEnabled || backgroundEnabled || markupProcessorEnabled || strikethroughEnabled);
const bool isOverlayStyle = underlineEnabled || strikethroughEnabled;
AddRenderer(control, relayoutSize, hasMultipleTextColors, containsColorGlyph, styleEnabled, isOverlayStyle);
return pixelData;
}
-void TextVisual::CreateTextureSet(TilingInfo& info, Renderer& renderer, Sampler& sampler, bool hasMultipleTextColors, bool containsColorGlyph, bool styleEnabled, bool isOverlayStyle)
+void TextVisual::CreateTextureSet(TilingInfo& info, VisualRenderer& renderer, Sampler& sampler, bool hasMultipleTextColors, bool containsColorGlyph, bool styleEnabled, bool isOverlayStyle)
{
TextureSet textureSet = TextureSet::New();
unsigned int textureSetIndex = 0u;
++textureSetIndex;
}
- if(styleEnabled && isOverlayStyle)
+ if(styleEnabled && isOverlayStyle && info.styleBuffer)
{
PixelData overlayStyleData = ConvertToPixelData(info.styleBuffer, info.width, info.height, info.offsetPosition, Pixel::RGBA8888);
AddTexture(textureSet, overlayStyleData, sampler, textureSetIndex);
renderer.SetTextures(textureSet);
//Register transform properties
- mImpl->mTransform.RegisterUniforms(renderer, Direction::LEFT_TO_RIGHT);
+ mImpl->mTransform.SetUniforms(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(VisualRenderer::Property::TRANSFORM_SIZE, Vector2(info.width, info.height));
+ renderer.SetProperty(VisualRenderer::Property::TRANSFORM_OFFSET, Vector2(info.offSet.x, info.offSet.y));
renderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
+ renderer.RegisterProperty("uHasMultipleTextColors", static_cast<float>(hasMultipleTextColors));
mRendererList.push_back(renderer);
}
mImpl->mRenderer.SetTextures(textureSet);
//Register transform properties
- mImpl->mTransform.RegisterUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
+ mImpl->mTransform.SetUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
mImpl->mRenderer.RegisterProperty("uHasMultipleTextColors", static_cast<float>(hasMultipleTextColors));
mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
// Create a renderer by cutting maxTextureSize.
while(verifiedHeight > 0)
{
- Renderer tilingRenderer = Renderer::New(geometry, shader);
+ VisualRenderer tilingRenderer = VisualRenderer::New(geometry, shader);
tilingRenderer.SetProperty(Dali::Renderer::Property::DEPTH_INDEX, Toolkit::DepthIndex::CONTENT);
// New offset position of buffer for tiling.
info.offsetPosition += offsetPosition;
} // namespace Toolkit
-} // namespace Dali
\ No newline at end of file
+} // namespace Dali