Merge branch 'devel/master' into tizen accepted/tizen/unified/20200729.165644 accepted/tizen/unified/20200731.145738 submit/tizen/20200727.071635 submit/tizen/20200728.012923 submit/tizen/20200731.001840
authorHeeyong Song <heeyong.song@samsung.com>
Mon, 27 Jul 2020 06:34:44 +0000 (15:34 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Mon, 27 Jul 2020 06:34:47 +0000 (15:34 +0900)
Change-Id: I4f54b7ac8b7f220d9c335e111d2932becaf61f6b

examples/native-image-source/native-image-source-example.cpp
examples/reflection-demo/reflection-example.cpp
packaging/com.samsung.dali-demo.spec

index b4f4656..c5aca03 100644 (file)
@@ -17,7 +17,6 @@
 
 // EXTERNAL INCLUDES
 #include <dali/dali.h>
-#include <dali/devel-api/images/native-image-interface-extension.h>
 #include <dali-toolkit/dali-toolkit.h>
 #include <cstring>
 
@@ -38,10 +37,10 @@ const std::string CAPTURE_FILENAME = "/tmp/native-image-capture.png";
 
 /**
  * @brief Creates a shader used to render a native image
- * @param[in] nativeImageInterface The native image interface
+ * @param[in] nativeImage The native image
  * @return A shader to render the native image
  */
-Shader CreateShader( NativeImageInterface& nativeImageInterface )
+Shader CreateShader( NativeImageInterface& nativeImage )
 {
   static const char* DEFAULT_SAMPLER_TYPENAME = "sampler2D";
 
@@ -70,36 +69,29 @@ Shader CreateShader( NativeImageInterface& nativeImageInterface )
       }\n
   );
 
-  NativeImageInterface::Extension* extension( nativeImageInterface.GetExtension() );
-  if( extension )
-  {
-    std::string fragmentShader;
-
-    //Get custom fragment shader prefix
-    const char* fragmentPreFix = extension->GetCustomFragmentPreFix();
-    if( fragmentPreFix )
-    {
-      fragmentShader = fragmentPreFix;
-      fragmentShader += FRAGMENT_SHADER_TEXTURE;
-    }
-    else
-    {
-      fragmentShader = FRAGMENT_SHADER_TEXTURE;
-    }
 
-    //Get custom sampler type name
-    const char* customSamplerTypename = extension->GetCustomSamplerTypename();
-    if( customSamplerTypename )
-    {
-      fragmentShader.replace( fragmentShader.find( DEFAULT_SAMPLER_TYPENAME ), strlen(DEFAULT_SAMPLER_TYPENAME), customSamplerTypename );
-    }
+  std::string fragmentShader;
 
-    return Shader::New( VERTEX_SHADER_TEXTURE, fragmentShader );
+  //Get custom fragment shader prefix
+  const char* fragmentPrefix = nativeImage.GetCustomFragmentPrefix();
+  if( fragmentPrefix )
+  {
+    fragmentShader = fragmentPrefix;
+    fragmentShader += FRAGMENT_SHADER_TEXTURE;
   }
   else
   {
-    return Shader::New( VERTEX_SHADER_TEXTURE, FRAGMENT_SHADER_TEXTURE );
+    fragmentShader = FRAGMENT_SHADER_TEXTURE;
   }
+
+  //Get custom sampler type name
+  const char* customSamplerTypename = nativeImage.GetCustomSamplerTypename();
+  if( customSamplerTypename )
+  {
+    fragmentShader.replace( fragmentShader.find( DEFAULT_SAMPLER_TYPENAME ), strlen(DEFAULT_SAMPLER_TYPENAME), customSamplerTypename );
+  }
+
+  return Shader::New( VERTEX_SHADER_TEXTURE, fragmentShader );
 }
 
 }
index ecd635d..0900d80 100644 (file)
@@ -26,6 +26,9 @@
 using namespace Dali;
 using Dali::Toolkit::TextLabel;
 
+namespace
+{
+
 const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
   attribute mediump vec3 aPosition;\n
   attribute mediump vec3 aNormal;\n
@@ -165,6 +168,115 @@ struct Model
   Geometry  geometry;
 };
 
