Added GetUniformName to Sampler. 62/48162/2
authorChu Hoang <c.hoang@samsung.com>
Mon, 14 Sep 2015 15:20:50 +0000 (16:20 +0100)
committerChu Hoang <c.hoang@samsung.com>
Tue, 15 Sep 2015 11:14:41 +0000 (12:14 +0100)
Change-Id: I962305f3cdf5b19ac5d2d1c23186c3204057be6e

automated-tests/src/dali-devel/utc-Dali-Sampler.cpp
dali/devel-api/rendering/sampler.cpp
dali/devel-api/rendering/sampler.h
dali/internal/event/rendering/sampler-impl.cpp
dali/internal/event/rendering/sampler-impl.h

index 4cecb5f..81ae455 100644 (file)
@@ -15,6 +15,7 @@
  *
  */
 
+#include <unistd.h>
 #include <dali/public-api/dali-core.h>
 #include <dali-test-suite-utils.h>
 
@@ -189,6 +190,52 @@ int UtcDaliSamplerSetUniformName02(void)
   END_TEST;
 }
 
+int UtcDaliSamplerGetUniformName01(void)
+{
+  TestApplication application;
+
+  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
+  std::string uniformName = "sTextureTEST";
+  Sampler sampler = Sampler::New(image, uniformName);
+
+  std::string actual = sampler.GetUniformName();
+
+  DALI_TEST_EQUALS( uniformName, actual, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliSamplerGetUniformName02(void)
+{
+  TestApplication application;
+
+  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
+  Sampler sampler = Sampler::New(image, "sTextureFAIL" );
+
+  std::string uniformName = "sTextureTEST";
+  sampler.SetUniformName( uniformName );
+
+  Material material = CreateMaterial(1.0f);
+  material.AddSampler( sampler );
+  Geometry geometry = CreateQuadGeometry();
+  Renderer renderer = Renderer::New( geometry, material );
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetParentOrigin( ParentOrigin::CENTER );
+  actor.SetSize(400, 400);
+
+  Stage::GetCurrent().Add( actor );
+
+  application.SendNotification();
+  application.Render();
+
+  std::string actual = sampler.GetUniformName();
+
+  DALI_TEST_EQUALS( uniformName, actual, TEST_LOCATION );
+
+  END_TEST;
+}
+
 int UtcDaliSamplerSetGetImage(void)
 {
   TestApplication application;
index d56ed24..2b2ab5e 100644 (file)
@@ -61,6 +61,11 @@ void Sampler::SetUniformName( const std::string& name )
   GetImplementation(*this).SetTextureUnitUniformName( name );
 }
 
+const std::string& Sampler::GetUniformName() const
+{
+  return GetImplementation(*this).GetTextureUnitUniformName();
+}
+
 void Sampler::SetImage( Image& image )
 {
   Internal::ImagePtr imagePtr = &GetImplementation( image );
index b5d53d7..4d1b80d 100644 (file)
@@ -129,6 +129,13 @@ public:
   void SetUniformName( const std::string& name );
 
   /**
+   * @brief Gets the name of the shader uniform that this sampler uses
+   *
+   * @return Returns the name of the uniform
+   */
+  const std::string& GetUniformName() const;
+
+  /**
    * @brief Set the image used by this sampler
    *
    * @param[in] image Image used by this sampler
index 1787179..3fb8ca4 100644 (file)
@@ -68,6 +68,11 @@ void Sampler::SetTextureUnitUniformName( const std::string& name )
   SetTextureUnitUniformNameMessage( GetEventThreadServices(), *mSceneObject, name);
 }
 
+const std::string& Sampler::GetTextureUnitUniformName() const
+{
+  return mSceneObject->GetTextureUnitUniformName();
+}
+
 void Sampler::SetImage( ImagePtr& image )
 {
   // Keep a reference to the image object
index 340f140..33015f9 100644 (file)
@@ -59,6 +59,11 @@ public:
   void SetTextureUnitUniformName( const std::string& name );
 
   /**
+   * @copydoc Dali::Sampler::GetUniformName()
+   */
+  const std::string& GetTextureUnitUniformName() const;
+
+  /**
    * @copydoc Dali::Sampler::SetImage()
    */
   void SetImage( ImagePtr& image );