(Automated Tests) Sync with dali-core 90/235790/1
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 9 Jun 2020 21:24:38 +0000 (22:24 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 9 Jun 2020 21:24:38 +0000 (22:24 +0100)
Change-Id: I43ec43fedca24bd82c6a5304646e37fb7581ddc8

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/mesh-builder.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/mesh-builder.h
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.cpp
automated-tests/src/dali-toolkit/dali-toolkit-test-utils/test-actor-utils.h

index 48bc26b..f8e3917 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -41,6 +41,13 @@ TextureSet CreateTextureSet( Image image )
   return textureSet;
 }
 
   return textureSet;
 }
 
+TextureSet CreateTextureSet( Texture texture )
+{
+  TextureSet textureSet = TextureSet::New();
+  textureSet.SetTexture(0u, texture);
+  return textureSet;
+}
+
 PropertyBuffer CreatePropertyBuffer()
 {
   Property::Map texturedQuadVertexFormat;
 PropertyBuffer CreatePropertyBuffer()
 {
   Property::Map texturedQuadVertexFormat;
index d22f9c8..ea0b156 100644 (file)
@@ -2,7 +2,7 @@
 #define MESH_BUILDER_H
 
 /*
 #define MESH_BUILDER_H
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@ namespace Dali
 Shader CreateShader();
 TextureSet CreateTextureSet();
 TextureSet CreateTextureSet( Image image );
 Shader CreateShader();
 TextureSet CreateTextureSet();
 TextureSet CreateTextureSet( Image image );
+TextureSet CreateTextureSet( Texture texture );
 Geometry CreateQuadGeometry();
 PropertyBuffer CreatePropertyBuffer();
 
 Geometry CreateQuadGeometry();
 PropertyBuffer CreatePropertyBuffer();
 
index 4387ba7..32bccdd 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -57,7 +57,41 @@ const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
 
 Actor CreateRenderableActor()
 {
 
 Actor CreateRenderableActor()
 {
-  return CreateRenderableActor( Image(), VERTEX_SHADER, FRAGMENT_SHADER );
+  return CreateRenderableActor( Texture(), VERTEX_SHADER, FRAGMENT_SHADER );
+}
+
+Actor CreateRenderableActor( Texture texture )
+{
+  return CreateRenderableActor( texture, VERTEX_SHADER, FRAGMENT_SHADER );
+}
+
+Actor CreateRenderableActor( Texture texture, const std::string& vertexShader, const std::string& fragmentShader )
+{
+  // Create the geometry
+  Geometry geometry = CreateQuadGeometry();
+
+  // Create Shader
+  Shader shader = Shader::New( vertexShader, fragmentShader );
+
+  // Create renderer from geometry and material
+  Renderer renderer = Renderer::New( geometry, shader );
+
+  // Create actor and set renderer
+  Actor actor = Actor::New();
+  actor.AddRenderer( renderer );
+
+  // If we a texture, then create a texture-set and add to renderer
+  if( texture )
+  {
+    TextureSet textureSet = TextureSet::New();
+    textureSet.SetTexture( 0u, texture );
+    renderer.SetTextures( textureSet );
+
+    // Set actor to the size of the texture if set
+    actor.SetProperty( Actor::Property::SIZE, Vector2( texture.GetWidth(), texture.GetHeight() ) );
+  }
+
+  return actor;
 }
 
 Actor CreateRenderableActor( Image texture )
 }
 
 Actor CreateRenderableActor( Image texture )
index a62dcca..8b8859f 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_TEST_ACTOR_UTILS_H
 
 /*
 #define DALI_TEST_ACTOR_UTILS_H
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@ namespace Dali
 
 class Actor;
 class Image;
 
 class Actor;
 class Image;
+class Texture;
 
 /**
  * @brief Creates a simple renderable-actor with solid colored quad.
 
 /**
  * @brief Creates a simple renderable-actor with solid colored quad.
@@ -49,6 +50,22 @@ Actor CreateRenderableActor( Image texture );
  */
 Actor CreateRenderableActor( Image texture, const std::string& vertexShader, const std::string& fragmentShader );
 
  */
 Actor CreateRenderableActor( Image texture, const std::string& vertexShader, const std::string& fragmentShader );
 
+/**
+ * @brief Creates a renderable-actor with a texture.
+ * @param[in] texture Texture to set.
+ * @return An actor with a renderer.
+ */
+Actor CreateRenderableActor( Texture texture );
+
+/**
+ * @brief Creates a renderable-actor with a texture and custom shaders.
+ * @param[in] texture Texture to set.
+ * @param[in] vertexShader The vertex-shader.
+ * @param[in] fragmentShader The fragment-shader.
+ * @return An actor with a renderer.
+ */
+Actor CreateRenderableActor( Texture texture, const std::string& vertexShader, const std::string& fragmentShader );
+
 } // namespace Dali
 
 #endif // DALI_TEST_ACTOR_UTILS_H
 } // namespace Dali
 
 #endif // DALI_TEST_ACTOR_UTILS_H