[dali_2.1.38] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / image / image-visual.cpp
index ef71786..87d6ea6 100644 (file)
@@ -684,7 +684,19 @@ void ImageVisual::InitializeRenderer()
     mImpl->mRenderer.SetTextures(mTextures);
     ComputeTextureSize();
     CheckMaskTexture();
-    if(DevelTexture::IsNative(mTextures.GetTexture(0)))
+
+    bool needToUpdateShader = DevelTexture::IsNative(mTextures.GetTexture(0));
+
+    if(mTextures.GetTextureCount() == 3)
+    {
+      if(mTextures.GetTexture(0).GetPixelFormat() == Pixel::L8 && mTextures.GetTexture(1).GetPixelFormat() == Pixel::CHROMINANCE_U && mTextures.GetTexture(2).GetPixelFormat() == Pixel::CHROMINANCE_V)
+      {
+        mNeedYuvToRgb      = true;
+        needToUpdateShader = true;
+      }
+    }
+
+    if(needToUpdateShader)
     {
       UpdateShader();
     }
@@ -906,6 +918,15 @@ void ImageVisual::LoadComplete(bool loadingSuccess, TextureInformation textureIn
       mImpl->mRenderer.SetTextures(textureInformation.textureSet);
       ComputeTextureSize();
       CheckMaskTexture();
+
+      if(textureInformation.textureSet.GetTextureCount() == 3)
+      {
+        if(textureInformation.textureSet.GetTexture(0).GetPixelFormat() == Pixel::L8 && textureInformation.textureSet.GetTexture(1).GetPixelFormat() == Pixel::CHROMINANCE_U && textureInformation.textureSet.GetTexture(2).GetPixelFormat() == Pixel::CHROMINANCE_V)
+        {
+          mNeedYuvToRgb = true;
+          UpdateShader();
+        }
+      }
     }
 
     if(actor)
@@ -1068,7 +1089,8 @@ Shader ImageVisual::GenerateShader() const
         .EnableRoundedCorner(IsRoundedCornerRequired())
         .EnableBorderline(IsBorderlineRequired())
         .SetTextureForFragmentShaderCheck(useNativeImage ? mTextures.GetTexture(0) : Dali::Texture())
-        .EnableAlphaMaskingOnRendering(requiredAlphaMaskingOnRendering));
+        .EnableAlphaMaskingOnRendering(requiredAlphaMaskingOnRendering)
+        .EnableYuvToRgb(mNeedYuvToRgb));
   }
   else
   {