- /*
+/*
* Copyright (c) 2015 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
// EXTERNAL INCLUDES
#include <dali/integration-api/debug.h>
-#define MAKE_SHADER(A)#A
-
namespace
{
Debug::Filter* gLogFilter = Debug::Filter::New(Debug::Concise, true, "LOG_TEXT_RENDERING");
#endif
-const char* VERTEX_SHADER = MAKE_SHADER(
-attribute mediump vec2 aPosition;
-attribute mediump vec2 aTexCoord;
-uniform mediump mat4 uMvpMatrix;
-varying mediump vec2 vTexCoord;
-
-void main()
-{
- mediump vec4 position = vec4( aPosition, 0.0, 1.0 );
- gl_Position = uMvpMatrix * position;
- vTexCoord = aTexCoord;
-}
-);
-
-const char* FRAGMENT_SHADER = MAKE_SHADER(
-uniform sampler2D sTexture;
-varying mediump vec2 vTexCoord;
-
-void main()
-{
- gl_FragColor = texture2D( sTexture, vTexCoord );
-}
-);
-
-const char* VERTEX_SHADER_SHADOW = MAKE_SHADER(
-attribute mediump vec2 aPosition;
-attribute mediump vec2 aTexCoord;
-varying mediump vec2 vTexCoord;
-
-void main()
-{
- mediump vec4 position = vec4( aPosition, 0.0, 1.0 );
- gl_Position = position;
- vTexCoord = aTexCoord;
-}
-);
-
-const char* FRAGMENT_SHADER_SHADOW = MAKE_SHADER(
-uniform sampler2D sTexture;
-uniform lowp vec4 uColor;
-varying mediump vec2 vTexCoord;
-
-void main()
-{
- mediump vec4 color = texture2D( sTexture, vTexCoord );
- gl_FragColor = vec4(uColor.rgb, uColor.a*color.r);
-}
-);
-
} // unnamed namespace
namespace Dali
AtlasGlyphManager::AtlasGlyphManager()
{
mAtlasManager = Dali::Toolkit::AtlasManager::New();
- mEffectBufferShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
- mShadowShader = Shader::New( VERTEX_SHADER_SHADOW, FRAGMENT_SHADER_SHADOW, Dali::Shader::HINT_MODIFIES_GEOMETRY );
}
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 );
- mAtlasManager.Add( bitmap, slot );
+ // 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
+ Dali::Texture atlas = mAtlasManager.GetAtlasContainer( slot.mAtlasId );
+ TextureSet textureSet = TextureSet::New();
+ textureSet.SetTexture( 0u, atlas );
+ mAtlasManager.SetTextures( slot.mAtlasId, textureSet );
+ }
GlyphRecordEntry record;
record.mIndex = glyph.index;
mAtlasManager.GenerateMeshData( imageId, position, mesh, false );
}
-void AtlasGlyphManager::StitchMesh( Toolkit::AtlasManager::Mesh2D& first,
- const Toolkit::AtlasManager::Mesh2D& second )
-{
- mAtlasManager.StitchMesh( first, second );
-}
-
-bool AtlasGlyphManager::Cached( Text::FontId fontId,
+bool AtlasGlyphManager::IsCached( Text::FontId fontId,
Text::GlyphIndex index,
Dali::Toolkit::AtlasManager::AtlasSlot& slot )
{
}
}
-Material AtlasGlyphManager::GetMaterial( uint32_t atlasId ) const
-{
- return mAtlasManager.GetMaterial( atlasId );
-}
-
-Sampler AtlasGlyphManager::GetSampler( uint32_t atlasId ) const
+TextureSet AtlasGlyphManager::GetTextures( uint32_t atlasId ) const
{
- return mAtlasManager.GetSampler( atlasId );
+ return mAtlasManager.GetTextures( atlasId );
}
AtlasGlyphManager::~AtlasGlyphManager()