#include <dali/devel-api/text-abstraction/font-client.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/control-depth-index-ranges.h>
+#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
#include <dali-toolkit/internal/text/glyph-run.h>
#include <dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h>
#include <dali-toolkit/internal/text/rendering/atlas/atlas-mesh-factory.h>
namespace
{
#if defined(DEBUG_ENABLED)
- Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_RENDERING");
+ Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_TEXT_RENDERING");
#endif
const float ZERO( 0.0f );
mQuadVertexFormat[ "aPosition" ] = Property::VECTOR2;
mQuadVertexFormat[ "aTexCoord" ] = Property::VECTOR2;
mQuadVertexFormat[ "aColor" ] = Property::VECTOR4;
- mQuadIndexFormat[ "indices" ] = Property::INTEGER;
}
bool IsGlyphUnderlined( GlyphIndex index,
void AddGlyphs( Text::ViewInterface& view,
const Vector<Vector2>& positions,
const Vector<GlyphInfo>& glyphs,
- const Vector<Vector4>& colors,
+ const Vector4& defaultColor,
+ const Vector4* const colorsBuffer,
+ const ColorIndex* const colorIndicesBuffer,
int depth )
{
AtlasManager::AtlasSlot slot;
mDepth = depth;
const Vector2& actorSize( view.GetControlSize() );
- const Vector2 halfActorSize( actorSize * 0.5f );
+ const Vector2& textSize( view.GetLayoutSize() );
+ const Vector2 halfTextSize( textSize * 0.5f );
const Vector2& shadowOffset( view.GetShadowOffset() );
const Vector4& shadowColor( view.GetShadowColor() );
const bool underlineEnabled( view.IsUnderlineEnabled() );
const Vector4& underlineColor( view.GetUnderlineColor() );
const float underlineHeight( view.GetUnderlineHeight() );
+ const bool useDefaultColor = ( NULL == colorsBuffer );
+
// Get the underline runs.
const Length numberOfUnderlineRuns = view.GetNumberOfUnderlineRuns();
Vector<GlyphRun> underlineRuns;
Vector< TextCacheEntry > newTextCache;
const GlyphInfo* const glyphsBuffer = glyphs.Begin();
const Vector2* const positionsBuffer = positions.Begin();
- const Vector4* const colorsBuffer = colors.Begin();
for( uint32_t i = 0, glyphSize = glyphs.Size(); i < glyphSize; ++i )
{
}
// Create a new image for the glyph
- BufferImage bitmap = mFontClient.CreateBitmap( glyph.fontId, glyph.index );
+ PixelData bitmap = mFontClient.CreateBitmap( glyph.fontId, glyph.index );
if( bitmap )
{
MaxBlockSize& blockSize = mBlockSizes[currentBlockSize];
}
// Move the origin (0,0) of the mesh to the center of the actor
- const Vector2 position = *( positionsBuffer + i ) - halfActorSize;
+ const Vector2 position = *( positionsBuffer + i ) - halfTextSize;
// Generate mesh data for this quad, plugging in our supplied position
AtlasManager::Mesh2D newMesh;
}
// Get the color of the character.
- const Vector4& color = *( colorsBuffer + i );
+ const ColorIndex colorIndex = useDefaultColor ? 0u : *( colorIndicesBuffer + i );
+ const Vector4& color = ( useDefaultColor || ( 0u == colorIndex ) ) ? defaultColor : *( colorsBuffer + colorIndex - 1u );
for( unsigned int index = 0u, size = newMesh.mVertices.Count();
index < size;
{
MeshRecord& meshRecord = *it;
- Actor actor = CreateMeshActor( meshRecord, actorSize );
+ Actor actor = CreateMeshActor( meshRecord, textSize );
// Create an effect if necessary
if( style == STYLE_DROP_SHADOW )
containerActor.SetParentOrigin( ParentOrigin::CENTER );
containerActor.SetSize( actorSize );
- Actor shadowActor = CreateMeshActor( meshRecord, actorSize );
+ Actor shadowActor = CreateMeshActor( meshRecord, textSize );
#if defined(DEBUG_ENABLED)
shadowActor.SetName( "Text Shadow renderable actor" );
#endif
if( actor.GetRendererCount() )
{
Dali::Renderer renderer( shadowActor.GetRendererAt( 0 ) );
- renderer.SetDepthIndex( renderer.GetDepthIndex() - 1 );
- shadowActor.SetParentOrigin( ParentOrigin::CENTER );
- shadowActor.SetSize( actorSize );
+ int depthIndex = renderer.GetProperty<int>(Dali::Renderer::Property::DEPTH_INDEX);
+ renderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, depthIndex - 1 );
containerActor.Add( shadowActor );
containerActor.Add( actor );
+#if defined(DEBUG_ENABLED)
+ containerActor.SetName("TextContainer");
+#endif
actor = containerActor;
}
}
Actor CreateMeshActor( const MeshRecord& meshRecord, const Vector2& actorSize )
{
- PropertyBuffer quadVertices = PropertyBuffer::New( mQuadVertexFormat, meshRecord.mMesh.mVertices.Size() );
- PropertyBuffer quadIndices = PropertyBuffer::New( mQuadIndexFormat, meshRecord.mMesh.mIndices.Size() );
- quadVertices.SetData( const_cast< AtlasManager::Vertex2D* >( &meshRecord.mMesh.mVertices[ 0 ] ) );
- quadIndices.SetData( const_cast< unsigned int* >( &meshRecord.mMesh.mIndices[ 0 ] ) );
+ PropertyBuffer quadVertices = PropertyBuffer::New( mQuadVertexFormat );
+ quadVertices.SetData( const_cast< AtlasManager::Vertex2D* >( &meshRecord.mMesh.mVertices[ 0 ] ), meshRecord.mMesh.mVertices.Size() );
Geometry quadGeometry = Geometry::New();
quadGeometry.AddVertexBuffer( quadVertices );
- quadGeometry.SetIndexBuffer( quadIndices );
-
- Material material = mGlyphManager.GetMaterial( meshRecord.mAtlasId );
- Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, material );
- renderer.SetDepthIndex( CONTENT_DEPTH_INDEX + mDepth );
+ quadGeometry.SetIndexBuffer( &meshRecord.mMesh.mIndices[0], meshRecord.mMesh.mIndices.Size() );
+
+ TextureSet textureSet( mGlyphManager.GetTextures( meshRecord.mAtlasId ) );
+ Shader shader( mGlyphManager.GetShader( meshRecord.mAtlasId ) );
+ Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, shader );
+ renderer.SetTextures( textureSet );
+ renderer.SetProperty( Dali::Renderer::Property::BLEND_MODE, BlendMode::ON );
+ renderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, DepthIndex::CONTENT + mDepth );
Actor actor = Actor::New();
#if defined(DEBUG_ENABLED)
actor.SetName( "Text renderable actor" );
#endif
actor.AddRenderer( renderer );
- actor.SetParentOrigin( ParentOrigin::CENTER ); // Keep all of the origins aligned
+
+ // Keep all of the origins aligned
+ actor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ actor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
actor.SetSize( actorSize );
actor.RegisterProperty("uOffset", Vector2::ZERO );
return actor;
vert.mPosition.y = baseLine;
vert.mTexCoords.x = ZERO;
vert.mTexCoords.y = ZERO;
+ vert.mColor = underlineColor;
newMesh.mVertices.PushBack( vert );
vert.mPosition.x = brx;
vert.mPosition.y = baseLine;
vert.mTexCoords.x = u;
+ vert.mColor = underlineColor;
newMesh.mVertices.PushBack( vert );
vert.mPosition.x = tlx;
vert.mPosition.y = baseLine + thickness;
vert.mTexCoords.x = ZERO;
vert.mTexCoords.y = v;
+ vert.mColor = underlineColor;
newMesh.mVertices.PushBack( vert );
vert.mPosition.x = brx;
vert.mPosition.y = baseLine + thickness;
vert.mTexCoords.x = u;
+ vert.mColor = underlineColor;
newMesh.mVertices.PushBack( vert );
// Six indices in counter clockwise winding
newMesh.mIndices.PushBack( faceIndex + 1u );
faceIndex += 4;
- vert.mColor = underlineColor;
-
Toolkit::Internal::AtlasMeshFactory::AppendMesh( meshRecords[ index ].mMesh, newMesh );
}
}
std::vector< MaxBlockSize > mBlockSizes; ///> Maximum size needed to contain a glyph in a block within a new atlas
Vector< TextCacheEntry > mTextCache; ///> Caches data from previous render
Property::Map mQuadVertexFormat; ///> Describes the vertex format for text
- Property::Map mQuadIndexFormat; ///> Describes the index format for text
int mDepth; ///> DepthIndex passed by control when connect to stage
};
Actor AtlasRenderer::Render( Text::ViewInterface& view, int depth )
{
+ DALI_LOG_INFO( gLogFilter, Debug::General, "Text::AtlasRenderer::Render()\n" );
+
UnparentAndReset( mImpl->mActor );
Length numberOfGlyphs = view.GetNumberOfGlyphs();
Vector<Vector2> positions;
positions.Resize( numberOfGlyphs );
- Vector<Vector4> colors;
- colors.Resize( numberOfGlyphs, view.GetTextColor() );
-
numberOfGlyphs = view.GetGlyphs( glyphs.Begin(),
positions.Begin(),
- colors.Begin(),
0u,
numberOfGlyphs );
glyphs.Resize( numberOfGlyphs );
positions.Resize( numberOfGlyphs );
- colors.Resize( numberOfGlyphs );
+
+ const Vector4* const colorsBuffer = view.GetColors();
+ const ColorIndex* const colorIndicesBuffer = view.GetColorIndices();
+ const Vector4& defaultColor = view.GetTextColor();
mImpl->AddGlyphs( view,
positions,
glyphs,
- colors,
+ defaultColor,
+ colorsBuffer,
+ colorIndicesBuffer,
depth );
/* In the case where AddGlyphs does not create a renderable Actor for example when glyphs are all whitespace create a new Actor. */