END_TEST;
}
+int UtcDaliTextureSetGetImage(void)
+{
+ TestApplication application;
+
+ TextureSet textureSet = CreateTextureSet();
+ DALI_TEST_EQUALS( textureSet.GetImage(0), Image(), TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetImage(1), Image(), TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetImage(2), Image(), TEST_LOCATION );
+
+ Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
+ textureSet.SetImage( 0u, image );
+
+ DALI_TEST_EQUALS( textureSet.GetImage(0), image, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetImage(1), Image(), TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetImage(2), Image(), TEST_LOCATION );
+
+ textureSet.SetImage( 2u, image );
+ DALI_TEST_EQUALS( textureSet.GetImage(0), image, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetImage(1), Image(), TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetImage(2), image, TEST_LOCATION );
+
+ textureSet.SetImage( 2u, Image() );
+ DALI_TEST_EQUALS( textureSet.GetImage(0), image, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetImage(1), Image(), TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetImage(2), Image(), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTextureSetGetSampler(void)
+{
+ TestApplication application;
+
+ TextureSet textureSet = CreateTextureSet();
+ DALI_TEST_EQUALS( textureSet.GetSampler(0), Sampler(), TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetSampler(1), Sampler(), TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetSampler(2), Sampler(), TEST_LOCATION );
+
+ Sampler sampler = Sampler::New();
+ sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST );
+ textureSet.SetSampler( 0u, sampler );
+
+ DALI_TEST_EQUALS( textureSet.GetSampler(0), sampler, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetSampler(1), Sampler(), TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetSampler(2), Sampler(), TEST_LOCATION );
+
+ textureSet.SetSampler( 2u, sampler );
+ DALI_TEST_EQUALS( textureSet.GetSampler(0), sampler, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetSampler(1), Sampler(), TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetSampler(2), sampler, TEST_LOCATION );
+
+ textureSet.SetSampler( 2u, Sampler() );
+ DALI_TEST_EQUALS( textureSet.GetSampler(0), sampler, TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetSampler(1), Sampler(), TEST_LOCATION );
+ DALI_TEST_EQUALS( textureSet.GetSampler(2), Sampler(), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliTextureSetGetTextureCount(void)
+{
+ TestApplication application;
+
+ TextureSet textureSet = CreateTextureSet();
+ DALI_TEST_EQUALS( textureSet.GetTextureCount(), 0u, TEST_LOCATION );
+
+ Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
+ textureSet.SetImage( 0u, image );
+ DALI_TEST_EQUALS( textureSet.GetTextureCount(), 1u, TEST_LOCATION );
+
+ textureSet.SetImage( 1u, image );
+ DALI_TEST_EQUALS( textureSet.GetTextureCount(), 2u, TEST_LOCATION );
+
+ textureSet.SetSampler( 2u, Sampler::New() );
+ DALI_TEST_EQUALS( textureSet.GetTextureCount(), 3u, TEST_LOCATION );
+
+ END_TEST;
+}
// EXTERNAL INCLUDES
#include <cstddef> // std::size_t
-#include <string> // std::string
// INTERNAL INCLUDES
#include <dali/public-api/images/image.h> // Dali::Image
void SetImage( size_t index, Image image );
/**
- * @brief Set the sampler to be used by the image at position "index"
+ * @brief Get the image at position "index"
* @param[in] index The position in the texture set of the image
- * @param[in] image The sampler to use
+ * @return A handle to the image at the the specified position
+ */
+ Image GetImage( size_t index ) const;
+
+ /**
+ * @brief Set the sampler to be used by the image at position "index"
+ * @param[in] index The position in the texture set of the sampler
+ * @param[in] sampler The sampler to use
*/
void SetSampler( size_t index, Sampler sampler );
+ /**
+ * @brief Set the sampler to be used by the image at position "index"
+ * @param[in] index The position in the texture set of the image
+ * @return A handle to the sampler at the specified position
+ */
+ Sampler GetSampler( size_t index ) const;
+
+ /**
+ * @brief Get the number of textures present in the TextureSet
+ *
+ * @return The number of textures in the TextureSet
+ */
+ size_t GetTextureCount() const;
+
public:
/**
* @brief The constructor
}
}
+Image* TextureSet::GetImage( size_t index ) const
+{
+ Image* result(0);
+ if( index < mTextures.size() )
+ {
+ result = mTextures[index].image.Get();
+ }
+ else
+ {
+ DALI_LOG_ERROR( "Error: Invalid index to TextureSet::GetImage");
+ }
+
+ return result;
+}
+
void TextureSet::SetSampler( size_t index, SamplerPtr sampler )
{
size_t textureCount( mTextures.size() );
SceneGraph::SetSamplerMessage( GetEventThreadServices(), *mSceneObject, index, renderSampler );
}
-ImagePtr TextureSet::GetImage( size_t index )
+Sampler* TextureSet::GetSampler( size_t index ) const
{
- ImagePtr result(0);
+ Sampler* result(0);
if( index < mTextures.size() )
{
- result = mTextures[index].image;
+ result = mTextures[index].sampler.Get();
}
else
{
- DALI_LOG_ERROR( "Error: Invalid index to TextureSet::GetImage");
+ DALI_LOG_ERROR( "Error: Invalid index to TextureSet::GetSampler");
}
return result;
}
+size_t TextureSet::GetTextureCount() const
+{
+ return mTextures.size();
+}
+
const SceneGraph::TextureSet* TextureSet::GetTextureSetSceneObject() const
{
return mSceneObject;