X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Frendering%2Fatlas%2Ftext-atlas-renderer.cpp;h=80a11115ad11369bbf2f58caa54a179439f0e724;hb=70510385d88cfbd5c232117d8436ca74c523e172;hp=2fe54b0a9ce9e7edd54329f70ae0c4d9488c7d59;hpb=1710c1317e96351975f49bd208314f573021ae54;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 2fe54b0..80a1111 100755 --- a/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp +++ b/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp @@ -31,6 +31,7 @@ #include #include #include +#include using namespace Dali; using namespace Dali::Toolkit; @@ -42,52 +43,6 @@ namespace Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, 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 highp 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 lowp vec4 textColorAnimatable; -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 * textColorAnimatable.rgb, uColor.a * vColor.a * textColorAnimatable.a * color.r ); -} -); - -const char* FRAGMENT_SHADER_RGBA = MAKE_SHADER( -uniform lowp vec4 uColor; -uniform lowp vec4 textColorAnimatable; -uniform sampler2D sTexture; -varying mediump vec2 vTexCoord; - -void main() -{ - gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor * textColorAnimatable; -} -); - const float ZERO( 0.0f ); const float HALF( 0.5f ); const float ONE( 1.0f ); @@ -371,7 +326,7 @@ struct AtlasRenderer::Impl mActor = Actor::New(); mActor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); mActor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); - mActor.SetSize( textSize ); + mActor.SetProperty( Actor::Property::SIZE, textSize ); mActor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR ); } @@ -549,7 +504,8 @@ struct AtlasRenderer::Impl } // Move the origin (0,0) of the mesh to the center of the actor - const Vector2 position = *( positionsBuffer + i ) - halfTextSize - lineOffsetPosition; + const Vector2& temp = *( positionsBuffer + i ); + const Vector2 position = Vector2( roundf( temp.x ), temp.y ) - halfTextSize - lineOffsetPosition; // roundf() avoids pixel alignment issues. if ( 0u != slot.mImageId ) // invalid slot id, glyph has failed to be added to atlas { @@ -678,7 +634,7 @@ struct AtlasRenderer::Impl Actor CreateMeshActor( Actor textControl, Property::Index animatablePropertyIndex, const Vector4& defaultColor, const MeshRecord& meshRecord, const Vector2& actorSize, Style style ) { - PropertyBuffer quadVertices = PropertyBuffer::New( mQuadVertexFormat ); + VertexBuffer quadVertices = VertexBuffer::New( mQuadVertexFormat ); quadVertices.SetData( const_cast< AtlasManager::Vertex2D* >( &meshRecord.mMesh.mVertices[ 0 ] ), meshRecord.mMesh.mVertices.Size() ); Geometry quadGeometry = Geometry::New(); @@ -695,7 +651,7 @@ struct AtlasRenderer::Impl // The glyph is an emoji and is not a shadow. if( !mShaderRgba ) { - mShaderRgba = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_RGBA ); + mShaderRgba = Shader::New( SHADER_TEXT_ATLAS_SHADER_VERT, SHADER_TEXT_ATLAS_RGBA_SHADER_FRAG ); } shader = mShaderRgba; } @@ -704,7 +660,7 @@ struct AtlasRenderer::Impl // The glyph is text or a shadow. if( !mShaderL8 ) { - mShaderL8 = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER_L8 ); + mShaderL8 = Shader::New( SHADER_TEXT_ATLAS_SHADER_VERT, SHADER_TEXT_ATLAS_L8_SHADER_FRAG ); } shader = mShaderL8; } @@ -742,7 +698,7 @@ struct AtlasRenderer::Impl // Keep all of the origins aligned actor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); actor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); - actor.SetSize( actorSize ); + actor.SetProperty( Actor::Property::SIZE, actorSize ); actor.RegisterProperty("uOffset", Vector2::ZERO ); actor.SetProperty( Actor::Property::COLOR_MODE, USE_OWN_MULTIPLY_PARENT_COLOR );