- /*
+/*
* Copyright (c) 2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
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 sampler2D sTexture;
-varying mediump vec2 vTexCoord;
-
-void main()
-{
- gl_FragColor = texture2D( sTexture, vTexCoord );
-}
-);
-
} // unnamed namespace
namespace Dali
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 BufferImage& bitmap,
+ 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 material details for the atlas
- Dali::Atlas atlas = mAtlasManager.GetAtlasContainer( slot.mAtlasId );
- Pixel::Format pixelFormat = mAtlasManager.GetPixelFormat( slot.mAtlasId );
- Material material = Material::New( pixelFormat == Pixel::L8 ? mShaderL8 : mShaderRgba );
- material.AddTexture( atlas, "sTexture" );
- mAtlasManager.SetMaterial( slot.mAtlasId, material );
+ // A new atlas was created so set the texture set details for the atlas
+ Dali::Texture atlas = mAtlasManager.GetAtlasContainer( slot.mAtlasId );
+ TextureSet textureSet = TextureSet::New();
+ textureSet.SetTexture( 0u, atlas );
+ mAtlasManager.SetTextures( slot.mAtlasId, textureSet );
}
GlyphRecordEntry record;
}
}
-Material AtlasGlyphManager::GetMaterial( uint32_t atlasId ) const
+TextureSet AtlasGlyphManager::GetTextures( uint32_t atlasId ) const
{
- return mAtlasManager.GetMaterial( atlasId );
+ return mAtlasManager.GetTextures( atlasId );
}
AtlasGlyphManager::~AtlasGlyphManager()