X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Frendering%2Fatlas%2Ftext-atlas-renderer.cpp;h=437758c5294c4503e7c85a38178fc5438d1e40d7;hb=7bc9bb47cb9c552982e9144b202861190eeadc96;hp=7d17847c56b1527886302e97d9fc9f1c9533cece;hpb=62bf58132aff475e1db6416fe72d74101c0a2934;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 7d17847..437758c 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 ); @@ -141,7 +141,6 @@ struct AtlasRenderer::Impl mQuadVertexFormat[ "aPosition" ] = Property::VECTOR2; mQuadVertexFormat[ "aTexCoord" ] = Property::VECTOR2; mQuadVertexFormat[ "aColor" ] = Property::VECTOR4; - mQuadIndexFormat[ "indices" ] = Property::INTEGER; } bool IsGlyphUnderlined( GlyphIndex index, @@ -166,7 +165,9 @@ struct AtlasRenderer::Impl void AddGlyphs( Text::ViewInterface& view, const Vector& positions, const Vector& glyphs, - const Vector& colors, + const Vector4& defaultColor, + const Vector4* const colorsBuffer, + const ColorIndex* const colorIndicesBuffer, int depth ) { AtlasManager::AtlasSlot slot; @@ -176,7 +177,7 @@ struct AtlasRenderer::Impl mDepth = depth; const Vector2& actorSize( view.GetControlSize() ); - const Vector2& textSize( view.GetActualSize() ); + const Vector2& textSize( view.GetLayoutSize() ); const Vector2 halfTextSize( textSize * 0.5f ); const Vector2& shadowOffset( view.GetShadowOffset() ); const Vector4& shadowColor( view.GetShadowColor() ); @@ -184,6 +185,8 @@ struct AtlasRenderer::Impl 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 underlineRuns; @@ -212,7 +215,6 @@ struct AtlasRenderer::Impl 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 ) { @@ -287,7 +289,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]; @@ -352,7 +354,8 @@ struct AtlasRenderer::Impl } // 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; @@ -430,6 +433,9 @@ struct AtlasRenderer::Impl 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; } } @@ -480,17 +486,17 @@ struct AtlasRenderer::Impl Actor CreateMeshActor( const MeshRecord& meshRecord, const Vector2& actorSize ) { PropertyBuffer quadVertices = PropertyBuffer::New( mQuadVertexFormat ); - PropertyBuffer quadIndices = PropertyBuffer::New( mQuadIndexFormat ); quadVertices.SetData( const_cast< AtlasManager::Vertex2D* >( &meshRecord.mMesh.mVertices[ 0 ] ), meshRecord.mMesh.mVertices.Size() ); - quadIndices.SetData( const_cast< unsigned int* >( &meshRecord.mMesh.mIndices[ 0 ] ), meshRecord.mMesh.mIndices.Size() ); Geometry quadGeometry = Geometry::New(); quadGeometry.AddVertexBuffer( quadVertices ); - quadGeometry.SetIndexBuffer( quadIndices ); + quadGeometry.SetIndexBuffer( &meshRecord.mMesh.mIndices[0], meshRecord.mMesh.mIndices.Size() ); - Material material = mGlyphManager.GetMaterial( meshRecord.mAtlasId ); - Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, material ); - renderer.SetProperty( Dali::Renderer::Property::BLENDING_MODE, BlendingMode::ON ); + 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) @@ -501,7 +507,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; @@ -684,22 +689,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 @@ -711,8 +720,6 @@ struct AtlasRenderer::Impl newMesh.mIndices.PushBack( faceIndex + 1u ); faceIndex += 4; - vert.mColor = underlineColor; - Toolkit::Internal::AtlasMeshFactory::AppendMesh( meshRecords[ index ].mMesh, newMesh ); } } @@ -723,7 +730,6 @@ struct AtlasRenderer::Impl 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 }; @@ -736,6 +742,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(); @@ -748,23 +756,24 @@ Actor AtlasRenderer::Render( Text::ViewInterface& view, int depth ) Vector positions; positions.Resize( numberOfGlyphs ); - Vector 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. */