+template<class T>
+bool LoadFile( const std::string& filename, std::vector<T>& bytes )
+{
+  Dali::FileStream fileStream( filename, Dali::FileStream::READ | Dali::FileStream::BINARY );
+  FILE* fin = fileStream.GetFile();
+
+  if( fin )
+  {
+    if( fseek( fin, 0, SEEK_END ) )
+    {
+      return false;
+    }
+    bytes.resize( uint32_t(ftell( fin )) );
+    std::fill( bytes.begin(), bytes.end(), 0 );
+    if( fseek( fin, 0, SEEK_SET ) )
+    {
+      return false;
+    }
+    size_t result = fread( bytes.data(), 1, bytes.size(), fin );
+    return ( result != 0 );
+  }
+
+  return false;
+}
+
+Shader CreateShader( const std::string& vsh, const std::string& fsh )
+{
+  std::vector<char> vshShaderSource;
+  std::vector<char> fshShaderSource;
+
+  // VSH
+  if(vsh[0] == '/')
+  {
+    std::string vshPath( DEMO_GAME_DIR );
+    vshPath += '/';
+    vshPath += vsh;
+    LoadFile( vshPath, vshShaderSource );
+  }
+  else
+  {
+    vshShaderSource.insert(vshShaderSource.end(), vsh.begin(), vsh.end());
+  }
+
+  // FSH
+  if(fsh[0] == '/')
+  {
+    std::string fshPath( DEMO_GAME_DIR );
+    fshPath += '/';
+    fshPath += fsh;
+    LoadFile( fshPath, fshShaderSource );
+  }
+  else
+  {
+    fshShaderSource.insert(fshShaderSource.end(), fsh.begin(), fsh.end());
+  }
+
+  vshShaderSource.emplace_back(0);
+  fshShaderSource.emplace_back(0);
+  return Shader::New( std::string(vshShaderSource.data()), std::string(fshShaderSource.data()) );
+}
+
+std::unique_ptr<Model> CreateModel( glTF& gltf,
+                                    const glTF_Mesh* mesh,
+                                    const std::string& vertexShaderSource,
+                                    const std::string& fragmentShaderSource )
+{
+  /*
+   * Obtain interleaved buffer for first mesh with position and normal attributes
+   */
+  auto positionBuffer = gltf.GetMeshAttributeBuffer( *mesh,
+                                                     {
+                                                       glTFAttributeType::POSITION,
+                                                       glTFAttributeType::NORMAL,
+                                                       glTFAttributeType::TEXCOORD_0
+                                                     } );
+
+  auto attributeCount = gltf.GetMeshAttributeCount( mesh );
+  /**
+   * Create matching property buffer
+   */
+  auto vertexBuffer = PropertyBuffer::New( Property::Map()
+                                             .Add("aPosition", Property::VECTOR3 )
+                                             .Add("aNormal", Property::VECTOR3)
+                                             .Add("aTexCoord", Property::VECTOR2)
+  );
+
+  // set vertex data
+  vertexBuffer.SetData( positionBuffer.data(), attributeCount );
+
+  auto geometry = Geometry::New();
+  geometry.AddVertexBuffer( vertexBuffer );
+  auto indexBuffer = gltf.GetMeshIndexBuffer( mesh );
+  geometry.SetIndexBuffer( indexBuffer.data(), indexBuffer.size() );
+  geometry.SetType( Geometry::Type::TRIANGLES );
+  std::unique_ptr<Model> retval( new Model() );
+  retval->shader = CreateShader( vertexShaderSource, fragmentShaderSource );
+  retval->geometry = geometry;
+  return retval;
+}
+
+void ReplaceShader( Actor& actor, const std::string& vsh, const std::string& fsh )
+{
+  auto renderer = actor.GetRendererAt(0);
+  auto shader = CreateShader(vsh, fsh);
+  renderer.SetShader( shader );
+}
+
+} // unnamed namespace
+
 // This example shows how to create and display mirrored reflection using CameraActor
 //
 class ReflectionExample : public ConnectionTracker
@@ -485,113 +597,6 @@ private:
     }
   }
 
