Use pre-multiplied alpha format in GradientRenderer 16/68016/2
authorXiangyin Ma <x1.ma@samsung.com>
Fri, 29 Apr 2016 16:33:44 +0000 (17:33 +0100)
committerXiangyin Ma <x1.ma@samsung.com>
Fri, 29 Apr 2016 16:40:20 +0000 (17:40 +0100)
Change-Id: Ic363699481c40dcb51c3ba9507be6f7458eb6d8c

dali-toolkit/internal/controls/renderers/gradient/gradient-renderer.cpp

index eec8029..6b35829 100644 (file)
@@ -183,6 +183,7 @@ GradientRenderer::GradientRenderer( RendererFactoryCache& factoryCache )
 : ControlRenderer( factoryCache ),
   mGradientType( LINEAR )
 {
+  mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
 }
 
 GradientRenderer::~GradientRenderer()
@@ -275,7 +276,17 @@ void GradientRenderer::DoCreatePropertyMap( Property::Map& map ) const
   for( unsigned int i=0; i<stops.Count(); i++ )
   {
     offsets.PushBack( stops[i].mOffset );
-    colors.PushBack( stops[i].mStopColor );
+    if( EqualsZero(stops[i].mStopColor.a) )
+    {
+      colors.PushBack( Vector4::ZERO );
+    }
+    else
+    {
+      colors.PushBack( Vector4( stops[i].mStopColor.r / stops[i].mStopColor.a,
+                                stops[i].mStopColor.g / stops[i].mStopColor.a,
+                                stops[i].mStopColor.b / stops[i].mStopColor.a,
+                                stops[i].mStopColor.a));
+    }
   }
 
   map.Insert( STOP_OFFSET_NAME, offsets );
@@ -381,7 +392,7 @@ bool GradientRenderer::NewGradient(Type gradientType, const Property::Map& prope
       {
         if( (colorArray->GetElementAt(i)).Get(color) )
         {
-          mGradient->AddStop( offsetArray[i], color);
+          mGradient->AddStop( offsetArray[i], Vector4(color.r*color.a, color.g*color.a, color.b*color.a, color.a));
           numValidStop++;
         }
       }