[4.0] Fixed an issue where the text would multiply the alpha value twice 83/162083/4
authorJinho, Lee <jeano.lee@samsung.com>
Wed, 29 Nov 2017 05:10:54 +0000 (14:10 +0900)
committerJinho, Lee <jeano.lee@samsung.com>
Wed, 29 Nov 2017 08:14:20 +0000 (17:14 +0900)
Change-Id: I40ea8666026d00ec074a8b555ceb75285366a213

dali-toolkit/internal/text/rendering/text-typesetter.cpp
dali-toolkit/internal/text/text-scroller.cpp
dali-toolkit/internal/visuals/text/text-visual.cpp

index dcd803c..410b782 100755 (executable)
@@ -221,7 +221,7 @@ void TypesetGlyph( GlyphData& data,
           {
             // Check alpha of overlapped pixels
             uint8_t& currentAlpha = *( bitmapBuffer + verticalOffset + xOffsetIndex );
-            uint8_t newAlpha = static_cast<uint8_t>( color->a * static_cast<float>( alpha ) );
+            uint8_t newAlpha = static_cast<uint8_t>( static_cast<float>( alpha ) );
 
             // For any pixel overlapped with the pixel in previous glyphs, make sure we don't
             // overwrite a previous bigger alpha with a smaller alpha (in order to avoid
index f8089a2..6f57700 100644 (file)
@@ -97,7 +97,6 @@ const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
       discard;\n
     \n
     mediump vec4 textTexture = texture2D( sTexture, vTexCoord );\n
-    textTexture.rgb *= mix( 1.0, textTexture.a, preMultipliedAlpha );\n
     \n
     gl_FragColor = textTexture * uColor * visualMixColor();
   }\n
index f5817ea..be9d505 100755 (executable)
@@ -332,6 +332,15 @@ Dali::Property::Index StringKeyToIndexKey( const std::string& stringKey )
   return result;
 }
 
+void TextColorConstraint( Vector4& current, const PropertyInputContainer& inputs )
+{
+  Vector4 color = inputs[0]->GetVector4();
+  current.r = color.r * color.a;
+  current.g = color.g * color.a;
+  current.b = color.b * color.a;
+  current.a = color.a;
+}
+
 } // unnamed namespace
 
 TextVisualPtr TextVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
@@ -477,7 +486,7 @@ void TextVisual::DoSetOnStage( Actor& actor )
     // Create constraint for the animatable text's color Property with uTextColorAnimatable in the renderer.
     if( shaderTextColorIndex != Property::INVALID_INDEX )
     {
-      Constraint constraint = Constraint::New<Vector4>( mImpl->mRenderer, shaderTextColorIndex, EqualToConstraint() );
+      Constraint constraint = Constraint::New<Vector4>( mImpl->mRenderer, shaderTextColorIndex, TextColorConstraint );
       constraint.AddSource( Source( actor, mAnimatableTextColorPropertyIndex ) );
       constraint.Apply();
     }