2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.h>
22 #include <dali/dali.h>
23 #include <dali/devel-api/object/property-buffer.h>
24 #include <dali/devel-api/rendering/geometry.h>
25 #include <dali/devel-api/rendering/renderer.h>
26 #include <dali/devel-api/rendering/sampler.h>
27 #include <dali/devel-api/rendering/shader.h>
28 #include <dali/devel-api/text-abstraction/font-client.h>
29 #include <dali/integration-api/debug.h>
31 #include <dali-toolkit/public-api/controls/control-depth-index-ranges.h>
32 #include <dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h>
35 using namespace Dali::Toolkit;
36 using namespace Dali::Toolkit::Text;
40 #if defined(DEBUG_ENABLED)
41 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_RENDERING");
44 const float ZERO( 0.0f );
45 const float HALF( 0.5f );
46 const float ONE( 1.0f );
47 const float TWO( 2.0f );
48 const uint32_t DEFAULT_ATLAS_WIDTH = 512u;
49 const uint32_t DEFAULT_ATLAS_HEIGHT = 512u;
51 struct AtlasRenderer::Impl : public ConnectionTracker
64 AtlasManager::Mesh2D mMesh;
65 FrameBufferImage mBuffer;
74 float mUnderlinePosition;
75 float mUnderlineThickness;
76 uint32_t mMeshRecordIndex;
82 uint32_t mNeededBlockWidth;
83 uint32_t mNeededBlockHeight;
89 Text::GlyphIndex mIndex;
95 Text::GlyphIndex mIndex;
101 mGlyphManager = AtlasGlyphManager::Get();
102 mFontClient = TextAbstraction::FontClient::Get();
104 mQuadVertexFormat[ "aPosition" ] = Property::VECTOR2;
105 mQuadVertexFormat[ "aTexCoord" ] = Property::VECTOR2;
106 mQuadIndexFormat[ "indices" ] = Property::UNSIGNED_INTEGER;
109 void AddGlyphs( const std::vector<Vector2>& positions,
110 const Vector<GlyphInfo>& glyphs,
111 const Vector4& textColor,
112 const Vector2& shadowOffset,
113 const Vector4& shadowColor,
114 bool underlineEnabled,
115 const Vector4& underlineColor,
116 float underlineHeight,
119 AtlasManager::AtlasSlot slot;
120 std::vector< MeshRecord > meshContainer;
121 Vector< Extent > extents;
122 TextCacheEntry textCacheEntry;
125 float currentUnderlinePosition = ZERO;
126 float currentUnderlineThickness = underlineHeight;
127 uint32_t currentBlockSize = 0;
128 FontId lastFontId = 0;
129 Style style = STYLE_NORMAL;
131 if ( fabsf( shadowOffset.x ) > Math::MACHINE_EPSILON_1 || fabsf( shadowOffset.y ) > Math::MACHINE_EPSILON_1 )
133 style = STYLE_DROP_SHADOW;
136 if ( mTextCache.Size() )
138 // Update the glyph cache with any changes to current text
139 RemoveText( glyphs );
142 CalculateBlocksSize( glyphs );
144 for( uint32_t i = 0, glyphSize = glyphs.Size(); i < glyphSize; ++i )
146 const GlyphInfo& glyph = glyphs[ i ];
148 // No operation for white space
149 if ( glyph.width && glyph.height )
151 // Are we still using the same fontId as previous
152 if ( glyph.fontId != lastFontId )
154 // We need to fetch fresh font underline metrics
155 FontMetrics fontMetrics;
156 mFontClient.GetFontMetrics( glyph.fontId, fontMetrics );
157 currentUnderlinePosition = ceil( fabsf( fontMetrics.underlinePosition ) );
158 float descender = ceil( fabsf( fontMetrics.descender ) );
160 if ( underlineHeight == ZERO )
162 currentUnderlineThickness = fontMetrics.underlineThickness;
164 // Ensure underline will be at least a pixel high
165 if ( currentUnderlineThickness < ONE )
167 currentUnderlineThickness = ONE;
171 currentUnderlineThickness = ceil( currentUnderlineThickness );
175 // Clamp the underline position at the font descender and check for ( as EFL describes it ) a broken font
176 if ( currentUnderlinePosition > descender )
178 currentUnderlinePosition = descender;
180 if ( ZERO == currentUnderlinePosition )
182 // Move offset down by one ( EFL behavior )
183 currentUnderlinePosition = ONE;
187 const Vector2& position = positions[ i ];
188 AtlasManager::Mesh2D newMesh;
190 if ( !mGlyphManager.Cached( glyph.fontId, glyph.index, slot ) )
192 // Select correct size for new atlas if needed....?
193 if ( lastFontId != glyph.fontId )
195 for ( uint32_t j = 0; j < mBlockSizes.size(); ++j )
197 if ( mBlockSizes[ j ].mFontId == glyph.fontId )
199 currentBlockSize = j;
200 mGlyphManager.SetNewAtlasSize( DEFAULT_ATLAS_WIDTH,
201 DEFAULT_ATLAS_HEIGHT,
202 mBlockSizes[ j ].mNeededBlockWidth,
203 mBlockSizes[ j ].mNeededBlockHeight );
208 // Create a new image for the glyph
209 BufferImage bitmap = mFontClient.CreateBitmap( glyph.fontId, glyph.index );
212 // Ensure that the next image will fit into the current block size
213 bool setSize = false;
214 if ( bitmap.GetWidth() > mBlockSizes[ currentBlockSize ].mNeededBlockWidth )
217 mBlockSizes[ currentBlockSize ].mNeededBlockWidth = bitmap.GetWidth();
219 if ( bitmap.GetHeight() > mBlockSizes[ currentBlockSize ].mNeededBlockHeight )
222 mBlockSizes[ currentBlockSize ].mNeededBlockHeight = bitmap.GetHeight();
227 mGlyphManager.SetNewAtlasSize( DEFAULT_ATLAS_WIDTH,
228 DEFAULT_ATLAS_HEIGHT,
229 mBlockSizes[ currentBlockSize ].mNeededBlockWidth,
230 mBlockSizes[ currentBlockSize ].mNeededBlockHeight );
233 // Locate a new slot for our glyph
234 mGlyphManager.Add( glyph, bitmap, slot );
238 // Generate mesh data for this quad, plugging in our supplied position
239 mGlyphManager.GenerateMeshData( slot.mImageId, position, newMesh );
240 textCacheEntry.mFontId = glyph.fontId;
241 textCacheEntry.mImageId = slot.mImageId;
242 textCacheEntry.mIndex = glyph.index;
243 mTextCache.PushBack( textCacheEntry );
245 // Find an existing mesh data object to attach to ( or create a new one, if we can't find one using the same atlas)
246 StitchTextMesh( meshContainer,
250 position.y + glyph.yBearing,
251 currentUnderlinePosition,
252 currentUnderlineThickness,
254 lastFontId = glyph.fontId;
258 if ( underlineEnabled )
260 // Check to see if any of the text needs an underline
261 GenerateUnderlines( meshContainer, extents, underlineColor, textColor );
264 // For each MeshData object, create a mesh actor and add to the renderable actor
265 if ( meshContainer.size() )
267 for ( std::vector< MeshRecord >::iterator mIt = meshContainer.begin(); mIt != meshContainer.end(); ++mIt )
269 Actor actor = CreateMeshActor( *mIt );
271 // Create an effect if necessary
272 if ( style == STYLE_DROP_SHADOW )
274 actor.Add( GenerateShadow( *mIt, shadowOffset, shadowColor ) );
279 actor.SetParentOrigin( ParentOrigin::CENTER ); // Keep all of the origins aligned
288 #if defined(DEBUG_ENABLED)
289 Toolkit::AtlasGlyphManager::Metrics metrics = mGlyphManager.GetMetrics();
290 DALI_LOG_INFO( gLogFilter, Debug::General, "TextAtlasRenderer::GlyphManager::GlyphCount: %i, AtlasCount: %i, TextureMemoryUse: %iK\n",
292 metrics.mAtlasMetrics.mAtlasCount,
293 metrics.mAtlasMetrics.mTextureMemoryUsed / 1024 );
294 for ( uint32_t i = 0; i < metrics.mAtlasMetrics.mAtlasCount; ++i )
296 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Atlas [%i] %sPixels: %s Size: %ix%i, BlockSize: %ix%i, BlocksUsed: %i/%i\n",
297 i + 1, i > 8 ? "" : " ",
298 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mPixelFormat == Pixel::L8 ? "L8 " : "BGRA",
299 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mSize.mWidth,
300 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mSize.mHeight,
301 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mSize.mBlockWidth,
302 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mSize.mBlockHeight,
303 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mBlocksUsed,
304 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mTotalBlocks );
309 Actor CreateMeshActor( const MeshRecord& meshRecord )
311 PropertyBuffer quadVertices = PropertyBuffer::New( mQuadVertexFormat, meshRecord.mMesh.mVertices.Size() );
312 PropertyBuffer quadIndices = PropertyBuffer::New( mQuadIndexFormat, meshRecord.mMesh.mIndices.Size() );
313 quadVertices.SetData( const_cast< AtlasManager::Vertex2D* >( &meshRecord.mMesh.mVertices[ 0 ] ) );
314 quadIndices.SetData( const_cast< unsigned int* >( &meshRecord.mMesh.mIndices[ 0 ] ) );
316 Geometry quadGeometry = Geometry::New();
317 quadGeometry.AddVertexBuffer( quadVertices );
318 quadGeometry.SetIndexBuffer( quadIndices );
320 Material material = mGlyphManager.GetMaterial( meshRecord.mAtlasId );
321 Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, material );
322 renderer.SetDepthIndex( CONTENT_DEPTH_INDEX + mDepth );
323 Actor actor = Actor::New();
324 #if defined(DEBUG_ENABLED)
325 actor.SetName( "Text renderable actor" );
327 actor.AddRenderer( renderer );
328 actor.SetSize( 1.0f, 1.0f );
329 actor.SetColor( meshRecord.mColor );
331 if ( meshRecord.mIsUnderline )
333 actor.SetColorMode( USE_OWN_COLOR );
337 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
342 void StitchTextMesh( std::vector< MeshRecord >& meshContainer,
343 AtlasManager::Mesh2D& newMesh,
344 Vector< Extent >& extents,
345 const Vector4& color,
347 float underlinePosition,
348 float underlineThickness,
349 AtlasManager::AtlasSlot& slot )
353 float left = newMesh.mVertices[ 0 ].mPosition.x;
354 float right = newMesh.mVertices[ 1 ].mPosition.x;
356 // Check to see if there's a mesh data object that references the same atlas ?
358 for ( std::vector< MeshRecord >::iterator mIt = meshContainer.begin(); mIt != meshContainer.end(); ++mIt, ++index )
360 if ( slot.mAtlasId == mIt->mAtlasId && color == mIt->mColor )
362 // Stitch the mesh to the existing mesh and adjust any extents
363 mGlyphManager.StitchMesh( mIt->mMesh, newMesh );
364 AdjustExtents( extents,
371 underlineThickness );
376 // No mesh data object currently exists that references this atlas, so create a new one
377 MeshRecord meshRecord;
378 meshRecord.mAtlasId = slot.mAtlasId;
379 meshRecord.mMesh = newMesh;
380 meshRecord.mColor = color;
381 meshRecord.mIsUnderline = false;
382 meshContainer.push_back( meshRecord );
384 // Adjust extents for this new meshrecord
385 AdjustExtents( extents,
387 meshContainer.size() - 1u,
392 underlineThickness );
397 void AdjustExtents( Vector< Extent >& extents,
398 std::vector< MeshRecord>& meshRecords,
403 float underlinePosition,
404 float underlineThickness )
406 bool foundExtent = false;
407 for ( Vector< Extent >::Iterator eIt = extents.Begin(); eIt != extents.End(); ++eIt )
409 if ( Equals( baseLine, eIt->mBaseLine ) )
412 if ( left < eIt->mLeft )
416 if ( right > eIt->mRight )
421 if ( underlinePosition > eIt->mUnderlinePosition )
423 eIt->mUnderlinePosition = underlinePosition;
425 if ( underlineThickness > eIt->mUnderlineThickness )
427 eIt->mUnderlineThickness = underlineThickness;
435 extent.mRight = right;
436 extent.mBaseLine = baseLine;
437 extent.mUnderlinePosition = underlinePosition;
438 extent.mUnderlineThickness = underlineThickness;
439 extent.mMeshRecordIndex = index;
440 extents.PushBack( extent );
444 void RemoveText( const Vector<GlyphInfo>& glyphs )
446 Vector< CheckEntry > checked;
447 CheckEntry checkEntry;
449 for ( Vector< TextCacheEntry >::Iterator tCit = mTextCache.Begin(); tCit != mTextCache.End(); ++tCit )
451 uint32_t index = tCit->mIndex;
452 uint32_t fontId = tCit->mFontId;
454 // Check that this character has not already been checked...
455 bool wasChecked = false;
456 for ( Vector< CheckEntry >::Iterator cEit = checked.Begin(); cEit != checked.End(); ++cEit )
458 if ( fontId == cEit->mFontId && index == cEit->mIndex )
467 int32_t newCount = 0;
468 int32_t oldCount = 0;
470 // How many times does this character occur in the old text ?
471 for ( Vector< TextCacheEntry >::Iterator oTcit = mTextCache.Begin(); oTcit != mTextCache.End(); ++oTcit )
473 if ( fontId == oTcit->mFontId && index == oTcit->mIndex )
479 // And how many times in the new ?
480 for ( Vector< GlyphInfo >::Iterator cGit = glyphs.Begin(); cGit != glyphs.End(); ++cGit )
482 if ( fontId == cGit->fontId && index == cGit->index )
487 mGlyphManager.AdjustReferenceCount( fontId, tCit->mImageId, newCount - oldCount );
488 checkEntry.mIndex = index;
489 checkEntry.mFontId = fontId;
490 checked.PushBack( checkEntry );
493 mTextCache.Resize( 0 );
496 void CalculateBlocksSize( const Vector<GlyphInfo>& glyphs )
498 MaxBlockSize maxBlockSize;
499 for ( uint32_t i = 0; i < glyphs.Size(); ++i )
501 FontId fontId = glyphs[ i ].fontId;
502 bool foundFont = false;
503 for ( uint32_t j = 0; j < mBlockSizes.size(); ++j )
505 if ( mBlockSizes[ j ].mFontId == fontId )
512 FontMetrics fontMetrics;
513 mFontClient.GetFontMetrics( fontId, fontMetrics );
514 maxBlockSize.mNeededBlockWidth = static_cast< uint32_t >( fontMetrics.height );
515 maxBlockSize.mNeededBlockHeight = static_cast< uint32_t >( fontMetrics.height );
516 maxBlockSize.mFontId = fontId;
517 mBlockSizes.push_back( maxBlockSize );
522 void GenerateUnderlines( std::vector< MeshRecord>& meshRecords,
523 Vector< Extent >& extents,
524 const Vector4& underlineColor,
525 const Vector4& textColor )
527 AtlasManager::Mesh2D newMesh;
528 unsigned short faceIndex = 0;
529 for ( Vector< Extent >::ConstIterator eIt = extents.Begin(); eIt != extents.End(); ++eIt )
531 AtlasManager::Vertex2D vert;
532 uint32_t index = eIt->mMeshRecordIndex;
533 Vector2 uv = mGlyphManager.GetAtlasSize( meshRecords[ index ].mAtlasId );
535 // Make sure we don't hit texture edge for single pixel texture ( filled pixel is in top left of every atlas )
536 float u = HALF / uv.x;
537 float v = HALF / uv.y;
538 float thickness = eIt->mUnderlineThickness;
539 float baseLine = eIt->mBaseLine + eIt->mUnderlinePosition - ( thickness * HALF );
540 float tlx = eIt->mLeft;
541 float brx = eIt->mRight;
543 vert.mPosition.x = tlx;
544 vert.mPosition.y = baseLine;
545 vert.mTexCoords.x = ZERO;
546 vert.mTexCoords.y = ZERO;
547 newMesh.mVertices.PushBack( vert );
549 vert.mPosition.x = brx;
550 vert.mPosition.y = baseLine;
551 vert.mTexCoords.x = u;
552 newMesh.mVertices.PushBack( vert );
554 vert.mPosition.x = tlx;
555 vert.mPosition.y = baseLine + thickness;
556 vert.mTexCoords.x = ZERO;
557 vert.mTexCoords.y = v;
558 newMesh.mVertices.PushBack( vert );
560 vert.mPosition.x = brx;
561 vert.mPosition.y = baseLine + thickness;
562 vert.mTexCoords.x = u;
563 newMesh.mVertices.PushBack( vert );
565 // Six indices in counter clockwise winding
566 newMesh.mIndices.PushBack( faceIndex + 1u );
567 newMesh.mIndices.PushBack( faceIndex );
568 newMesh.mIndices.PushBack( faceIndex + 2u );
569 newMesh.mIndices.PushBack( faceIndex + 2u );
570 newMesh.mIndices.PushBack( faceIndex + 3u );
571 newMesh.mIndices.PushBack( faceIndex + 1u );
574 if ( underlineColor == textColor )
576 mGlyphManager.StitchMesh( meshRecords[ index ].mMesh, newMesh );
581 record.mMesh = newMesh;
582 record.mAtlasId = meshRecords[ index ].mAtlasId;
583 record.mColor = underlineColor;
584 record.mIsUnderline = true;
585 meshRecords.push_back( record );
590 Actor GenerateShadow( MeshRecord& meshRecord,
591 const Vector2& shadowOffset,
592 const Vector4& shadowColor )
594 // Scan vertex buffer to determine width and height of effect buffer needed
595 const Vector< AtlasManager::Vertex2D >& verts = meshRecord.mMesh.mVertices;
596 float tlx = verts[ 0 ].mPosition.x;
597 float tly = verts[ 0 ].mPosition.y;
601 for ( uint32_t i = 0; i < verts.Size(); ++i )
603 if ( verts[ i ].mPosition.x < tlx )
605 tlx = verts[ i ].mPosition.x;
607 if ( verts[ i ].mPosition.y < tly )
609 tly = verts[ i ].mPosition.y;
611 if ( verts[ i ].mPosition.x > brx )
613 brx = verts[ i ].mPosition.x;
615 if ( verts[ i ].mPosition.y > bry )
617 bry = verts[ i ].mPosition.y;
621 float width = brx - tlx;
622 float height = bry - tly;
623 float divWidth = TWO / width;
624 float divHeight = TWO / height;
626 // Create a buffer to render to
627 meshRecord.mBuffer = FrameBufferImage::New( width, height );
629 // We will render a quad into this buffer
630 unsigned int indices[ 6 ] = { 1, 0, 2, 2, 3, 1 };
631 PropertyBuffer quadVertices = PropertyBuffer::New( mQuadVertexFormat, 4u );
632 PropertyBuffer quadIndices = PropertyBuffer::New( mQuadIndexFormat, sizeof(indices)/sizeof(indices[0]) );
634 AtlasManager::Vertex2D vertices[ 4 ] = {
635 { Vector2( tlx + shadowOffset.x, tly + shadowOffset.y ), Vector2( ZERO, ZERO ) },
636 { Vector2( brx + shadowOffset.x, tly + shadowOffset.y ), Vector2( ONE, ZERO ) },
637 { Vector2( tlx + shadowOffset.x, bry + shadowOffset.y ), Vector2( ZERO, ONE ) },
638 { Vector2( brx + shadowOffset.x, bry + shadowOffset.y ), Vector2( ONE, ONE ) } };
640 quadVertices.SetData( vertices );
641 quadIndices.SetData( indices );
643 Geometry quadGeometry = Geometry::New();
644 quadGeometry.AddVertexBuffer( quadVertices );
645 quadGeometry.SetIndexBuffer( quadIndices );
647 Sampler sampler = Sampler::New( meshRecord.mBuffer, "sTexture" );
648 Material material = Material::New( mGlyphManager.GetEffectBufferShader() );
649 material.AddSampler( sampler );
651 Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, material );
653 // Ensure shadow is behind the text...
654 renderer.SetDepthIndex( CONTENT_DEPTH_INDEX + mDepth - 1 );
655 Actor actor = Actor::New();
656 actor.AddRenderer( renderer );
657 actor.SetSize( 1.0f, 1.0f );
659 // Create a sub actor to render the source with normalized vertex positions
660 Vector< AtlasManager::Vertex2D > normVertexList;
661 for ( uint32_t i = 0; i < verts.Size(); ++i )
663 AtlasManager::Vertex2D vertex = verts[ i ];
664 vertex.mPosition.x = ( ( vertex.mPosition.x - tlx ) * divWidth ) - ONE;
665 vertex.mPosition.y = ( ( vertex.mPosition.y - tly ) * divHeight ) - ONE;
666 normVertexList.PushBack( vertex );
669 PropertyBuffer normVertices = PropertyBuffer::New( mQuadVertexFormat, normVertexList.Size() );
670 PropertyBuffer normIndices = PropertyBuffer::New( mQuadIndexFormat, meshRecord.mMesh.mIndices.Size() );
671 normVertices.SetData( const_cast< AtlasManager::Vertex2D* >( &normVertexList[ 0 ] ) );
672 normIndices.SetData( const_cast< unsigned int* >( &meshRecord.mMesh.mIndices[ 0 ] ) );
674 Geometry normGeometry = Geometry::New();
675 normGeometry.AddVertexBuffer( normVertices );
676 normGeometry.SetIndexBuffer( normIndices );
678 Material normMaterial = Material::New( mGlyphManager.GetGlyphShadowShader() );
679 Sampler normSampler = mGlyphManager.GetSampler( meshRecord.mAtlasId );
680 normMaterial.AddSampler( normSampler );
681 Dali::Renderer normRenderer = Dali::Renderer::New( normGeometry, normMaterial );
682 Actor subActor = Actor::New();
683 subActor.AddRenderer( normRenderer );
684 subActor.SetSize( 1.0f, 1.0f );
685 subActor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
686 subActor.SetColor( shadowColor );
688 // Create a render task to render the effect
689 RenderTask task = Stage::GetCurrent().GetRenderTaskList().CreateTask();
690 task.SetTargetFrameBuffer( meshRecord.mBuffer );
691 task.SetSourceActor( subActor );
692 task.SetClearEnabled( true );
693 task.SetClearColor( Vector4::ZERO );
694 task.SetExclusive( true );
695 task.SetRefreshRate( RenderTask::REFRESH_ONCE );
696 task.FinishedSignal().Connect( this, &AtlasRenderer::Impl::RenderComplete );
697 actor.Add( subActor );
702 void RenderComplete( RenderTask& renderTask )
704 // Disconnect and remove this single shot render task
705 renderTask.FinishedSignal().Disconnect( this, &AtlasRenderer::Impl::RenderComplete );
706 Stage::GetCurrent().GetRenderTaskList().RemoveTask( renderTask );
708 // Get the actor used for render to buffer and remove it from the parent
709 Actor renderActor = renderTask.GetSourceActor();
712 Actor parent = renderActor.GetParent();
715 parent.Remove( renderActor );
720 Actor mActor; ///< The actor parent which renders the text
721 AtlasGlyphManager mGlyphManager; ///< Glyph Manager to handle upload and caching
722 TextAbstraction::FontClient mFontClient; ///> The font client used to supply glyph information
723 std::vector< MaxBlockSize > mBlockSizes; ///> Maximum size needed to contain a glyph in a block within a new atlas
724 std::vector< uint32_t > mFace; ///> Face indices for a quad
725 Vector< TextCacheEntry > mTextCache;
726 Property::Map mQuadVertexFormat;
727 Property::Map mQuadIndexFormat;
731 Text::RendererPtr AtlasRenderer::New()
733 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Text::AtlasRenderer::New()\n" );
735 return Text::RendererPtr( new AtlasRenderer() );
738 Actor AtlasRenderer::Render( Text::ViewInterface& view, int depth )
740 UnparentAndReset( mImpl->mActor );
742 Length numberOfGlyphs = view.GetNumberOfGlyphs();
744 if( numberOfGlyphs > 0u )
746 Vector<GlyphInfo> glyphs;
747 glyphs.Resize( numberOfGlyphs );
749 std::vector<Vector2> positions;
750 positions.resize( numberOfGlyphs );
752 numberOfGlyphs = view.GetGlyphs( glyphs.Begin(),
756 glyphs.Resize( numberOfGlyphs );
757 positions.resize( numberOfGlyphs );
759 mImpl->AddGlyphs( positions,
762 view.GetShadowOffset(),
763 view.GetShadowColor(),
764 view.IsUnderlineEnabled(),
765 view.GetUnderlineColor(),
766 view.GetUnderlineHeight(),
770 return mImpl->mActor;
773 AtlasRenderer::AtlasRenderer()
779 AtlasRenderer::~AtlasRenderer()
781 Vector< GlyphInfo > emptyGlyphs;
782 mImpl->RemoveText( emptyGlyphs );