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/internal/atlas-manager/atlas-manager.h>
29 #include <dali-toolkit/internal/text/line-run.h>
30 #include <dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager.h>
31 #include <dali-toolkit/internal/text/rendering/shaders/text-basic-shader.h>
32 #include <dali-toolkit/internal/text/rendering/shaders/text-bgra-shader.h>
33 //#include <dali-toolkit/internal/text/rendering/shaders/text-basic-shadow-shader.h>
36 using namespace Dali::Toolkit;
37 using namespace Dali::Toolkit::Text;
41 #if defined(DEBUG_ENABLED)
42 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_RENDERING");
45 const float ZERO( 0.0f );
46 const float HALF( 0.5f );
47 const float ONE( 1.0f );
48 const float TWO( 2.0f );
49 const uint32_t DEFAULT_ATLAS_WIDTH = 512u;
50 const uint32_t DEFAULT_ATLAS_HEIGHT = 512u;
52 #define MAKE_SHADER(A)#A
54 const char* VERTEX_SHADER = MAKE_SHADER(
55 attribute mediump vec2 aPosition;
56 attribute mediump vec2 aTexCoord;
57 uniform mediump mat4 uMvpMatrix;
58 uniform mediump vec3 uSize;
59 varying mediump vec2 vTexCoord;
63 mediump vec4 position = vec4( aPosition, 0.0, 1.0 );
64 position.xyz *= uSize;
65 gl_Position = uMvpMatrix * position;
66 vTexCoord = aTexCoord;
70 const char* FRAGMENT_SHADER = MAKE_SHADER(
71 uniform sampler2D sTexture;
72 varying mediump vec2 vTexCoord;
76 //gl_FragColor = vec4( 1.0 );
77 gl_FragColor = texture2D( sTexture, vTexCoord );
81 const char* VERTEX_SHADER_SHADOW = MAKE_SHADER(
82 attribute mediump vec2 aPosition;
83 attribute mediump vec2 aTexCoord;
84 uniform mediump vec3 uSize;
85 varying mediump vec2 vTexCoord;
89 mediump vec4 position = vec4( aPosition, 0.0, 1.0 );
90 position.xyz *= uSize;
91 gl_Position = position;
92 vTexCoord = aTexCoord;
96 const char* FRAGMENT_SHADER_SHADOW = MAKE_SHADER(
97 uniform sampler2D sTexture;
98 uniform lowp vec4 uColor;
99 varying mediump vec2 vTexCoord;
103 mediump vec4 color = texture2D( sTexture, vTexCoord );
104 gl_FragColor = vec4(uColor.rgb, uColor.a*color.r);
109 struct AtlasRenderer::Impl : public ConnectionTracker
122 AtlasManager::Mesh2D mMesh;
123 FrameBufferImage mBuffer;
132 float mUnderlinePosition;
133 float mUnderlineThickness;
134 uint32_t mMeshRecordIndex;
140 Text::GlyphIndex mIndex;
146 uint32_t mNeededBlockWidth;
147 uint32_t mNeededBlockHeight;
152 mGlyphManager = AtlasGlyphManager::Get();
153 mFontClient = TextAbstraction::FontClient::Get();
155 mQuadVertexFormat[ "aPosition" ] = Property::VECTOR2;
156 mQuadVertexFormat[ "aTexCoord" ] = Property::VECTOR2;
157 mQuadIndexFormat[ "indices" ] = Property::UNSIGNED_INTEGER;
159 mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
160 mShadowShader = Shader::New( VERTEX_SHADER_SHADOW, FRAGMENT_SHADER_SHADOW, Dali::Shader::HINT_MODIFIES_GEOMETRY );
163 void AddGlyphs( const std::vector<Vector2>& positions,
164 const Vector<GlyphInfo>& glyphs,
165 const Vector4& textColor,
166 const Vector2& shadowOffset,
167 const Vector4& shadowColor,
168 bool underlineEnabled,
169 const Vector4& underlineColor,
170 float underlineHeight )
172 AtlasManager::AtlasSlot slot;
173 std::vector< MeshRecord > meshContainer;
174 Vector< Extent > extents;
176 float currentUnderlinePosition = ZERO;
177 float currentUnderlineThickness = underlineHeight;
178 uint32_t currentBlockSize = 0;
179 FontId lastFontId = 0;
180 Style style = STYLE_NORMAL;
182 if ( fabsf( shadowOffset.x ) > Math::MACHINE_EPSILON_1 || fabsf( shadowOffset.y ) > Math::MACHINE_EPSILON_1 )
184 style = STYLE_DROP_SHADOW;
187 if ( mImageIds.Size() )
189 // Unreference any currently used glyphs
193 CalculateBlocksSize( glyphs );
195 for( uint32_t i = 0, glyphSize = glyphs.Size(); i < glyphSize; ++i )
197 const GlyphInfo& glyph = glyphs[ i ];
199 // No operation for white space
200 if ( glyph.width && glyph.height )
202 // Are we still using the same fontId as previous
203 if ( glyph.fontId != lastFontId )
205 // We need to fetch fresh font underline metrics
206 FontMetrics fontMetrics;
207 mFontClient.GetFontMetrics( glyph.fontId, fontMetrics );
208 currentUnderlinePosition = ceil( fabsf( fontMetrics.underlinePosition ) );
209 float descender = ceil( fabsf( fontMetrics.descender ) );
211 if ( underlineHeight == ZERO )
213 currentUnderlineThickness = fontMetrics.underlineThickness;
215 // Ensure underline will be at least a pixel high
216 if ( currentUnderlineThickness < ONE )
218 currentUnderlineThickness = ONE;
222 currentUnderlineThickness = ceil( currentUnderlineThickness );
226 // Clamp the underline position at the font descender and check for ( as EFL describes it ) a broken font
227 if ( currentUnderlinePosition > descender )
229 currentUnderlinePosition = descender;
231 if ( ZERO == currentUnderlinePosition )
233 // Move offset down by one ( EFL behavior )
234 currentUnderlinePosition = ONE;
238 const Vector2& position = positions[ i ];
239 AtlasManager::Mesh2D newMesh;
240 mGlyphManager.Cached( glyph.fontId, glyph.index, slot );
244 // This glyph already exists so generate mesh data plugging in our supplied position
245 mGlyphManager.GenerateMeshData( slot.mImageId, position, newMesh );
246 mImageIds.PushBack( slot.mImageId );
251 // Select correct size for new atlas if needed....?
252 if ( lastFontId != glyph.fontId )
254 for ( uint32_t j = 0; j < mBlockSizes.size(); ++j )
256 if ( mBlockSizes[ j ].mFontId == glyph.fontId )
258 currentBlockSize = j;
259 mGlyphManager.SetNewAtlasSize( DEFAULT_ATLAS_WIDTH,
260 DEFAULT_ATLAS_HEIGHT,
261 mBlockSizes[ j ].mNeededBlockWidth,
262 mBlockSizes[ j ].mNeededBlockHeight );
267 // Create a new image for the glyph
268 BufferImage bitmap = mFontClient.CreateBitmap( glyph.fontId, glyph.index );
271 // Ensure that the next image will fit into the current block size
272 bool setSize = false;
273 if ( bitmap.GetWidth() > mBlockSizes[ currentBlockSize ].mNeededBlockWidth )
276 mBlockSizes[ currentBlockSize ].mNeededBlockWidth = bitmap.GetWidth();
278 if ( bitmap.GetHeight() > mBlockSizes[ currentBlockSize ].mNeededBlockHeight )
281 mBlockSizes[ currentBlockSize ].mNeededBlockHeight = bitmap.GetHeight();
286 mGlyphManager.SetNewAtlasSize( DEFAULT_ATLAS_WIDTH,
287 DEFAULT_ATLAS_HEIGHT,
288 mBlockSizes[ currentBlockSize ].mNeededBlockWidth,
289 mBlockSizes[ currentBlockSize ].mNeededBlockHeight );
292 // Locate a new slot for our glyph
293 mGlyphManager.Add( glyph, bitmap, slot );
295 // Generate mesh data for this quad, plugging in our supplied position
298 mGlyphManager.GenerateMeshData( slot.mImageId, position, newMesh );
299 mImageIds.PushBack( slot.mImageId );
303 // Find an existing mesh data object to attach to ( or create a new one, if we can't find one using the same atlas)
304 StitchTextMesh( meshContainer,
308 position.y + glyph.yBearing,
309 currentUnderlinePosition,
310 currentUnderlineThickness,
312 lastFontId = glyph.fontId;
316 if ( underlineEnabled )
318 // Check to see if any of the text needs an underline
319 GenerateUnderlines( meshContainer, extents, underlineColor, textColor );
322 // For each MeshData object, create a mesh actor and add to the renderable actor
323 if ( meshContainer.size() )
325 for ( std::vector< MeshRecord >::iterator mIt = meshContainer.begin(); mIt != meshContainer.end(); ++mIt )
327 Actor actor = CreateMeshActor( *mIt );
329 // Create an effect if necessary
330 if ( style == STYLE_DROP_SHADOW )
332 actor.Add( GenerateShadow( *mIt, shadowOffset, shadowColor ) );
344 mActor.OffStageSignal().Connect( this, &AtlasRenderer::Impl::OffStageDisconnect );
346 #if defined(DEBUG_ENABLED)
347 Toolkit::AtlasGlyphManager::Metrics metrics = mGlyphManager.GetMetrics();
348 DALI_LOG_INFO( gLogFilter, Debug::General, "TextAtlasRenderer::GlyphManager::GlyphCount: %i, AtlasCount: %i, TextureMemoryUse: %iK\n",
350 metrics.mAtlasMetrics.mAtlasCount,
351 metrics.mAtlasMetrics.mTextureMemoryUsed / 1024 );
352 for ( uint32_t i = 0; i < metrics.mAtlasMetrics.mAtlasCount; ++i )
354 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Atlas [%i] %sPixels: %s Size: %ix%i, BlockSize: %ix%i, BlocksUsed: %i/%i\n",
355 i + 1, i > 8 ? "" : " ",
356 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mPixelFormat == Pixel::L8 ? "L8 " : "BGRA",
357 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mSize.mWidth,
358 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mSize.mHeight,
359 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mSize.mBlockWidth,
360 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mSize.mBlockHeight,
361 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mBlocksUsed,
362 metrics.mAtlasMetrics.mAtlasMetrics[ i ].mTotalBlocks );
367 Actor CreateMeshActor( const MeshRecord& meshRecord )
369 PropertyBuffer quadVertices = PropertyBuffer::New( mQuadVertexFormat, meshRecord.mMesh.mVertices.Size() );
370 PropertyBuffer quadIndices = PropertyBuffer::New( mQuadIndexFormat, meshRecord.mMesh.mIndices.Size() );
371 quadVertices.SetData( const_cast< AtlasManager::Vertex2D* >( &meshRecord.mMesh.mVertices[ 0 ] ) );
372 quadIndices.SetData( const_cast< unsigned int* >( &meshRecord.mMesh.mIndices[ 0 ] ) );
374 Geometry quadGeometry = Geometry::New();
375 quadGeometry.AddVertexBuffer( quadVertices );
376 quadGeometry.SetIndexBuffer( quadIndices );
378 Material material = mGlyphManager.GetMaterial( meshRecord.mAtlasId );
379 Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, material );
380 renderer.SetDepthIndex( 0 );
381 Actor actor = Actor::New();
382 actor.AddRenderer( renderer );
383 actor.SetSize( 1.0f, 1.0f );
384 actor.SetColor( meshRecord.mColor );
386 if ( meshRecord.mIsUnderline )
388 actor.SetColorMode( USE_OWN_COLOR );
392 actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
397 void StitchTextMesh( std::vector< MeshRecord >& meshContainer,
398 AtlasManager::Mesh2D& newMesh,
399 Vector< Extent >& extents,
400 const Vector4& color,
402 float underlinePosition,
403 float underlineThickness,
404 AtlasManager::AtlasSlot& slot )
408 float left = newMesh.mVertices[ 0 ].mPosition.x;
409 float right = newMesh.mVertices[ 1 ].mPosition.x;
411 // Check to see if there's a mesh data object that references the same atlas ?
413 for ( std::vector< MeshRecord >::iterator mIt = meshContainer.begin(); mIt != meshContainer.end(); ++mIt, ++index )
415 if ( slot.mAtlasId == mIt->mAtlasId && color == mIt->mColor )
417 // Stitch the mesh to the existing mesh and adjust any extents
418 mGlyphManager.StitchMesh( mIt->mMesh, newMesh );
419 AdjustExtents( extents,
426 underlineThickness );
431 // No mesh data object currently exists that references this atlas, so create a new one
432 MeshRecord meshRecord;
433 meshRecord.mAtlasId = slot.mAtlasId;
434 meshRecord.mMesh = newMesh;
435 meshRecord.mColor = color;
436 meshRecord.mIsUnderline = false;
437 meshContainer.push_back( meshRecord );
439 // Adjust extents for this new meshrecord
440 AdjustExtents( extents,
442 meshContainer.size() - 1u,
447 underlineThickness );
452 void AdjustExtents( Vector< Extent >& extents,
453 std::vector< MeshRecord>& meshRecords,
458 float underlinePosition,
459 float underlineThickness )
461 bool foundExtent = false;
462 for ( Vector< Extent >::Iterator eIt = extents.Begin(); eIt != extents.End(); ++eIt )
464 if ( Equals( baseLine, eIt->mBaseLine ) )
467 if ( left < eIt->mLeft )
471 if ( right > eIt->mRight )
476 if ( underlinePosition > eIt->mUnderlinePosition )
478 eIt->mUnderlinePosition = underlinePosition;
480 if ( underlineThickness > eIt->mUnderlineThickness )
482 eIt->mUnderlineThickness = underlineThickness;
490 extent.mRight = right;
491 extent.mBaseLine = baseLine;
492 extent.mUnderlinePosition = underlinePosition;
493 extent.mUnderlineThickness = underlineThickness;
494 extent.mMeshRecordIndex = index;
495 extents.PushBack( extent );
499 // Unreference any glyphs that were used with this actor
500 void OffStageDisconnect( Dali::Actor actor )
507 for ( uint32_t i = 0; i < mImageIds.Size(); ++i )
509 mGlyphManager.Remove( mImageIds[ i ] );
511 mImageIds.Resize( 0 );
514 void CalculateBlocksSize( const Vector<GlyphInfo>& glyphs )
516 MaxBlockSize maxBlockSize;
517 for ( uint32_t i = 0; i < glyphs.Size(); ++i )
519 FontId fontId = glyphs[ i ].fontId;
520 bool foundFont = false;
521 for ( uint32_t j = 0; j < mBlockSizes.size(); ++j )
523 if ( mBlockSizes[ j ].mFontId == fontId )
530 FontMetrics fontMetrics;
531 mFontClient.GetFontMetrics( fontId, fontMetrics );
532 maxBlockSize.mNeededBlockWidth = static_cast< uint32_t >( fontMetrics.height );
533 maxBlockSize.mNeededBlockHeight = static_cast< uint32_t >( fontMetrics.height );
534 maxBlockSize.mFontId = fontId;
535 mBlockSizes.push_back( maxBlockSize );
540 void GenerateUnderlines( std::vector< MeshRecord>& meshRecords,
541 Vector< Extent >& extents,
542 const Vector4& underlineColor,
543 const Vector4& textColor )
545 AtlasManager::Mesh2D newMesh;
546 unsigned short faceIndex = 0;
547 for ( Vector< Extent >::ConstIterator eIt = extents.Begin(); eIt != extents.End(); ++eIt )
549 AtlasManager::Vertex2D vert;
550 uint32_t index = eIt->mMeshRecordIndex;
551 Vector2 uv = mGlyphManager.GetAtlasSize( meshRecords[ index ].mAtlasId );
553 // Make sure we don't hit texture edge for single pixel texture ( filled pixel is in top left of every atlas )
554 float u = HALF / uv.x;
555 float v = HALF / uv.y;
556 float thickness = eIt->mUnderlineThickness;
557 float baseLine = eIt->mBaseLine + eIt->mUnderlinePosition - ( thickness * HALF );
558 float tlx = eIt->mLeft;
559 float brx = eIt->mRight;
561 vert.mPosition.x = tlx;
562 vert.mPosition.y = baseLine;
563 vert.mTexCoords.x = ZERO;
564 vert.mTexCoords.y = ZERO;
565 newMesh.mVertices.PushBack( vert );
567 vert.mPosition.x = brx;
568 vert.mPosition.y = baseLine;
569 vert.mTexCoords.x = u;
570 newMesh.mVertices.PushBack( vert );
572 vert.mPosition.x = tlx;
573 vert.mPosition.y = baseLine + thickness;
574 vert.mTexCoords.x = ZERO;
575 vert.mTexCoords.y = v;
576 newMesh.mVertices.PushBack( vert );
578 vert.mPosition.x = brx;
579 vert.mPosition.y = baseLine + thickness;
580 vert.mTexCoords.x = u;
581 newMesh.mVertices.PushBack( vert );
583 // Six indices in counter clockwise winding
584 newMesh.mIndices.PushBack( faceIndex + 1u );
585 newMesh.mIndices.PushBack( faceIndex );
586 newMesh.mIndices.PushBack( faceIndex + 2u );
587 newMesh.mIndices.PushBack( faceIndex + 2u );
588 newMesh.mIndices.PushBack( faceIndex + 3u );
589 newMesh.mIndices.PushBack( faceIndex + 1u );
592 if ( underlineColor == textColor )
594 mGlyphManager.StitchMesh( meshRecords[ index ].mMesh, newMesh );
599 record.mMesh = newMesh;
600 record.mAtlasId = meshRecords[ index ].mAtlasId;
601 record.mColor = underlineColor;
602 record.mIsUnderline = true;
603 meshRecords.push_back( record );
608 Actor GenerateShadow( MeshRecord& meshRecord,
609 const Vector2& shadowOffset,
610 const Vector4& shadowColor )
612 // Scan vertex buffer to determine width and height of effect buffer needed
613 const Vector< AtlasManager::Vertex2D >& verts = meshRecord.mMesh.mVertices;
614 float tlx = verts[ 0 ].mPosition.x;
615 float tly = verts[ 0 ].mPosition.y;
619 for ( uint32_t i = 0; i < verts.Size(); ++i )
621 if ( verts[ i ].mPosition.x < tlx )
623 tlx = verts[ i ].mPosition.x;
625 if ( verts[ i ].mPosition.y < tly )
627 tly = verts[ i ].mPosition.y;
629 if ( verts[ i ].mPosition.x > brx )
631 brx = verts[ i ].mPosition.x;
633 if ( verts[ i ].mPosition.y > bry )
635 bry = verts[ i ].mPosition.y;
639 float width = brx - tlx;
640 float height = bry - tly;
641 float divWidth = TWO / width;
642 float divHeight = TWO / height;
644 // Create a buffer to render to
645 meshRecord.mBuffer = FrameBufferImage::New( width, height );
647 // We will render a quad into this buffer
648 unsigned int indices[ 6 ] = { 1, 0, 2, 2, 3, 1 };
649 PropertyBuffer quadVertices = PropertyBuffer::New( mQuadVertexFormat, 4u );
650 PropertyBuffer quadIndices = PropertyBuffer::New( mQuadIndexFormat, sizeof(indices)/sizeof(indices[0]) );
652 AtlasManager::Vertex2D vertices[ 4 ] = {
653 { Vector2( tlx + shadowOffset.x, tly + shadowOffset.y ), Vector2( ZERO, ZERO ) },
654 { Vector2( brx + shadowOffset.x, tly + shadowOffset.y ), Vector2( ONE, ZERO ) },
655 { Vector2( tlx + shadowOffset.x, bry + shadowOffset.y ), Vector2( ZERO, ONE ) },
656 { Vector2( brx + shadowOffset.x, bry + shadowOffset.y ), Vector2( ONE, ONE ) } };
658 quadVertices.SetData( vertices );
659 quadIndices.SetData( indices );
661 Geometry quadGeometry = Geometry::New();
662 quadGeometry.AddVertexBuffer( quadVertices );
663 quadGeometry.SetIndexBuffer( quadIndices );
665 Sampler sampler = Sampler::New( meshRecord.mBuffer, "sTexture" );
666 Material material = Material::New( mShader );
667 material.AddSampler( sampler );
669 Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, material );
670 renderer.SetDepthIndex( -1 );
671 Actor actor = Actor::New();
672 actor.AddRenderer( renderer );
673 actor.SetSize( 1.0f, 1.0f );
675 // Create a sub actor to render the source with normalized vertex positions
676 Vector< AtlasManager::Vertex2D > normVertexList;
677 for ( uint32_t i = 0; i < verts.Size(); ++i )
679 AtlasManager::Vertex2D vertex = verts[ i ];
680 vertex.mPosition.x = ( ( vertex.mPosition.x - tlx ) * divWidth ) - ONE;
681 vertex.mPosition.y = ( ( vertex.mPosition.y - tly ) * divHeight ) - ONE;
682 normVertexList.PushBack( vertex );
685 PropertyBuffer normVertices = PropertyBuffer::New( mQuadVertexFormat, normVertexList.Size() );
686 PropertyBuffer normIndices = PropertyBuffer::New( mQuadIndexFormat, meshRecord.mMesh.mIndices.Size() );
687 normVertices.SetData( const_cast< AtlasManager::Vertex2D* >( &normVertexList[ 0 ] ) );
688 normIndices.SetData( const_cast< unsigned int* >( &meshRecord.mMesh.mIndices[ 0 ] ) );
690 Geometry normGeometry = Geometry::New();
691 normGeometry.AddVertexBuffer( normVertices );
692 normGeometry.SetIndexBuffer( normIndices );
694 Material normMaterial = Material::New( mShadowShader );
695 Sampler normSampler = mGlyphManager.GetSampler( meshRecord.mAtlasId );
696 normMaterial.AddSampler( normSampler );
697 Dali::Renderer normRenderer = Dali::Renderer::New( normGeometry, normMaterial );
698 Actor subActor = Actor::New();
699 subActor.AddRenderer( normRenderer );
700 subActor.SetSize( 1.0f, 1.0f );
701 subActor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR );
702 subActor.SetColor( shadowColor );
704 // Create a render task to render the effect
705 RenderTask task = Stage::GetCurrent().GetRenderTaskList().CreateTask();
706 task.SetTargetFrameBuffer( meshRecord.mBuffer );
707 task.SetSourceActor( subActor );
708 task.SetClearEnabled( true );
709 task.SetClearColor( Vector4::ZERO );
710 task.SetExclusive( true );
711 task.SetRefreshRate( RenderTask::REFRESH_ONCE );
712 task.FinishedSignal().Connect( this, &AtlasRenderer::Impl::RenderComplete );
713 actor.Add( subActor );
718 void RenderComplete( RenderTask& renderTask )
720 // Disconnect and remove this single shot render task
721 renderTask.FinishedSignal().Disconnect( this, &AtlasRenderer::Impl::RenderComplete );
722 Stage::GetCurrent().GetRenderTaskList().RemoveTask( renderTask );
724 // Get the actor used for render to buffer and remove it from the parent
725 Actor renderActor = renderTask.GetSourceActor();
728 Actor parent = renderActor.GetParent();
731 parent.Remove( renderActor );
736 Actor mActor; ///< The actor parent which renders the text
737 AtlasGlyphManager mGlyphManager; ///< Glyph Manager to handle upload and caching
738 Vector< uint32_t > mImageIds; ///< A list of imageIDs used by the renderer
739 TextAbstraction::FontClient mFontClient; ///> The font client used to supply glyph information
740 Shader mShader; ///> Shader used to render drop shadow buffer textures
741 Shader mShadowShader; ///> Shader used to render drop shadow into buffer
742 std::vector< MaxBlockSize > mBlockSizes; ///> Maximum size needed to contain a glyph in a block within a new atlas
743 std::vector< uint32_t > mFace; ///> Face indices for a quad
744 Property::Map mQuadVertexFormat;
745 Property::Map mQuadIndexFormat;
748 Text::RendererPtr AtlasRenderer::New()
750 DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Text::AtlasRenderer::New()\n" );
752 return Text::RendererPtr( new AtlasRenderer() );
755 Actor AtlasRenderer::Render( Text::ViewInterface& view )
757 UnparentAndReset( mImpl->mActor );
759 Length numberOfGlyphs = view.GetNumberOfGlyphs();
761 if( numberOfGlyphs > 0u )
763 Vector<GlyphInfo> glyphs;
764 glyphs.Resize( numberOfGlyphs );
766 std::vector<Vector2> positions;
767 positions.resize( numberOfGlyphs );
769 numberOfGlyphs = view.GetGlyphs( glyphs.Begin(),
773 glyphs.Resize( numberOfGlyphs );
774 positions.resize( numberOfGlyphs );
776 mImpl->AddGlyphs( positions,
779 view.GetShadowOffset(),
780 view.GetShadowColor(),
781 view.IsUnderlineEnabled(),
782 view.GetUnderlineColor(),
783 view.GetUnderlineHeight() );
786 return mImpl->mActor;
789 AtlasRenderer::AtlasRenderer()
795 AtlasRenderer::~AtlasRenderer()