-  template<class T>
-  bool LoadFile( const std::string& filename, std::vector<T>& bytes )
-  {
-    Dali::FileStream fileStream( filename, Dali::FileStream::READ | Dali::FileStream::BINARY );
-    FILE* fin = fileStream.GetFile();
-
-    if( fin )
-    {
-      if( fseek( fin, 0, SEEK_END ) )
-      {
-        return false;
-      }
-      bytes.resize( uint32_t(ftell( fin )) );
-      std::fill( bytes.begin(), bytes.end(), 0 );
-      if( fseek( fin, 0, SEEK_SET ) )
-      {
-        return false;
-      }
-      size_t result = fread( bytes.data(), 1, bytes.size(), fin );
-      return ( result != 0 );
-    }
-
-    return false;
-  }
-
-  Shader CreateShader( const std::string& vsh, const std::string& fsh )
-  {
-    std::vector<char> vshShaderSource;
-    std::vector<char> fshShaderSource;
-
-    // VSH
-    if(vsh[0] == '/')
-    {
-      std::string vshPath( DEMO_GAME_DIR );
-      vshPath += '/';
-      vshPath += vsh;
-      LoadFile( vshPath, vshShaderSource );
-    }
-    else
-    {
-      vshShaderSource.insert(vshShaderSource.end(), vsh.begin(), vsh.end());
-    }
-
-    // FSH
-    if(fsh[0] == '/')
-    {
-      std::string fshPath( DEMO_GAME_DIR );
-      fshPath += '/';
-      fshPath += fsh;
-      LoadFile( fshPath, fshShaderSource );
-    }
-    else
-    {
-      fshShaderSource.insert(fshShaderSource.end(), fsh.begin(), fsh.end());
-    }
-
-    vshShaderSource.emplace_back(0);
-    fshShaderSource.emplace_back(0);
-    return Shader::New( std::string(vshShaderSource.data()), std::string(fshShaderSource.data()) );
-  }
-
-  std::unique_ptr<Model> CreateModel( glTF& gltf,
-                                      const glTF_Mesh* mesh,
-                                      const std::string& vertexShaderSource,
-                                      const std::string& fragmentShaderSource )
-  {
-    /*
-     * Obtain interleaved buffer for first mesh with position and normal attributes
-     */
-    auto positionBuffer = gltf.GetMeshAttributeBuffer( *mesh,
-                                                       {
-                                                         glTFAttributeType::POSITION,
-                                                         glTFAttributeType::NORMAL,
-                                                         glTFAttributeType::TEXCOORD_0
-                                                       } );
-
-    auto attributeCount = gltf.GetMeshAttributeCount( mesh );
-    /**
-     * Create matching property buffer
-     */
-    auto vertexBuffer = PropertyBuffer::New( Property::Map()
-                                               .Add("aPosition", Property::VECTOR3 )
-                                               .Add("aNormal", Property::VECTOR3)
-                                               .Add("aTexCoord", Property::VECTOR2)
-    );
-
-    // set vertex data
-    vertexBuffer.SetData( positionBuffer.data(), attributeCount );
-
-    auto geometry = Geometry::New();
-    geometry.AddVertexBuffer( vertexBuffer );
-    auto indexBuffer = gltf.GetMeshIndexBuffer( mesh );
-    geometry.SetIndexBuffer( indexBuffer.data(), indexBuffer.size() );
-    geometry.SetType( Geometry::Type::TRIANGLES );
-    std::unique_ptr<Model> retval( new Model() );
-    retval->shader = CreateShader( vertexShaderSource, fragmentShaderSource );
-    retval->geometry = geometry;
-    return retval;
-  }
-
-  void ReplaceShader( Actor& actor, const std::string& vsh, const std::string& fsh )
-  {
-    auto renderer = actor.GetRendererAt(0);
-    auto shader = CreateShader(vsh, fsh);
-    renderer.SetShader( shader );
-  }
-
   void OnPan( Actor actor, const PanGesture& panGesture )
   {
     auto displacement = panGesture.screenDisplacement;
index 11b9178..21dec7f 100755 (executable)
@@ -2,7 +2,7 @@
 
 Name:       com.samsung.dali-demo
 Summary:    The OpenGLES Canvas Core Demo
-Version:    1.9.21
+Version:    1.9.22
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0