Revert "[Tizen] Fix webview rendering issue in TV"
authorShinwoo Kim <cinoo.kim@samsung.com>
Tue, 1 Jun 2021 02:09:21 +0000 (11:09 +0900)
committerShinwoo Kim <cinoo.kim@samsung.com>
Tue, 1 Jun 2021 02:09:21 +0000 (11:09 +0900)
This reverts commit 2159a622030595fe54fd63c34756483e62821c57.

automated-tests/src/dali-toolkit/utc-Dali-ImageVisual.cpp
dali-toolkit/internal/controls/web-view/web-view-impl.cpp
dali-toolkit/internal/visuals/image/image-visual.cpp

index fdf1697..e9bd76e 100644 (file)
@@ -24,7 +24,6 @@
 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
 #include <dali-toolkit/devel-api/controls/control-devel.h>
 #include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
-#include <dali-toolkit/public-api/image-loader/image.h>
 #include <dali-toolkit/dali-toolkit.h>
 #include "dummy-control.h"
 
@@ -417,51 +416,6 @@ int UtcDaliImageVisualRemoteImageLoad(void)
   END_TEST;
 }
 
-
-int UtcDaliImageVisualWithNativeImage(void)
-{
-  ToolkitTestApplication application;
-  tet_infoline( "Use Native Image as url" );
-
-  NativeImageSourcePtr nativeImageSource = NativeImageSource::New(500, 500, NativeImageSource::COLOR_DEPTH_DEFAULT);
-  std::string url = Dali::Toolkit::Image::GenerateUrl(nativeImageSource);
-
-  VisualFactory factory = VisualFactory::Get();
-  DALI_TEST_CHECK( factory );
-
-  Property::Map propertyMap;
-  propertyMap.Insert( Toolkit::Visual::Property::TYPE,  Visual::IMAGE );
-  propertyMap.Insert( ImageVisual::Property::URL,  url );
-
-  Visual::Base visual = factory.CreateVisual( propertyMap );
-  DALI_TEST_CHECK( visual );
-
-  DummyControl actor = DummyControl::New();
-  DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
-  dummyImpl.RegisterVisual( Control::CONTROL_PROPERTY_END_INDEX + 1, visual );
-
-  DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
-
-  application.GetScene().Add( actor );
-
-  DALI_TEST_EQUALS( actor.GetRendererCount(), 1u, TEST_LOCATION );
-
-  Renderer renderer = actor.GetRendererAt(0);
-  Shader shader = renderer.GetShader();
-
-  Property::Value value = shader.GetProperty(Shader::Property::PROGRAM);
-  DALI_TEST_CHECK(value.GetType() == Property::MAP);
-  const Property::Map* outMap = value.GetMap();
-  std::string fragmentShader = (*outMap)["fragment"].Get<std::string>();
-
-  const char* fragmentPrefix = nativeImageSource->GetCustomFragmentPrefix();
-  size_t pos = fragmentShader.find(fragmentPrefix);
-
-  DALI_TEST_EQUALS( pos != std::string::npos, true, TEST_LOCATION );
-
-  END_TEST;
-}
-
 int UtcDaliImageVisualTextureReuse1(void)
 {
   ToolkitTestApplication application;
index 3342374..6907a90 100755 (executable)
@@ -109,7 +109,52 @@ DALI_TYPE_REGISTRATION_END()
 
 const std::string kEmptyString;
 
-} // namespace
+const char* DEFAULT_SAMPLER_TYPENAME = "sampler2D";
+
+const char* FRAGMENT_SHADER_TEXTURE = DALI_COMPOSE_SHADER(
+  varying mediump vec2 vTexCoord;\n
+  uniform sampler2D sTexture;\n
+  uniform lowp vec4 uColor;\n
+  uniform lowp vec3 mixColor;\n
+  uniform lowp float preMultipliedAlpha;\n
+  \n
+  void main()\n
+  {\n
+      gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor * vec4( mixColor, 1.0 );\n
+  }\n
+);
+
+Dali::Toolkit::Visual::Base CreateNativeImageVisual( NativeImageInterfacePtr nativeImageInterface )
+{
+  std::string fragmentShader;
+
+  const char* fragmentPrefix = nativeImageInterface->GetCustomFragmentPrefix();
+  if( fragmentPrefix )
+  {
+    fragmentShader = fragmentPrefix;
+    fragmentShader += FRAGMENT_SHADER_TEXTURE;
+  }
+  else
+  {
+    fragmentShader = FRAGMENT_SHADER_TEXTURE;
+  }
+
+  const char* customSamplerTypename = nativeImageInterface->GetCustomSamplerTypename();
+  if( customSamplerTypename )
+  {
+    fragmentShader.replace( fragmentShader.find( DEFAULT_SAMPLER_TYPENAME ), strlen( DEFAULT_SAMPLER_TYPENAME ), customSamplerTypename );
+  }
+
+  Texture texture = Dali::Texture::New( *nativeImageInterface );
+  const std::string nativeImageUrl = Dali::Toolkit::TextureManager::AddTexture( texture );
+
+  return Toolkit::VisualFactory::Get().CreateVisual(
+    { { Toolkit::Visual::Property::TYPE,  Toolkit::Visual::IMAGE } ,
+      { Toolkit::Visual::Property::SHADER, { { Toolkit::Visual::Shader::Property::FRAGMENT_SHADER, fragmentShader } } },
+      { Toolkit::ImageVisual::Property::URL, nativeImageUrl } } );
+}
+
+} // anonymous namepsace
 
 #define GET_ENUM_STRING(structName, inputExp) \
   Scripting::GetLinearEnumerationName<Toolkit::WebView::structName::Type>(static_cast<Toolkit::WebView::structName::Type>(inputExp), structName##_TABLE, structName##_TABLE_COUNT)
@@ -284,11 +329,7 @@ void WebView::LoadUrl(const std::string& url)
   mUrl = url;
   if(mWebEngine)
   {
-    Texture           texture        = Dali::Texture::New(*mWebEngine.GetNativeImageSource());
-    const std::string nativeImageUrl = Dali::Toolkit::TextureManager::AddTexture(texture);
-    mVisual                          = Toolkit::VisualFactory::Get().CreateVisual(
-      {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
-       {Toolkit::ImageVisual::Property::URL, nativeImageUrl}});
+    mVisual = CreateNativeImageVisual( mWebEngine.GetNativeImageSource() );
 
     if(mVisual)
     {
@@ -308,11 +349,7 @@ void WebView::LoadHtmlString(const std::string& htmlString)
 {
   if(mWebEngine)
   {
-    Texture           texture        = Dali::Texture::New(*mWebEngine.GetNativeImageSource());
-    const std::string nativeImageUrl = Dali::Toolkit::TextureManager::AddTexture(texture);
-    mVisual                          = Toolkit::VisualFactory::Get().CreateVisual(
-      {{Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE},
-       {Toolkit::ImageVisual::Property::URL, nativeImageUrl}});
+    mVisual = CreateNativeImageVisual( mWebEngine.GetNativeImageSource() );
 
     if(mVisual)
     {
index 1c5f5e7..03e0657 100644 (file)
@@ -626,10 +626,6 @@ void ImageVisual::InitializeRenderer()
   if(mTextures)
   {
     mImpl->mRenderer.SetTextures(mTextures);
-    if(DevelTexture::IsNative(mTextures.GetTexture(0)))
-    {
-      UpdateShader();
-    }
     mTextures.Reset(); // Visual should not keep a handle to the texture after this point.
   }