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%2Ftext-atlas-renderer.cpp;h=c3663dd3ddc329b1d8d022dc375f5ad725d4b831;hp=69416c12486669417fe09e64b0517fba18f28052;hb=51bd29a1b76ba44dd3b0cc34db1193ab83fa7661;hpb=dfebb1e3da197e21bd7f4424ab65884b98f42fea 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 69416c1..c3663dd 100644 --- a/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp +++ b/dali-toolkit/internal/text/rendering/atlas/text-atlas-renderer.cpp @@ -24,6 +24,7 @@ #include #include #include +#include // INTERNAL INCLUDES #include @@ -64,6 +65,7 @@ void main() 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; @@ -71,18 +73,19 @@ 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 ); + gl_FragColor = vec4( vColor.rgb * uColor.rgb * textColorAnimatable.rgb, 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; + gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor * textColorAnimatable; } ); @@ -208,6 +211,8 @@ struct AtlasRenderer::Impl } void AddGlyphs( Text::ViewInterface& view, + Actor textControl, + Property::Index animatablePropertyIndex, const Vector& positions, const Vector& glyphs, const Vector4& defaultColor, @@ -451,6 +456,7 @@ struct AtlasRenderer::Impl mActor.SetParentOrigin( ParentOrigin::TOP_LEFT ); mActor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); mActor.SetSize( textSize ); + mActor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR ); } for( std::vector< MeshRecord >::iterator it = meshContainer.begin(), @@ -459,7 +465,7 @@ struct AtlasRenderer::Impl { MeshRecord& meshRecord = *it; - Actor actor = CreateMeshActor( meshRecord, textSize, STYLE_NORMAL ); + Actor actor = CreateMeshActor( textControl, animatablePropertyIndex, defaultColor, meshRecord, textSize, STYLE_NORMAL ); // Whether the actor has renderers. const bool hasRenderer = actor.GetRendererCount() > 0u; @@ -479,7 +485,7 @@ struct AtlasRenderer::Impl vertex.mColor = shadowColor; } - Actor shadowActor = CreateMeshActor( meshRecord, textSize, STYLE_DROP_SHADOW ); + Actor shadowActor = CreateMeshActor(textControl, animatablePropertyIndex, defaultColor, meshRecord, textSize, STYLE_DROP_SHADOW ); #if defined(DEBUG_ENABLED) shadowActor.SetName( "Text Shadow renderable actor" ); #endif @@ -530,7 +536,8 @@ struct AtlasRenderer::Impl mTextCache.Resize( 0 ); } - Actor CreateMeshActor( const MeshRecord& meshRecord, const Vector2& actorSize, Style style ) + Actor CreateMeshActor( Actor textControl, Property::Index animatablePropertyIndex, const Vector4& defaultColor, const MeshRecord& meshRecord, + const Vector2& actorSize, Style style ) { PropertyBuffer quadVertices = PropertyBuffer::New( mQuadVertexFormat ); quadVertices.SetData( const_cast< AtlasManager::Vertex2D* >( &meshRecord.mMesh.mVertices[ 0 ] ), meshRecord.mMesh.mVertices.Size() ); @@ -563,21 +570,42 @@ struct AtlasRenderer::Impl shader = mShaderL8; } + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "defaultColor[%f, %f, %f, %f ]\n", defaultColor.r, defaultColor.g, defaultColor.b, defaultColor.a ); + + Dali::Property::Index shaderTextColorIndex = shader.RegisterProperty( "textColorAnimatable", defaultColor ); + + if ( animatablePropertyIndex != Property::INVALID_INDEX ) + { + // create constraint for the animatable text's color Property with textColorAnimatable in the shader. + if( shaderTextColorIndex ) + { + Constraint constraint = Constraint::New( shader, shaderTextColorIndex, EqualToConstraint() ); + constraint.AddSource( Source( textControl, animatablePropertyIndex ) ); + constraint.Apply(); + } + } + else + { + // If not animating the text colour then set to 1's so shader uses the current vertex color + shader.RegisterProperty( "textColorAnimatable", Vector4(1.0, 1.0, 1.0, 1.0 ) ); + } + 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) actor.SetName( "Text renderable actor" ); #endif actor.AddRenderer( renderer ); - // Keep all of the origins aligned actor.SetParentOrigin( ParentOrigin::TOP_LEFT ); actor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); actor.SetSize( actorSize ); actor.RegisterProperty("uOffset", Vector2::ZERO ); + actor.SetColorMode( USE_OWN_MULTIPLY_PARENT_COLOR ); return actor; } @@ -812,6 +840,8 @@ Text::RendererPtr AtlasRenderer::New() } Actor AtlasRenderer::Render( Text::ViewInterface& view, + Actor textControl, + Property::Index animatablePropertyIndex, float& alignmentOffset, int depth ) { @@ -843,6 +873,8 @@ Actor AtlasRenderer::Render( Text::ViewInterface& view, const Vector4& defaultColor = view.GetTextColor(); mImpl->AddGlyphs( view, + textControl, + animatablePropertyIndex, positions, glyphs, defaultColor,