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/integration-api/debug.h>
24 #include <dali/devel-api/text-abstraction/font-client.h>
28 #include <dali-toolkit/public-api/controls/control-depth-index-ranges.h>
29 #include <dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h>
32 using namespace Dali::Toolkit;
33 using namespace Dali::Toolkit::Text;
37 #if defined(DEBUG_ENABLED)
38 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_RENDERING");
41 const float ZERO( 0.0f );
42 const float HALF( 0.5f );
43 const float ONE( 1.0f );
44 const float TWO( 2.0f );
45 const uint32_t DEFAULT_ATLAS_WIDTH = 512u;
46 const uint32_t DEFAULT_ATLAS_HEIGHT = 512u;
48 #define MAKE_SHADER(A)#A
50 const char* VERTEX_SHADER = MAKE_SHADER(
51 attribute mediump vec2 aPosition;
52 attribute mediump vec2 aTexCoord;
53 uniform mediump mat4 uMvpMatrix;
54 uniform mediump vec3 uSize;
55 varying mediump vec2 vTexCoord;
59 mediump vec4 position = vec4( aPosition, 0.0, 1.0 );
60 position.xyz *= uSize;
61 gl_Position = uMvpMatrix * position;
62 vTexCoord = aTexCoord;
66 const char* FRAGMENT_SHADER = MAKE_SHADER(
67 uniform sampler2D sTexture;
68 varying mediump vec2 vTexCoord;
72 //gl_FragColor = vec4( 1.0 );
73 gl_FragColor = texture2D( sTexture, vTexCoord );
77 const char* VERTEX_SHADER_SHADOW = MAKE_SHADER(
78 attribute mediump vec2 aPosition;
79 attribute mediump vec2 aTexCoord;
80 uniform mediump vec3 uSize;
81 varying mediump vec2 vTexCoord;
85 mediump vec4 position = vec4( aPosition, 0.0, 1.0 );
86 position.xyz *= uSize;
87 gl_Position = position;
88 vTexCoord = aTexCoord;
92 const char* FRAGMENT_SHADER_SHADOW = MAKE_SHADER(
93 uniform sampler2D sTexture;
94 uniform lowp vec4 uColor;
95 varying mediump vec2 vTexCoord;
99 mediump vec4 color = texture2D( sTexture, vTexCoord );
100 gl_FragColor = vec4(uColor.rgb, uColor.a*color.r);
105 struct AtlasRenderer::Impl : public ConnectionTracker
118 AtlasManager::Mesh2D mMesh;
119 FrameBufferImage mBuffer;
128 float mUnderlinePosition;
129 float mUnderlineThickness;
130 uint32_t mMeshRecordIndex;
136 Text::GlyphIndex mIndex;
142 uint32_t mNeededBlockWidth;
143 uint32_t mNeededBlockHeight;
148 mGlyphManager = AtlasGlyphManager::Get();
149 mFontClient = TextAbstraction::FontClient::Get();
151 mQuadVertexFormat[ "aPosition" ] = Property::VECTOR2;
152 mQuadVertexFormat[ "aTexCoord" ] = Property::VECTOR2;
153 mQuadIndexFormat[ "indices" ] = Property::UNSIGNED_INTEGER;
155 mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
156 mShadowShader = Shader::New( VERTEX_SHADER_SHADOW, FRAGMENT_SHADER_SHADOW, Dali::Shader::HINT_MODIFIES_GEOMETRY );
159 void AddGlyphs( const std::vector<Vector2>& positions,
160 const Vector<GlyphInfo>& glyphs,
161 const Vector4& textColor,
162 const Vector2& shadowOffset,
163 const Vector4& shadowColor,
164 bool underlineEnabled,
165 const Vector4& underlineColor,
166 float underlineHeight )
168 AtlasManager::AtlasSlot slot;
169 std::vector< MeshRecord > meshContainer;
170 Vector< Extent > extents;
172 float currentUnderlinePosition = ZERO;
173 float currentUnderlineThickness = underlineHeight;
174 uint32_t currentBlockSize = 0;
175 FontId lastFontId = 0;
176 Style style = STYLE_NORMAL;
178 if ( fabsf( shadowOffset.x ) > Math::MACHINE_EPSILON_1 || fabsf( shadowOffset.y ) > Math::MACHINE_EPSILON_1 )
180 style = STYLE_DROP_SHADOW;
183 if ( mImageIds.Size() )
185 // Unreference any currently used glyphs
189 CalculateBlocksSize( glyphs );
191 for( uint32_t i = 0, glyphSize = glyphs.Size(); i < glyphSize; ++i )
193 const GlyphInfo& glyph = glyphs[ i ];
195 // No operation for white space
196 if ( glyph.width && glyph.height )
198 // Are we still using the same fontId as previous
199 if ( glyph.fontId != lastFontId )
201 // We need to fetch fresh font underline metrics
202 FontMetrics fontMetrics;
203 mFontClient.GetFontMetrics( glyph.fontId, fontMetrics );
204 currentUnderlinePosition = ceil( fabsf( fontMetrics.underlinePosition ) );
205 float descender = ceil( fabsf( fontMetrics.descender ) );
207 if ( underlineHeight == ZERO )
209 currentUnderlineThickness = fontMetrics.underlineThickness;
211 // Ensure underline will be at least a pixel high
212 if ( currentUnderlineThickness < ONE )
214 currentUnderlineThickness = ONE;
218 currentUnderlineThickness = ceil( currentUnderlineThickness );
222 // Clamp the underline position at the font descender and check for ( as EFL describes it ) a broken font
223 if ( currentUnderlinePosition > descender )
225 currentUnderlinePosition = descender;
227 if ( ZERO == currentUnderlinePosition )
229 // Move offset down by one ( EFL behavior )
230 currentUnderlinePosition = ONE;
234 const Vector2& position = positions[ i ];
235 AtlasManager::Mesh2D newMesh;
236 mGlyphManager.Cached( glyph.fontId, glyph.index, slot );
240 // This glyph already exists so generate mesh data plugging in our supplied position
241 mGlyphManager.GenerateMeshData( slot.mImageId, position, newMesh );
242 mImageIds.PushBack( slot.mImageId );
247 // Select correct size for new atlas if needed....?
248 if ( lastFontId != glyph.fontId )
250 for ( uint32_t j = 0; j < mBlockSizes.size(); ++j )
252 if ( mBlockSizes[ j ].mFontId == glyph.fontId )
254 currentBlockSize = j;
255 mGlyphManager.SetNewAtlasSize( DEFAULT_ATLAS_WIDTH,
256 DEFAULT_ATLAS_HEIGHT,
257 mBlockSizes[ j ].mNeededBlockWidth,
258 mBlockSizes[ j ].mNeededBlockHeight );
263 // Create a new image for the glyph
264 BufferImage bitmap = mFontClient.CreateBitmap( glyph.fontId, glyph.index );
267 // Ensure that the next image will fit into the current block size
268 bool setSize = false;
269 if ( bitmap.GetWidth() > mBlockSizes[ currentBlockSize ].mNeededBlockWidth )
272 mBlockSizes[ currentBlockSize ].mNeededBlockWidth = bitmap.GetWidth();
274 if ( bitmap.GetHeight() > mBlockSizes[ currentBlockSize ].mNeededBlockHeight )
277 mBlockSizes[ currentBlockSize ].mNeededBlockHeight = bitmap.GetHeight();
282 mGlyphManager.SetNewAtlasSize( DEFAULT_ATLAS_WIDTH,
283 DEFAULT_ATLAS_HEIGHT,
284 mBlockSizes[ currentBlockSize ].mNeededBlockWidth,
285 mBlockSizes[ currentBlockSize ].mNeededBlockHeight );
288 // Locate a new slot for our glyph
289 mGlyphManager.Add( glyph, bitmap, slot );
291 // Generate mesh data for this quad, plugging in our supplied position
294 mGlyphManager.GenerateMeshData( slot.mImageId, position, newMesh );
295 mImageIds.PushBack( slot.mImageId );
299 // Find an existing mesh data object to attach to ( or create a new one, if we can't find one using the same atlas)
300 StitchTextMesh( meshContainer,
304 position.y + glyph.yBearing,
305 currentUnderlinePosition,
306 currentUnderlineThickness,
308 lastFontId = glyph.fontId;
312 if ( underlineEnabled )
314 // Check to see if any of the text needs an underline
315 GenerateUnderlines( meshContainer, extents, underlineColor, textColor );
318 // For each MeshData object, create a mesh actor and add to the renderable actor
319 if ( meshContainer.size() )
321 for ( std::vector< MeshRecord >::iterator mIt = meshContainer.begin(); mIt != meshContainer.end(); ++mIt )
323 Actor actor = CreateMeshActor( *mIt );
325 // Create an effect if necessary
326 if ( style == STYLE_DROP_SHADOW )
328 actor.Add( GenerateShadow( *mIt, shadowOffset, shadowColor ) );
340 mActor.OffStageSignal().Connect( this, &AtlasRenderer::Impl::OffStageDisconnect );
342 #if defined(DEBUG_ENABLED)
343 Toolkit::AtlasGlyphManager::Metrics metrics = mGlyphManager.GetMetrics();
344 DALI_LOG_INFO( gLogFilter, Debug::General, "TextAtlasRenderer::GlyphManager::GlyphCount: %i, AtlasCount: %i, TextureMemoryUse: %iK\n",
346 metrics.mAtlasMetrics.mAtlasCount,
347 metrics.mAtlasMetrics.mTextureMemoryUsed / 1024 );
348 for ( uint32_t i = 0; i < metrics.mAtlasMetrics.mAtlasCount; ++i )
350 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Atlas [%i] %sPixels: %s Size: %ix%i, BlockSize: %ix%i, BlocksUsed: %i/%i\n",
351 i + 1, i > 8 ? "" : " ",
352 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mPixelFormat == Pixel::L8 ? "L8 " : "BGRA",
353 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mSize.mWidth,
354 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mSize.mHeight,
355 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mSize.mBlockWidth,
356 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mSize.mBlockHeight,
357 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mBlocksUsed,
358 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mTotalBlocks );
363 Actor CreateMeshActor( const MeshRecord& meshRecord )
365 PropertyBuffer quadVertices = PropertyBuffer::New( mQuadVertexFormat, meshRecord.mMesh.mVertices.Size() );
366 PropertyBuffer quadIndices = PropertyBuffer::New( mQuadIndexFormat, meshRecord.mMesh.mIndices.Size() );
367 quadVertices.SetData( const_cast< AtlasManager::Vertex2D* >( &meshRecord.mMesh.mVertices[ 0 ] ) );
368 quadIndices.SetData( const_cast< unsigned int* >( &meshRecord.mMesh.mIndices[ 0 ] ) );
370 Geometry quadGeometry = Geometry::New();
371 quadGeometry.AddVertexBuffer( quadVertices );
372 quadGeometry.SetIndexBuffer( quadIndices );
374 Material material = mGlyphManager.GetMaterial( meshRecord.mAtlasId );
375 Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, material );
376 Actor actor = Actor::New();
377 actor.AddRenderer( renderer );
378 actor.SetSize( 1.0f, 1.0f );
379 actor.SetColor( meshRecord.mColor );
381 if ( meshRecord.mIsUnderline )
383 actor.SetColorMode( USE_OWN_COLOR );
387 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
392 void StitchTextMesh( std::vector< MeshRecord >& meshContainer,
393 AtlasManager::Mesh2D& newMesh,
394 Vector< Extent >& extents,
395 const Vector4& color,
397 float underlinePosition,
398 float underlineThickness,
399 AtlasManager::AtlasSlot& slot )
403 float left = newMesh.mVertices[ 0 ].mPosition.x;
404 float right = newMesh.mVertices[ 1 ].mPosition.x;
406 // Check to see if there's a mesh data object that references the same atlas ?
408 for ( std::vector< MeshRecord >::iterator mIt = meshContainer.begin(); mIt != meshContainer.end(); ++mIt, ++index )
410 if ( slot.mAtlasId == mIt->mAtlasId && color == mIt->mColor )
412 // Stitch the mesh to the existing mesh and adjust any extents
413 mGlyphManager.StitchMesh( mIt->mMesh, newMesh );
414 AdjustExtents( extents,
421 underlineThickness );
426 // No mesh data object currently exists that references this atlas, so create a new one
427 MeshRecord meshRecord;
428 meshRecord.mAtlasId = slot.mAtlasId;
429 meshRecord.mMesh = newMesh;
430 meshRecord.mColor = color;
431 meshRecord.mIsUnderline = false;
432 meshContainer.push_back( meshRecord );
434 // Adjust extents for this new meshrecord
435 AdjustExtents( extents,
437 meshContainer.size() - 1u,
442 underlineThickness );
447 void AdjustExtents( Vector< Extent >& extents,
448 std::vector< MeshRecord>& meshRecords,
453 float underlinePosition,
454 float underlineThickness )
456 bool foundExtent = false;
457 for ( Vector< Extent >::Iterator eIt = extents.Begin(); eIt != extents.End(); ++eIt )
459 if ( Equals( baseLine, eIt->mBaseLine ) )
462 if ( left < eIt->mLeft )
466 if ( right > eIt->mRight )
471 if ( underlinePosition > eIt->mUnderlinePosition )
473 eIt->mUnderlinePosition = underlinePosition;
475 if ( underlineThickness > eIt->mUnderlineThickness )
477 eIt->mUnderlineThickness = underlineThickness;
485 extent.mRight = right;
486 extent.mBaseLine = baseLine;
487 extent.mUnderlinePosition = underlinePosition;
488 extent.mUnderlineThickness = underlineThickness;
489 extent.mMeshRecordIndex = index;
490 extents.PushBack( extent );
494 // Unreference any glyphs that were used with this actor
495 void OffStageDisconnect( Dali::Actor actor )
502 for ( uint32_t i = 0; i < mImageIds.Size(); ++i )
504 mGlyphManager.Remove( mImageIds[ i ] );
506 mImageIds.Resize( 0 );
509 void CalculateBlocksSize( const Vector<GlyphInfo>& glyphs )
511 MaxBlockSize maxBlockSize;
512 for ( uint32_t i = 0; i < glyphs.Size(); ++i )
514 FontId fontId = glyphs[ i ].fontId;
515 bool foundFont = false;
516 for ( uint32_t j = 0; j < mBlockSizes.size(); ++j )
518 if ( mBlockSizes[ j ].mFontId == fontId )
525 FontMetrics fontMetrics;
526 mFontClient.GetFontMetrics( fontId, fontMetrics );
527 maxBlockSize.mNeededBlockWidth = static_cast< uint32_t >( fontMetrics.height );
528 maxBlockSize.mNeededBlockHeight = static_cast< uint32_t >( fontMetrics.height );
529 maxBlockSize.mFontId = fontId;
530 mBlockSizes.push_back( maxBlockSize );
535 void GenerateUnderlines( std::vector< MeshRecord>& meshRecords,
536 Vector< Extent >& extents,
537 const Vector4& underlineColor,
538 const Vector4& textColor )
540 AtlasManager::Mesh2D newMesh;
541 unsigned short faceIndex = 0;
542 for ( Vector< Extent >::ConstIterator eIt = extents.Begin(); eIt != extents.End(); ++eIt )
544 AtlasManager::Vertex2D vert;
545 uint32_t index = eIt->mMeshRecordIndex;
546 Vector2 uv = mGlyphManager.GetAtlasSize( meshRecords[ index ].mAtlasId );
548 // Make sure we don't hit texture edge for single pixel texture ( filled pixel is in top left of every atlas )
549 float u = HALF / uv.x;
550 float v = HALF / uv.y;
551 float thickness = eIt->mUnderlineThickness;
552 float baseLine = eIt->mBaseLine + eIt->mUnderlinePosition - ( thickness * HALF );
553 float tlx = eIt->mLeft;
554 float brx = eIt->mRight;
556 vert.mPosition.x = tlx;
557 vert.mPosition.y = baseLine;
558 vert.mTexCoords.x = ZERO;
559 vert.mTexCoords.y = ZERO;
560 newMesh.mVertices.PushBack( vert );
562 vert.mPosition.x = brx;
563 vert.mPosition.y = baseLine;
564 vert.mTexCoords.x = u;
565 newMesh.mVertices.PushBack( vert );
567 vert.mPosition.x = tlx;
568 vert.mPosition.y = baseLine + thickness;
569 vert.mTexCoords.x = ZERO;
570 vert.mTexCoords.y = v;
571 newMesh.mVertices.PushBack( vert );
573 vert.mPosition.x = brx;
574 vert.mPosition.y = baseLine + thickness;
575 vert.mTexCoords.x = u;
576 newMesh.mVertices.PushBack( vert );
578 // Six indices in counter clockwise winding
579 newMesh.mIndices.PushBack( faceIndex + 1u );
580 newMesh.mIndices.PushBack( faceIndex );
581 newMesh.mIndices.PushBack( faceIndex + 2u );
582 newMesh.mIndices.PushBack( faceIndex + 2u );
583 newMesh.mIndices.PushBack( faceIndex + 3u );
584 newMesh.mIndices.PushBack( faceIndex + 1u );
587 if ( underlineColor == textColor )
589 mGlyphManager.StitchMesh( meshRecords[ index ].mMesh, newMesh );
594 record.mMesh = newMesh;
595 record.mAtlasId = meshRecords[ index ].mAtlasId;
596 record.mColor = underlineColor;
597 record.mIsUnderline = true;
598 meshRecords.push_back( record );
603 Actor GenerateShadow( MeshRecord& meshRecord,
604 const Vector2& shadowOffset,
605 const Vector4& shadowColor )
607 // Scan vertex buffer to determine width and height of effect buffer needed
608 const Vector< AtlasManager::Vertex2D >& verts = meshRecord.mMesh.mVertices;
609 float tlx = verts[ 0 ].mPosition.x;
610 float tly = verts[ 0 ].mPosition.y;
614 for ( uint32_t i = 0; i < verts.Size(); ++i )
616 if ( verts[ i ].mPosition.x < tlx )
618 tlx = verts[ i ].mPosition.x;
620 if ( verts[ i ].mPosition.y < tly )
622 tly = verts[ i ].mPosition.y;
624 if ( verts[ i ].mPosition.x > brx )
626 brx = verts[ i ].mPosition.x;
628 if ( verts[ i ].mPosition.y > bry )
630 bry = verts[ i ].mPosition.y;
634 float width = brx - tlx;
635 float height = bry - tly;
636 float divWidth = TWO / width;
637 float divHeight = TWO / height;
639 // Create a buffer to render to
640 meshRecord.mBuffer = FrameBufferImage::New( width, height );
642 // We will render a quad into this buffer
643 unsigned int indices[ 6 ] = { 1, 0, 2, 2, 3, 1 };
644 PropertyBuffer quadVertices = PropertyBuffer::New( mQuadVertexFormat, 4u );
645 PropertyBuffer quadIndices = PropertyBuffer::New( mQuadIndexFormat, sizeof(indices)/sizeof(indices[0]) );
647 AtlasManager::Vertex2D vertices[ 4 ] = {
648 { Vector2( tlx + shadowOffset.x, tly + shadowOffset.y ), Vector2( ZERO, ZERO ) },
649 { Vector2( brx + shadowOffset.x, tly + shadowOffset.y ), Vector2( ONE, ZERO ) },
650 { Vector2( tlx + shadowOffset.x, bry + shadowOffset.y ), Vector2( ZERO, ONE ) },
651 { Vector2( brx + shadowOffset.x, bry + shadowOffset.y ), Vector2( ONE, ONE ) } };
653 quadVertices.SetData( vertices );
654 quadIndices.SetData( indices );
656 Geometry quadGeometry = Geometry::New();
657 quadGeometry.AddVertexBuffer( quadVertices );
658 quadGeometry.SetIndexBuffer( quadIndices );
660 Sampler sampler = Sampler::New( meshRecord.mBuffer, "sTexture" );
661 Material material = Material::New( mShader );
662 material.AddSampler( sampler );
664 Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, material );
666 // Ensure shadow is behind the text...
667 renderer.SetDepthIndex( CONTENT_DEPTH_INDEX - 1 );
668 Actor actor = Actor::New();
669 actor.AddRenderer( renderer );
670 actor.SetSize( 1.0f, 1.0f );
672 // Create a sub actor to render the source with normalized vertex positions
673 Vector< AtlasManager::Vertex2D > normVertexList;
674 for ( uint32_t i = 0; i < verts.Size(); ++i )
676 AtlasManager::Vertex2D vertex = verts[ i ];
677 vertex.mPosition.x = ( ( vertex.mPosition.x - tlx ) * divWidth ) - ONE;
678 vertex.mPosition.y = ( ( vertex.mPosition.y - tly ) * divHeight ) - ONE;
679 normVertexList.PushBack( vertex );
682 PropertyBuffer normVertices = PropertyBuffer::New( mQuadVertexFormat, normVertexList.Size() );
683 PropertyBuffer normIndices = PropertyBuffer::New( mQuadIndexFormat, meshRecord.mMesh.mIndices.Size() );
684 normVertices.SetData( const_cast< AtlasManager::Vertex2D* >( &normVertexList[ 0 ] ) );
685 normIndices.SetData( const_cast< unsigned int* >( &meshRecord.mMesh.mIndices[ 0 ] ) );
687 Geometry normGeometry = Geometry::New();
688 normGeometry.AddVertexBuffer( normVertices );
689 normGeometry.SetIndexBuffer( normIndices );
691 Material normMaterial = Material::New( mShadowShader );
692 Sampler normSampler = mGlyphManager.GetSampler( meshRecord.mAtlasId );
693 normMaterial.AddSampler( normSampler );
694 Dali::Renderer normRenderer = Dali::Renderer::New( normGeometry, normMaterial );
695 Actor subActor = Actor::New();
696 subActor.AddRenderer( normRenderer );
697 subActor.SetSize( 1.0f, 1.0f );
698 subActor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
699 subActor.SetColor( shadowColor );
701 // Create a render task to render the effect
702 RenderTask task = Stage::GetCurrent().GetRenderTaskList().CreateTask();
703 task.SetTargetFrameBuffer( meshRecord.mBuffer );
704 task.SetSourceActor( subActor );
705 task.SetClearEnabled( true );
706 task.SetClearColor( Vector4::ZERO );
707 task.SetExclusive( true );
708 task.SetRefreshRate( RenderTask::REFRESH_ONCE );
709 task.FinishedSignal().Connect( this, &AtlasRenderer::Impl::RenderComplete );
710 actor.Add( subActor );
715 void RenderComplete( RenderTask& renderTask )
717 // Disconnect and remove this single shot render task
718 renderTask.FinishedSignal().Disconnect( this, &AtlasRenderer::Impl::RenderComplete );
719 Stage::GetCurrent().GetRenderTaskList().RemoveTask( renderTask );
721 // Get the actor used for render to buffer and remove it from the parent
722 Actor renderActor = renderTask.GetSourceActor();
725 Actor parent = renderActor.GetParent();
728 parent.Remove( renderActor );
733 Actor mActor; ///< The actor parent which renders the text
734 AtlasGlyphManager mGlyphManager; ///< Glyph Manager to handle upload and caching
735 Vector< uint32_t > mImageIds; ///< A list of imageIDs used by the renderer
736 TextAbstraction::FontClient mFontClient; ///> The font client used to supply glyph information
737 Shader mShader; ///> Shader used to render drop shadow buffer textures
738 Shader mShadowShader; ///> Shader used to render drop shadow into buffer
739 std::vector< MaxBlockSize > mBlockSizes; ///> Maximum size needed to contain a glyph in a block within a new atlas
740 std::vector< uint32_t > mFace; ///> Face indices for a quad
741 Property::Map mQuadVertexFormat;
742 Property::Map mQuadIndexFormat;
745 Text::RendererPtr AtlasRenderer::New()
747 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Text::AtlasRenderer::New()\n" );
749 return Text::RendererPtr( new AtlasRenderer() );
752 Actor AtlasRenderer::Render( Text::ViewInterface& view )
754 UnparentAndReset( mImpl->mActor );
756 Length numberOfGlyphs = view.GetNumberOfGlyphs();
758 if( numberOfGlyphs > 0u )
760 Vector<GlyphInfo> glyphs;
761 glyphs.Resize( numberOfGlyphs );
763 std::vector<Vector2> positions;
764 positions.resize( numberOfGlyphs );
766 numberOfGlyphs = view.GetGlyphs( glyphs.Begin(),
770 glyphs.Resize( numberOfGlyphs );
771 positions.resize( numberOfGlyphs );
773 mImpl->AddGlyphs( positions,
776 view.GetShadowOffset(),
777 view.GetShadowColor(),
778 view.IsUnderlineEnabled(),
779 view.GetUnderlineColor(),
780 view.GetUnderlineHeight() );
783 return mImpl->mActor;
786 AtlasRenderer::AtlasRenderer()
792 AtlasRenderer::~AtlasRenderer()