X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Frendering%2Fatlas%2Ftext-atlas-renderer.cpp;h=5ba07cee2b7c76670238a5d72a9fbcd2b347cf49;hb=d00a250741411c386d988e7ac34525cf94a1918e;hp=2db0faa6a6c957260b4570098b66e537d72f5c2f;hpb=6991753931a9a5b8a6b253c5e9e1541556239d1b;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp b/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp index 2db0faa..5ba07ce 100644 --- a/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp +++ b/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. @@ -19,10 +19,10 @@ #include // EXTERNAL INCLUDES -#include -#include -#include +#include +#include #include +#include // INTERNAL INCLUDES #include @@ -38,7 +38,7 @@ using namespace Dali::Toolkit::Text; 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 ); @@ -176,7 +176,6 @@ struct AtlasRenderer::Impl TextCacheEntry textCacheEntry; mDepth = depth; - const Vector2& actorSize( view.GetControlSize() ); const Vector2& textSize( view.GetLayoutSize() ); const Vector2 halfTextSize( textSize * 0.5f ); const Vector2& shadowOffset( view.GetShadowOffset() ); @@ -289,7 +288,7 @@ struct AtlasRenderer::Impl } // 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]; @@ -393,6 +392,15 @@ struct AtlasRenderer::Impl // For each MeshData object, create a mesh actor and add to the renderable actor if( !meshContainer.empty() ) { + if( !mActor ) + { + // Create a container actor to act as a common parent for text and shadow, to avoid color inheritence issues. + mActor = Actor::New(); + mActor.SetParentOrigin( ParentOrigin::TOP_LEFT ); + mActor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mActor.SetSize( textSize ); + } + for( std::vector< MeshRecord >::iterator it = meshContainer.begin(), endIt = meshContainer.end(); it != endIt; ++it ) @@ -401,8 +409,12 @@ struct AtlasRenderer::Impl Actor actor = CreateMeshActor( meshRecord, textSize ); + // Whether the actor has renderers. + const bool hasRenderer = actor.GetRendererCount() > 0u; + // Create an effect if necessary - if( style == STYLE_DROP_SHADOW ) + if( hasRenderer && + ( style == STYLE_DROP_SHADOW ) ) { // Change the color of the vertices. for( Vector::Iterator vIt = meshRecord.mMesh.mVertices.Begin(), @@ -415,36 +427,22 @@ struct AtlasRenderer::Impl vertex.mColor = shadowColor; } - // Create a container actor to act as a common parent for text and shadow, to avoid color inheritence issues. - Actor containerActor = Actor::New(); - containerActor.SetParentOrigin( ParentOrigin::CENTER ); - containerActor.SetSize( actorSize ); - Actor shadowActor = CreateMeshActor( meshRecord, textSize ); #if defined(DEBUG_ENABLED) shadowActor.SetName( "Text Shadow renderable actor" ); #endif // Offset shadow in x and y shadowActor.RegisterProperty("uOffset", shadowOffset ); - if( actor.GetRendererCount() ) - { - Dali::Renderer renderer( shadowActor.GetRendererAt( 0 ) ); - int depthIndex = renderer.GetProperty(Dali::Renderer::Property::DEPTH_INDEX); - renderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, depthIndex - 1 ); - containerActor.Add( shadowActor ); - containerActor.Add( actor ); - actor = containerActor; - } + Dali::Renderer renderer( shadowActor.GetRendererAt( 0 ) ); + int depthIndex = renderer.GetProperty(Dali::Renderer::Property::DEPTH_INDEX); + renderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, depthIndex - 1 ); + mActor.Add( shadowActor ); } - if( mActor ) + if( hasRenderer ) { mActor.Add( actor ); } - else - { - mActor = actor; - } } } #if defined(DEBUG_ENABLED) @@ -504,7 +502,6 @@ struct AtlasRenderer::Impl // 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; @@ -687,22 +684,26 @@ struct AtlasRenderer::Impl 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 @@ -714,8 +715,6 @@ struct AtlasRenderer::Impl newMesh.mIndices.PushBack( faceIndex + 1u ); faceIndex += 4; - vert.mColor = underlineColor; - Toolkit::Internal::AtlasMeshFactory::AppendMesh( meshRecords[ index ].mMesh, newMesh ); } } @@ -738,6 +737,8 @@ Text::RendererPtr AtlasRenderer::New() 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();