X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Frendering%2Fatlas%2Fatlas-glyph-manager-impl.cpp;h=957fd8eec63c20cb36bcf9fa9674b92accc928e7;hp=12d39a51b30532f3c176abd91db7e2a70442c9f0;hb=bef7b82cd945f4d2fd3b4d776184c1fc0851c8c6;hpb=514c0aa48eab20fd3cbe0d687ec8e93f82e61e51 diff --git a/dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager-impl.cpp b/dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager-impl.cpp index 12d39a5..957fd8e 100644 --- a/dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager-impl.cpp +++ b/dali-toolkit/internal/text/rendering/atlas/atlas-glyph-manager-impl.cpp @@ -27,50 +27,6 @@ namespace Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_RENDERING"); #endif -#define MAKE_SHADER(A)#A - -const char* VERTEX_SHADER = MAKE_SHADER( -attribute mediump vec2 aPosition; -attribute mediump vec2 aTexCoord; -attribute mediump vec4 aColor; -uniform mediump vec2 uOffset; -uniform mediump mat4 uMvpMatrix; -varying mediump vec2 vTexCoord; -varying mediump vec4 vColor; - -void main() -{ - mediump vec4 position = vec4( aPosition.xy + uOffset, 0.0, 1.0 ); - gl_Position = uMvpMatrix * position; - vTexCoord = aTexCoord; - vColor = aColor; -} -); - -const char* FRAGMENT_SHADER_L8 = MAKE_SHADER( -uniform lowp vec4 uColor; -uniform sampler2D sTexture; -varying mediump vec2 vTexCoord; -varying mediump vec4 vColor; - -void main() -{ - mediump vec4 color = texture2D( sTexture, vTexCoord ); - gl_FragColor = vec4( vColor.rgb * uColor.rgb, vColor.a * uColor.a * color.r ); -} -); - -const char* FRAGMENT_SHADER_RGBA = MAKE_SHADER( -uniform lowp vec4 uColor; -uniform sampler2D sTexture; -varying mediump vec2 vTexCoord; - -void main() -{ - gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor; -} -); - } // unnamed namespace namespace Dali @@ -84,17 +40,18 @@ namespace Internal AtlasGlyphManager::AtlasGlyphManager() { - mShaderL8 = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_L8 ); - mShaderRgba = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_RGBA ); mAtlasManager = Dali::Toolkit::AtlasManager::New(); } void AtlasGlyphManager::Add( const Text::GlyphInfo& glyph, + const uint32_t outlineWidth, const PixelData& bitmap, Dali::Toolkit::AtlasManager::AtlasSlot& slot ) { DALI_LOG_INFO( gLogFilter, Debug::General, "Added glyph, font: %d index: %d\n", glyph.fontId, glyph.index ); + // If glyph added to an existing or new atlas then a new glyph record is required. + // Check if an existing atlas will fit the image, create a new one if required. if ( mAtlasManager.Add( bitmap, slot ) ) { // A new atlas was created so set the texture set details for the atlas @@ -106,6 +63,7 @@ void AtlasGlyphManager::Add( const Text::GlyphInfo& glyph, GlyphRecordEntry record; record.mIndex = glyph.index; + record.mOutlineWidth = outlineWidth; record.mImageId = slot.mImageId; record.mCount = 1; @@ -142,6 +100,7 @@ void AtlasGlyphManager::GenerateMeshData( uint32_t imageId, bool AtlasGlyphManager::IsCached( Text::FontId fontId, Text::GlyphIndex index, + uint32_t outlineWidth, Dali::Toolkit::AtlasManager::AtlasSlot& slot ) { for ( std::vector< FontGlyphRecord >::iterator fontGlyphRecordIt = mFontGlyphRecords.begin(); @@ -154,7 +113,7 @@ bool AtlasGlyphManager::IsCached( Text::FontId fontId, glyphRecordIt != fontGlyphRecordIt->mGlyphRecords.End(); ++glyphRecordIt ) { - if ( glyphRecordIt->mIndex == index ) + if ( glyphRecordIt->mIndex == index && glyphRecordIt->mOutlineWidth == outlineWidth ) { slot.mImageId = glyphRecordIt->mImageId; slot.mAtlasId = mAtlasManager.GetAtlas( slot.mImageId ); @@ -215,7 +174,7 @@ const Toolkit::AtlasGlyphManager::Metrics& AtlasGlyphManager::GetMetrics() return mMetrics; } -void AtlasGlyphManager::AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, int32_t delta ) +void AtlasGlyphManager::AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, uint32_t outlineWidth, int32_t delta ) { if( 0 != delta ) { @@ -231,7 +190,7 @@ void AtlasGlyphManager::AdjustReferenceCount( Text::FontId fontId, Text::GlyphIn glyphRecordIt != fontGlyphRecordIt->mGlyphRecords.End(); ++glyphRecordIt ) { - if ( glyphRecordIt->mIndex == index ) + if ( glyphRecordIt->mIndex == index && glyphRecordIt->mOutlineWidth == outlineWidth ) { glyphRecordIt->mCount += delta; DALI_ASSERT_DEBUG( glyphRecordIt->mCount >= 0 && "Glyph ref-count should not be negative" ); @@ -257,12 +216,6 @@ TextureSet AtlasGlyphManager::GetTextures( uint32_t atlasId ) const return mAtlasManager.GetTextures( atlasId ); } -Shader AtlasGlyphManager::GetShader( uint32_t atlasId ) const -{ - Pixel::Format pixelFormat = mAtlasManager.GetPixelFormat( atlasId ); - return pixelFormat == Pixel::L8 ? mShaderL8 : mShaderRgba; -} - AtlasGlyphManager::~AtlasGlyphManager() { // mAtlasManager handle is automatically released here